1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/chrome/MozEnteredDomFullscreen_chrome.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,83 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 +<!-- 1.8 + Test that "MozEnteredFullscreen" is dispatched to chrome on documents that enter fullscreen. 1.9 + 1.10 + Test Description: 1.11 + 1.12 + This chrome window has a browser. The browser's contentDocument (the "outer document") 1.13 + in turn has an iframe (the "inner document"). 1.14 + 1.15 + We request fullscreen in the outer document, and check that MozEnteredDomFullscreen is 1.16 + dispatched to chrome, targeted at the outer document. 1.17 + 1.18 + Then we request fullscreen in the inner document, and check that MozEnteredDomFullscreen 1.19 + is dispatched to chrome, targeted at the inner document. 1.20 + 1.21 + Then we cancel fullscreen in the inner document, and check that MozEnteredDomFullscreen is 1.22 + dispatched again to chrome, targeted at the outer document. This still happens, since the 1.23 + outer document's domain was never approved for fullscreen. 1.24 +--> 1.25 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="start();"> 1.26 + 1.27 +<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script> 1.28 +<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.29 +<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.30 +<script type="application/javascript"><![CDATA[ 1.31 + 1.32 +function ok(condition, msg) { 1.33 + window.opener.wrappedJSObject.ok(condition, msg); 1.34 +} 1.35 + 1.36 +function is(a, b, msg) { 1.37 + window.opener.wrappedJSObject.is(a, b, msg); 1.38 +} 1.39 + 1.40 +var gBrowser = null; 1.41 +var gOuterDoc = null; 1.42 +var gInnerDoc = null; 1.43 + 1.44 +function firstEntry(event) { 1.45 + is(event.target, gOuterDoc, "First MozEnteredDomFullscreen should be targeted at outer doc"); 1.46 + window.removeEventListener("MozEnteredDomFullscreen", firstEntry, false); 1.47 + ok(gOuterDoc.mozFullScreenElement != null, "Outer doc should be in fullscreen"); 1.48 + gInnerDoc = gOuterDoc.getElementById("innerFrame").contentDocument; 1.49 + window.addEventListener("MozEnteredDomFullscreen", secondEntry, false); 1.50 + gInnerDoc.defaultView.focus(); 1.51 + gInnerDoc.body.mozRequestFullScreen(); 1.52 +} 1.53 + 1.54 +function secondEntry(event) { 1.55 + is(event.target, gInnerDoc, "Second MozEnteredDomFullscreen should be targeted at inner doc"); 1.56 + ok(gInnerDoc.mozFullScreenElement != null, "Inner doc should be in fullscreen"); 1.57 + window.removeEventListener("MozEnteredDomFullscreen", secondEntry, false); 1.58 + window.addEventListener("MozEnteredDomFullscreen", thirdEntry, false); 1.59 + gInnerDoc.mozCancelFullScreen(); 1.60 +} 1.61 + 1.62 +function thirdEntry(event) { 1.63 + is(event.target, gOuterDoc, "Third MozEnteredDomFullscreen should be targeted at outer doc"); 1.64 + ok(gOuterDoc.mozFullScreenElement != null, "Outer doc return to fullscreen after cancel fullscreen in inner doc"); 1.65 + window.removeEventListener("MozEnteredDomFullscreen", thirdEntry, false); 1.66 + gOuterDoc.mozCancelFullScreen(); 1.67 + window.opener.wrappedJSObject.done(); 1.68 +} 1.69 + 1.70 +function start() { 1.71 + SimpleTest.waitForFocus( 1.72 + function() { 1.73 + gBrowser = document.getElementById("browser"); 1.74 + gOuterDoc = gBrowser.contentDocument; 1.75 + gBrowser.contentWindow.focus(); 1.76 + window.addEventListener("MozEnteredDomFullscreen", firstEntry, false); 1.77 + gOuterDoc.body.mozRequestFullScreen(); 1.78 + }); 1.79 +} 1.80 + 1.81 +]]> 1.82 +</script> 1.83 +<!-- chrome://mochitests/content/chrome/dom/tests/mochitest/chrome/test_MozEnteredDomFullscreen_event.xul --> 1.84 +<browser type="content" id="browser" width="400" height="400" src="http://mochi.test:8888/tests/dom/tests/mochitest/general/file_MozEnteredDomFullscreen.html"/> 1.85 + 1.86 +</window>