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

Unified Diff: third_party/WebKit/LayoutTests/custom-elements/imports/attribute-changed-callback.html

Issue 2312613002: Fix 'will execute script' condition for creating custom elements in imports (Closed)
Patch Set: Created 4 years, 3 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/LayoutTests/custom-elements/imports/resources/attribute-parsercreate.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/custom-elements/imports/attribute-changed-callback.html
diff --git a/third_party/WebKit/LayoutTests/custom-elements/imports/attribute-changed-callback.html b/third_party/WebKit/LayoutTests/custom-elements/imports/attribute-changed-callback.html
new file mode 100644
index 0000000000000000000000000000000000000000..cf854ed375f78fac54bb0dd846d7b6a63bc67057
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/custom-elements/imports/attribute-changed-callback.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<link id="import1" rel="import" href="resources/attribute-upgrade.html">
+<script>
+'use strict';
+
+let reactions = [];
+
+customElements.define('a-a', class extends HTMLElement {
+ static get observedAttributes() { return ['attr']; }
+ attributeChangedCallback() {
+ reactions.push(this);
+ }
+});
+</script>
+<link id="import2" rel="import" href="resources/attribute-parsercreate.html">
+<script>
+'use strict';
+
+test(() => {
+ let importDoc1 = import1.import;
+ let importDoc2 = import2.import;
+
+ let a = importDoc1.querySelector('#a');
+ let b = importDoc1.querySelector('#b');
+ let c = importDoc2.querySelector('#c');
+ let d = importDoc2.querySelector('#d');
+
+ assert_array_equals(reactions, [b, d],
+ 'attributeChangedCallback should be called for both upgrade and create.');
+
+ reactions = [];
+
+ a.setAttribute('attr', 'a');
+ b.setAttribute('attr', 'b');
+ c.setAttribute('attr', 'c');
+ d.setAttribute('attr', 'd');
+
+ assert_array_equals(reactions, [a, b, c, d],
+ 'attributeChangedCallback should be called for setAttribute().');
+
+ reactions = [];
+
+ d.removeAttribute('attr', 'd');
+ c.removeAttribute('attr', 'c');
+ b.removeAttribute('attr', 'b');
+ a.removeAttribute('attr', 'a');
+
+ assert_array_equals(reactions, [d, c, b, a],
+ 'attributeChangedCallback should be called for removeAttribute().');
+}, 'attributeChangedCallback should be invoked for elements in import');
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/custom-elements/imports/resources/attribute-parsercreate.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698