sizemode_attribute.xhtml (2106B)
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()"> 11 12 <script type="text/javascript"> 13 let tests = [ 14 function test1() { 15 checkAndContinue("normal"); 16 }, 17 18 function test2() { 19 listen("fullscreen", () => checkAndContinue("fullscreen")); 20 window.fullScreen = true; 21 }, 22 23 function test3() { 24 listen("fullscreen", () => checkAndContinue("normal")); 25 window.fullScreen = false; 26 }, 27 28 function test4() { 29 listen("resize", () => checkAndContinue("maximized")); 30 window.maximize(); 31 }, 32 33 function test5() { 34 listen("fullscreen", () => checkAndContinue("fullscreen")); 35 window.fullScreen = true; 36 }, 37 38 function test6() { 39 listen("fullscreen", () => checkAndContinue("maximized")); 40 window.fullScreen = false; 41 }, 42 43 function test7() { 44 listen("resize", () => checkAndContinue("normal")); 45 window.restore(); 46 }, 47 48 function test8() { 49 window.arguments[0].done(); 50 } 51 ]; 52 53 function nextStep() { 54 tests.shift()(); 55 } 56 57 function listen(event, fn) { 58 window.addEventListener(event, function listener() { 59 fn(); 60 }, { once: true }); 61 } 62 63 function checkAndContinue(sizemode) { 64 65 let windowStates = { 66 "fullscreen": window.STATE_FULLSCREEN, 67 "normal": window.STATE_NORMAL, 68 "maximized": window.STATE_MAXIMIZED 69 }; 70 71 setTimeout(function() { 72 is(window.document.documentElement.getAttribute("sizemode"), sizemode, "sizemode attribute should match actual window state"); 73 is(window.fullScreen, sizemode == "fullscreen", "window.fullScreen should match actual window state"); 74 is(window.windowState, windowStates[sizemode], "window.sizeMode should match actual window state"); 75 nextStep(); 76 }, 0); 77 } 78 79 let is = window.arguments[0].is; 80 81 </script> 82 83 <body xmlns="http://www.w3.org/1999/xhtml"> 84 85 </body> 86 </window>