Make it possible to not include IPC Messages headers in other headers
[WebKit-https.git] / LayoutTests / fast / events / page-visibility-iframe-move-test.html
1 <html>
2 <body onload="startTest()">
3
4 <script src="../../resources/js-test-pre.js"></script>
5
6 <script>
7
8 description("This test checks that an iframe that moves between pages with different visibility will have the correct visibility value.");
9
10 var jsTestIsAsync = true;
11
12 var window2, iframe;
13 var numVisibilityChanges = 0;
14
15 function window2Loaded() {
16     debug("Window 2 Loaded");
17
18     iframe = window2.document.getElementById("iframe");
19
20     shouldBeFalse("window.document.hidden");
21     shouldBeFalse("window2.document.hidden");
22     shouldBeFalse("iframe.contentDocument.hidden");
23
24     // Change the visibility of the current page to invisible.
25     if (window.testRunner) {
26         numVisibilityChanges++;
27         window.testRunner.setPageVisibility("hidden");
28     }
29 }
30
31 function onVisibilityChange() {
32     shouldBeTrue("window.document.hidden");
33     shouldBeFalse("window2.document.hidden");
34     shouldBeFalse("iframe.contentDocument.hidden");
35
36     window.document.adoptNode(iframe);
37     window.document.body.appendChild(iframe);
38     debug("Adopted iframe to Window 1");
39
40     shouldBeTrue("window.document.hidden");
41     shouldBeFalse("window2.document.hidden");
42     shouldBeTrue("iframe.contentDocument.hidden");
43
44     window2.close();
45
46     finishTest();
47 }
48
49 function startTest() {
50     if (window.testRunner) {
51         testRunner.waitUntilDone();
52         testRunner.setCanOpenWindows();
53     }
54
55     debug("Window 1 Loaded");
56     document.addEventListener("visibilitychange",
57                               onVisibilityChange, false);
58
59     window2 = window.open("resources/page-visibility-iframe-move-new-page.html");
60     window2.addEventListener("load", window2Loaded, false);
61 }
62
63 function finishTest() {
64     document.removeEventListener("visibilitychange",
65                               onVisibilityChange, false);
66     window2.removeEventListener("load", window2Loaded, false);
67
68     if (window.testRunner) {
69         testRunner.resetPageVisibility();
70     }
71     finishJSTest();
72 }
73
74 </script>
75
76 <script src="../../resources/js-test-post.js"></script>
77
78 </body>
79 </html>