Source code

Revision control

Copy as Markdown

Other Tools

<!doctype html>
<title>Viewport: URL bar changes height</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="viewport_support.js"></script>
setup({explicit_timeout: true});
body {
margin-bottom: 1000px;
<h1>Viewport: URL bar changes height</h1>
Test Description: This test checks that hiding the URL bar correctly
affects the visualViewport height. Skip if the UA doesn't have a URL bar
that hides/shows with scrolling.
<h2 style="color: red">THIS IS A MANUAL TEST</h2>
<p id="skip">
<button id="skipbtn" onclick="skipManualTest();">Skip Test</button>
<p id="instruction"></p>
<button id="continue">Start Test</button>
<div id="log"></div>
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 heights = [ window.visualViewport.height ];
function() {
window.visualViewport.addEventListener('resize', function(e) {
heights.push( window.visualViewport.height );
'1. Scroll down (slowly, e.g. over ~1 sec) so the URL bar hides.');
function() {
heights.length, 2, 'URL bar caused multiple resize events');
var smallest = heights[0];
var largest = heights[0];
for (var height in heights) {
if (height < smallest)
smallest = height;
if (height > largest)
largest = height;
var hasIntermediate = false;
for (var height in heights) {
if (height != smallest && height != largest) {
hasIntermediate = true;
'Resize fired for intermediate viewport height values');
'URL bar updates height continually',
'Test Complete');