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
|
<!DOCTYPE HTML>
<html>
<head>
<title>nsIDOMWindowUtils::getScrollbarSize test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body id="body">
<script type="application/javascript;version=1.8">
function doTests() {
let iframe = document.getElementById("iframe");
let cwindow = iframe.contentWindow;
let utils = SpecialPowers.getDOMWindowUtils(cwindow);
let doc = cwindow.document;
function haveNonFloatingScrollbars() {
return doc.getElementById("float").offsetWidth > 200;
}
checkScrollbarSizeFlush(utils, (w, h) => w == 0 && h == 0,
"[overflow=hidden] corrrect scrollbar size after flushing");
// Some platforms (esp. mobile) may have floating scrollbars that don't
// affect layout. Thus getScrollbarSize() would always return zeros.
if (haveNonFloatingScrollbars()) {
let body = doc.querySelector("body");
body.style.overflowY = "scroll";
checkScrollbarSize(utils, (w, h) => w == 0 && h == 0,
"[overflowY=scroll] correct scrollbar size w/o flushing");
checkScrollbarSizeFlush(utils, (w, h) => w > 0 && h == 0,
"[overflowY=scroll] correct scrollbar size after flushing");
body.style.overflowX = "scroll";
checkScrollbarSize(utils, (w, h) => w > 0 && h == 0,
"[overflowXY=scroll] correct scrollbar size w/o flushing");
checkScrollbarSizeFlush(utils, (w, h) => w > 0 && h > 0,
"[overflowXY=scroll] correct scrollbar size after flushing");
}
SimpleTest.finish();
}
function checkScrollbarSize(utils, check, msg, flush = false) {
let width = {}, height = {};
utils.getScrollbarSize(flush, width, height);
ok(check(width.value, height.value), msg);
}
function checkScrollbarSizeFlush(utils, check, msg) {
checkScrollbarSize(utils, check, msg, true);
}
SimpleTest.waitForExplicitFinish();
</script>
<iframe src="http://mochi.test:8888/tests/dom/tests/mochitest/general/file_domWindowUtils_scrollbarSize.html"
id="iframe" onload="doTests();">
</iframe>
</body>
</html>
|