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

Side by Side Diff: third_party/WebKit/LayoutTests/custom-elements/constructor-may-poach-upgrading-element.html

Issue 2032373002: Revert of Implement the script parts of custom element upgrade steps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ce-upgrade-in-document-dom-merge2
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharness-helpers.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="spec/resources/custom-elements-helpers.js"></script>
6 <body>
7 <script>
8 'use strict';
9
10 test_with_window((w) => {
11 let doc = w.document;
12 let e = doc.createElement('a-a');
13 doc.body.appendChild(e);
14 var misbehave = true;
15 var invocations = [];
16 class X extends w.HTMLElement {
17 constructor() {
18 if (misbehave) {
19 misbehave = false;
20 invocations.push('misbehaving');
21 return new X();
22 }
23 super();
24 invocations.push(this);
25 }
26 }
27 w.customElements.define('a-a', X);
28 assert_array_equals(invocations, ['misbehaving', e],
29 'returning the existing element should have succeeded');
30 }, 'HTMLElement constructor: poach but return upgrade candidate');
31
32 test_with_window((w) => {
33 let doc = w.document;
34 let e = doc.createElement('a-a');
35 doc.body.appendChild(e);
36 var misbehave = true;
37 var invocations = [];
38 var poacher;
39 class X extends w.HTMLElement {
40 constructor() {
41 if (misbehave) {
42 misbehave = false;
43 poacher = new X();
44 }
45 try {
46 super();
47 invocations.push(this);
48 } catch (e) {
49 invocations.push(e);
50 }
51 }
52 }
53 w.customElements.define('a-a', X);
54 assert_equals(invocations.length, 2,
55 'the constructor should have been invoked once for upgrade ' +
56 'and once for the recursive call to "new"');
57 assert_equals(poacher, e,
58 'the recursive "new" should steal the upgrade candidate');
59 assert_equals(poacher, invocations[0],
60 'the recursize "new" should happen first');
61 assert_true(invocations[1] instanceof w.DOMException,
62 'the super call should have thrown a DOMException');
63 assert_equals(invocations[1].name, 'InvalidStateError',
64 'the exception should be an InvalidStateError');
65 }, 'HTMLElement constructor: poach upgrade candidate');
66 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698