blob: c7c87fcdd3fbb0059217299a8e9ca9df8c6ae989 [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
// This test verifies the rootScroller behavior while the document is in
// fullscreen. We expect that the effective rootScroller of all documents on
// a page revert to the document itself. On exiting fullscreen, the
// designated document.rootScroller should take effect again.
// Helper async function to block execution for n number of rAFs.
async function nFrames(n) {
return new Promise(resolve => {
let remainingFrames = n;
let func = function() {
--remainingFrames;
if (remainingFrames === 0)
resolve();
else {
requestAnimationFrame(func);
}
};
if (n === 0) {
resolve();
} else {
requestAnimationFrame(() => {
func(resolve);
});
}
});
}
const test = async_test("Fullscreen rootScroller Test");
let iframe;
let childDocument;
let scroller;
async function fullscreenChanged() {
if (document.webkitIsFullScreen) {
await nFrames(2);
test.step(() => {
assert_equals(
window.internals.effectiveRootScroller(document),
document,
"Entering fullscreen should reset root document's effective " +
"root scroller");
assert_equals(
window.internals.effectiveRootScroller(childDocument),
childDocument,
"Entering fullscreen should reset iframe's effective root " +
"scroller");
});
document.webkitExitFullscreen();
} else {
await nFrames(2);
test.step(() => {
assert_equals(
window.internals.effectiveRootScroller(document),
iframe,
"Exiting fullscreen should set the iframe back as the root " +
"document's effective root scroller.");
assert_equals(
window.internals.effectiveRootScroller(childDocument),
scroller,
"Exiting fullscreen should set the scroller div back as the " +
"iframe's effective root scroller.");
});
test.done();
}
}
addEventListener('load', async () => {
if (!window.internals)
return;
iframe = document.getElementById('frame');
childDocument = iframe.contentDocument;
scroller = childDocument.getElementById('scroller');
scroller.addEventListener('click', () => {
scroller.webkitRequestFullscreen();
});
document.addEventListener('webkitfullscreenchange', fullscreenChanged);
document.rootScroller = iframe;
childDocument.rootScroller = scroller;
await nFrames(1);
test.step(() => {
assert_equals(
window.internals.effectiveRootScroller(document),
iframe,
"Root document should initially have iframe as effective root " +
"scroller");
assert_equals(
window.internals.effectiveRootScroller(childDocument),
scroller,
"Iframe should initially have scroller div as effective root " +
"scroller");
});
// Fullscreen must be click-activated since it needs a user gesture.
chrome.gpuBenchmarking.pointerActionSequence([
{
"source": "mouse",
"actions": [
{ "name": "pointerDown", "x": 10, "y": 10 },
{ "name": "pointerUp" }
]
}]);
});
</script>
<style>
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
html, body {
width: 100%;
height: 100%;
margin: 0;
}
iframe {
width: 100%;
height: 100%;
border: 0;
}
</style>
<iframe id="frame" srcdoc="
<!DOCTYPE html>
<style>
body,html {
width: 100%;
height: 100%;
margin: 0;
}
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
</style>
<div id='scroller' style='width:100%; height:100%; overflow: auto;'>
<div style='height: 2000px; width: 2000px;'></div>
</div>" allowfullscreen>
</iframe>