Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>nsIDOMWindowUtils::getScrollbarSize 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 </head>
9 <body id="body">
10 <script type="application/javascript;version=1.8">
11 function doTests() {
12 let iframe = document.getElementById("iframe");
13 let cwindow = iframe.contentWindow;
14 let utils = SpecialPowers.getDOMWindowUtils(cwindow);
15 let doc = cwindow.document;
17 function haveNonFloatingScrollbars() {
18 return doc.getElementById("float").offsetWidth > 200;
19 }
21 checkScrollbarSizeFlush(utils, function (w, h) w == 0 && h == 0,
22 "[overflow=hidden] corrrect scrollbar size after flushing");
24 // Some platforms (esp. mobile) may have floating scrollbars that don't
25 // affect layout. Thus getScrollbarSize() would always return zeros.
26 if (haveNonFloatingScrollbars()) {
27 let body = doc.querySelector("body");
28 body.style.overflowY = "scroll";
30 checkScrollbarSize(utils, function (w, h) w == 0 && h == 0,
31 "[overflowY=scroll] correct scrollbar size w/o flushing");
33 checkScrollbarSizeFlush(utils, function (w, h) w > 0 && h == 0,
34 "[overflowY=scroll] correct scrollbar size after flushing");
36 body.style.overflowX = "scroll";
37 checkScrollbarSize(utils, function (w, h) w > 0 && h == 0,
38 "[overflowXY=scroll] correct scrollbar size w/o flushing");
40 checkScrollbarSizeFlush(utils, function (w, h) w > 0 && h > 0,
41 "[overflowXY=scroll] correct scrollbar size after flushing");
42 }
44 SimpleTest.finish();
45 }
47 function checkScrollbarSize(utils, check, msg, flush = false) {
48 let width = {}, height = {};
49 utils.getScrollbarSize(flush, width, height);
50 ok(check(width.value, height.value), msg);
51 }
53 function checkScrollbarSizeFlush(utils, check, msg) {
54 checkScrollbarSize(utils, check, msg, true);
55 }
57 SimpleTest.waitForExplicitFinish();
58 </script>
60 <iframe src="http://mochi.test:8888/tests/dom/tests/mochitest/general/file_domWindowUtils_scrollbarSize.html"
61 id="iframe" onload="doTests();">
62 </iframe>
64 </body>
65 </html>