layout/base/tests/chrome/test_leaf_layers_partition_browser_window.xul

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

mercurial