Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>nsIDOMWindowUtils::elementFromPoint test</title>
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
7 <style>
8 body {
9 /* Make room for scrolling */
10 }
11 </style>
12 </head>
14 <body id="body">
15 <script type="application/javascript;version=1.8">
16 /*
17 void getScrollXY(in boolean aFlushLayout, out long aScrollX, out long aScrollY);
18 */
19 function doTests() {
20 testScrollXY();
21 testHiddenIframe();
23 SimpleTest.finish();
24 }
26 function testScrollXY() {
27 let iframe = document.getElementById("iframe");
28 let cwindow = iframe.contentWindow;
29 let domWindowUtils = SpecialPowers.getDOMWindowUtils(cwindow);
31 function checkGetScrollXYState(flush, vals, testName) {
32 let scrollX = {}, scrollY = {};
33 domWindowUtils.getScrollXY(flush, scrollX, scrollY);
34 is(scrollX.value, vals[0], "getScrollXY x for test: " + testName);
35 is(scrollY.value, vals[1], "getScrollXY y for test: " + testName);
36 }
38 function checkWindowScrollState(vals, testName) {
39 is(cwindow.scrollX, vals[0], "scrollX for test: " + testName);
40 is(cwindow.scrollY, vals[1], "scrollY for test: " + testName);
41 }
43 // Check initial state (0, 0)
44 checkGetScrollXYState(false, [0, 0], "initial getScrollXY state");
45 checkGetScrollXYState(true, [0, 0], "initial getScrollXY state+flush");
46 checkWindowScrollState([0, 0], "initial window.scroll* state");
48 // scroll
49 cwindow.scrollTo(900, 1000);
50 checkGetScrollXYState(false, [900, 1000], "after scroll getScrollXY state");
51 checkGetScrollXYState(true, [900, 1000], "after scroll getScrollXY state+flush");
52 checkWindowScrollState([900, 1000], "after scroll window.scroll* state");
54 // ensure flush=false works
55 cwindow.document.body.style.width = 'auto';
56 cwindow.document.body.style.height = 'auto';
57 checkGetScrollXYState(false, [900, 1000], "didn't flush layout for getScrollXY");
58 checkGetScrollXYState(true, [0, 0], "flushed layout for getScrollXY");
59 }
61 function testHiddenIframe() {
62 let iframe = document.getElementById("hidden-iframe");
63 let cwindow = iframe.contentWindow;
64 let domWindowUtils = SpecialPowers.getDOMWindowUtils(cwindow);
66 // make sure getScrollXY doesn't throw
67 let scrollX = {}, scrollY = {};
68 domWindowUtils.getScrollXY(false, scrollX, scrollY);
70 is(scrollX.value, 0, "scrollX is zero for display:none iframe");
71 is(scrollY.value, 0, "scrollY is zero for display:none iframe");
72 }
74 SimpleTest.waitForExplicitFinish();
75 </script>
77 <!-- can't run this in the test document, since it potentially runs in a
78 scrolling="no" test harness iframe, and that causes a failure for some
79 reason -->
80 <iframe src="data:text/html,<body style='width: 100000px; height: 100000px;'><p>top</p></body>"
81 id="iframe"
82 onload="doTests();">
83 </iframe>
85 <iframe id="hidden-iframe" style="display: none;"></iframe>
87 <p id="display"></p>
89 </body>
90 </html>