|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
4 <!-- |
|
5 Test that "MozEnteredFullscreen" is dispatched to chrome on documents that enter fullscreen. |
|
6 |
|
7 Test Description: |
|
8 |
|
9 This chrome window has a browser. The browser's contentDocument (the "outer document") |
|
10 in turn has an iframe (the "inner document"). |
|
11 |
|
12 We request fullscreen in the outer document, and check that MozEnteredDomFullscreen is |
|
13 dispatched to chrome, targeted at the outer document. |
|
14 |
|
15 Then we request fullscreen in the inner document, and check that MozEnteredDomFullscreen |
|
16 is dispatched to chrome, targeted at the inner document. |
|
17 |
|
18 Then we cancel fullscreen in the inner document, and check that MozEnteredDomFullscreen is |
|
19 dispatched again to chrome, targeted at the outer document. This still happens, since the |
|
20 outer document's domain was never approved for fullscreen. |
|
21 --> |
|
22 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="start();"> |
|
23 |
|
24 <script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script> |
|
25 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
26 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
27 <script type="application/javascript"><![CDATA[ |
|
28 |
|
29 function ok(condition, msg) { |
|
30 window.opener.wrappedJSObject.ok(condition, msg); |
|
31 } |
|
32 |
|
33 function is(a, b, msg) { |
|
34 window.opener.wrappedJSObject.is(a, b, msg); |
|
35 } |
|
36 |
|
37 var gBrowser = null; |
|
38 var gOuterDoc = null; |
|
39 var gInnerDoc = null; |
|
40 |
|
41 function firstEntry(event) { |
|
42 is(event.target, gOuterDoc, "First MozEnteredDomFullscreen should be targeted at outer doc"); |
|
43 window.removeEventListener("MozEnteredDomFullscreen", firstEntry, false); |
|
44 ok(gOuterDoc.mozFullScreenElement != null, "Outer doc should be in fullscreen"); |
|
45 gInnerDoc = gOuterDoc.getElementById("innerFrame").contentDocument; |
|
46 window.addEventListener("MozEnteredDomFullscreen", secondEntry, false); |
|
47 gInnerDoc.defaultView.focus(); |
|
48 gInnerDoc.body.mozRequestFullScreen(); |
|
49 } |
|
50 |
|
51 function secondEntry(event) { |
|
52 is(event.target, gInnerDoc, "Second MozEnteredDomFullscreen should be targeted at inner doc"); |
|
53 ok(gInnerDoc.mozFullScreenElement != null, "Inner doc should be in fullscreen"); |
|
54 window.removeEventListener("MozEnteredDomFullscreen", secondEntry, false); |
|
55 window.addEventListener("MozEnteredDomFullscreen", thirdEntry, false); |
|
56 gInnerDoc.mozCancelFullScreen(); |
|
57 } |
|
58 |
|
59 function thirdEntry(event) { |
|
60 is(event.target, gOuterDoc, "Third MozEnteredDomFullscreen should be targeted at outer doc"); |
|
61 ok(gOuterDoc.mozFullScreenElement != null, "Outer doc return to fullscreen after cancel fullscreen in inner doc"); |
|
62 window.removeEventListener("MozEnteredDomFullscreen", thirdEntry, false); |
|
63 gOuterDoc.mozCancelFullScreen(); |
|
64 window.opener.wrappedJSObject.done(); |
|
65 } |
|
66 |
|
67 function start() { |
|
68 SimpleTest.waitForFocus( |
|
69 function() { |
|
70 gBrowser = document.getElementById("browser"); |
|
71 gOuterDoc = gBrowser.contentDocument; |
|
72 gBrowser.contentWindow.focus(); |
|
73 window.addEventListener("MozEnteredDomFullscreen", firstEntry, false); |
|
74 gOuterDoc.body.mozRequestFullScreen(); |
|
75 }); |
|
76 } |
|
77 |
|
78 ]]> |
|
79 </script> |
|
80 <!-- chrome://mochitests/content/chrome/dom/tests/mochitest/chrome/test_MozEnteredDomFullscreen_event.xul --> |
|
81 <browser type="content" id="browser" width="400" height="400" src="http://mochi.test:8888/tests/dom/tests/mochitest/general/file_MozEnteredDomFullscreen.html"/> |
|
82 |
|
83 </window> |