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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/custom-elements/reaction-timing.html

Issue 2376103007: Import wpt@09907a9c4bcee14986431d53e4381384c7c69107 (Closed)
Patch Set: update platform expectations Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Custom Elements: Custom element reactions must be invoked before returnin g to author scripts</title>
5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
6 <meta name="assert" content="Custom element reactions must be invoked before ret urning to author scripts">
7 <link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#inv oke-custom-element-reactions">
8 <script src="/resources/testharness.js"></script>
9 <script src="/resources/testharnessreport.js"></script>
10 </head>
11 <body>
12 <div id="log"></div>
13 <script>
14
15 class MyCustomElement extends HTMLElement {
16 attributeChangedCallback(...args) {
17 this.handler(...args);
18 }
19
20 handler() { }
21 }
22 MyCustomElement.observedAttributes = ['data-title', 'title'];
23 customElements.define('my-custom-element', MyCustomElement);
24
25 test(function () {
26 var instance = document.createElement('my-custom-element');
27 var anotherInstance = document.createElement('my-custom-element');
28
29 var callbackOrder = [];
30 instance.handler = function () {
31 callbackOrder.push([this, 'begin']);
32 anotherInstance.setAttribute('data-title', 'baz');
33 callbackOrder.push([this, 'end']);
34 }
35 anotherInstance.handler = function () {
36 callbackOrder.push([this, 'begin']);
37 callbackOrder.push([this, 'end']);
38 }
39
40 instance.setAttribute('title', 'foo');
41 assert_equals(callbackOrder.length, 4);
42
43 assert_array_equals(callbackOrder[0], [instance, 'begin']);
44 assert_array_equals(callbackOrder[1], [anotherInstance, 'begin']);
45 assert_array_equals(callbackOrder[2], [anotherInstance, 'end']);
46 assert_array_equals(callbackOrder[3], [instance, 'end']);
47
48 }, 'setAttribute and removeAttribute must enqueue and invoke attributeChangedCal lback');
49
50 test(function () {
51 var shouldCloneAnotherInstance = false;
52 var anotherInstanceClone;
53 var log = [];
54
55 class SelfCloningElement extends HTMLElement {
56 constructor() {
57 super();
58 log.push([this, 'begin']);
59 if (shouldCloneAnotherInstance) {
60 shouldCloneAnotherInstance = false;
61 anotherInstanceClone = anotherInstance.cloneNode(false);
62 }
63 log.push([this, 'end']);
64 }
65 }
66 customElements.define('self-cloning-element', SelfCloningElement);
67
68 var instance = document.createElement('self-cloning-element');
69 var anotherInstance = document.createElement('self-cloning-element');
70 shouldCloneAnotherInstance = true;
71
72 assert_equals(log.length, 4);
73 var instanceClone = instance.cloneNode(false);
74
75 assert_equals(log.length, 8);
76 assert_array_equals(log[0], [instance, 'begin']);
77 assert_array_equals(log[1], [instance, 'end']);
78 assert_array_equals(log[2], [anotherInstance, 'begin']);
79 assert_array_equals(log[3], [anotherInstance, 'end']);
80 assert_array_equals(log[4], [instanceClone, 'begin']);
81 assert_array_equals(log[5], [anotherInstanceClone, 'begin']);
82 assert_array_equals(log[6], [anotherInstanceClone, 'end']);
83 assert_array_equals(log[7], [instanceClone, 'end']);
84 }, 'Calling Node.prototype.cloneNode(false) must push a new element queue to the processing stack');
85
86 </script>
87 </body>
88 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698