tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / events / page-visibility-iframe-move-test.html
1 <html>
2 <body onload="startTest()">
3
4 <script src="../js/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.webkitHidden");
21     shouldBeFalse("window2.document.webkitHidden");
22     shouldBeFalse("iframe.contentDocument.webkitHidden");
23
24     // Change the visibility of the current page to invisible.
25     if (window.layoutTestController) {
26         numVisibilityChanges++;
27         window.layoutTestController.setPageVisibility("hidden");
28     }
29 }
30
31 function onVisibilityChange() {
32     shouldBeTrue("window.document.webkitHidden");
33     shouldBeFalse("window2.document.webkitHidden");
34     shouldBeFalse("iframe.contentDocument.webkitHidden");
35
36     window.document.adoptNode(iframe);
37     window.document.body.appendChild(iframe);
38     debug("Adopted iframe to Window 1");
39
40     shouldBeTrue("window.document.webkitHidden");
41     shouldBeFalse("window2.document.webkitHidden");
42     shouldBeTrue("iframe.contentDocument.webkitHidden");
43
44     window2.close();
45
46     finishTest();
47 }
48
49 function startTest() {
50     if (window.layoutTestController) {
51         layoutTestController.waitUntilDone();
52         layoutTestController.setCanOpenWindows();
53     }
54
55     debug("Window 1 Loaded");
56     document.addEventListener("webkitvisibilitychange",
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     if (window.layoutTestController) {
65         layoutTestController.resetPageVisibility();
66     }
67     finishJSTest();
68 }
69
70 </script>
71
72 <script src="../js/resources/js-test-post.js"></script>
73
74 </body>
75 </html>