dom/tests/mochitest/general/test_domWindowUtils_scrollbarSize.html

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>nsIDOMWindowUtils::getScrollbarSize test</title>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
michael@0 7 </head>
michael@0 8
michael@0 9 <body id="body">
michael@0 10 <script type="application/javascript;version=1.8">
michael@0 11 function doTests() {
michael@0 12 let iframe = document.getElementById("iframe");
michael@0 13 let cwindow = iframe.contentWindow;
michael@0 14 let utils = SpecialPowers.getDOMWindowUtils(cwindow);
michael@0 15 let doc = cwindow.document;
michael@0 16
michael@0 17 function haveNonFloatingScrollbars() {
michael@0 18 return doc.getElementById("float").offsetWidth > 200;
michael@0 19 }
michael@0 20
michael@0 21 checkScrollbarSizeFlush(utils, function (w, h) w == 0 && h == 0,
michael@0 22 "[overflow=hidden] corrrect scrollbar size after flushing");
michael@0 23
michael@0 24 // Some platforms (esp. mobile) may have floating scrollbars that don't
michael@0 25 // affect layout. Thus getScrollbarSize() would always return zeros.
michael@0 26 if (haveNonFloatingScrollbars()) {
michael@0 27 let body = doc.querySelector("body");
michael@0 28 body.style.overflowY = "scroll";
michael@0 29
michael@0 30 checkScrollbarSize(utils, function (w, h) w == 0 && h == 0,
michael@0 31 "[overflowY=scroll] correct scrollbar size w/o flushing");
michael@0 32
michael@0 33 checkScrollbarSizeFlush(utils, function (w, h) w > 0 && h == 0,
michael@0 34 "[overflowY=scroll] correct scrollbar size after flushing");
michael@0 35
michael@0 36 body.style.overflowX = "scroll";
michael@0 37 checkScrollbarSize(utils, function (w, h) w > 0 && h == 0,
michael@0 38 "[overflowXY=scroll] correct scrollbar size w/o flushing");
michael@0 39
michael@0 40 checkScrollbarSizeFlush(utils, function (w, h) w > 0 && h > 0,
michael@0 41 "[overflowXY=scroll] correct scrollbar size after flushing");
michael@0 42 }
michael@0 43
michael@0 44 SimpleTest.finish();
michael@0 45 }
michael@0 46
michael@0 47 function checkScrollbarSize(utils, check, msg, flush = false) {
michael@0 48 let width = {}, height = {};
michael@0 49 utils.getScrollbarSize(flush, width, height);
michael@0 50 ok(check(width.value, height.value), msg);
michael@0 51 }
michael@0 52
michael@0 53 function checkScrollbarSizeFlush(utils, check, msg) {
michael@0 54 checkScrollbarSize(utils, check, msg, true);
michael@0 55 }
michael@0 56
michael@0 57 SimpleTest.waitForExplicitFinish();
michael@0 58 </script>
michael@0 59
michael@0 60 <iframe src="http://mochi.test:8888/tests/dom/tests/mochitest/general/file_domWindowUtils_scrollbarSize.html"
michael@0 61 id="iframe" onload="doTests();">
michael@0 62 </iframe>
michael@0 63
michael@0 64 </body>
michael@0 65 </html>

mercurial