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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
<!doctype html>
<html>
<head>
<title>Viewport: Dimensions with custom scrollbars</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="viewport_support.js"></script>
<script>
setup({explicit_done: true, explicit_timeout: true});
</script>
<style>
#spacer {
width: 10000px;
height: 10000px;
position: absolute;
visibility: hidden;
}
::-webkit-scrollbar {
width: 20px;
height: 25px;
}
::-webkit-scrollbar-track {
background-color: #b46868;
}
::-webkit-scrollbar-thumb {
background-color: rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<h1>Viewport: Dimensions with custom scrollbars</h1>
<h4>
Test Description: Tests the viewport dimensions correctly account for
custom scrollbars
</h4>
<h2 style="color: red">THIS IS A MANUAL TEST</h2>
<p id="skip">
<button id="skipbtn" onclick="skipManualTest();">Skip</button>
<p>
Skip this test if your browser doesn't support custom scrollbars or
browser-zoom (Ctrl+/-).
</p>
</p>
<p id="instruction"></p>
<button id="continue">Start Test</button>
<div id="log"></div>
<div id="spacer"></div>
</body>
<script>
var continueBtn = document.getElementById("continue");
function continueTest() {
nextStep(function(instructionText) {
var instruction = document.getElementById("instruction");
continueBtn.innerText = "Continue";
instruction.innerText = instructionText;
});
}
continueBtn.addEventListener('click', continueTest);
var originalWidth = 0;
var originalHeight = 0;
var originalInnerWidth = 0;
var originalInnerHeight = 0;
addManualTestStep(
function() {},
null,
'1. Ensure the browser is at the default pinch and browser zoom ' +
'levels (100%). Most browsers: ctrl+0');
addManualTestStep(
function() {
originalWidth = window.visualViewport.width;
originalHeight = window.visualViewport.height;
// Remember the inner dimensions here for the next test to
// address an edge case where originalInnerWidth is an odd
// number of pixels. The test expects that at 2x browser-zoom,
// visualViewport.width = innerWidth - customScrollbarThickness
// The equality only holds if originalInnerWidth / innerWidth is
// exactly 2, which is not the case in the aforementioned
// scenario because innerWidth always has to be an integer
// number of CSS pixels. Ditto for the height computation.
originalInnerWidth = window.innerWidth;
originalInnerHeight = window.innerHeight;
assert_equals(
window.visualViewport.width,
window.innerWidth - 20,
"Custom scrollbar width subtracted from viewport.");
assert_equals(
window.visualViewport.height,
window.innerHeight - 25,
"Custom scrollbar height subtracted from viewport.");
},
'No zoom or scale applied',
'2. Browser-zoom into 200% (ctrl +)');
addManualTestStep(
function() {
// Ensure we zoomed in to about what we expect.
assert_approx_equals(
originalInnerWidth / window.innerWidth,
2.0,
0.1,
"Browser zoom to correct level");
// The custom scrollbars are also 2x larger on the screen, so
// the viewport is smaller than half of the original size.
assert_equals(
window.visualViewport.width,
originalInnerWidth / 2 - 20,
"Custom scrollbar width subtracted from viewport.");
assert_equals(
window.visualViewport.height,
originalInnerHeight / 2 - 25,
"Custom scrollbar height subtracted from viewport.");
},
'With 200% browser zoom',
'3. Reset browser zoom (ctrl+0).');
addManualTestStep(
showPinchWidget.bind(null, 2.0, 0, 0, continueTest),
null,
'Pinch-zoom dialog in progress');
addManualTestStep(
function() {
assert_approx_equals(
window.visualViewport.scale, 2, 0.2, "Pinch zoom to correct scale");
// Scrollbars do not grow with pinch-zoom so they take up fewer
// CSS pixels as you zoom in.
assert_approx_equals(
window.visualViewport.width,
originalWidth / window.visualViewport.scale,
1,
"Custom scrollbar width subtracted from viewport.");
assert_approx_equals(
window.visualViewport.height,
originalHeight / window.visualViewport.scale,
1,
"Custom scrollbar width subtracted from viewport.");
},
'With ~200% pinch zoom',
'4. Pinch-zoom out.');
addManualTestStep(
function() { continueBtn.remove(); },
null,
'Test Complete');
</script>
</html>
|