OLD | NEW |
1 <script> | 1 <script> |
2 var expectedEventData; | 2 var expectedEventData; |
3 var capturedEventData; | 3 var capturedEventData; |
4 var nextFrameId; | 4 var nextFrameId; |
5 var frameIds; | 5 var frameIds; |
6 | 6 |
7 function expect(data) { | 7 function expect(data) { |
8 expectedEventData = data; | 8 expectedEventData = data; |
9 capturedEventData = []; | 9 capturedEventData = []; |
10 nextFrameId = 1; | 10 nextFrameId = 1; |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 chrome.experimental.webNavigation.onCommitted.addListener(function(details) { | 41 chrome.experimental.webNavigation.onCommitted.addListener(function(details) { |
42 captureEvent("onCommitted", details); | 42 captureEvent("onCommitted", details); |
43 }); | 43 }); |
44 | 44 |
45 chrome.experimental.webNavigation.onDOMContentLoaded.addListener( | 45 chrome.experimental.webNavigation.onDOMContentLoaded.addListener( |
46 function(details) { | 46 function(details) { |
47 captureEvent("onDOMContentLoaded", details); | 47 captureEvent("onDOMContentLoaded", details); |
48 }); | 48 }); |
49 | 49 |
| 50 chrome.experimental.webNavigation.onCompleted.addListener( |
| 51 function(details) { |
| 52 captureEvent("onCompleted", details); |
| 53 }); |
| 54 |
50 chrome.experimental.webNavigation.onErrorOccurred.addListener( | 55 chrome.experimental.webNavigation.onErrorOccurred.addListener( |
51 function(details) { | 56 function(details) { |
52 captureEvent("onErrorOccurred", details); | 57 captureEvent("onErrorOccurred", details); |
53 }); | 58 }); |
54 | 59 |
55 var getURL = chrome.extension.getURL; | 60 var getURL = chrome.extension.getURL; |
56 chrome.tabs.getSelected(null, function(tab) { | 61 chrome.tabs.getSelected(null, function(tab) { |
57 var tabId = tab.id; | 62 var tabId = tab.id; |
58 | 63 |
59 chrome.test.runTests([ | 64 chrome.test.runTests([ |
(...skipping 10 matching lines...) Expand all Loading... |
70 { frameId: 0, | 75 { frameId: 0, |
71 tabId: tabId, | 76 tabId: tabId, |
72 timeStamp: 0, | 77 timeStamp: 0, |
73 transitionQualifiers: "", | 78 transitionQualifiers: "", |
74 transitionType: "link", | 79 transitionType: "link", |
75 url: getURL('simpleLoad/a.html') }], | 80 url: getURL('simpleLoad/a.html') }], |
76 [ "onDOMContentLoaded", | 81 [ "onDOMContentLoaded", |
77 { frameId: 0, | 82 { frameId: 0, |
78 tabId: tabId, | 83 tabId: tabId, |
79 timeStamp: 0, | 84 timeStamp: 0, |
| 85 url: getURL('simpleLoad/a.html') }], |
| 86 [ "onCompleted", |
| 87 { frameId: 0, |
| 88 tabId: tabId, |
| 89 timeStamp: 0, |
80 url: getURL('simpleLoad/a.html') }]]); | 90 url: getURL('simpleLoad/a.html') }]]); |
81 chrome.tabs.update(tabId, { url: getURL('simpleLoad/a.html') }); | 91 chrome.tabs.update(tabId, { url: getURL('simpleLoad/a.html') }); |
82 }, | 92 }, |
83 | 93 |
84 /* Navigates to a.html that redirects to b.html (using javascript) | 94 /* Navigates to a.html that redirects to b.html (using javascript) |
85 after a delay of 500ms, so the initial navigation is completed and | 95 after a delay of 500ms, so the initial navigation is completed and |
86 the redirection is marked as client_redirect */ | 96 the redirection is marked as client_redirect */ |
87 function clientRedirect() { | 97 function clientRedirect() { |
88 expect([ | 98 expect([ |
89 [ "onBeforeNavigate", | 99 [ "onBeforeNavigate", |
90 { frameId: 0, | 100 { frameId: 0, |
91 requestId: 0, | 101 requestId: 0, |
92 tabId: tabId, | 102 tabId: tabId, |
93 timeStamp: 0, | 103 timeStamp: 0, |
94 url: getURL('clientRedirect/a.html') }], | 104 url: getURL('clientRedirect/a.html') }], |
95 [ "onCommitted", | 105 [ "onCommitted", |
96 { frameId: 0, | 106 { frameId: 0, |
97 tabId: tabId, | 107 tabId: tabId, |
98 timeStamp: 0, | 108 timeStamp: 0, |
99 transitionQualifiers: "", | 109 transitionQualifiers: "", |
100 transitionType: "link", | 110 transitionType: "link", |
101 url: getURL('clientRedirect/a.html') }], | 111 url: getURL('clientRedirect/a.html') }], |
102 [ "onDOMContentLoaded", | 112 [ "onDOMContentLoaded", |
103 { frameId: 0, | 113 { frameId: 0, |
104 tabId: tabId, | 114 tabId: tabId, |
105 timeStamp: 0, | 115 timeStamp: 0, |
106 url: getURL('clientRedirect/a.html') }], | 116 url: getURL('clientRedirect/a.html') }], |
| 117 [ "onCompleted", |
| 118 { frameId: 0, |
| 119 tabId: tabId, |
| 120 timeStamp: 0, |
| 121 url: getURL('clientRedirect/a.html') }], |
107 [ "onBeforeNavigate", | 122 [ "onBeforeNavigate", |
108 { frameId: 0, | 123 { frameId: 0, |
109 requestId: 0, | 124 requestId: 0, |
110 tabId: tabId, | 125 tabId: tabId, |
111 timeStamp: 0, | 126 timeStamp: 0, |
112 url: getURL('clientRedirect/b.html') }], | 127 url: getURL('clientRedirect/b.html') }], |
113 [ "onCommitted", | 128 [ "onCommitted", |
114 { frameId: 0, | 129 { frameId: 0, |
115 tabId: tabId, | 130 tabId: tabId, |
116 timeStamp: 0, | 131 timeStamp: 0, |
117 transitionQualifiers: "client_redirect", | 132 transitionQualifiers: "client_redirect", |
118 transitionType: "link", | 133 transitionType: "link", |
119 url: getURL('clientRedirect/b.html') }], | 134 url: getURL('clientRedirect/b.html') }], |
120 [ "onDOMContentLoaded", | 135 [ "onDOMContentLoaded", |
121 { frameId: 0, | 136 { frameId: 0, |
122 tabId: tabId, | 137 tabId: tabId, |
123 timeStamp: 0, | 138 timeStamp: 0, |
| 139 url: getURL('clientRedirect/b.html') }], |
| 140 [ "onCompleted", |
| 141 { frameId: 0, |
| 142 tabId: tabId, |
| 143 timeStamp: 0, |
124 url: getURL('clientRedirect/b.html') }]]); | 144 url: getURL('clientRedirect/b.html') }]]); |
125 chrome.tabs.update(tabId, { url: getURL('clientRedirect/a.html') }); | 145 chrome.tabs.update(tabId, { url: getURL('clientRedirect/a.html') }); |
126 }, | 146 }, |
127 | 147 |
128 /* First navigates to a.html which redirects to to b.html which uses | 148 /* First navigates to a.html which redirects to to b.html which uses |
129 history.back() to navigate back to a.html */ | 149 history.back() to navigate back to a.html */ |
130 function forwardBack() { | 150 function forwardBack() { |
131 expect([ | 151 expect([ |
132 [ "onBeforeNavigate", | 152 [ "onBeforeNavigate", |
133 { frameId: 0, | 153 { frameId: 0, |
134 requestId: 0, | 154 requestId: 0, |
135 tabId: tabId, | 155 tabId: tabId, |
136 timeStamp: 0, | 156 timeStamp: 0, |
137 url: getURL('forwardBack/a.html') }], | 157 url: getURL('forwardBack/a.html') }], |
138 [ "onCommitted", | 158 [ "onCommitted", |
139 { frameId: 0, | 159 { frameId: 0, |
140 tabId: tabId, | 160 tabId: tabId, |
141 timeStamp: 0, | 161 timeStamp: 0, |
142 transitionQualifiers: "", | 162 transitionQualifiers: "", |
143 transitionType: "link", | 163 transitionType: "link", |
144 url: getURL('forwardBack/a.html') }], | 164 url: getURL('forwardBack/a.html') }], |
145 [ "onDOMContentLoaded", | 165 [ "onDOMContentLoaded", |
146 { frameId: 0, | 166 { frameId: 0, |
147 tabId: tabId, | 167 tabId: tabId, |
148 timeStamp: 0, | 168 timeStamp: 0, |
149 url: getURL('forwardBack/a.html') }], | 169 url: getURL('forwardBack/a.html') }], |
| 170 [ "onCompleted", |
| 171 { frameId: 0, |
| 172 tabId: tabId, |
| 173 timeStamp: 0, |
| 174 url: getURL('forwardBack/a.html') }], |
150 [ "onBeforeNavigate", | 175 [ "onBeforeNavigate", |
151 { frameId: 0, | 176 { frameId: 0, |
152 requestId: 0, | 177 requestId: 0, |
153 tabId: tabId, | 178 tabId: tabId, |
154 timeStamp: 0, | 179 timeStamp: 0, |
155 url: getURL('forwardBack/b.html') }], | 180 url: getURL('forwardBack/b.html') }], |
156 [ "onCommitted", | 181 [ "onCommitted", |
157 { frameId: 0, | 182 { frameId: 0, |
158 tabId: tabId, | 183 tabId: tabId, |
159 timeStamp: 0, | 184 timeStamp: 0, |
160 transitionQualifiers: "client_redirect", | 185 transitionQualifiers: "client_redirect", |
161 transitionType: "link", | 186 transitionType: "link", |
162 url: getURL('forwardBack/b.html') }], | 187 url: getURL('forwardBack/b.html') }], |
163 [ "onDOMContentLoaded", | 188 [ "onDOMContentLoaded", |
164 { frameId: 0, | 189 { frameId: 0, |
165 tabId: tabId, | 190 tabId: tabId, |
166 timeStamp: 0, | 191 timeStamp: 0, |
167 url: getURL('forwardBack/b.html') }], | 192 url: getURL('forwardBack/b.html') }], |
| 193 [ "onCompleted", |
| 194 { frameId: 0, |
| 195 tabId: tabId, |
| 196 timeStamp: 0, |
| 197 url: getURL('forwardBack/b.html') }], |
168 [ "onBeforeNavigate", | 198 [ "onBeforeNavigate", |
169 { frameId: 0, | 199 { frameId: 0, |
170 requestId: 0, | 200 requestId: 0, |
171 tabId: tabId, | 201 tabId: tabId, |
172 timeStamp: 0, | 202 timeStamp: 0, |
173 url: getURL('forwardBack/a.html') }], | 203 url: getURL('forwardBack/a.html') }], |
174 [ "onCommitted", | 204 [ "onCommitted", |
175 { frameId: 0, | 205 { frameId: 0, |
176 tabId: tabId, | 206 tabId: tabId, |
177 timeStamp: 0, | 207 timeStamp: 0, |
178 transitionQualifiers: "forward_back", | 208 transitionQualifiers: "forward_back", |
179 transitionType: "link", | 209 transitionType: "link", |
180 url: getURL('forwardBack/a.html') }], | 210 url: getURL('forwardBack/a.html') }], |
181 [ "onDOMContentLoaded", | 211 [ "onDOMContentLoaded", |
182 { frameId: 0, | 212 { frameId: 0, |
183 tabId: tabId, | 213 tabId: tabId, |
184 timeStamp: 0, | 214 timeStamp: 0, |
| 215 url: getURL('forwardBack/a.html') }], |
| 216 [ "onCompleted", |
| 217 { frameId: 0, |
| 218 tabId: tabId, |
| 219 timeStamp: 0, |
185 url: getURL('forwardBack/a.html') }]]); | 220 url: getURL('forwardBack/a.html') }]]); |
186 chrome.tabs.update(tabId, { url: getURL('forwardBack/a.html') }); | 221 chrome.tabs.update(tabId, { url: getURL('forwardBack/a.html') }); |
187 }, | 222 }, |
188 | 223 |
189 /* Navigates to a.html which includes b.html as an iframe. b.html | 224 /* Navigates to a.html which includes b.html as an iframe. b.html |
190 redirects to c.html. */ | 225 redirects to c.html. */ |
191 function iframe() { | 226 function iframe() { |
192 expect([ | 227 expect([ |
193 [ "onBeforeNavigate", | 228 [ "onBeforeNavigate", |
194 { frameId: 0, | 229 { frameId: 0, |
(...skipping 24 matching lines...) Expand all Loading... |
219 tabId: tabId, | 254 tabId: tabId, |
220 timeStamp: 0, | 255 timeStamp: 0, |
221 transitionQualifiers: "", | 256 transitionQualifiers: "", |
222 transitionType: "auto_subframe", | 257 transitionType: "auto_subframe", |
223 url: getURL('iframe/b.html') }], | 258 url: getURL('iframe/b.html') }], |
224 [ "onDOMContentLoaded", | 259 [ "onDOMContentLoaded", |
225 { frameId: 1, | 260 { frameId: 1, |
226 tabId: tabId, | 261 tabId: tabId, |
227 timeStamp: 0, | 262 timeStamp: 0, |
228 url: getURL('iframe/b.html') }], | 263 url: getURL('iframe/b.html') }], |
| 264 [ "onCompleted", |
| 265 { frameId: 1, |
| 266 tabId: tabId, |
| 267 timeStamp: 0, |
| 268 url: getURL('iframe/b.html') }], |
| 269 [ "onCompleted", |
| 270 { frameId: 0, |
| 271 tabId: tabId, |
| 272 timeStamp: 0, |
| 273 url: getURL('iframe/a.html') }], |
229 [ "onBeforeNavigate", | 274 [ "onBeforeNavigate", |
230 { frameId: 1, | 275 { frameId: 1, |
231 requestId: 0, | 276 requestId: 0, |
232 tabId: tabId, | 277 tabId: tabId, |
233 timeStamp: 0, | 278 timeStamp: 0, |
234 url: getURL('iframe/c.html') }], | 279 url: getURL('iframe/c.html') }], |
235 [ "onCommitted", | 280 [ "onCommitted", |
236 { frameId: 1, | 281 { frameId: 1, |
237 tabId: tabId, | 282 tabId: tabId, |
238 timeStamp: 0, | 283 timeStamp: 0, |
239 transitionQualifiers: "", | 284 transitionQualifiers: "", |
240 transitionType: "manual_subframe", | 285 transitionType: "manual_subframe", |
241 url: getURL('iframe/c.html') }], | 286 url: getURL('iframe/c.html') }], |
242 [ "onDOMContentLoaded", | 287 [ "onDOMContentLoaded", |
243 { frameId: 1, | 288 { frameId: 1, |
244 tabId: tabId, | 289 tabId: tabId, |
245 timeStamp: 0, | 290 timeStamp: 0, |
| 291 url: getURL('iframe/c.html') }], |
| 292 [ "onCompleted", |
| 293 { frameId: 1, |
| 294 tabId: tabId, |
| 295 timeStamp: 0, |
246 url: getURL('iframe/c.html') }]]); | 296 url: getURL('iframe/c.html') }]]); |
247 chrome.tabs.update(tabId, { url: getURL('iframe/a.html') }); | 297 chrome.tabs.update(tabId, { url: getURL('iframe/a.html') }); |
248 }, | 298 }, |
249 | 299 |
250 /* Navigates to d.html which includes e.html and f.html as iframes. To be | 300 /* Navigates to d.html which includes e.html and f.html as iframes. To be |
251 able to predict which iframe has which id, the iframe for f.html is | 301 able to predict which iframe has which id, the iframe for f.html is |
252 created by javascript. f.html then navigates to g.html. */ | 302 created by javascript. f.html then navigates to g.html. */ |
253 function iframe2() { | 303 function iframe2() { |
254 expect([ | 304 expect([ |
255 [ "onBeforeNavigate", | 305 [ "onBeforeNavigate", |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 { frameId: 1, | 337 { frameId: 1, |
288 tabId: tabId, | 338 tabId: tabId, |
289 timeStamp: 0, | 339 timeStamp: 0, |
290 url: getURL('iframe/e.html') }], | 340 url: getURL('iframe/e.html') }], |
291 [ "onBeforeNavigate", | 341 [ "onBeforeNavigate", |
292 { frameId: 2, | 342 { frameId: 2, |
293 requestId: 0, | 343 requestId: 0, |
294 tabId: tabId, | 344 tabId: tabId, |
295 timeStamp: 0, | 345 timeStamp: 0, |
296 url: getURL('iframe/f.html') }], | 346 url: getURL('iframe/f.html') }], |
| 347 [ "onCompleted", |
| 348 { frameId: 1, |
| 349 tabId: tabId, |
| 350 timeStamp: 0, |
| 351 url: getURL('iframe/e.html') }], |
297 [ "onCommitted", | 352 [ "onCommitted", |
298 { frameId: 2, | 353 { frameId: 2, |
299 tabId: tabId, | 354 tabId: tabId, |
300 timeStamp: 0, | 355 timeStamp: 0, |
301 transitionQualifiers: "", | 356 transitionQualifiers: "", |
302 transitionType: "auto_subframe", | 357 transitionType: "auto_subframe", |
303 url: getURL('iframe/f.html') }], | 358 url: getURL('iframe/f.html') }], |
304 [ "onDOMContentLoaded", | 359 [ "onDOMContentLoaded", |
305 { frameId: 2, | 360 { frameId: 2, |
306 tabId: tabId, | 361 tabId: tabId, |
307 timeStamp: 0, | 362 timeStamp: 0, |
308 url: getURL('iframe/f.html') }], | 363 url: getURL('iframe/f.html') }], |
| 364 [ "onCompleted", |
| 365 { frameId: 2, |
| 366 tabId: tabId, |
| 367 timeStamp: 0, |
| 368 url: getURL('iframe/f.html') }], |
| 369 [ "onCompleted", |
| 370 { frameId: 0, |
| 371 tabId: tabId, |
| 372 timeStamp: 0, |
| 373 url: getURL('iframe/d.html') }], |
309 [ "onBeforeNavigate", | 374 [ "onBeforeNavigate", |
310 { frameId: 2, | 375 { frameId: 2, |
311 requestId: 0, | 376 requestId: 0, |
312 tabId: tabId, | 377 tabId: tabId, |
313 timeStamp: 0, | 378 timeStamp: 0, |
314 url: getURL('iframe/g.html') }], | 379 url: getURL('iframe/g.html') }], |
315 [ "onCommitted", | 380 [ "onCommitted", |
316 { frameId: 2, | 381 { frameId: 2, |
317 tabId: tabId, | 382 tabId: tabId, |
318 timeStamp: 0, | 383 timeStamp: 0, |
319 transitionQualifiers: "", | 384 transitionQualifiers: "", |
320 transitionType: "manual_subframe", | 385 transitionType: "manual_subframe", |
321 url: getURL('iframe/g.html') }], | 386 url: getURL('iframe/g.html') }], |
322 [ "onDOMContentLoaded", | 387 [ "onDOMContentLoaded", |
323 { frameId: 2, | 388 { frameId: 2, |
324 tabId: tabId, | 389 tabId: tabId, |
325 timeStamp: 0, | 390 timeStamp: 0, |
| 391 url: getURL('iframe/g.html') }], |
| 392 [ "onCompleted", |
| 393 { frameId: 2, |
| 394 tabId: tabId, |
| 395 timeStamp: 0, |
326 url: getURL('iframe/g.html') }]]); | 396 url: getURL('iframe/g.html') }]]); |
327 chrome.tabs.update(tabId, { url: getURL('iframe/d.html') }); | 397 chrome.tabs.update(tabId, { url: getURL('iframe/d.html') }); |
328 }, | 398 }, |
329 ]); | 399 ]); |
330 }); | 400 }); |
331 </script> | 401 </script> |
OLD | NEW |