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

Unified Diff: LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles.html

Issue 216543002: Revert of Remove applyAuthorStyles flag from ShadowRoot. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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/shadow-root-applyAuthorStyles.html
diff --git a/LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles.html b/LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles.html
new file mode 100644
index 0000000000000000000000000000000000000000..137471e762f6023663061a0774a45890da8239b8
--- /dev/null
+++ b/LayoutTests/fast/dom/shadow/shadow-root-applyAuthorStyles.html
@@ -0,0 +1,151 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+span {
+ background-color: #eef;
+ border: solid;
+ color: #fee;
+ display: boxed-inline;
+ font-size: 24px;
+ margin: 2px;
+ outline-color: #f00;
+ padding-left: 5px;
+ text-align: start;
+ text-decoration: underline;
+}
+input[type="file"] {
+ text-align: end;
+}
+</style>
+</head>
+<body>
+<div id="apply-author-style"></div>
+<div id="no-apply-author-style"></div>
+<div id="with-inline-style-declaration"></div>
+<div id="try-to-override-important"></div>
+<div id="change-apply-author-style-from-true-to-false"></div>
+<div id="change-apply-author-style-from-false-to-true"></div>
+
+<script>
+function shouldBe(a, b)
+{
+ if (a != b) {
+ throw "failure:" + a + ": should be " + b;
+ }
+}
+
+function shouldNotBe(a, b)
+{
+ if (a == b) {
+ throw "failure:" + a + ": should not be " + b;
+ }
+}
+
+function assertTrue(id, actual) {
+ if (!actual) {
+ throw "failure:" + id + ": assertTrue failed";
+ }
+}
+
+function assertFalse(id, actual) {
+ if (actual) {
+ throw "failure:" + id + ": assertFalse failed";
+ }
+}
+
+function renderApplyAuthorStyleCase() {
+ var div = document.createElement('div');
+ document.getElementById('apply-author-style').appendChild(div);
+
+ var shadowRoot = div.createShadowRoot();
+ assertFalse('default applyAuthorStyles', shadowRoot.applyAuthorStyles);
+ shadowRoot.applyAuthorStyles = true;
+ assertTrue('applyAuthorStyles should be true', shadowRoot.applyAuthorStyles);
+ shadowRoot.innerHTML = '<span></span>';
+}
+
+function renderNoApplyAuthorStyleCase() {
+ var div = document.createElement('div');
+ document.getElementById('no-apply-author-style').appendChild(div);
+
+ var shadowRoot = div.createShadowRoot();
+ assertFalse('default applyAuthorStyles', shadowRoot.applyAuthorStyles);
+ shadowRoot.applyAuthorStyles = false;
+ assertFalse('applyAuthorStyles should be false', shadowRoot.applyAuthorStyles);
+ shadowRoot.innerHTML = '<span></span>';
+}
+
+function renderApplyAuthorStyleWithInlineStyleDeclarationCase() {
+ var div = document.createElement('div');
+ document.getElementById('with-inline-style-declaration').appendChild(div);
+
+ var shadowRoot = div.createShadowRoot();
+ assertFalse('default applyAuthorStyles', shadowRoot.applyAuthorStyles);
+ shadowRoot.applyAuthorStyles = true;
+ assertTrue('applyAuthorStyles should be true', shadowRoot.applyAuthorStyles);
+ shadowRoot.innerHTML = '<span style="border:none; color:#daa; font-size:18px; text-decoration:none"></span>';
+}
+
+function renderApplyAuthorStyleWithOverridingImportantPropertyCase() {
+ var div = document.createElement('div');
+ document.getElementById('try-to-override-important').appendChild(div);
+
+ var shadowRoot = div.createShadowRoot();
+ assertFalse('default applyAuthorStyles', shadowRoot.applyAuthorStyles);
+ shadowRoot.applyAuthorStyles = true;
+ assertTrue('applyAuthorStyles should be true', shadowRoot.applyAuthorStyles);
+ shadowRoot.innerHTML = '<input type="file" />';
+}
+
+function testChangingApplyAuthorStyleFromTrueToFalse() {
+ var div = document.createElement('div');
+ document.getElementById('change-apply-author-style-from-true-to-false').appendChild(div);
+
+ var shadowRoot = div.createShadowRoot();
+ assertFalse('default applyAuthorStyles', shadowRoot.applyAuthorStyles);
+ shadowRoot.applyAuthorStyles = true;
+ assertTrue('applyAuthorStyles should be true', shadowRoot.applyAuthorStyles);
+ shadowRoot.innerHTML = '<div><span id="test1"></span></div>';
+ div.offsetLeft;
+ var target = shadowRoot.getElementById('test1');
+ shouldBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
+ shouldBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
+
+ shadowRoot.applyAuthorStyles = false;
+ assertFalse('applyAuthorStyles should be false', shadowRoot.applyAuthorStyles);
+ div.offsetLeft;
+ shouldNotBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
+ shouldNotBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
+}
+
+function testChangingApplyAuthorStyleFromFalseToTrue() {
+ var div = document.createElement('div');
+ document.getElementById('change-apply-author-style-from-false-to-true').appendChild(div);
+
+ var shadowRoot = div.createShadowRoot();
+ shadowRoot.applyAuthorStyles = false;
+ assertFalse('applyAuthorStyles should be false', shadowRoot.applyAuthorStyles);
+ shadowRoot.innerHTML = '<div><span id="test2"></span></div>';
+ div.offsetLeft;
+ var target = shadowRoot.getElementById('test2');
+ shouldNotBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
+ shouldNotBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
+
+ shadowRoot.applyAuthorStyles = true;
+ assertTrue('applyAuthorStyles should be true', shadowRoot.applyAuthorStyles);
+ div.offsetLeft;
+ shouldBe(window.getComputedStyle(target).getPropertyValue('font-size'), "24px");
+ shouldBe(window.getComputedStyle(target).getPropertyValue('text-decoration'), "underline");
+}
+
+renderApplyAuthorStyleCase();
+// Looks: regression.
+// renderNoApplyAuthorStyleCase();
+renderApplyAuthorStyleWithInlineStyleDeclarationCase();
+renderApplyAuthorStyleWithOverridingImportantPropertyCase();
+testChangingApplyAuthorStyleFromTrueToFalse();
+testChangingApplyAuthorStyleFromFalseToTrue();
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698