layout/base/tests/chrome/test_leaf_layers_partition_browser_window.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/tests/chrome/test_leaf_layers_partition_browser_window.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,108 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     1.7 +                 type="text/css"?>
     1.8 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     1.9 +  <script type="application/javascript"
    1.10 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.11 +
    1.12 +  <!-- test results are displayed in the html:body -->
    1.13 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.14 +  </body>
    1.15 +
    1.16 +  <!-- test code goes here -->
    1.17 +  <script type="application/javascript">
    1.18 +  <![CDATA[
    1.19 +    SimpleTest.waitForExplicitFinish();
    1.20 +
    1.21 +    var winLowerThanVista = navigator.platform.indexOf("Win") == 0;
    1.22 +    if (winLowerThanVista) {
    1.23 +      var version = Components.classes["@mozilla.org/system-info;1"]
    1.24 +                              .getService(Components.interfaces.nsIPropertyBag2)
    1.25 +                              .getProperty("version");
    1.26 +      winLowerThanVista = parseFloat(version) < 6.0;
    1.27 +    }
    1.28 +
    1.29 +    var tests = [{maximize: false}, {maximize: true}];
    1.30 +    var testIndex = 0;
    1.31 +    var win;
    1.32 +
    1.33 +    function testInfo() {
    1.34 +      return tests[testIndex].maximize ? " (maximized)" : " (non-maximized)";
    1.35 +    }
    1.36 +
    1.37 +    function doTest(evt) {
    1.38 +      var initialCount = win.mozPaintCount;
    1.39 +
    1.40 +      function nextStep() {
    1.41 +        if (win.mozPaintCount == initialCount || win.isMozAfterPaintPending) {
    1.42 +          SimpleTest.info("Waiting for mozPaintCount (= " + initialCount + ") to increase" + testInfo());
    1.43 +          // Do not use SimpleTest.executeSoon() here: give a little more time.
    1.44 +          setTimeout(nextStep, 100);
    1.45 +          return;
    1.46 +        }
    1.47 +
    1.48 +        isnot(win.mozPaintCount, initialCount, "mozPaintCount has increased" + testInfo());
    1.49 +
    1.50 +        function testLeafLayersPartitionWindow() {
    1.51 +          var success = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
    1.52 +                           .getInterface(Components.interfaces.nsIDOMWindowUtils)
    1.53 +                           .leafLayersPartitionWindow();
    1.54 +          // "[leafLayersPartitionWindow()] Always returns true in non-DEBUG builds."
    1.55 +          // To prevent random failures on Windows, try to run this again after a timeout.
    1.56 +          if (!success && navigator.platform.indexOf("Win") >= 0) {
    1.57 +            setTimeout(testLeafLayersPartitionWindow, 100);
    1.58 +            return;
    1.59 +          }
    1.60 +          ok(success,
    1.61 +             "Leaf layers should form a non-overlapping partition of the browser window" + testInfo() +
    1.62 +             (success ? "" : ". [Set MOZ_DUMP_PAINT_LIST=1 env var to investigate.]"));
    1.63 +
    1.64 +          win.close();
    1.65 +          ++testIndex;
    1.66 +          nextTest();
    1.67 +        }
    1.68 +        testLeafLayersPartitionWindow();
    1.69 +      }
    1.70 +
    1.71 +      if (tests[testIndex].maximize) {
    1.72 +        function resizeListener() {
    1.73 +          win.removeEventListener("resize", resizeListener, true);
    1.74 +          // We want a paint after resize.
    1.75 +          initialCount = win.mozPaintCount;
    1.76 +          SimpleTest.executeSoon(nextStep);
    1.77 +        }
    1.78 +        win.addEventListener("resize", resizeListener, true);
    1.79 +        SimpleTest.info("Maximizing test " + testIndex + " window" + testInfo());
    1.80 +        Components.classes["@mozilla.org/appshell/window-mediator;1"]
    1.81 +                  .getService(Components.interfaces.nsIWindowMediator)
    1.82 +                  .getMostRecentWindow("navigator:browser")
    1.83 +                  .maximize();
    1.84 +      } else {
    1.85 +        SimpleTest.executeSoon(nextStep);
    1.86 +      }
    1.87 +    }
    1.88 +
    1.89 +    function nextTest() {
    1.90 +      if (testIndex >= tests.length) {
    1.91 +        SimpleTest.finish();
    1.92 +        return;
    1.93 +      }
    1.94 +
    1.95 +      if (winLowerThanVista && !tests[testIndex].maximize) {
    1.96 +        ok(true, "Skipping non-maximized test " + testIndex + " on winLowerThanVista since the resizer causes overlapping layers");
    1.97 +        ++testIndex;
    1.98 +        nextTest();
    1.99 +        return;
   1.100 +      }
   1.101 +
   1.102 +      // Run the test in a separate window so we get a clean browser window.
   1.103 +      win = window.open("data:text/html,<html style='overflow:scroll'>",
   1.104 +                "", "scrollbars=yes,toolbar,menubar,width=500,height=500");
   1.105 +      win.addEventListener("load", doTest, false);
   1.106 +    }
   1.107 +
   1.108 +    nextTest();
   1.109 +  ]]>
   1.110 +  </script>
   1.111 +</window>

mercurial