layout/base/tests/chrome/no_clip_iframe_window.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/tests/chrome/no_clip_iframe_window.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,96 @@
     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 +        onload="runTests()">
    1.10 +  <script type="application/javascript"
    1.11 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="text/javascript"
    1.13 +          src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
    1.14 +  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
    1.15 +
    1.16 +  <div id="container" xmlns="http://www.w3.org/1999/xhtml" style="height:400px; overflow:auto; background:gray">
    1.17 +    <div style="height:0">
    1.18 +      <iframe type="content" id="f" src="no_clip_iframe_subdoc.html"
    1.19 +       style="margin-top:50px; border:1px solid black; width:100px; height:100px;"/>
    1.20 +    </div>
    1.21 +    <div id="ref" style="background:gray;">
    1.22 +      <div style="border:1px solid black; margin-top:50px; width:100px; height:100px;">
    1.23 +        <div id="ref-d" style="background:lime; height:250px; width:150px;">
    1.24 +          <div style="position:relative; top:-50px; width:150px; height:100%; background:yellow;"/>
    1.25 +        </div>
    1.26 +      </div>
    1.27 +    </div>
    1.28 +  </div>
    1.29 +  <vbox flex="1"/>
    1.30 +
    1.31 +  <script type="application/javascript">
    1.32 +  <![CDATA[
    1.33 +    var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ];
    1.34 +    for each (var name in imports) {
    1.35 +      window[name] = window.opener.wrappedJSObject[name];
    1.36 +    }
    1.37 +
    1.38 +    SimpleTest.waitForExplicitFinish();
    1.39 +
    1.40 +    var Ci = Components.interfaces;
    1.41 +    var frame = document.getElementById("f");
    1.42 +    var fl = frame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
    1.43 +    is(fl.clipSubdocument, true, "clipSubdocument should default to true");
    1.44 +    fl.clipSubdocument = false;
    1.45 +    is(fl.clipSubdocument, false, "clipSubdocument should have been set to false");
    1.46 +
    1.47 +    function runTests() {
    1.48 +      var ref = document.getElementById("ref");
    1.49 +      frame.contentWindow.scrollTo(0,0);
    1.50 +
    1.51 +      ref.style.visibility = "hidden";
    1.52 +      var testCanvas = snapshotWindow(window);
    1.53 +      ref.style.visibility = "";
    1.54 +      var refCanvas = snapshotWindow(window);
    1.55 +      var comparison = compareSnapshots(testCanvas, refCanvas, true);
    1.56 +      ok(comparison[0], "Basic overflow drawing; got " + comparison[1] + ", expected " + comparison[2]);
    1.57 +
    1.58 +      document.getElementById("container").style.height = "200px";
    1.59 +      ref.style.visibility = "hidden";
    1.60 +      testCanvas = snapshotWindow(window);
    1.61 +      ref.style.visibility = "";
    1.62 +      refCanvas = snapshotWindow(window);
    1.63 +      comparison = compareSnapshots(testCanvas, refCanvas, true);
    1.64 +      ok(comparison[0], "Drawing with vertical scrollbar to show overflow area computation; got " +
    1.65 +                        comparison[1] + ", expected " + comparison[2]);
    1.66 +
    1.67 +      frame.contentDocument.getElementById("d").style.height = "350px";
    1.68 +      document.getElementById("ref-d").style.height = "350px";
    1.69 +      ref.style.visibility = "hidden";
    1.70 +      testCanvas = snapshotWindow(window);
    1.71 +      ref.style.visibility = "";
    1.72 +      refCanvas = snapshotWindow(window);
    1.73 +      comparison = compareSnapshots(testCanvas, refCanvas, true);
    1.74 +      ok(comparison[0], "testing dynamic overflow area change affecting scrollbar; got " +
    1.75 +                        comparison[1] + ", expected " + comparison[2]);
    1.76 +
    1.77 +      // Now do invalidation tests
    1.78 +      ref.style.visibility = "hidden";
    1.79 +      document.getElementById("container").style.height = "400px";
    1.80 +      waitForAllPaintsFlushed(function() {
    1.81 +        frame.contentWindow.scrollTo(0,80);
    1.82 +        waitForAllPaintsFlushed(function(x1, y1, x2, y2) {
    1.83 +          ok(x1 <= 1 && x2 >= 151 && y1 <= 0 && y2 >= 400,
    1.84 +             "Entire scrolled region is painted: " + x1 + "," + y1 + "," + x2 + "," + y2);
    1.85 +          frame.contentDocument.getElementById("p").style.background = "cyan";
    1.86 +          waitForAllPaintsFlushed(function(x1, y1, x2, y2) {
    1.87 +            ok(x1 <= 1 && x2 >= 151 && y1 <= 271 && y2 >= 320,
    1.88 +               "Entire updated region is painted: " + x1 + "," + y1 + "," + x2 + "," + y2);
    1.89 +      
    1.90 +            var tester = window.SimpleTest;
    1.91 +            window.close();
    1.92 +            tester.finish();
    1.93 +          }, frame.contentDocument);
    1.94 +        });
    1.95 +      });
    1.96 +    }
    1.97 +  ]]>
    1.98 +  </script>
    1.99 +</window>

mercurial