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

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

Issue 2333673002: Add a test for {connected,disconnected}Callback in HTML 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/connected-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/connected-callback.html
diff --git a/third_party/WebKit/LayoutTests/custom-elements/imports/connected-callback.html b/third_party/WebKit/LayoutTests/custom-elements/imports/connected-callback.html
new file mode 100644
index 0000000000000000000000000000000000000000..3f3fb5897cf87a21837daced4bba971c6370023e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/custom-elements/imports/connected-callback.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<link id="import1" rel="import" href="resources/connected-upgrade.html">
+<script>
+'use strict';
+
+let reactions = [];
+
+customElements.define('a-a', class extends HTMLElement {
+ connectedCallback() {
+ reactions.push(this);
+ }
+ disconnectedCallback() {
+ reactions.push(this);
+ }
+});
+</script>
+<link id="import2" rel="import" href="resources/connected-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, [a, b, c, d],
+ 'connectedCallback should be called for both upgrade and create.');
+
+ reactions = [];
+
+ d.remove();
+ c.remove();
+ b.remove();
+ a.remove();
+
+ assert_array_equals(reactions, [d, c, b, a],
+ 'disconnectedCallback should be called in imports.');
+
+ reactions = [];
+
+ let div1 = document.createElement('div');
+ let div2 = document.createElement('div');
+ let div3 = document.createElement('div');
+
+ div1.appendChild(div2);
+ div1.appendChild(a);
+ div1.appendChild(div3);
+
+ div2.appendChild(d);
+ div2.appendChild(c);
+ div3.appendChild(b);
+
+ importDoc1.body.appendChild(div1);
+
+ assert_array_equals(reactions, [d, c, a, b],
+ 'connectedCallback should be called in document order.');
+
+ reactions = [];
+
+ div1.remove();
+ assert_array_equals(reactions, [d, c, a, b],
+ 'disconnectedCallback should be called in document order.');
+}, 'connectedCallback and disconnectedCallback should be invoked for elements in import');
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/custom-elements/imports/resources/connected-parsercreate.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698