blob: 380514c6d7aefd77e4e1b7bb856e324c4420385c [file] [log] [blame]
<!DOCTYPE html>
<script src='../resources/testharness.js'></script>
<script src='../resources/testharnessreport.js'></script>
<script src='resources/shadow-dom.js'></script>
<script src='../fullscreen/trusted-click.js'></script>
<div id='host0'>
<template data-mode='open'>
<canvas></canvas>
</template>
</div>
<script>
convertTemplatesToShadowRootsWithin(host0);
async_test((test) => {
document.onfullscreenerror = test.unreached_func('onfullscreenerror is not expected.');
// All fullscreenElement should default to null.
assert_equals(document.fullscreenElement, null);
assert_equals(document.webkitFullscreenElement, null);
assert_equals(document.webkitCurrentFullScreenElement, null);
assert_equals(host0.shadowRoot.fullscreenElement, null);
var canvas = host0.shadowRoot.querySelector('canvas');
trusted_request(test, canvas);
document.onfullscreenchange = test.step_func(() => {
// Not interested in handling before or after exitFullscreen.
if (document.fullscreenElement === null)
return;
assert_equals(document.fullscreenElement, host0);
assert_equals(document.webkitFullscreenElement, host0);
assert_equals(document.webkitCurrentFullScreenElement, host0);
assert_equals(host0.shadowRoot.fullscreenElement, canvas);
// TODO(kochi): The 'retargeting' behavior is controlled by
// 'FullscreenUnprefixed' runtime flag dynamically. Until the
// flag is turned on, document.webkitFullscreenElement leaks the
// fullscreen element under shadow roots.
internals.runtimeFlags.fullscreenUnprefixedEnabled = false;
assert_false(internals.runtimeFlags.fullscreenUnprefixedEnabled);
assert_equals(document.webkitFullscreenElement, canvas);
assert_equals(document.webkitCurrentFullScreenElement, canvas);
document.exitFullscreen();
test.done();
});
}, 'Test for fullscreenElement adjustment for single shadow tree.');
</script>