- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / webnavigation / test_targetBlank.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://127.0.0.1:PORT/extensions/api_test/webnavigation/targetBlank/a.html";
8   var URL_TARGET =
9       "http://127.0.0.1:PORT/extensions/api_test/webnavigation/targetBlank/b.html";
10   chrome.tabs.create({"url": "about:blank"}, function(tab) {
11     var tabId = tab.id;
12     chrome.test.getConfig(function(config) {
13       var fixPort = function(url) {
14         return url.replace(/PORT/g, config.testServer.port);
15       };
16       URL_LOAD = fixPort(URL_LOAD);
17       URL_TARGET = fixPort(URL_TARGET);
18
19       chrome.test.runTests([
20         // Opens a tab and waits for the user to click on a link with
21         // target=_blank in it.
22         function targetBlank() {
23           expect([
24             { label: "a-onBeforeNavigate",
25               event: "onBeforeNavigate",
26               details: { frameId: 0,
27                          parentFrameId: -1,
28                          processId: 0,
29                          tabId: 0,
30                          timeStamp: 0,
31                          url: URL_LOAD }},
32             { label: "a-onCommitted",
33               event: "onCommitted",
34               details: { frameId: 0,
35                          processId: 0,
36                          tabId: 0,
37                          timeStamp: 0,
38                          transitionQualifiers: [],
39                          transitionType: "link",
40                          url: URL_LOAD }},
41             { label: "a-onDOMContentLoaded",
42               event: "onDOMContentLoaded",
43               details: { frameId: 0,
44                          processId: 0,
45                          tabId: 0,
46                          timeStamp: 0,
47                          url: URL_LOAD }},
48             { label: "a-onCompleted",
49               event: "onCompleted",
50               details: { frameId: 0,
51                          processId: 0,
52                          tabId: 0,
53                          timeStamp: 0,
54                          url: URL_LOAD }},
55             { label: "b-onCreatedNavigationTarget",
56               event: "onCreatedNavigationTarget",
57               details: { sourceFrameId: 0,
58                          sourceProcessId: 0,
59                          sourceTabId: 0,
60                          tabId: 1,
61                          timeStamp: 0,
62                          url: URL_TARGET }},
63             { label: "b-onBeforeNavigate",
64               event: "onBeforeNavigate",
65               details: { frameId: 0,
66                          parentFrameId: -1,
67                          processId: 0,
68                          tabId: 1,
69                          timeStamp: 0,
70                          url: URL_TARGET }},
71             { label: "b-onCommitted",
72               event: "onCommitted",
73               details: { frameId: 0,
74                          processId: 0,
75                          tabId: 1,
76                          timeStamp: 0,
77                          transitionQualifiers: [],
78                          transitionType: "link",
79                          url: URL_TARGET }},
80             { label: "b-onDOMContentLoaded",
81               event: "onDOMContentLoaded",
82               details: { frameId: 0,
83                          processId: 0,
84                          tabId: 1,
85                          timeStamp: 0,
86                          url: URL_TARGET }},
87             { label: "b-onCompleted",
88               event: "onCompleted",
89               details: { frameId: 0,
90                          processId: 0,
91                          tabId: 1,
92                          timeStamp: 0,
93                          url: URL_TARGET }}],
94             [ navigationOrder("a-"),
95               navigationOrder("b-"),
96               [ "a-onDOMContentLoaded",
97                 "b-onCreatedNavigationTarget",
98                 "b-onBeforeNavigate" ]]);
99
100           // Notify the api test that we're waiting for the user.
101           chrome.test.notifyPass();
102         },
103       ]);
104     });
105   });
106 };