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() { |
| 13 if (++docsLoaded < numFrames) |
| 14 return; |
| 15 |
| 16 debug("Loaded all frames."); |
| 17 |
| 18 frames.push(document.getElementById("frame1")); |
| 19 frames.push(frame1.contentDocument.getElementById("subIframe1")); |
| 20 frames.push(frame1.contentDocument.getElementById("subIframe2")); |
| 21 |
| 22 for (var i = 0; i < frames.length; ++i) { |
| 23 frames[i].contentDocument.addEventListener( |
| 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 |