summaryrefslogtreecommitdiffstats
path: root/layout/base/tests/chrome/no_clip_iframe_window.xul
blob: 960477e9e84513dac9b49133d96aec6a7c44cac5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?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"
        onload="runTests()">
  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/paint_listener.js"></script>

  <div id="container" xmlns="http://www.w3.org/1999/xhtml" style="height:400px; overflow:auto; background:gray">
    <div style="height:0">
      <iframe type="content" id="f" src="no_clip_iframe_subdoc.html"
       style="margin-top:50px; border:1px solid black; width:100px; height:100px;"/>
    </div>
    <div id="ref" style="background:gray;">
      <div style="border:1px solid black; margin-top:50px; width:100px; height:100px;">
        <div id="ref-d" style="background:lime; height:250px; width:150px;">
          <div style="position:relative; top:-50px; width:150px; height:100%; background:yellow;"/>
        </div>
      </div>
    </div>
  </div>
  <vbox flex="1"/>

  <script type="application/javascript">
  <![CDATA[
    var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ];
    for (var name of imports) {
      window[name] = window.opener.wrappedJSObject[name];
    }

    SimpleTest.waitForExplicitFinish();

    var Ci = Components.interfaces;
    var frame = document.getElementById("f");
    var fl = frame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
    is(fl.clipSubdocument, true, "clipSubdocument should default to true");
    fl.clipSubdocument = false;
    is(fl.clipSubdocument, false, "clipSubdocument should have been set to false");

    function runTests() {
      var ref = document.getElementById("ref");
      frame.contentWindow.scrollTo(0,0);

      ref.style.visibility = "hidden";
      var testCanvas = snapshotWindow(window);
      ref.style.visibility = "";
      var refCanvas = snapshotWindow(window);
      var comparison = compareSnapshots(testCanvas, refCanvas, true);
      ok(comparison[0], "Basic overflow drawing; got " + comparison[1] + ", expected " + comparison[2]);

      document.getElementById("container").style.height = "200px";
      ref.style.visibility = "hidden";
      testCanvas = snapshotWindow(window);
      ref.style.visibility = "";
      refCanvas = snapshotWindow(window);
      comparison = compareSnapshots(testCanvas, refCanvas, true);
      ok(comparison[0], "Drawing with vertical scrollbar to show overflow area computation; got " +
                        comparison[1] + ", expected " + comparison[2]);

      frame.contentDocument.getElementById("d").style.height = "350px";
      document.getElementById("ref-d").style.height = "350px";
      ref.style.visibility = "hidden";
      testCanvas = snapshotWindow(window);
      ref.style.visibility = "";
      refCanvas = snapshotWindow(window);
      comparison = compareSnapshots(testCanvas, refCanvas, true);
      ok(comparison[0], "testing dynamic overflow area change affecting scrollbar; got " +
                        comparison[1] + ", expected " + comparison[2]);

      // Now do invalidation tests
      ref.style.visibility = "hidden";
      document.getElementById("container").style.height = "400px";
      waitForAllPaintsFlushed(function() {
        frame.contentWindow.scrollTo(0,80);
        waitForAllPaintsFlushed(function(x1, y1, x2, y2) {
          ok(x1 <= 1 && x2 >= 151 && y1 <= 0 && y2 >= 400,
             "Entire scrolled region is painted: " + x1 + "," + y1 + "," + x2 + "," + y2);
          frame.contentDocument.getElementById("p").style.background = "cyan";
          waitForAllPaintsFlushed(function(x1, y1, x2, y2) {
            ok(x1 <= 1 && x2 >= 151 && y1 <= 271 && y2 >= 320,
               "Entire updated region is painted: " + x1 + "," + y1 + "," + x2 + "," + y2);
      
            var tester = window.SimpleTest;
            window.close();
            tester.finish();
          }, frame.contentDocument);
        });
      });
    }
  ]]>
  </script>
</window>