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

Unified Diff: LayoutTests/http/tests/security/contentSecurityPolicy/inline-style-allowed-while-cloning-objects.html

Issue 14234005: CSP blocks style application in cloned nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: CSP blocks style application in cloned nodes Created 7 years, 8 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/security/contentSecurityPolicy/inline-style-allowed-while-cloning-objects-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/security/contentSecurityPolicy/inline-style-allowed-while-cloning-objects.html
diff --git a/LayoutTests/http/tests/security/contentSecurityPolicy/inline-style-allowed-while-cloning-objects.html b/LayoutTests/http/tests/security/contentSecurityPolicy/inline-style-allowed-while-cloning-objects.html
new file mode 100644
index 0000000000000000000000000000000000000000..27f7cb809a18d6b824e375da0dfbb7c6c508a2ab
--- /dev/null
+++ b/LayoutTests/http/tests/security/contentSecurityPolicy/inline-style-allowed-while-cloning-objects.html
@@ -0,0 +1,86 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Security-Policy" content="style-src 'self';">
+ <script src="../../resources/js-test-pre.js"></script>
+ <script>
+ window.onload = function () {
+ debug("This test ensures that styles can be set by object.cloneNode()");
+
+ window.nodes = document.getElementById('nodes');
+ window.node1 = document.getElementById('node1');
+ window.node1.style.background = "yellow";
+ window.node1.style.color = "red";
+ window.node2 = document.getElementById('node1').cloneNode(true);
+ window.node2.id = "node2";
+ window.node3 = document.getElementById('node3');
+ window.node3.style.background = "blue";
+ window.node3.style.color = "green";
+ window.node4 = document.getElementById('node3').cloneNode(false);
+ window.node4.id = "node4";
+ window.node4.innerHTML = "Node #4";
+
+ nodes.appendChild(node1);
+ nodes.appendChild(node2);
+ nodes.appendChild(node3);
+ nodes.appendChild(node4);
+
+ shouldBeEqualToString("node1.style.background", "yellow");
+ shouldBeEqualToString("node2.style.background", "yellow");
+ shouldBeEqualToString("node3.style.background", "blue");
+ shouldBeEqualToString("node4.style.background", "blue");
+
+ shouldBeEqualToString("node1.style.color", "red");
+ shouldBeEqualToString("node2.style.color", "red");
+ shouldBeEqualToString("node3.style.color", "green");
+ shouldBeEqualToString("node4.style.color", "green");
+
+ shouldBe("window.getComputedStyle(node1).getPropertyCSSValue('background').cssText", "window.getComputedStyle(node2).getPropertyCSSValue('background').cssText");
+ shouldBe("window.getComputedStyle(node3).getPropertyCSSValue('background').cssText", "window.getComputedStyle(node4).getPropertyCSSValue('background').cssText");
+
+ shouldBe("window.getComputedStyle(node1).getPropertyCSSValue('color').cssText", "window.getComputedStyle(node2).getPropertyCSSValue('color').cssText");
+ shouldBe("window.getComputedStyle(node3).getPropertyCSSValue('color').cssText", "window.getComputedStyle(node4).getPropertyCSSValue('color').cssText");
+
+ window.ops = document.getElementById('ops');
+ ops.style.color = 'red';
+ window.clonedOps = ops.cloneNode(true);
+ window.violetOps = document.getElementById('violetOps');
+
+ violetOps.style.background = 'rgb(238, 130, 238)';
+ document.getElementsByTagName('body')[0].appendChild(clonedOps);
+
+ shouldBeEqualToString("ops.style.background", "");
+ debug("getComputedStyle(clonedOps).getPropertyCSSValue('background').cssText: " + window.getComputedStyle(ops).getPropertyCSSValue('background').cssText);
+ shouldBeEqualToString("ops.style.color", "red");
+ shouldBeEqualToString("clonedOps.style.background", "");
+ shouldBeEqualToString("violetOps.style.background", "rgb(238, 130, 238)");
+
+ shouldBe("window.getComputedStyle(clonedOps).getPropertyCSSValue('background').cssText", "window.getComputedStyle(ops).getPropertyCSSValue('background').cssText");
+ shouldBe("window.getComputedStyle(clonedOps).getPropertyCSSValue('color').cssText", "window.getComputedStyle(ops).getPropertyCSSValue('color').cssText");
+ debug("getComputedStyle(violetOps).getPropertyCSSValue('background').cssText: " + window.getComputedStyle(violetOps).getPropertyCSSValue('background').cssText);
+ shouldNotBe("window.getComputedStyle(ops).getPropertyCSSValue('background').cssText", "window.getComputedStyle(violetOps).getPropertyCSSValue('background').cssText");
+ shouldNotBe("window.getComputedStyle(clonedOps).getPropertyCSSValue('background').cssText", "window.getComputedStyle(violetOps).getPropertyCSSValue('background').cssText");
+
+ shouldBeEqualToString("ops.id", "ops");
+ shouldBe("ops.id", "clonedOps.id");
+ };
+ </script>
+</head>
+<body>
+
+ <div id="nodes">
+ This is a div (nodes)
+ <div id="node1"> This is a div. (node 1 or 2)</div>
+ <div id="node3"> This is a div. (node 3 or 4)</div>
+ </div>
+
+ <div id="ops" style="background: rgb(238, 130, 238)">
+ Yet another div.
+ </div>
+
+ <div id="violetOps">
+ Yet another div.
+ </div>
+
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/http/tests/security/contentSecurityPolicy/inline-style-allowed-while-cloning-objects-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698