Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / webnavigation / openTab / test_openTab.js
blob381fe14f26a559d7f403e2c0b80b04af4f8067da
1 // Copyright 2013 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.
5 onload = function() {
6   var getURL = chrome.extension.getURL;
7   chrome.tabs.create({"url": "about:blank"}, function(tab) {
8     var tabId = tab.id;
10     chrome.test.runTests([
11       // Opens a new tab from javascript.
12       function openTab() {
13         expect([
14           { label: "a-onBeforeNavigate",
15             event: "onBeforeNavigate",
16             details: { frameId: 0,
17                        parentFrameId: -1,
18                        processId: 0,
19                        tabId: 0,
20                        timeStamp: 0,
21                        url: getURL('a.html') }},
22           { label: "a-onCommitted",
23             event: "onCommitted",
24             details: { frameId: 0,
25                        processId: 0,
26                        tabId: 0,
27                        timeStamp: 0,
28                        transitionQualifiers: [],
29                        transitionType: "link",
30                        url: getURL('a.html') }},
31           { label: "a-onDOMContentLoaded",
32             event: "onDOMContentLoaded",
33             details: { frameId: 0,
34                        processId: 0,
35                        tabId: 0,
36                        timeStamp: 0,
37                        url: getURL('a.html') }},
38           { label: "a-onCompleted",
39             event: "onCompleted",
40             details: { frameId: 0,
41                        processId: 0,
42                        tabId: 0,
43                        timeStamp: 0,
44                        url: getURL('a.html') }},
45           { label: "a-onCreatedNavigationTarget",
46             event: "onCreatedNavigationTarget",
47             details: { sourceFrameId: 0,
48                        sourceProcessId: 0,
49                        sourceTabId: 0,
50                        tabId: 1,
51                        timeStamp: 0,
52                        url: getURL('b.html') }},
53           { label: "b-onBeforeNavigate",
54             event: "onBeforeNavigate",
55             details: { frameId: 0,
56                        parentFrameId: -1,
57                        processId: 0,
58                        tabId: 1,
59                        timeStamp: 0,
60                        url: getURL('b.html') }},
61           { label: "b-onCommitted",
62             event: "onCommitted",
63             details: { frameId: 0,
64                        processId: 0,
65                        tabId: 1,
66                        timeStamp: 0,
67                        transitionQualifiers: [],
68                        transitionType: "link",
69                        url: getURL('b.html') }},
70           { label: "b-onDOMContentLoaded",
71             event: "onDOMContentLoaded",
72             details: { frameId: 0,
73                        processId: 0,
74                        tabId: 1,
75                        timeStamp: 0,
76                        url: getURL('b.html') }},
77           { label: "b-onCompleted",
78             event: "onCompleted",
79             details: { frameId: 0,
80                        processId: 0,
81                        tabId: 1,
82                        timeStamp: 0,
83                        url: getURL('b.html') }}],
84           [ navigationOrder("a-"),
85             navigationOrder("b-"),
86             ["a-onDOMContentLoaded", "a-onCreatedNavigationTarget",
87              "b-onBeforeNavigate"]]);
88         chrome.tabs.update(tabId, { url: getURL('a.html') });
89       },
91       // Opens a new tab from javascript within an iframe.
92       function openTabFrame() {
93         expect([
94           { label: "c-onBeforeNavigate",
95             event: "onBeforeNavigate",
96             details: { frameId: 0,
97                        parentFrameId: -1,
98                        processId: 0,
99                        tabId: 0,
100                        timeStamp: 0,
101                        url: getURL('c.html') }},
102           { label: "c-onCommitted",
103             event: "onCommitted",
104             details: { frameId: 0,
105                        processId: 0,
106                        tabId: 0,
107                        timeStamp: 0,
108                        transitionQualifiers: [],
109                        transitionType: "link",
110                        url: getURL('c.html') }},
111           { label: "c-onDOMContentLoaded",
112             event: "onDOMContentLoaded",
113             details: { frameId: 0,
114                        processId: 0,
115                        tabId: 0,
116                        timeStamp: 0,
117                        url: getURL('c.html') }},
118           { label: "c-onCompleted",
119             event: "onCompleted",
120             details: { frameId: 0,
121                        processId: 0,
122                        tabId: 0,
123                        timeStamp: 0,
124                        url: getURL('c.html') }},
125           { label: "a-onBeforeNavigate",
126             event: "onBeforeNavigate",
127             details: { frameId: 1,
128                        parentFrameId: 0,
129                        processId: 0,
130                        tabId: 0,
131                        timeStamp: 0,
132                        url: getURL('a.html') }},
133           { label: "a-onCommitted",
134             event: "onCommitted",
135             details: { frameId: 1,
136                        processId: 0,
137                        tabId: 0,
138                        timeStamp: 0,
139                        transitionQualifiers: [],
140                        transitionType: "auto_subframe",
141                        url: getURL('a.html') }},
142           { label: "a-onDOMContentLoaded",
143             event: "onDOMContentLoaded",
144             details: { frameId: 1,
145                        processId: 0,
146                        tabId: 0,
147                        timeStamp: 0,
148                        url: getURL('a.html') }},
149           { label: "a-onCompleted",
150             event: "onCompleted",
151             details: { frameId: 1,
152                        processId: 0,
153                        tabId: 0,
154                        timeStamp: 0,
155                        url: getURL('a.html') }},
156           { label: "a-onCreatedNavigationTarget",
157             event: "onCreatedNavigationTarget",
158             details: { sourceFrameId: 1,
159                        sourceProcessId: 0,
160                        sourceTabId: 0,
161                        tabId: 1,
162                        timeStamp: 0,
163                        url: getURL('b.html') }},
164           { label: "b-onBeforeNavigate",
165             event: "onBeforeNavigate",
166             details: { frameId: 0,
167                        parentFrameId: -1,
168                        processId: 0,
169                        tabId: 1,
170                        timeStamp: 0,
171                        url: getURL('b.html') }},
172           { label: "b-onCommitted",
173             event: "onCommitted",
174             details: { frameId: 0,
175                        processId: 0,
176                        tabId: 1,
177                        timeStamp: 0,
178                        transitionQualifiers: [],
179                        transitionType: "link",
180                        url: getURL('b.html') }},
181           { label: "b-onDOMContentLoaded",
182             event: "onDOMContentLoaded",
183             details: { frameId: 0,
184                        processId: 0,
185                        tabId: 1,
186                        timeStamp: 0,
187                        url: getURL('b.html') }},
188           { label: "b-onCompleted",
189             event: "onCompleted",
190             details: { frameId: 0,
191                        processId: 0,
192                        tabId: 1,
193                        timeStamp: 0,
194                        url: getURL('b.html') }}],
195           [ navigationOrder("a-"),
196             navigationOrder("b-"),
197             navigationOrder("c-"),
198             isIFrameOf("a-", "c-"),
199             ["a-onDOMContentLoaded", "a-onCreatedNavigationTarget",
200              "b-onBeforeNavigate"]]);
201         chrome.tabs.update(tabId, { url: getURL('c.html') });
202       },
203     ]);
204   });