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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/custom/svg-use-shadow-tree.html

Issue 1427783004: Don't expose UA shadow roots in custom element callbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert doc changes. Created 5 years, 2 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 | third_party/WebKit/Source/core/dom/custom/CustomElementCallbackQueue.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/dom/custom/svg-use-shadow-tree.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/custom/svg-use-shadow-tree.html b/third_party/WebKit/LayoutTests/fast/dom/custom/svg-use-shadow-tree.html
new file mode 100644
index 0000000000000000000000000000000000000000..9222cbdb48a7c73ed63a04eab060ccfbf8db999b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/custom/svg-use-shadow-tree.html
@@ -0,0 +1,101 @@
+<!DOCTYPE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+
+<template id="template">
+<svg>
+ <defs>
+ <g id="used-group">
+ <rect
+ id="rect"
+ is="x-rect"
+ x="10" y="10"
+ width="100" height="100"
+ fill="red"/>
+ </g>
+ </defs>
+ <use xlink:href="#used-group"/>
+</svg>
+</template>
+
+<div id="container"></div>
+
+<script>
+"use strict";
+
+var instances = [];
+
+function createPrototype(superClass) {
+ class ElementType extends superClass {
dominicc (has gone to gerrit) 2015/10/30 02:42:39 This nested class definition w/ superClass is very
+ get ownerScope() {
+ var scope = this.parentNode;
+ while (scope && scope.parentNode)
+ scope = scope.parentNode;
+ return scope;
+ }
+ createdCallback() {
+ this.instanceId = instances.length;
+ instances[this.instanceId] = this;
+ assert_false(this.ownerScope instanceof ShadowRoot,
+ "Should not call createdCallback in UA ShadowRoot.");
+ }
+ attachedCallback() {
+ assert_false(this.ownerScope instanceof ShadowRoot,
+ "Should not call attachedCallback in UA ShadowRoot.");
+ assert_equals(instances[this.instanceId], this);
+ }
+ detachedCallback() {
+ assert_false(this.ownerScope instanceof ShadowRoot,
+ "Should not call detachedCallback in UA ShadowRoot.");
+ assert_equals(instances[this.instanceId], this);
+ }
+ attributeChangedCallback() {
+ assert_unreached("attributeChangedCallback should never be called.");
+ }
+ };
+ return ElementType.prototype;
+}
+
+// <rect is=x-rect>
+var XRectElement = document.registerElement('x-rect', {
+ extends: 'rect',
+ prototype: createPrototype(SVGRectElement),
+});
+
+// <x-test>
+var XTestElement = document.registerElement('x-test', {
+ prototype: createPrototype(HTMLElement),
+});
+
+test(function () {
+ var template = document.getElementById("template");
+ var svg = document.importNode(template.content, true).firstElementChild;
+ var usedGroup = svg.getElementById("used-group");
+ document.body.appendChild(svg);
+
+ // Force a recreation of the use trees.
+ document.body.offsetTop;
+ assert_array_equals([usedGroup.firstElementChild], instances);
+
+ var elements = [
+ usedGroup.firstElementChild,
+ new XRectElement(),
+ new XTestElement(),
+ new XRectElement(),
+ ];
+
+ // Add another <rect is=x-rect>, and a child <x-test> that also contains one.
+ usedGroup.appendChild(elements[1]);
+ var test = usedGroup.appendChild(elements[2]);
+ test.appendChild(elements[3]);
+
+ // Force a recreation of the use trees.
+ document.body.offsetTop;
+ assert_array_equals(elements, instances);
+
+ for (var i = 0; i < instances.length; ++i) {
+ assert_true(instances[i].ownerScope instanceof Document,
+ "No instances should be inside a ShadowRoot.");
+ }
+}, "SVG <use> shadow trees should not be exposed through custom elements.");
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/custom/CustomElementCallbackQueue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698