Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
michael@0 | 4 | type="text/css"?> |
michael@0 | 5 | <window title="Test for bug 715867" |
michael@0 | 6 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 7 | |
michael@0 | 8 | <script type="application/javascript" |
michael@0 | 9 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> |
michael@0 | 10 | |
michael@0 | 11 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 12 | <p id="display"></p> |
michael@0 | 13 | <div id="content" style="display: none"> |
michael@0 | 14 | |
michael@0 | 15 | </div> |
michael@0 | 16 | <pre id="test"> |
michael@0 | 17 | </pre> |
michael@0 | 18 | </body> |
michael@0 | 19 | |
michael@0 | 20 | <script class="testbody" type="application/javascript"> |
michael@0 | 21 | <![CDATA[ |
michael@0 | 22 | |
michael@0 | 23 | const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
michael@0 | 24 | |
michael@0 | 25 | gWindow = null; |
michael@0 | 26 | |
michael@0 | 27 | gSizeModeDidChange = false; |
michael@0 | 28 | gSizeModeDidChangeTo = 0; |
michael@0 | 29 | |
michael@0 | 30 | function sizemodeChanged(e) { |
michael@0 | 31 | gSizeModeDidChange = true; |
michael@0 | 32 | gSizeModeDidChangeTo = gWindow.windowState; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | function expectSizeModeChange(newMode, duringActionCallback) { |
michael@0 | 36 | gSizeModeDidChange = false; |
michael@0 | 37 | |
michael@0 | 38 | duringActionCallback(); |
michael@0 | 39 | |
michael@0 | 40 | if (newMode == 0) { |
michael@0 | 41 | // No change should have taken place, no event should have fired. |
michael@0 | 42 | ok(!gSizeModeDidChange, "No sizemodechange event should have fired."); |
michael@0 | 43 | } else { |
michael@0 | 44 | // Size mode change event was expected to fire. |
michael@0 | 45 | ok(gSizeModeDidChange, "A sizemodechanged event should have fired."); |
michael@0 | 46 | is(gSizeModeDidChangeTo, newMode, "The new sizemode should have the expected value."); |
michael@0 | 47 | } |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function startTest() { |
michael@0 | 51 | if (navigator.platform.indexOf("Lin") != -1) { |
michael@0 | 52 | ok(true, "This test is disabled on Linux because it expects window sizemode changes to be synchronous (which is not the case on Linux)."); |
michael@0 | 53 | SimpleTest.finish(); |
michael@0 | 54 | return; |
michael@0 | 55 | }; |
michael@0 | 56 | openWindow(); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | function openWindow() { |
michael@0 | 60 | gWindow = open('empty_window.xul', '_blank', 'chrome,screenX=50,screenY=50,width=200,height=200,resizable'); |
michael@0 | 61 | SimpleTest.waitForFocus(runTest, gWindow); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | function runTest() { |
michael@0 | 65 | // Install event handler. |
michael@0 | 66 | gWindow.addEventListener("sizemodechange", sizemodeChanged, false); |
michael@0 | 67 | |
michael@0 | 68 | // Run tests. |
michael@0 | 69 | expectSizeModeChange(gWindow.STATE_MINIMIZED, function () { |
michael@0 | 70 | gWindow.minimize(); |
michael@0 | 71 | }); |
michael@0 | 72 | |
michael@0 | 73 | expectSizeModeChange(gWindow.STATE_NORMAL, function () { |
michael@0 | 74 | gWindow.restore(); |
michael@0 | 75 | }); |
michael@0 | 76 | |
michael@0 | 77 | expectSizeModeChange(gWindow.STATE_MAXIMIZED, function () { |
michael@0 | 78 | gWindow.maximize(); |
michael@0 | 79 | }); |
michael@0 | 80 | |
michael@0 | 81 | expectSizeModeChange(gWindow.STATE_NORMAL, function () { |
michael@0 | 82 | gWindow.restore(); |
michael@0 | 83 | }); |
michael@0 | 84 | |
michael@0 | 85 | // Normal window resizing shouldn't fire a sizemodechanged event, bug 715867. |
michael@0 | 86 | expectSizeModeChange(0, function () { |
michael@0 | 87 | gWindow.resizeTo(gWindow.outerWidth + 10, gWindow.outerHeight); |
michael@0 | 88 | }); |
michael@0 | 89 | |
michael@0 | 90 | expectSizeModeChange(0, function () { |
michael@0 | 91 | gWindow.resizeTo(gWindow.outerWidth, gWindow.outerHeight + 10); |
michael@0 | 92 | }); |
michael@0 | 93 | |
michael@0 | 94 | gWindow.removeEventListener("sizemodechange", sizemodeChanged, false); |
michael@0 | 95 | gWindow.close(); |
michael@0 | 96 | SimpleTest.finish(); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 100 | SimpleTest.waitForFocus(startTest); |
michael@0 | 101 | |
michael@0 | 102 | ]]> |
michael@0 | 103 | </script> |
michael@0 | 104 | |
michael@0 | 105 | </window> |