0

Update a bunch of tests to use current declarative shadow DOM

These tests inadvertently use the deprecated form of declarative
shadow DOM, with the `shadowroot` attribute. Update them to use
the new `shadowrootmode` attribute. Also delete one test that
exercises an Origin Trial that ended long ago.

Bug: 1396384
Change-Id: Iaa1767a0393d729737e558834b0f84687c363383
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4777673
Commit-Queue: Mason Freed <masonf@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1183741}
This commit is contained in:
Mason Freed
2023-08-15 19:05:55 +00:00
committed by Chromium LUCI CQ
parent c3e93c8007
commit f773e19999
8 changed files with 11 additions and 40 deletions

@ -71,10 +71,7 @@ testPaste("<div><b><i><span style=\"font-weight: normal\">plain text<b><i>bold i
testPaste("<span>foo</span><template>Hello</template><span>bar</span>", "foobar");
// Note that an empty <div> is left in the resulting pasted text, which isn't ideal:
testPaste("<span>foo</span><div><template>Hello</template></div><span>bar</span>", "foo<div></div>bar");
// Contained shadow DOM is stripped, but content is retained (old non-streaming DSD API, shadowroot):
testPaste("<span>foo</span><div><template shadowroot='open'>Hello</template></div><span>bar</span>", "foo<div>Hello</div>bar", "non-streaming DSD 1");
testPaste("<span>foo</span><div><template shadowroot='open'><slot></slot>DEF</template>ABC</div><span>bar</span>", "foo<div><slot>ABC</slot>DEF</div>bar", "non-streaming DSD 2");
// Contained shadow DOM is stripped, but content is retained (new streaming DSD API, shadowrootmode):
// Contained shadow DOM is stripped, but content is retained (streaming DSD API, shadowrootmode attribute):
testPaste("<span>foo</span><div><template shadowrootmode='open'>Hello</template></div><span>bar</span>", "foo<div>Hello</div>bar");
testPaste("<span>foo</span><div><template shadowrootmode='open'><slot></slot>DEF</template>ABC</div><span>bar</span>", "foo<div><slot>ABC</slot>DEF</div>bar");
// Make sure non-declarative <template shadowroot> doesn't form a shadow root on paste:

@ -5,7 +5,7 @@
<div style="height:2000px"></div>
<div id=shadowhost>
<template shadowroot=open>
<template shadowrootmode=open>
<details id=detailselement>
<summary>summary</summary>
details

@ -12,7 +12,7 @@
<body>
<div id="shadowHost">
<template shadowroot="open">
<template shadowrootmode="open">
<input type="date" id="date0" value="2000-01-02">
</template>
</div>

@ -52,7 +52,7 @@
<div aria-describedby="node30"></div>
<header id="header">role=[banner] test</header>
<div id="shadow-host">
<template shadowroot="open">
<template shadowrootmode="open">
<input id="shadow-input" placeholder="Shadow input"></input>
</template>
</div>

@ -1,26 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<!-- Generate token with the command:
generate_token.py --version 3 http://127.0.0.1:8000 DeclarativeShadowDOM --expire-timestamp=2000000000
-- -->
<meta http-equiv="origin-trial" content="A80LutZa5Y3GLQ8KvEiYH5ism5H62hH0Yk231NOhuQlkVDIMoJ8lh9xPALEPNZuWT+JymA4H7CkeOeystF+K9gwAAABceyJvcmlnaW4iOiAiaHR0cDovLzEyNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiRGVjbGFyYXRpdmVTaGFkb3dET00iLCAiZXhwaXJ5IjogMjAwMDAwMDAwMH0=" />
<title>DeclarativeShadowDOM - enabled by origin trial</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(t => {
assert_true(HTMLTemplateElement.prototype.hasOwnProperty("shadowRoot"),'Unable to feature detect');
}, 'Declarative Shadow DOM feature detection for origin-trial enabled document.');
</script>
<div id=host>
<template shadowroot="open"></template>
</div>
<script>
test(t => {
const host = document.querySelector('#host');
assert_true(!!host,"Unable to locate host");
assert_true(!!host.shadowRoot,"No shadow root found");
}, 'Declarative Shadow DOM enabled for origin-trial enabled document.');
</script>

@ -13,7 +13,7 @@ node: value= name=#text shadowRootType=undefined
node: value=undefined name=HOST-ELEMENT shadowRootType=undefined
node: value= name=#text shadowRootType=closed
node: value=undefined name=H2 shadowRootType=closed
node: value=Closes shadow root name=#text shadowRootType=closed
node: value=Closed shadow root name=#text shadowRootType=closed
node: value= name=#text shadowRootType=closed
node: value= name=#text shadowRootType=undefined
node: value=undefined name=TEXTAREA shadowRootType=undefined

@ -3,13 +3,13 @@
<html>
<body>
<host-element>
<template shadowroot="open">
<template shadowrootmode="open">
<h2>Open shadow root</h2>
</template>
</host-element>
<host-element>
<template shadowroot="closed">
<h2>Closes shadow root</h2>
<template shadowrootmode="closed">
<h2>Closed shadow root</h2>
</template>
</host-element>
<textarea>test for ua shadow roots are not returned by DOMSnapshot.captureSnapshot</textarea>

@ -13,7 +13,7 @@
then throw a "NotSupportedError" DOMException.
-->
<video>
<template shadowroot=open>
<template shadowrootmode=open>
</template>
</video>
@ -33,7 +33,7 @@ class ShadowDisabledElement extends HTMLElement {
customElements.define('shadow-disabled-element', ShadowDisabledElement);
</script>
<shadow-disabled-element>
<template shadowroot=open>
<template shadowrootmode=open>
</template>
</shadow-disabled-element>
@ -46,7 +46,7 @@ root" property is false, then throw an "NotSupportedError" DOMException.
<script>
host.attachShadow({mode:'open'});
</script>
<template shadowroot=open>
<template shadowrootmode=open>
</template>
</div>