| Index: third_party/WebKit/LayoutTests/shadow-dom/offsetParent.html
|
| diff --git a/third_party/WebKit/LayoutTests/shadow-dom/offsetParent.html b/third_party/WebKit/LayoutTests/shadow-dom/offsetParent.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..734298a55f6ae0eddf498c7d2568375626c76a3f
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/shadow-dom/offsetParent.html
|
| @@ -0,0 +1,175 @@
|
| +<!DOCTYPE html>
|
| +<script src='../resources/testharness.js'></script>
|
| +<script src='../resources/testharnessreport.js'></script>
|
| +<script src='resources/shadow-dom.js'></script>
|
| +<style>
|
| +.container { position: relative; }
|
| +</style>
|
| +
|
| +<!--
|
| +When the context object is in a closed shadow tree, it can return the real
|
| +offset parent above the shadow tree, as it is unclosed.
|
| +-->
|
| +<div id='host_open0'>
|
| + <template data-mode='open' data-expose-as='root_open0'>
|
| + <style>.container { position: relative; }</style>
|
| + <div id='container' class='container'>
|
| + <div id='inner_node'>X</div>
|
| + </div>
|
| + </template>
|
| +</div>
|
| +
|
| +<script>
|
| +convertTemplatesToShadowRootsWithin(host_open0);
|
| +
|
| +test(() => {
|
| + let container = root_open0.querySelector('#container');
|
| + let inner_node = root_open0.querySelector('#inner_node');
|
| + assert_equals(inner_node.offsetParent, container);
|
| +}, 'offsetParent should return node in the same node tree in open shadow root.');
|
| +</script>
|
| +
|
| +<!--
|
| +When the real offsetParent is in a closed shadow tree, if it is unclosed to the
|
| +context object, that parent should be returned.
|
| +-->
|
| +<div id='host_closed0'>
|
| + <template data-mode='closed' data-expose-as='root_closed0'>
|
| + <style>.container { position: relative; }</style>
|
| + <div id='container' class='container'>
|
| + <div id='inner_node'>X</div>
|
| + </div>
|
| + </template>
|
| +</div>
|
| +
|
| +<script>
|
| +convertTemplatesToShadowRootsWithin(host_closed0);
|
| +
|
| +test(() => {
|
| + let container = root_closed0.querySelector('#container');
|
| + let inner_node = root_closed0.querySelector('#inner_node');
|
| + assert_equals(inner_node.offsetParent, container);
|
| +}, 'offsetParent should return node in the same node tree in closed shadow root.');
|
| +</script>
|
| +
|
| +<!--
|
| +When the real offsetParent is in a closed shadow tree, if it is unclosed to the
|
| +context object, that parent should be returned.
|
| +-->
|
| +<div id='host_closed1'>
|
| + <template data-mode='closed' data-expose-as='root_closed1'>
|
| + <style>.container { position: relative; }</style>
|
| + <div id='inner_host' class='container'>
|
| + <template data-mode='open' data-expose-as='root_open_inner1'>
|
| + <div id='inner_node'>X</div>
|
| + </template>
|
| + </div>
|
| + </template>
|
| +</div>
|
| +
|
| +<script>
|
| +convertTemplatesToShadowRootsWithin(host_closed1);
|
| +
|
| +test(() => {
|
| + let inner_host = root_closed1.querySelector('#inner_host');
|
| + let inner_node = root_open_inner1.querySelector('#inner_node');
|
| + assert_equals(inner_node.offsetParent, inner_host);
|
| +}, 'offsetParent should return an unclosed node in a closed shadow from open shadow.');
|
| +</script>
|
| +
|
| +<!--
|
| +When the context object is in a closed shadow tree, it can return the real
|
| +offset parent above the shadow tree, as it is unclosed.
|
| +-->
|
| +<div id='host_open1'>
|
| + <template data-mode='open' data-expose-as='root_open1'>
|
| + <style>.container { position: relative; }</style>
|
| + <div id='inner_host' class='container'>
|
| + <template data-mode='closed' data-expose-as='root_closed_inner1'>
|
| + <div id='inner_node'>X</div>
|
| + </template>
|
| + </div>
|
| + </template>
|
| +</div>
|
| +
|
| +<script>
|
| +convertTemplatesToShadowRootsWithin(host_open1);
|
| +
|
| +test(() => {
|
| + let inner_host = root_open1.querySelector('#inner_host');
|
| + let inner_node = root_closed_inner1.querySelector('#inner_node');
|
| + assert_equals(inner_node.offsetParent, inner_host);
|
| +}, 'offsetParent should return an unclosed node in a open shadow from closed shadow.');
|
| +</script>
|
| +
|
| +<!--
|
| +#host_open and #host_closed have the same structure, and #target_open /
|
| +#target_closed are slotted into each shadow slot, then real offsetParent would
|
| +be in the shadow. For the closed shadow, such element should not leak to the
|
| +light DOM, so it is adjusted to the nearest unclosed offsetParent.
|
| +
|
| +See also
|
| +https://github.com/w3c/webcomponents/issues/497
|
| +https://github.com/w3c/csswg-drafts/issues/159
|
| +-->
|
| +<div id='host_open2' class='container'>
|
| + <template data-mode='open' data-expose-as='root_open2'>
|
| + <style>.container { position: relative; }</style>
|
| + <div id='container_open' class='container'>
|
| + <slot name='x'></slot>
|
| + </div>
|
| + </template>
|
| + <span id='target_open' slot='x'>X</span>
|
| +</div>
|
| +
|
| +<div id='host_closed2' class='container'>
|
| + <template data-mode='closed' data-expose-as='root_closed2'>
|
| + <style>.container { position: relative; }</style>
|
| + <div id='container_closed' class='container'>
|
| + <slot name='x'></slot>
|
| + </div>
|
| + </template>
|
| + <span id='target_closed' slot='x'>Y</span>
|
| +</div>
|
| +
|
| +<script>
|
| +convertTemplatesToShadowRootsWithin(host_open2);
|
| +convertTemplatesToShadowRootsWithin(host_closed2);
|
| +
|
| +test(() => {
|
| + assert_equals(target_open.offsetParent.id, 'container_open');
|
| + assert_equals(target_closed.offsetParent.id, 'host_closed2');
|
| +}, 'offsetParent should return an unclosed node.');
|
| +</script>
|
| +
|
| +<!--
|
| +Check if offsetParent can properly traverse up to find unclosed node.
|
| +In the following example, #target_closed3 will distributed to slot y,
|
| +but its offsetParent should neither return #inner_node nor #inner_host.
|
| +-->
|
| +
|
| +<div id='host_closed3' class='container'>
|
| + <template data-mode='closed' data-expose-as='root_closed3'>
|
| + <style>.container { position: relative; }</style>
|
| + <div id='inner_host' class='container'>
|
| + <template data-mode='closed' data-expose-as='root_closed_inner3'>
|
| + <style>.container { position: relative; }</style>
|
| + <div id='inner_node' class='container'>
|
| + <slot name='y'></slot>
|
| + </div>
|
| + </template>
|
| + <slot name='x' slot='y'></slot>
|
| + </div>
|
| + </template>
|
| + <span id='target_closed3' slot='x'>Z</span>
|
| +</div>
|
| +
|
| +<script>
|
| +convertTemplatesToShadowRootsWithin(host_closed3);
|
| +
|
| +test(() => {
|
| + let slot_y = root_closed_inner3.querySelector('slot[name=y]');
|
| + assert_array_equals(slot_y.assignedNodes({flatten: true}), [target_closed3]);
|
| + assert_equals(target_closed3.offsetParent.id, 'host_closed3');
|
| +}, 'offsetParent should skip any non-unclosed nodes.');
|
| +</script>
|
|
|