dom/tests/mochitest/chrome/MozEnteredDomFullscreen_chrome.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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.
     7   Test Description:
     9   This chrome window has a browser. The browser's contentDocument (the "outer document")
    10   in turn has an iframe (the "inner document").
    12   We request fullscreen in the outer document, and check that MozEnteredDomFullscreen is
    13   dispatched to chrome, targeted at the outer document.
    15   Then we request fullscreen in the inner document, and check that MozEnteredDomFullscreen
    16   is dispatched to chrome, targeted at the inner document.
    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();">
    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[
    29 function ok(condition, msg) {
    30   window.opener.wrappedJSObject.ok(condition, msg);
    31 }
    33 function is(a, b, msg) {
    34   window.opener.wrappedJSObject.is(a, b, msg);
    35 }
    37 var gBrowser = null;
    38 var gOuterDoc = null;
    39 var gInnerDoc = null;
    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 }
    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 }
    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 }
    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 }
    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"/>
    83 </window>

mercurial