1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/general/test_domWindowUtils_scrollbarSize.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>nsIDOMWindowUtils::getScrollbarSize test</title> 1.8 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> 1.10 +</head> 1.11 + 1.12 +<body id="body"> 1.13 + <script type="application/javascript;version=1.8"> 1.14 + function doTests() { 1.15 + let iframe = document.getElementById("iframe"); 1.16 + let cwindow = iframe.contentWindow; 1.17 + let utils = SpecialPowers.getDOMWindowUtils(cwindow); 1.18 + let doc = cwindow.document; 1.19 + 1.20 + function haveNonFloatingScrollbars() { 1.21 + return doc.getElementById("float").offsetWidth > 200; 1.22 + } 1.23 + 1.24 + checkScrollbarSizeFlush(utils, function (w, h) w == 0 && h == 0, 1.25 + "[overflow=hidden] corrrect scrollbar size after flushing"); 1.26 + 1.27 + // Some platforms (esp. mobile) may have floating scrollbars that don't 1.28 + // affect layout. Thus getScrollbarSize() would always return zeros. 1.29 + if (haveNonFloatingScrollbars()) { 1.30 + let body = doc.querySelector("body"); 1.31 + body.style.overflowY = "scroll"; 1.32 + 1.33 + checkScrollbarSize(utils, function (w, h) w == 0 && h == 0, 1.34 + "[overflowY=scroll] correct scrollbar size w/o flushing"); 1.35 + 1.36 + checkScrollbarSizeFlush(utils, function (w, h) w > 0 && h == 0, 1.37 + "[overflowY=scroll] correct scrollbar size after flushing"); 1.38 + 1.39 + body.style.overflowX = "scroll"; 1.40 + checkScrollbarSize(utils, function (w, h) w > 0 && h == 0, 1.41 + "[overflowXY=scroll] correct scrollbar size w/o flushing"); 1.42 + 1.43 + checkScrollbarSizeFlush(utils, function (w, h) w > 0 && h > 0, 1.44 + "[overflowXY=scroll] correct scrollbar size after flushing"); 1.45 + } 1.46 + 1.47 + SimpleTest.finish(); 1.48 + } 1.49 + 1.50 + function checkScrollbarSize(utils, check, msg, flush = false) { 1.51 + let width = {}, height = {}; 1.52 + utils.getScrollbarSize(flush, width, height); 1.53 + ok(check(width.value, height.value), msg); 1.54 + } 1.55 + 1.56 + function checkScrollbarSizeFlush(utils, check, msg) { 1.57 + checkScrollbarSize(utils, check, msg, true); 1.58 + } 1.59 + 1.60 + SimpleTest.waitForExplicitFinish(); 1.61 + </script> 1.62 + 1.63 + <iframe src="http://mochi.test:8888/tests/dom/tests/mochitest/general/file_domWindowUtils_scrollbarSize.html" 1.64 + id="iframe" onload="doTests();"> 1.65 + </iframe> 1.66 + 1.67 +</body> 1.68 +</html>