2 <body onload=
"startTest()">
4 <script src=
"../../resources/js-test.js"></script>
8 description("This test checks that the page visibility event propagation does not crash the browser when frames are added / deleted.");
10 var jsTestIsAsync
= true;
12 var frame1
, frame2
, frame3
, frame4
, frame5
, subframe1
, subFrame2
, subFrame3
;
16 function startTest() {
22 debug("Loaded all frames.");
24 frame1
= document
.getElementById("topFrame1");
25 frame2
= document
.getElementById("topFrame2");
26 frame3
= document
.getElementById("topFrame3");
27 frame4
= document
.getElementById("topFrame4");
28 subFrame1
= frame3
.contentDocument
.getElementById("subIframe1");
29 subFrame2
= frame3
.contentDocument
.getElementById("subIframe2");
31 document
.addEventListener(
32 "visibilitychange", onMainPageVisibilityChange
, false);
33 frame2
.contentDocument
.addEventListener(
34 "visibilitychange", onFrame2VisibilityChange
, false);
35 // Change the visibility of the current page to invisible.
36 if (window
.testRunner
)
37 testRunner
.setPageVisibility("hidden");
41 function onMainPageVisibilityChange() {
42 debug("Visibility of main document changed.");
44 document
.body
.removeChild(frame4
);
47 frame3
.contentDocument
.body
.removeChild(subFrame2
);
49 // Add a new frame to top level.
50 frame5
= document
.createElement("iframe");
52 document
.body
.appendChild(frame5
);
54 // Add a new frame to frame2.
55 subFrame3
= frame2
.contentDocument
.createElement("iframe");
57 frame2
.contentDocument
.body
.appendChild(subFrame3
);
60 function onFrame2VisibilityChange() {
61 debug("Visibility of sub frame 2 changed.");
63 document
.body
.removeChild(frame1
);
69 <iframe id=
"topFrame1" onload=
"startTest()" ></iframe>
70 <iframe id=
"topFrame2" onload=
"startTest()" ></iframe>
71 <iframe id=
"topFrame3" onload=
"startTest()" src=
"resources/page-visibility-iframe-delete-test-frame.html"></iframe>
72 <iframe id=
"topFrame4" onload=
"startTest()" ></iframe>