OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var config; | 5 var config; |
6 var MAIN_HOST = 'b.com'; | 6 var MAIN_HOST = 'b.com'; |
7 var OTHER_HOST = 'c.com'; | 7 var OTHER_HOST = 'c.com'; |
8 | 8 |
9 var DOMContentLoadedEventsInFrame = []; | 9 var DOMContentLoadedEventsInFrame = []; |
10 | 10 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 }); | 280 }); |
281 } | 281 } |
282 | 282 |
283 // Checks whether the content scripts were run as expected in the frame that | 283 // Checks whether the content scripts were run as expected in the frame that |
284 // just received a failed provisional load (=received 204 reply). | 284 // just received a failed provisional load (=received 204 reply). |
285 function checkManifestScriptsAfter204Navigation(tabId) { | 285 function checkManifestScriptsAfter204Navigation(tabId) { |
286 chrome.tabs.executeScript(tabId, { | 286 chrome.tabs.executeScript(tabId, { |
287 allFrames: true, | 287 allFrames: true, |
288 code: '[' + | 288 code: '[' + |
289 '[window.documentStart,' + | 289 '[window.documentStart,' + |
290 ' window.documentEnd],' + | 290 ' window.documentEnd,' + |
| 291 ' performance.timing.domContentLoadedEventStart > 0],' + |
291 '[window.didRunAtDocumentStartUnexpected,' + | 292 '[window.didRunAtDocumentStartUnexpected,' + |
292 ' window.didRunAtDocumentEndUnexpected],' + | 293 ' window.didRunAtDocumentEndUnexpected],' + |
293 ']', | 294 ']', |
294 }, chrome.test.callbackPass(function(results) { | 295 }, chrome.test.callbackPass(function(results) { |
295 chrome.test.assertEq(2, results.length); | 296 chrome.test.assertEq(2, results.length); |
296 // Main frame. Should not be affected by child frame navigations. | 297 // Main frame. Should not be affected by child frame navigations. |
297 chrome.test.assertEq([[1, 1], [null, null]], results[0]); | 298 chrome.test.assertEq([[1, 1, true], [null, null]], results[0]); |
298 | 299 |
299 // Child frame. | 300 // Child frame. |
| 301 if (!results[1][0][2]) { // = if DOMContentLoaded did not run. |
| 302 // If the 204 reply was handled faster than the parsing of the frame |
| 303 // document, then the DOMContentLoaded event won't be triggered. |
| 304 chrome.test.assertEq([ |
| 305 // The 204 navigation was triggered by the page, so the document_start |
| 306 // script should have run by then. But since DOMContentLoaded is not |
| 307 // triggered, the document_end script should not run either. |
| 308 [1, null, false], |
| 309 // Should not inject non-matching scripts. |
| 310 [null, null], |
| 311 ], results[1]); |
| 312 return; |
| 313 } |
300 chrome.test.assertEq([ | 314 chrome.test.assertEq([ |
301 // Should run the content scripts even after a navigation to 204. | 315 // Should run the content scripts even after a navigation to 204. |
302 [1, 1], | 316 [1, 1, true], |
303 // Should not inject non-matching scripts. | 317 // Should not inject non-matching scripts. |
304 [null, null], | 318 [null, null], |
305 ], results[1]); | 319 ], results[1]); |
306 })); | 320 })); |
307 } | 321 } |
OLD | NEW |