<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                 type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  <script type="application/javascript"
          src="chrome://mochikit/content/MochiKit/packed.js"></script>
  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>

  <!-- test results are displayed in the html:body -->
  <body xmlns="http://www.w3.org/1999/xhtml">
  </body>

  <!-- test code goes here -->
  <script type="application/javascript">
  <![CDATA[
    SimpleTest.waitForExplicitFinish();

    // Bug 640889 - the test doesn't like seeing the WinXP resizer.
    var version = Components.classes["@mozilla.org/system-info;1"]
                            .getService(Components.interfaces.nsIPropertyBag2)
                            .getProperty("version");
    if (navigator.platform.indexOf("Win") == 0 && parseFloat(version) < 6.0) {
      todo(false, "Bug 640889 - the test doesn't like seeing the WinXP resizer.");
      SimpleTest.finish();
    } else {

    function doTest(evt) {
      var initialCount = win.mozPaintCount;

      function nextStep() {
        if (win.mozPaintCount == initialCount) {
          is(win.mozPaintCount, initialCount, "Waiting for mozPaintCount to increase.");
          // Do not use SimpleTest.executeSoon() here: give a little more time.
          setTimeout(nextStep, 25);
          return;
        }

        isnot(win.mozPaintCount, initialCount, "mozPaintCount has increased");

        var utils = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                       .getInterface(Components.interfaces.nsIDOMWindowUtils);
        ok(utils.leafLayersPartitionWindow(),
           "Leaf layers should form a non-overlapping partition of the browser window");

        win.close();
        SimpleTest.finish();
      }

      SimpleTest.executeSoon(nextStep);
    }

    // Run the test in a separate window so we get a clean browser window.
    var win = window.open("data:text/html,<html style='overflow:scroll'>",
                "", "scrollbars=yes,toolbar,menubar,width=500,height=500");
    win.addEventListener('load', doTest, false);

    }
  ]]>
  </script>
</window>
