Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
| 2 <body> | |
| 3 <script src="../../resources/js-test.js"></script> | |
| 4 <script> | |
| 5 description("This test checks that the page visibility event is fired when frame is unloaded."); | |
| 6 | |
| 7 var jsTestIsAsync = true; | |
| 8 var frames = []; | |
| 9 var docsLoaded = 0, visibilityChanged = 0; | |
| 10 var numFrames = 3; | |
| 11 | |
| 12 function startTest() { | |
|
dcheng
2016/03/11 09:13:36
window.addEventListener('load', function () {
/*
kinuko
2016/03/11 12:55:13
Yup, I figured out that this wouldn't be the simpl
| |
| 13 if (++docsLoaded < numFrames) | |
| 14 return; | |
| 15 | |
| 16 debug("Loaded all frames."); | |
| 17 | |
| 18 frames.push(document.getElementById("frame1")); | |
|
dcheng
2016/03/11 09:13:37
window[0]
| |
| 19 frames.push(frame1.contentDocument.getElementById("subIframe1")); | |
|
dcheng
2016/03/11 09:13:36
window[0][0]
| |
| 20 frames.push(frame1.contentDocument.getElementById("subIframe2")); | |
|
dcheng
2016/03/11 09:13:37
window[0][1]
| |
| 21 | |
| 22 for (var i = 0; i < frames.length; ++i) { | |
| 23 frames[i].contentDocument.addEventListener( | |
|
dcheng
2016/03/11 09:13:36
Then you can just use frames[i].document
kinuko
2016/03/11 12:55:13
cool, done.
| |
| 24 "visibilitychange", | |
| 25 onVisibilityChange.bind(null, i), false); | |
| 26 } | |
| 27 | |
| 28 document.body.removeChild(frames[0]); | |
| 29 } | |
| 30 | |
| 31 function onVisibilityChange(i) { | |
| 32 shouldBe('frames[' + i + '].contentDocument.visibilityState', '"hidden"'); | |
| 33 if (++visibilityChanged == numFrames) | |
| 34 finishJSTest(); | |
| 35 } | |
| 36 | |
| 37 </script> | |
| 38 <iframe id="frame1" src="resources/page-visibility-iframe-with-subframes.html">< /iframe> | |
| 39 </body> | |
| 40 </html> | |
| OLD | NEW |