- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / webnavigation / test_serverRedirectSingleProcess.js
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 onload = function() {
6   // TODO(jochen): Remove once the reason for http://crbug.com/161897 is found.
7   debug = true;
8
9   var URL_LOAD =
10       "http://www.a.com:PORT/extensions/api_test/webnavigation/serverRedirect/a.html";
11   var URL_REDIRECT = "http://www.b.com:PORT/server-redirect";
12   var URL_TARGET = "http://www.b.com:PORT/";
13   chrome.tabs.create({"url": "about:blank"}, function(tab) {
14     var tabId = tab.id;
15     chrome.test.getConfig(function(config) {
16       var fixPort = function(url) {
17         return url.replace(/PORT/g, config.testServer.port);
18       };
19       URL_REDIRECT = fixPort(URL_REDIRECT);
20       URL_TARGET = fixPort(URL_TARGET);
21       URL_LOAD = fixPort(URL_LOAD);
22       chrome.test.runTests([
23         // Two navigations initiated by the user while we ran out of renderer
24         // processes before. The second navigation results in a server redirect.
25         // At this point, we have two different render views attached to the
26         // web contents that are in the same process. Should not DCHECK.
27         function serverRedirectSingleProcess() {
28           expect([
29             { label: "a-onBeforeNavigate",
30               event: "onBeforeNavigate",
31               details: { frameId: 0,
32                          parentFrameId: -1,
33                          processId: 0,
34                          tabId: 0,
35                          timeStamp: 0,
36                          url: URL_LOAD }},
37             { label: "a-onCommitted",
38               event: "onCommitted",
39               details: { frameId: 0,
40                          processId: 0,
41                          tabId: 0,
42                          timeStamp: 0,
43                          transitionQualifiers: [],
44                          transitionType: "typed",
45                          url: URL_LOAD }},
46             { label: "a-onDOMContentLoaded",
47               event: "onDOMContentLoaded",
48               details: { frameId: 0,
49                          processId: 0,
50                          tabId: 0,
51                          timeStamp: 0,
52                          url: URL_LOAD }},
53             { label: "a-onCompleted",
54               event: "onCompleted",
55               details: { frameId: 0,
56                          processId: 0,
57                          tabId: 0,
58                          timeStamp: 0,
59                          url: URL_LOAD }},
60             { label: "b-onBeforeNavigate",
61               event: "onBeforeNavigate",
62               details: { frameId: 0,
63                          parentFrameId: -1,
64                          processId: 0,
65                          tabId: 0,
66                          timeStamp: 0,
67                          url: URL_REDIRECT }},
68             { label: "b-onCommitted",
69               event: "onCommitted",
70               details: { frameId: 0,
71                          processId: 0,
72                          tabId: 0,
73                          timeStamp: 0,
74                          transitionQualifiers: ["server_redirect"],
75                          transitionType: "typed",
76                          url: URL_TARGET }},
77             { label: "b-onDOMContentLoaded",
78               event: "onDOMContentLoaded",
79               details: { frameId: 0,
80                          processId: 0,
81                          tabId: 0,
82                          timeStamp: 0,
83                          url: URL_TARGET }},
84             { label: "b-onCompleted",
85               event: "onCompleted",
86               details: { frameId: 0,
87                          processId: 0,
88                          tabId: 0,
89                          timeStamp: 0,
90                          url: URL_TARGET }}],
91             [ navigationOrder("a-"), navigationOrder("b-") ]);
92
93           // Notify the api test that we're waiting for the user.
94           chrome.test.notifyPass();
95         },
96       ]);
97     });
98   });
99 };