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 type="text/css" href="chrome://global/skin"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
michael@0 | 4 | type="text/css"?> |
michael@0 | 5 | <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 6 | <script type="application/javascript" |
michael@0 | 7 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | |
michael@0 | 9 | <!-- test results are displayed in the html:body --> |
michael@0 | 10 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 11 | </body> |
michael@0 | 12 | |
michael@0 | 13 | <!-- test code goes here --> |
michael@0 | 14 | <script type="application/javascript"> |
michael@0 | 15 | <![CDATA[ |
michael@0 | 16 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 17 | |
michael@0 | 18 | var winLowerThanVista = navigator.platform.indexOf("Win") == 0; |
michael@0 | 19 | if (winLowerThanVista) { |
michael@0 | 20 | var version = Components.classes["@mozilla.org/system-info;1"] |
michael@0 | 21 | .getService(Components.interfaces.nsIPropertyBag2) |
michael@0 | 22 | .getProperty("version"); |
michael@0 | 23 | winLowerThanVista = parseFloat(version) < 6.0; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | var tests = [{maximize: false}, {maximize: true}]; |
michael@0 | 27 | var testIndex = 0; |
michael@0 | 28 | var win; |
michael@0 | 29 | |
michael@0 | 30 | function testInfo() { |
michael@0 | 31 | return tests[testIndex].maximize ? " (maximized)" : " (non-maximized)"; |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | function doTest(evt) { |
michael@0 | 35 | var initialCount = win.mozPaintCount; |
michael@0 | 36 | |
michael@0 | 37 | function nextStep() { |
michael@0 | 38 | if (win.mozPaintCount == initialCount || win.isMozAfterPaintPending) { |
michael@0 | 39 | SimpleTest.info("Waiting for mozPaintCount (= " + initialCount + ") to increase" + testInfo()); |
michael@0 | 40 | // Do not use SimpleTest.executeSoon() here: give a little more time. |
michael@0 | 41 | setTimeout(nextStep, 100); |
michael@0 | 42 | return; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | isnot(win.mozPaintCount, initialCount, "mozPaintCount has increased" + testInfo()); |
michael@0 | 46 | |
michael@0 | 47 | function testLeafLayersPartitionWindow() { |
michael@0 | 48 | var success = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
michael@0 | 49 | .getInterface(Components.interfaces.nsIDOMWindowUtils) |
michael@0 | 50 | .leafLayersPartitionWindow(); |
michael@0 | 51 | // "[leafLayersPartitionWindow()] Always returns true in non-DEBUG builds." |
michael@0 | 52 | // To prevent random failures on Windows, try to run this again after a timeout. |
michael@0 | 53 | if (!success && navigator.platform.indexOf("Win") >= 0) { |
michael@0 | 54 | setTimeout(testLeafLayersPartitionWindow, 100); |
michael@0 | 55 | return; |
michael@0 | 56 | } |
michael@0 | 57 | ok(success, |
michael@0 | 58 | "Leaf layers should form a non-overlapping partition of the browser window" + testInfo() + |
michael@0 | 59 | (success ? "" : ". [Set MOZ_DUMP_PAINT_LIST=1 env var to investigate.]")); |
michael@0 | 60 | |
michael@0 | 61 | win.close(); |
michael@0 | 62 | ++testIndex; |
michael@0 | 63 | nextTest(); |
michael@0 | 64 | } |
michael@0 | 65 | testLeafLayersPartitionWindow(); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | if (tests[testIndex].maximize) { |
michael@0 | 69 | function resizeListener() { |
michael@0 | 70 | win.removeEventListener("resize", resizeListener, true); |
michael@0 | 71 | // We want a paint after resize. |
michael@0 | 72 | initialCount = win.mozPaintCount; |
michael@0 | 73 | SimpleTest.executeSoon(nextStep); |
michael@0 | 74 | } |
michael@0 | 75 | win.addEventListener("resize", resizeListener, true); |
michael@0 | 76 | SimpleTest.info("Maximizing test " + testIndex + " window" + testInfo()); |
michael@0 | 77 | Components.classes["@mozilla.org/appshell/window-mediator;1"] |
michael@0 | 78 | .getService(Components.interfaces.nsIWindowMediator) |
michael@0 | 79 | .getMostRecentWindow("navigator:browser") |
michael@0 | 80 | .maximize(); |
michael@0 | 81 | } else { |
michael@0 | 82 | SimpleTest.executeSoon(nextStep); |
michael@0 | 83 | } |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | function nextTest() { |
michael@0 | 87 | if (testIndex >= tests.length) { |
michael@0 | 88 | SimpleTest.finish(); |
michael@0 | 89 | return; |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | if (winLowerThanVista && !tests[testIndex].maximize) { |
michael@0 | 93 | ok(true, "Skipping non-maximized test " + testIndex + " on winLowerThanVista since the resizer causes overlapping layers"); |
michael@0 | 94 | ++testIndex; |
michael@0 | 95 | nextTest(); |
michael@0 | 96 | return; |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | // Run the test in a separate window so we get a clean browser window. |
michael@0 | 100 | win = window.open("data:text/html,<html style='overflow:scroll'>", |
michael@0 | 101 | "", "scrollbars=yes,toolbar,menubar,width=500,height=500"); |
michael@0 | 102 | win.addEventListener("load", doTest, false); |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | nextTest(); |
michael@0 | 106 | ]]> |
michael@0 | 107 | </script> |
michael@0 | 108 | </window> |