blob: 4924b4adf04077871ae02732c016182d8bdff52d [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/gesture-util.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.
const test = async_test("Fullscreen rootScroller Test");
let iframe;
let childDocument;
let scroller;
async function fullscreenChanged() {
if (document.webkitIsFullScreen) {
await waitForCompositorCommit();
test.step(() => {
assert_equals(
internals.effectiveRootScroller(document),
document,
"Entering fullscreen should reset root document's effective " +
"root scroller");
assert_equals(
internals.effectiveRootScroller(childDocument),
childDocument,
"Entering fullscreen should reset iframe's effective root " +
"scroller");
});
document.webkitExitFullscreen();
} else {
await waitForCompositorCommit();
test.step(() => {
assert_equals(
internals.effectiveRootScroller(document),
iframe,
"Exiting fullscreen should set the iframe back as the root " +
"document's effective root scroller.");
assert_equals(
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;
// Root Scroller selection happens in a lifecycle update. However, rAF is
// executed before the lifecycle in a BeginMainFrame so we need to wait for
// a second rAF before the we can check the effective root scrollers.
await waitForCompositorCommit();
test.step(() => {
assert_equals(
internals.effectiveRootScroller(document),
iframe,
"Root document should initially have iframe as effective root " +
"scroller");
assert_equals(
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>