layout/base/tests/chrome/no_clip_iframe_window.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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         onload="runTests()">
     7   <script type="application/javascript"
     8           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="text/javascript"
    10           src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
    11   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>
    13   <div id="container" xmlns="http://www.w3.org/1999/xhtml" style="height:400px; overflow:auto; background:gray">
    14     <div style="height:0">
    15       <iframe type="content" id="f" src="no_clip_iframe_subdoc.html"
    16        style="margin-top:50px; border:1px solid black; width:100px; height:100px;"/>
    17     </div>
    18     <div id="ref" style="background:gray;">
    19       <div style="border:1px solid black; margin-top:50px; width:100px; height:100px;">
    20         <div id="ref-d" style="background:lime; height:250px; width:150px;">
    21           <div style="position:relative; top:-50px; width:150px; height:100%; background:yellow;"/>
    22         </div>
    23       </div>
    24     </div>
    25   </div>
    26   <vbox flex="1"/>
    28   <script type="application/javascript">
    29   <![CDATA[
    30     var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ];
    31     for each (var name in imports) {
    32       window[name] = window.opener.wrappedJSObject[name];
    33     }
    35     SimpleTest.waitForExplicitFinish();
    37     var Ci = Components.interfaces;
    38     var frame = document.getElementById("f");
    39     var fl = frame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
    40     is(fl.clipSubdocument, true, "clipSubdocument should default to true");
    41     fl.clipSubdocument = false;
    42     is(fl.clipSubdocument, false, "clipSubdocument should have been set to false");
    44     function runTests() {
    45       var ref = document.getElementById("ref");
    46       frame.contentWindow.scrollTo(0,0);
    48       ref.style.visibility = "hidden";
    49       var testCanvas = snapshotWindow(window);
    50       ref.style.visibility = "";
    51       var refCanvas = snapshotWindow(window);
    52       var comparison = compareSnapshots(testCanvas, refCanvas, true);
    53       ok(comparison[0], "Basic overflow drawing; got " + comparison[1] + ", expected " + comparison[2]);
    55       document.getElementById("container").style.height = "200px";
    56       ref.style.visibility = "hidden";
    57       testCanvas = snapshotWindow(window);
    58       ref.style.visibility = "";
    59       refCanvas = snapshotWindow(window);
    60       comparison = compareSnapshots(testCanvas, refCanvas, true);
    61       ok(comparison[0], "Drawing with vertical scrollbar to show overflow area computation; got " +
    62                         comparison[1] + ", expected " + comparison[2]);
    64       frame.contentDocument.getElementById("d").style.height = "350px";
    65       document.getElementById("ref-d").style.height = "350px";
    66       ref.style.visibility = "hidden";
    67       testCanvas = snapshotWindow(window);
    68       ref.style.visibility = "";
    69       refCanvas = snapshotWindow(window);
    70       comparison = compareSnapshots(testCanvas, refCanvas, true);
    71       ok(comparison[0], "testing dynamic overflow area change affecting scrollbar; got " +
    72                         comparison[1] + ", expected " + comparison[2]);
    74       // Now do invalidation tests
    75       ref.style.visibility = "hidden";
    76       document.getElementById("container").style.height = "400px";
    77       waitForAllPaintsFlushed(function() {
    78         frame.contentWindow.scrollTo(0,80);
    79         waitForAllPaintsFlushed(function(x1, y1, x2, y2) {
    80           ok(x1 <= 1 && x2 >= 151 && y1 <= 0 && y2 >= 400,
    81              "Entire scrolled region is painted: " + x1 + "," + y1 + "," + x2 + "," + y2);
    82           frame.contentDocument.getElementById("p").style.background = "cyan";
    83           waitForAllPaintsFlushed(function(x1, y1, x2, y2) {
    84             ok(x1 <= 1 && x2 >= 151 && y1 <= 271 && y2 >= 320,
    85                "Entire updated region is painted: " + x1 + "," + y1 + "," + x2 + "," + y2);
    87             var tester = window.SimpleTest;
    88             window.close();
    89             tester.finish();
    90           }, frame.contentDocument);
    91         });
    92       });
    93     }
    94   ]]>
    95   </script>
    96 </window>

mercurial