OLD | NEW |
---|---|
(Empty) | |
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 function runTests() { | |
6 var getURL = chrome.extension.getURL; | |
7 var URL_REGULAR = | |
8 "http://127.0.0.1:PORT/files/extensions/api_test/webnavigation/crossProces s/b.html"; | |
9 var URL_REDIRECT = "http://www.a.com:PORT/server-redirect"; | |
10 var URL_SLOW = "http://127.0.0.1:PORT/slow"; | |
11 chrome.tabs.create({"url": "about:blank"}, function(tab) { | |
12 var tabId = tab.id; | |
13 chrome.test.getConfig(function(config) { | |
14 var fixPort = function(url) { | |
15 return url.replace(/PORT/g, config.testServer.port); | |
16 }; | |
17 URL_REGULAR = fixPort(URL_REGULAR); | |
18 URL_REDIRECT = fixPort(URL_REDIRECT); | |
19 URL_SLOW = fixPort(URL_SLOW); | |
20 | |
21 chrome.test.runTests([ | |
22 // Navigates from an extension page to a HTTP page which causes a | |
23 // process switch. | |
24 function crossProcess() { | |
25 expect([ | |
26 { label: "a-onBeforeNavigate", | |
27 event: "onBeforeNavigate", | |
28 details: { frameId: 0, | |
29 processId: 0, | |
30 tabId: 0, | |
31 timeStamp: 0, | |
32 url: getURL('crossProcess/a.html') }}, | |
33 { label: "a-onCommitted", | |
34 event: "onCommitted", | |
35 details: { frameId: 0, | |
36 processId: 0, | |
37 tabId: 0, | |
38 timeStamp: 0, | |
39 transitionQualifiers: [], | |
40 transitionType: "link", | |
41 url: getURL('crossProcess/a.html') }}, | |
42 { label: "a-onDOMContentLoaded", | |
43 event: "onDOMContentLoaded", | |
44 details: { frameId: 0, | |
45 processId: 0, | |
46 tabId: 0, | |
47 timeStamp: 0, | |
48 url: getURL('crossProcess/a.html') }}, | |
49 { label: "a-onCompleted", | |
50 event: "onCompleted", | |
51 details: { frameId: 0, | |
52 processId: 0, | |
53 tabId: 0, | |
54 timeStamp: 0, | |
55 url: getURL('crossProcess/a.html') }}, | |
56 { label: "b-onBeforeNavigate", | |
57 event: "onBeforeNavigate", | |
58 details: { frameId: 0, | |
59 processId: 1, | |
60 tabId: 0, | |
61 timeStamp: 0, | |
62 url: URL_REGULAR }}, | |
63 { label: "b-onCommitted", | |
64 event: "onCommitted", | |
65 details: { frameId: 0, | |
66 processId: 1, | |
67 tabId: 0, | |
68 timeStamp: 0, | |
69 transitionQualifiers: [], | |
70 transitionType: "link", | |
71 url: URL_REGULAR }}, | |
72 { label: "b-onDOMContentLoaded", | |
73 event: "onDOMContentLoaded", | |
74 details: { frameId: 0, | |
75 processId: 1, | |
76 tabId: 0, | |
77 timeStamp: 0, | |
78 url: URL_REGULAR }}, | |
79 { label: "b-onCompleted", | |
80 event: "onCompleted", | |
81 details: { frameId: 0, | |
82 processId: 1, | |
83 tabId: 0, | |
84 timeStamp: 0, | |
85 url: URL_REGULAR }}], | |
86 [ navigationOrder("a-"), navigationOrder("b-") ]); | |
87 | |
88 chrome.tabs.update( | |
89 tabId, | |
90 { url: getURL('crossProcess/a.html?' + config.testServer.port) }); | |
91 }, | |
92 | |
93 // Redirects through an app extend, should cause two process switches. | |
Charlie Reis
2012/08/06 20:04:13
nit: extend -> extent
jochen (gone - plz use gerrit)
2012/08/06 21:08:39
Done.
| |
94 function crossProcessRedirect() { | |
95 expect([ | |
96 { label: "a-onBeforeNavigate", | |
97 event: "onBeforeNavigate", | |
98 details: { frameId: 0, | |
99 processId: 0, | |
100 tabId: 0, | |
101 timeStamp: 0, | |
102 url: getURL('crossProcess/c.html') }}, | |
103 { label: "a-onCommitted", | |
104 event: "onCommitted", | |
105 details: { frameId: 0, | |
106 processId: 0, | |
107 tabId: 0, | |
108 timeStamp: 0, | |
109 transitionQualifiers: [], | |
110 transitionType: "link", | |
111 url: getURL('crossProcess/c.html') }}, | |
112 { label: "a-onDOMContentLoaded", | |
113 event: "onDOMContentLoaded", | |
114 details: { frameId: 0, | |
115 processId: 0, | |
116 tabId: 0, | |
117 timeStamp: 0, | |
118 url: getURL('crossProcess/c.html') }}, | |
119 { label: "a-onCompleted", | |
120 event: "onCompleted", | |
121 details: { frameId: 0, | |
122 processId: 0, | |
123 tabId: 0, | |
124 timeStamp: 0, | |
125 url: getURL('crossProcess/c.html') }}, | |
126 { label: "b-onBeforeNavigate", | |
127 event: "onBeforeNavigate", | |
128 details: { frameId: 0, | |
129 processId: 1, | |
130 tabId: 0, | |
131 timeStamp: 0, | |
132 url: URL_REDIRECT }}, | |
133 { label: "b-onErrorOccurred", | |
134 event: "onErrorOccurred", | |
135 details: { error: "net::ERR_ABORTED", | |
136 frameId: 0, | |
137 processId: 1, | |
138 tabId: 0, | |
139 timeStamp: 0, | |
140 url: URL_REDIRECT }}, | |
141 { label: "c-onBeforeNavigate", | |
142 event: "onBeforeNavigate", | |
143 details: { frameId: 0, | |
144 processId: 2, | |
145 tabId: 0, | |
146 timeStamp: 0, | |
147 url: URL_REGULAR }}, | |
148 { label: "c-onCommitted", | |
149 event: "onCommitted", | |
150 details: { frameId: 0, | |
151 processId: 2, | |
152 tabId: 0, | |
153 timeStamp: 0, | |
154 transitionQualifiers: [], | |
155 transitionType: "link", | |
156 url: URL_REGULAR }}, | |
157 { label: "c-onDOMContentLoaded", | |
158 event: "onDOMContentLoaded", | |
159 details: { frameId: 0, | |
160 processId: 2, | |
161 tabId: 0, | |
162 timeStamp: 0, | |
163 url: URL_REGULAR }}, | |
164 { label: "c-onCompleted", | |
165 event: "onCompleted", | |
166 details: { frameId: 0, | |
167 processId: 2, | |
168 tabId: 0, | |
169 timeStamp: 0, | |
170 url: URL_REGULAR }}], | |
171 [ navigationOrder("a-"), | |
172 navigationOrder("c-"), | |
173 [ "a-onCompleted", "b-onBeforeNavigate", "b-onErrorOccurred", | |
174 "c-onBeforeNavigate"] ]); | |
175 | |
176 chrome.tabs.update( | |
177 tabId, | |
178 { url: getURL('crossProcess/c.html?' + config.testServer.port) }); | |
179 }, | |
180 | |
181 // Navigates to a different site, but then aborts the navigation by | |
182 // starting a new one. | |
183 function crossProcessAbort() { | |
184 expect([ | |
185 { label: "a-onBeforeNavigate", | |
186 event: "onBeforeNavigate", | |
187 details: { frameId: 0, | |
188 processId: 0, | |
189 tabId: 0, | |
190 timeStamp: 0, | |
191 url: getURL('crossProcess/d.html') }}, | |
192 { label: "a-onCommitted", | |
193 event: "onCommitted", | |
194 details: { frameId: 0, | |
195 processId: 0, | |
196 tabId: 0, | |
197 timeStamp: 0, | |
198 transitionQualifiers: [], | |
199 transitionType: "link", | |
200 url: getURL('crossProcess/d.html') }}, | |
201 { label: "a-onDOMContentLoaded", | |
202 event: "onDOMContentLoaded", | |
203 details: { frameId: 0, | |
204 processId: 0, | |
205 tabId: 0, | |
206 timeStamp: 0, | |
207 url: getURL('crossProcess/d.html') }}, | |
208 { label: "a-onCompleted", | |
209 event: "onCompleted", | |
210 details: { frameId: 0, | |
211 processId: 0, | |
212 tabId: 0, | |
213 timeStamp: 0, | |
214 url: getURL('crossProcess/d.html') }}, | |
215 { label: "b-onBeforeNavigate", | |
216 event: "onBeforeNavigate", | |
217 details: { frameId: 0, | |
218 processId: 1, | |
219 tabId: 0, | |
220 timeStamp: 0, | |
221 url: URL_SLOW }}, | |
222 { label: "b-onErrorOccurred", | |
223 event: "onErrorOccurred", | |
224 details: { error: "net::ERR_ABORTED", | |
225 frameId: 0, | |
226 processId: 1, | |
227 tabId: 0, | |
228 timeStamp: 0, | |
229 url: URL_SLOW }}, | |
230 { label: "c-onBeforeNavigate", | |
231 event: "onBeforeNavigate", | |
232 details: { frameId: 0, | |
233 processId: 0, | |
234 tabId: 0, | |
235 timeStamp: 0, | |
236 url: getURL('crossProcess/b.html') }}, | |
237 { label: "c-onCommitted", | |
238 event: "onCommitted", | |
239 details: { frameId: 0, | |
240 processId: 0, | |
241 tabId: 0, | |
242 timeStamp: 0, | |
243 transitionQualifiers: ["client_redirect"], | |
244 transitionType: "link", | |
245 url: getURL('crossProcess/b.html') }}, | |
246 { label: "c-onDOMContentLoaded", | |
247 event: "onDOMContentLoaded", | |
248 details: { frameId: 0, | |
249 processId: 0, | |
250 tabId: 0, | |
251 timeStamp: 0, | |
252 url: getURL('crossProcess/b.html') }}, | |
253 { label: "c-onCompleted", | |
254 event: "onCompleted", | |
255 details: { frameId: 0, | |
256 processId: 0, | |
257 tabId: 0, | |
258 timeStamp: 0, | |
259 url: getURL('crossProcess/b.html') }}], | |
260 [ navigationOrder("a-"), | |
261 navigationOrder("c-"), | |
262 [ "a-onCompleted", "b-onBeforeNavigate", "b-onErrorOccurred", | |
263 "c-onCommitted"] ]); | |
264 | |
265 chrome.tabs.update( | |
266 tabId, | |
267 { url: getURL('crossProcess/d.html?' + config.testServer.port) }); | |
268 }, | |
269 | |
270 // Navigates to a different site, but then modifies the history using | |
271 // history.pushState(). | |
272 function crossProcessHistory() { | |
273 expect([ | |
274 { label: "a-onBeforeNavigate", | |
275 event: "onBeforeNavigate", | |
276 details: { frameId: 0, | |
277 processId: 0, | |
278 tabId: 0, | |
279 timeStamp: 0, | |
280 url: getURL('crossProcess/e.html') }}, | |
281 { label: "a-onCommitted", | |
282 event: "onCommitted", | |
283 details: { frameId: 0, | |
284 processId: 0, | |
285 tabId: 0, | |
286 timeStamp: 0, | |
287 transitionQualifiers: [], | |
288 transitionType: "link", | |
289 url: getURL('crossProcess/e.html') }}, | |
290 { label: "a-onDOMContentLoaded", | |
291 event: "onDOMContentLoaded", | |
292 details: { frameId: 0, | |
293 processId: 0, | |
294 tabId: 0, | |
295 timeStamp: 0, | |
296 url: getURL('crossProcess/e.html') }}, | |
297 { label: "a-onCompleted", | |
298 event: "onCompleted", | |
299 details: { frameId: 0, | |
300 processId: 0, | |
301 tabId: 0, | |
302 timeStamp: 0, | |
303 url: getURL('crossProcess/e.html') }}, | |
304 { label: "a-onHistoryStateUpdated", | |
305 event: "onHistoryStateUpdated", | |
306 details: { frameId: 0, | |
307 processId: 0, | |
308 tabId: 0, | |
309 timeStamp: 0, | |
310 transitionQualifiers: ["client_redirect"], | |
311 transitionType: "link", | |
312 url: getURL('crossProcess/b.html') }}, | |
313 { label: "b-onBeforeNavigate", | |
314 event: "onBeforeNavigate", | |
315 details: { frameId: 0, | |
316 processId: 1, | |
317 tabId: 0, | |
318 timeStamp: 0, | |
319 url: URL_SLOW }}, | |
320 { label: "b-onErrorOccurred", | |
321 event: "onErrorOccurred", | |
322 details: { error: "net::ERR_ABORTED", | |
323 frameId: 0, | |
324 processId: 1, | |
325 tabId: 0, | |
326 timeStamp: 0, | |
327 url: URL_SLOW }}], | |
328 [ navigationOrder("a-"), | |
329 [ "a-onCompleted", "b-onBeforeNavigate", | |
330 "a-onHistoryStateUpdated"] ]); | |
331 | |
332 chrome.tabs.update( | |
333 tabId, | |
334 { url: getURL('crossProcess/e.html?' + config.testServer.port) }); | |
335 }, | |
336 | |
337 // Navigates to a different site, but then modifies the reference | |
338 // framgent. | |
339 function crossProcessFragment() { | |
340 expect([ | |
341 { label: "a-onBeforeNavigate", | |
342 event: "onBeforeNavigate", | |
343 details: { frameId: 0, | |
344 processId: 0, | |
345 tabId: 0, | |
346 timeStamp: 0, | |
347 url: getURL('crossProcess/f.html') }}, | |
348 { label: "a-onCommitted", | |
349 event: "onCommitted", | |
350 details: { frameId: 0, | |
351 processId: 0, | |
352 tabId: 0, | |
353 timeStamp: 0, | |
354 transitionQualifiers: [], | |
355 transitionType: "link", | |
356 url: getURL('crossProcess/f.html') }}, | |
357 { label: "a-onDOMContentLoaded", | |
358 event: "onDOMContentLoaded", | |
359 details: { frameId: 0, | |
360 processId: 0, | |
361 tabId: 0, | |
362 timeStamp: 0, | |
363 url: getURL('crossProcess/f.html') }}, | |
364 { label: "a-onCompleted", | |
365 event: "onCompleted", | |
366 details: { frameId: 0, | |
367 processId: 0, | |
368 tabId: 0, | |
369 timeStamp: 0, | |
370 url: getURL('crossProcess/f.html') }}, | |
371 { label: "a-onReferenceFragmentUpdated", | |
372 event: "onReferenceFragmentUpdated", | |
373 details: { frameId: 0, | |
374 processId: 0, | |
375 tabId: 0, | |
376 timeStamp: 0, | |
377 transitionQualifiers: [], | |
378 transitionType: "link", | |
379 url: getURL('crossProcess/f.html#foo') }}, | |
380 { label: "b-onBeforeNavigate", | |
381 event: "onBeforeNavigate", | |
382 details: { frameId: 0, | |
383 processId: 1, | |
384 tabId: 0, | |
385 timeStamp: 0, | |
386 url: URL_SLOW }}, | |
387 { label: "b-onErrorOccurred", | |
388 event: "onErrorOccurred", | |
389 details: { error: "net::ERR_ABORTED", | |
390 frameId: 0, | |
391 processId: 1, | |
392 tabId: 0, | |
393 timeStamp: 0, | |
394 url: URL_SLOW }}], | |
395 [ navigationOrder("a-"), | |
396 [ "a-onCompleted", "b-onBeforeNavigate", | |
397 "a-onReferenceFragmentUpdated"] ]); | |
398 | |
399 chrome.tabs.update( | |
400 tabId, | |
401 { url: getURL('crossProcess/f.html?' + config.testServer.port) }); | |
402 }, | |
403 ]); | |
404 }); | |
405 }); | |
406 } | |
OLD | NEW |