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.
6 var getURL = chrome.extension.getURL;
7 chrome.tabs.create({"url": "about:blank"}, function(tab) {
10 chrome.test.runTests([
11 // Navigates to a.html which includes b.html as an iframe. b.html
12 // redirects to c.html.
15 { label: "a-onBeforeNavigate",
16 event: "onBeforeNavigate",
17 details: { frameId: 0,
22 url: getURL('a.html') }},
23 { label: "a-onCommitted",
25 details: { frameId: 0,
29 transitionQualifiers: [],
30 transitionType: "link",
31 url: getURL('a.html') }},
32 { label: "a-onDOMContentLoaded",
33 event: "onDOMContentLoaded",
34 details: { frameId: 0,
38 url: getURL('a.html') }},
39 { label: "a-onCompleted",
41 details: { frameId: 0,
45 url: getURL('a.html') }},
46 { label: "b-onBeforeNavigate",
47 event: "onBeforeNavigate",
48 details: { frameId: 1,
53 url: getURL('b.html') }},
54 { label: "b-onCommitted",
56 details: { frameId: 1,
60 transitionQualifiers: [],
61 transitionType: "auto_subframe",
62 url: getURL('b.html') }},
63 { label: "b-onDOMContentLoaded",
64 event: "onDOMContentLoaded",
65 details: { frameId: 1,
69 url: getURL('b.html') }},
70 { label: "b-onCompleted",
72 details: { frameId: 1,
76 url: getURL('b.html') }},
77 { label: "c-onBeforeNavigate",
78 event: "onBeforeNavigate",
79 details: { frameId: 1,
84 url: getURL('c.html') }},
85 { label: "c-onCommitted",
87 details: { frameId: 1,
91 transitionQualifiers: [],
92 transitionType: "auto_subframe",
93 url: getURL('c.html') }},
94 { label: "c-onDOMContentLoaded",
95 event: "onDOMContentLoaded",
96 details: { frameId: 1,
100 url: getURL('c.html') }},
101 { label: "c-onCompleted",
102 event: "onCompleted",
103 details: { frameId: 1,
107 url: getURL('c.html') }}],
108 [ navigationOrder("a-"),
109 navigationOrder("b-"),
110 navigationOrder("c-"),
111 isIFrameOf("b-", "a-"),
112 isLoadedBy("c-", "b-")]);
113 chrome.tabs.update(tabId, { url: getURL('a.html') });
116 // Navigates to d.html which includes e.html and f.html as iframes. To be
117 // able to predict which iframe has which id, the iframe for f.html is
118 // created by javascript. f.html then navigates to g.html.
119 function iframeMultiple() {
121 { label: "d-onBeforeNavigate",
122 event: "onBeforeNavigate",
123 details: { frameId: 0,
128 url: getURL('d.html') }},
129 { label: "d-onCommitted",
130 event: "onCommitted",
131 details: { frameId: 0,
135 transitionQualifiers: [],
136 transitionType: "link",
137 url: getURL('d.html') }},
138 { label: "d-onDOMContentLoaded",
139 event: "onDOMContentLoaded",
140 details: { frameId: 0,
144 url: getURL('d.html') }},
145 { label: "d-onCompleted",
146 event: "onCompleted",
147 details: { frameId: 0,
151 url: getURL('d.html') }},
152 { label: "e-onBeforeNavigate",
153 event: "onBeforeNavigate",
154 details: { frameId: 1,
159 url: getURL('e.html') }},
160 { label: "e-onCommitted",
161 event: "onCommitted",
162 details: { frameId: 1,
166 transitionQualifiers: [],
167 transitionType: "auto_subframe",
168 url: getURL('e.html') }},
169 { label: "e-onDOMContentLoaded",
170 event: "onDOMContentLoaded",
171 details: { frameId: 1,
175 url: getURL('e.html') }},
176 { label: "e-onCompleted",
177 event: "onCompleted",
178 details: { frameId: 1,
182 url: getURL('e.html') }},
183 { label: "f-onBeforeNavigate",
184 event: "onBeforeNavigate",
185 details: { frameId: 2,
190 url: getURL('f.html') }},
191 { label: "f-onCommitted",
192 event: "onCommitted",
193 details: { frameId: 2,
197 transitionQualifiers: [],
198 transitionType: "auto_subframe",
199 url: getURL('f.html') }},
200 { label: "f-onDOMContentLoaded",
201 event: "onDOMContentLoaded",
202 details: { frameId: 2,
206 url: getURL('f.html') }},
207 { label: "f-onCompleted",
208 event: "onCompleted",
209 details: { frameId: 2,
213 url: getURL('f.html') }},
214 { label: "g-onBeforeNavigate",
215 event: "onBeforeNavigate",
216 details: { frameId: 2,
221 url: getURL('g.html') }},
222 { label: "g-onCommitted",
223 event: "onCommitted",
224 details: { frameId: 2,
228 transitionQualifiers: [],
229 transitionType: "auto_subframe",
230 url: getURL('g.html') }},
231 { label: "g-onDOMContentLoaded",
232 event: "onDOMContentLoaded",
233 details: { frameId: 2,
237 url: getURL('g.html') }},
238 { label: "g-onCompleted",
239 event: "onCompleted",
240 details: { frameId: 2,
244 url: getURL('g.html') }}],
245 [ navigationOrder("d-"),
246 navigationOrder("e-"),
247 navigationOrder("f-"),
248 navigationOrder("g-"),
249 isIFrameOf("e-", "d-"),
250 ["d-onDOMContentLoaded", "f-onBeforeNavigate", "f-onCompleted",
252 isLoadedBy("g-", "f-")]);
253 chrome.tabs.update(tabId, { url: getURL('d.html') });
256 // Navigates to h.html which includes i.html that triggers a navigation
257 // on the main frame.
258 function iframeNavigate() {
260 { label: "h-onBeforeNavigate",
261 event: "onBeforeNavigate",
262 details: { frameId: 0,
267 url: getURL('h.html') }},
268 { label: "h-onCommitted",
269 event: "onCommitted",
270 details: { frameId: 0,
274 transitionQualifiers: [],
275 transitionType: "link",
276 url: getURL('h.html') }},
277 { label: "h-onDOMContentLoaded",
278 event: "onDOMContentLoaded",
279 details: { frameId: 0,
283 url: getURL('h.html') }},
284 { label: "h-onCompleted",
285 event: "onCompleted",
286 details: { frameId: 0,
290 url: getURL('h.html') }},
291 { label: "i-onBeforeNavigate",
292 event: "onBeforeNavigate",
293 details: { frameId: 1,
298 url: getURL('i.html') }},
299 { label: "i-onCommitted",
300 event: "onCommitted",
301 details: { frameId: 1,
305 transitionQualifiers: [],
306 transitionType: "auto_subframe",
307 url: getURL('i.html') }},
308 { label: "i-onDOMContentLoaded",
309 event: "onDOMContentLoaded",
310 details: { frameId: 1,
314 url: getURL('i.html') }},
315 { label: "i-onCompleted",
316 event: "onCompleted",
317 details: { frameId: 1,
321 url: getURL('i.html') }},
322 { label: "c-onBeforeNavigate",
323 event: "onBeforeNavigate",
324 details: { frameId: 0,
329 url: getURL('c.html') }},
330 { label: "c-onCommitted",
331 event: "onCommitted",
332 details: { frameId: 0,
336 transitionQualifiers: ['maybe_client_redirect'],
337 transitionType: "link",
338 url: getURL('c.html') }},
339 { label: "c-onDOMContentLoaded",
340 event: "onDOMContentLoaded",
341 details: { frameId: 0,
345 url: getURL('c.html') }},
346 { label: "c-onCompleted",
347 event: "onCompleted",
348 details: { frameId: 0,
352 url: getURL('c.html') }}],
353 [ navigationOrder("h-"),
354 navigationOrder("i-"),
355 navigationOrder("c-"),
356 isIFrameOf("i-", "h-"),
357 isLoadedBy("c-", "i-") ]);
358 chrome.tabs.update(tabId, { url: getURL('h.html') });