Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: LayoutTests/fast/dom/shadow/closed-mode-deep-combinator-and-shadow-pseudo.html

Issue 1270313002: Handle closed mode shadow for /deep/ and ::shadow selectors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/dom/shadow/closed-mode-deep-combinator-and-shadow-pseudo.html
diff --git a/LayoutTests/fast/dom/shadow/closed-mode-deep-combinator-and-shadow-pseudo.html b/LayoutTests/fast/dom/shadow/closed-mode-deep-combinator-and-shadow-pseudo.html
new file mode 100644
index 0000000000000000000000000000000000000000..164c102ba2f7c0178431a4956b1f50ee210c6765
--- /dev/null
+++ b/LayoutTests/fast/dom/shadow/closed-mode-deep-combinator-and-shadow-pseudo.html
@@ -0,0 +1,129 @@
+<!doctype html>
hayato 2015/08/19 05:45:24 Could you add a test for a selector which has two
kochi 2015/08/19 07:33:54 A test for two /deep/s would make sense, and will
kochi 2015/08/19 07:52:44 two combinators layout test is added to this CL.
+<script src="../../../resources/js-test.js"></script>
+<script src="resources/shadow-dom.js"></script>
+<style id="style1">
+</style>
+<body></body>
+<script>
+function prepareShadowTree(hostId, mode1, mode2, div1, div2, div3) {
+ var parent = document.body;
+ parent.appendChild(
+ createDOM('div', {'id': hostId},
+ createShadowRoot({'mode': mode1},
+ createDOM('div', {'id': div1},
+ createShadowRoot({'mode': mode2},
+ createDOM('div', {'id': div2}),
+ createDOM('content')),
hayato 2015/08/19 05:45:24 It looks div3 has more than one responsibilities i
kochi 2015/08/19 07:33:54 The <content> was an artifact while I was trying t
+ createDOM('div', {'id': div3})))));
+}
+
+prepareShadowTree('host_open_open', 'open', 'open', 'div1', 'div2', 'div1b');
+prepareShadowTree('host_open_closed', 'open', 'closed', 'div3', 'div4', 'div3b');
+prepareShadowTree('host_closed_open', 'closed', 'open', 'div5', 'div6', 'div5b');
+prepareShadowTree('host_closed_closed', 'closed', 'closed', 'div7', 'div8', 'div7b');
+
+debug('(1/6) /deep/ style rule on top-level document.');
+var styleElement = document.getElementById('style1');
+styleElement.textContent = 'div /deep/ div { background-color: blue; }';
+styleElement.offsetTop; // trigger style recalc
hayato 2015/08/19 05:45:24 Do we need this? Doesn't getComputedStyle() trigge
kochi 2015/08/19 07:33:54 Done (removed all *.offsetTop in this file).
+
+backgroundColorShouldBe('host_open_open/div1', 'rgb(0, 0, 255)');
hayato 2015/08/19 05:45:24 Could you add tests for top-level shadow hosts? e
kochi 2015/08/19 07:33:54 Done. The expected color is rgba(0, 0, 0, 0), as
+backgroundColorShouldBe('host_open_open/div1/div2', 'rgb(0, 0, 255)');
+backgroundColorShouldBe('host_open_open/div1b', 'rgb(0, 0, 255)');
+backgroundColorShouldBe('host_open_closed/div3', 'rgb(0, 0, 255)');
+backgroundColorShouldBe('host_open_closed/div3/div4', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_open_closed/div3b', 'rgb(0, 0, 255)');
+backgroundColorShouldBe('host_closed_open/div5', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_open/div5/div6', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_open/div5b', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_closed/div7', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_closed/div7/div8', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_closed/div7b', 'rgba(0, 0, 0, 0)');
+
+debug('(2/6) ::shadow style rule on top-level document.');
+styleElement.innerHTML = 'div::shadow div { background-color: green; }';
+styleElement.offsetTop; // trigger style recalc
+
+backgroundColorShouldBe('host_open_open/div1', 'rgb(0, 128, 0)');
+backgroundColorShouldBe('host_open_open/div1/div2', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_open_open/div1b', 'rgb(0, 128, 0)');
+backgroundColorShouldBe('host_open_closed/div3', 'rgb(0, 128, 0)');
+backgroundColorShouldBe('host_open_closed/div3/div4', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_open_closed/div3b', 'rgb(0, 128, 0)');
+backgroundColorShouldBe('host_closed_open/div5', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_open/div5/div6', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_open/div5b', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_closed/div7', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_closed/div7/div8', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_closed/div7b', 'rgba(0, 0, 0, 0)');
+
+debug('(3/6) /deep/ style on shadow tree.');
+styleElement.innerHTML = '';
+var div1 = getNodeInTreeOfTrees('host_open_open/div1');
+div1.insertAdjacentHTML('afterbegin', '<style>div /deep/ div { background-color: blue; }</style>');
+var div3 = getNodeInTreeOfTrees('host_open_closed/div3');
+div3.insertAdjacentHTML('afterbegin', '<style>div /deep/ div { background-color: blue; }</style>');
+var div5 = getNodeInTreeOfTrees('host_closed_open/div5');
+div5.insertAdjacentHTML('afterbegin', '<style>div /deep/ div { background-color: blue; }</style>');
+var div7 = getNodeInTreeOfTrees('host_closed_closed/div7');
+div7.insertAdjacentHTML('afterbegin', '<style>div /deep/ div { background-color: blue; }</style>');
+styleElement.offsetTop; // trigger style recalc
+
+backgroundColorShouldBe('host_open_open/div1', 'rgba(0, 0, 0, 0)');
hayato 2015/08/19 05:45:24 Instead of adding style elements altogether, could
kochi 2015/08/19 07:33:54 Done.
+backgroundColorShouldBe('host_open_open/div1/div2', 'rgb(0, 0, 255)');
+backgroundColorShouldBe('host_open_open/div1b', 'rgb(0, 0, 255)');
+backgroundColorShouldBe('host_open_closed/div3', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_open_closed/div3/div4', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_open_closed/div3b', 'rgb(0, 0, 255)');
+backgroundColorShouldBe('host_closed_open/div5', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_open/div5/div6', 'rgb(0, 0, 255)');
+backgroundColorShouldBe('host_closed_open/div5b', 'rgb(0, 0, 255)');
+backgroundColorShouldBe('host_closed_closed/div7', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_closed/div7/div8', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_closed/div7b', 'rgb(0, 0, 255)');
+
+debug('(4/6) ::shadow style on shadow tree.');
+div1.removeChild(div1.firstElementChild);
+div3.removeChild(div3.firstElementChild);
+div5.removeChild(div5.firstElementChild);
+div7.removeChild(div7.firstElementChild);
+div1.insertAdjacentHTML('afterbegin', '<style>div::shadow div { background-color: green; }</style>');
+div3.insertAdjacentHTML('afterbegin', '<style>div::shadow div { background-color: green; }</style>');
+div5.insertAdjacentHTML('afterbegin', '<style>div::shadow div { background-color: green; }</style>');
+div7.insertAdjacentHTML('afterbegin', '<style>div::shadow div { background-color: green; }</style>');
+
+backgroundColorShouldBe('host_open_open/div1', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_open_open/div1/div2', 'rgb(0, 128, 0)');
+backgroundColorShouldBe('host_open_open/div1b', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_open_closed/div3', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_open_closed/div3/div4', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_open_closed/div3b', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_open/div5', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_open/div5/div6', 'rgb(0, 128, 0)');
+backgroundColorShouldBe('host_closed_open/div5b', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_closed/div7', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_closed/div7/div8', 'rgba(0, 0, 0, 0)');
+backgroundColorShouldBe('host_closed_closed/div7b', 'rgba(0, 0, 0, 0)');
+
+debug('(5/6) /deep/ selector in querySelectorAll()');
+shouldBe('host_open_open.querySelectorAll("div /deep/ div").length', '3');
+shouldBe('host_open_closed.querySelectorAll("div /deep/ div").length', '2');
+shouldBe('host_closed_open.querySelectorAll("div /deep/ div").length', '0');
+shouldBe('host_closed_closed.querySelectorAll("div /deep/ div").length', '0');
+
+shouldBe('div1.querySelectorAll("div /deep/ div").length', '2');
+shouldBe('div3.querySelectorAll("div /deep/ div").length', '1');
+shouldBe('div5.querySelectorAll("div /deep/ div").length', '2');
+shouldBe('div7.querySelectorAll("div /deep/ div").length', '1');
+
+debug('(6/6) ::shadow selector in querySelectorAll()');
+shouldBe('host_open_open.querySelectorAll("div::shadow div").length', '2');
+shouldBe('host_open_closed.querySelectorAll("div::shadow div").length', '2');
+shouldBe('host_closed_open.querySelectorAll("div::shadow div").length', '0');
+shouldBe('host_closed_closed.querySelectorAll("div::shadow div").length', '0');
+
+shouldBe('div1.querySelectorAll("div::shadow div").length', '1');
+shouldBe('div3.querySelectorAll("div::shadow div").length', '0');
+shouldBe('div5.querySelectorAll("div::shadow div").length', '1');
+shouldBe('div7.querySelectorAll("div::shadow div").length', '0');
+</script>

Powered by Google App Engine
This is Rietveld 408576698