dom/tests/mochitest/chrome/sizemode_attribute.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 for fullscreen sizemode in chrome
     6   -->
     7 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     8         persist="sizemode"
     9         sizemode="normal"
    10         onload="nextStep()">
    12 <script type="text/javascript;version=1.8">
    13 let tests = [
    14   function test1() {
    15     checkAndContinue("normal");
    16   },
    18   function test2() {
    19     listen("fullscreen", function() checkAndContinue("fullscreen"));
    20     window.fullScreen = true;
    21   },
    23   function test3() {
    24     listen("fullscreen", function() checkAndContinue("normal"));
    25     window.fullScreen = false;
    26   },
    28   function test4() {
    29     listen("resize", function() checkAndContinue("maximized"));
    30     window.maximize();
    31   },
    33   function test5() {
    34     listen("fullscreen", function() checkAndContinue("fullscreen"));
    35     window.fullScreen = true;
    36   },
    38   function test6() {
    39     listen("fullscreen", function() checkAndContinue("maximized"));
    40     window.fullScreen = false;
    41   },
    43   function test7() {
    44     listen("resize", function() checkAndContinue("normal"));
    45     window.restore();
    46   },
    48   function test8() {
    49     window.opener.wrappedJSObject.done();
    50   }
    51 ];
    53 function nextStep() {
    54   tests.shift()();
    55 }
    57 function listen(event, fn) {
    58   window.addEventListener(event, function listener() {
    59     window.removeEventListener(event, listener, false);
    60     fn();
    61   }, false);
    62 }
    64 function checkAndContinue(sizemode) {
    66   let windowStates = {
    67     "fullscreen": window.STATE_FULLSCREEN,
    68     "normal": window.STATE_NORMAL,
    69     "maximized": window.STATE_MAXIMIZED
    70   };
    72   setTimeout(function() {
    73     is(window.document.documentElement.getAttribute("sizemode"), sizemode, "sizemode attribute should match actual window state");
    74     is(window.fullScreen, sizemode == "fullscreen", "window.fullScreen should match actual window state");
    75     is(window.windowState, windowStates[sizemode], "window.sizeMode should match actual window state");
    76     nextStep();
    77   }, 0);
    78 }
    80 let is = window.opener.wrappedJSObject.is;
    82 </script>
    84 <body xmlns="http://www.w3.org/1999/xhtml">
    86 </body>
    87 </window>

mercurial