- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / webnavigation / test_serverRedirect.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   var URL_LOAD =
7       "http://www.a.com:PORT/extensions/api_test/webnavigation/serverRedirect/a.html";
8   var URL_LOAD_REDIRECT = "http://www.a.com:PORT/server-redirect";
9   chrome.tabs.create({"url": "about:blank"}, function(tab) {
10     var tabId = tab.id;
11     chrome.test.getConfig(function(config) {
12       var fixPort = function(url) {
13         return url.replace(/PORT/g, config.testServer.port);
14       };
15       URL_LOAD_REDIRECT = fixPort(URL_LOAD_REDIRECT);
16       URL_LOAD = fixPort(URL_LOAD);
17       chrome.test.runTests([
18         // Navigates to a page that redirects (on the server side) to a.html.
19         function serverRedirect() {
20           expect([
21             { label: "a-onBeforeNavigate",
22               event: "onBeforeNavigate",
23               details: { frameId: 0,
24                          parentFrameId: -1,
25                          processId: 0,
26                          tabId: 0,
27                          timeStamp: 0,
28                          url: URL_LOAD_REDIRECT }},
29             { label: "a-onCommitted",
30               event: "onCommitted",
31               details: { frameId: 0,
32                          processId: 0,
33                          tabId: 0,
34                          timeStamp: 0,
35                          transitionQualifiers: ["server_redirect"],
36                          transitionType: "link",
37                          url: URL_LOAD }},
38             { label: "a-onDOMContentLoaded",
39               event: "onDOMContentLoaded",
40               details: { frameId: 0,
41                          processId: 0,
42                          tabId: 0,
43                          timeStamp: 0,
44                          url: URL_LOAD }},
45             { label: "a-onCompleted",
46               event: "onCompleted",
47               details: { frameId: 0,
48                          processId: 0,
49                          tabId: 0,
50                          timeStamp: 0,
51                          url: URL_LOAD }}],
52             [ navigationOrder("a-") ]);
53           chrome.tabs.update(tabId,
54                              { url: URL_LOAD_REDIRECT + "?" + URL_LOAD });
55         },
56       ]);
57     });
58   });
59 };