Index: third_party/WebKit/LayoutTests/fast/events/page-visibility-iframe-unload.html |
diff --git a/third_party/WebKit/LayoutTests/fast/events/page-visibility-iframe-unload.html b/third_party/WebKit/LayoutTests/fast/events/page-visibility-iframe-unload.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2f148ab5f9c1c2559648508add39cc2c721d2faf |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/events/page-visibility-iframe-unload.html |
@@ -0,0 +1,40 @@ |
+<html> |
+<body> |
+<script src="../../resources/js-test.js"></script> |
+<script> |
+description("This test checks that the page visibility event is fired when frame is unloaded."); |
+ |
+var jsTestIsAsync = true; |
+var frames = []; |
+var docsLoaded = 0, visibilityChanged = 0; |
+var numFrames = 3; |
+ |
+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
|
+ if (++docsLoaded < numFrames) |
+ return; |
+ |
+ debug("Loaded all frames."); |
+ |
+ frames.push(document.getElementById("frame1")); |
dcheng
2016/03/11 09:13:37
window[0]
|
+ frames.push(frame1.contentDocument.getElementById("subIframe1")); |
dcheng
2016/03/11 09:13:36
window[0][0]
|
+ frames.push(frame1.contentDocument.getElementById("subIframe2")); |
dcheng
2016/03/11 09:13:37
window[0][1]
|
+ |
+ for (var i = 0; i < frames.length; ++i) { |
+ 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.
|
+ "visibilitychange", |
+ onVisibilityChange.bind(null, i), false); |
+ } |
+ |
+ document.body.removeChild(frames[0]); |
+} |
+ |
+function onVisibilityChange(i) { |
+ shouldBe('frames[' + i + '].contentDocument.visibilityState', '"hidden"'); |
+ if (++visibilityChanged == numFrames) |
+ finishJSTest(); |
+} |
+ |
+</script> |
+<iframe id="frame1" src="resources/page-visibility-iframe-with-subframes.html"></iframe> |
+</body> |
+</html> |