Skip to content

Commit

Permalink
Bug 1667446 [wpt PR 25794] - Add testing of :defined prior to call to…
Browse files Browse the repository at this point in the history
… super(), a=testonly

Automatic update from web-platform-tests
Add testing of :defined prior to call to super()

Per the conversation here [1], there is a desire to add more
testing of the :defined pseudo state, prior to the call to super().
Note that `this` is not accessible prior to super(), so the
instance itself is used. Also note that :defined already does not
match anywhere inside the constructor, for upgrades.

[1] whatwg/dom#894 (comment)

Bug: 1042130
Change-Id: I2372900981247ea5624e737d2597d004398de477
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2431558
Auto-Submit: Mason Freed <[email protected]>
Commit-Queue: Kouhei Ueno <[email protected]>
Reviewed-by: Kouhei Ueno <[email protected]>
Cr-Commit-Position: refs/heads/master@{#810991}

--

wpt-commits: 0e252e7d3d8f95725f6ae177148da85eac333ca2
wpt-pr: 25794
  • Loading branch information
mfreed7 authored and moz-wptsync-bot committed Oct 2, 2020
1 parent 6391eed commit 6ecc95c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,17 @@
var log = [];
var instance = document.createElement('my-custom-element-2');
document.body.appendChild(instance);
assert_false(instance.matches(":defined"), "Prior to definition, instance should not match :defined");
customElements.define('my-custom-element-2',class extends HTMLElement {
constructor() {
assert_false(instance.matches(":defined"), "During construction, prior to super(), instance should not match :defined");
super();
log.push([this, 'begin']);
assert_false(this.matches(":defined"), "During construction, this should not match :defined");
assert_false(this.matches(":defined"), "During construction, after super(), this should not match :defined");
log.push([this, 'end']);
}
});
assert_true(instance.matches(":defined"), "After construction, instance should match :defined");
assert_equals(log.length, 2);
assert_array_equals(log[0], [instance, 'begin']);
assert_array_equals(log[1], [instance, 'end']);
Expand Down

0 comments on commit 6ecc95c

Please sign in to comment.