1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/chrome/sizemode_attribute.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,87 @@ 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 for fullscreen sizemode in chrome 1.9 + --> 1.10 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.11 + persist="sizemode" 1.12 + sizemode="normal" 1.13 + onload="nextStep()"> 1.14 + 1.15 +<script type="text/javascript;version=1.8"> 1.16 +let tests = [ 1.17 + function test1() { 1.18 + checkAndContinue("normal"); 1.19 + }, 1.20 + 1.21 + function test2() { 1.22 + listen("fullscreen", function() checkAndContinue("fullscreen")); 1.23 + window.fullScreen = true; 1.24 + }, 1.25 + 1.26 + function test3() { 1.27 + listen("fullscreen", function() checkAndContinue("normal")); 1.28 + window.fullScreen = false; 1.29 + }, 1.30 + 1.31 + function test4() { 1.32 + listen("resize", function() checkAndContinue("maximized")); 1.33 + window.maximize(); 1.34 + }, 1.35 + 1.36 + function test5() { 1.37 + listen("fullscreen", function() checkAndContinue("fullscreen")); 1.38 + window.fullScreen = true; 1.39 + }, 1.40 + 1.41 + function test6() { 1.42 + listen("fullscreen", function() checkAndContinue("maximized")); 1.43 + window.fullScreen = false; 1.44 + }, 1.45 + 1.46 + function test7() { 1.47 + listen("resize", function() checkAndContinue("normal")); 1.48 + window.restore(); 1.49 + }, 1.50 + 1.51 + function test8() { 1.52 + window.opener.wrappedJSObject.done(); 1.53 + } 1.54 +]; 1.55 + 1.56 +function nextStep() { 1.57 + tests.shift()(); 1.58 +} 1.59 + 1.60 +function listen(event, fn) { 1.61 + window.addEventListener(event, function listener() { 1.62 + window.removeEventListener(event, listener, false); 1.63 + fn(); 1.64 + }, false); 1.65 +} 1.66 + 1.67 +function checkAndContinue(sizemode) { 1.68 + 1.69 + let windowStates = { 1.70 + "fullscreen": window.STATE_FULLSCREEN, 1.71 + "normal": window.STATE_NORMAL, 1.72 + "maximized": window.STATE_MAXIMIZED 1.73 + }; 1.74 + 1.75 + setTimeout(function() { 1.76 + is(window.document.documentElement.getAttribute("sizemode"), sizemode, "sizemode attribute should match actual window state"); 1.77 + is(window.fullScreen, sizemode == "fullscreen", "window.fullScreen should match actual window state"); 1.78 + is(window.windowState, windowStates[sizemode], "window.sizeMode should match actual window state"); 1.79 + nextStep(); 1.80 + }, 0); 1.81 +} 1.82 + 1.83 +let is = window.opener.wrappedJSObject.is; 1.84 + 1.85 +</script> 1.86 + 1.87 +<body xmlns="http://www.w3.org/1999/xhtml"> 1.88 + 1.89 +</body> 1.90 +</window>