Skip to content

Commit

Permalink
Resync WPT for custom elements
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=249756

Reviewed by Chris Dumez.

Resync web platform tests for custom elements as of b8cffc4.

* LayoutTests/imported/w3c/web-platform-tests/common/gc.js: Added.
(self.garbageCollect.async if):
(self.garbageCollect.gcRec):
(self.garbageCollect):
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/CustomElementRegistry-constructor-and-callbacks-are-held-strongly.html:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/ElementInternals-accessibility-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-accessibility-expected.txt.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/ElementInternals-accessibility.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-accessibility.html.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-target-element-is-held-strongly.html:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/w3c-import.log:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/AriaMixin-element-attributes-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/AriaMixin-element-attributes.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/AriaMixin-string-attributes-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/AriaMixin-string-attributes.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/w3c-import.log:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/scoped-registry/CustomElementRegistry-constructor.tentative-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/scoped-registry/CustomElementRegistry-constructor.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/scoped-registry/CustomElementRegistry-multi-register.tentative-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/scoped-registry/CustomElementRegistry-multi-register.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/scoped-registry/ShadowRoot-init-registry.tentative-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/scoped-registry/ShadowRoot-init-registry.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/scoped-registry/w3c-import.log: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/w3c-import.log:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/when-defined-reentry-crash.html: Added.

Canonical link: https://commits.webkit.org/258252@main
  • Loading branch information
rniwa committed Dec 22, 2022
1 parent dc5576a commit 8b06b89
Show file tree
Hide file tree
Showing 20 changed files with 458 additions and 9 deletions.
52 changes: 52 additions & 0 deletions LayoutTests/imported/w3c/web-platform-tests/common/gc.js
@@ -0,0 +1,52 @@
/**
* Does a best-effort attempt at invoking garbage collection. Attempts to use
* the standardized `TestUtils.gc()` function, but falls back to other
* environment-specific nonstandard functions, with a final result of just
* creating a lot of garbage (in which case you will get a console warning).
*
* This should generally only be used to attempt to trigger bugs and crashes
* inside tests, i.e. cases where if garbage collection happened, then this
* should not trigger some misbehavior. You cannot rely on garbage collection
* successfully trigger, or that any particular unreachable object will be
* collected.
*
* @returns {Promise<undefined>} A promise you should await to ensure garbage
* collection has had a chance to complete.
*/
self.garbageCollect = async () => {
// https://testutils.spec.whatwg.org/#the-testutils-namespace
if (self.TestUtils?.gc) {
return TestUtils.gc();
}

// Use --expose_gc for V8 (and Node.js)
// to pass this flag at chrome launch use: --js-flags="--expose-gc"
// Exposed in SpiderMonkey shell as well
if (self.gc) {
return self.gc();
}

// Present in some WebKit development environments
if (self.GCController) {
return GCController.collect();
}

console.warn(
'Tests are running without the ability to do manual garbage collection. ' +
'They will still work, but coverage will be suboptimal.');

for (var i = 0; i < 1000; i++) {
gcRec(10);
}

function gcRec(n) {
if (n < 1) {
return {};
}

let temp = { i: "ab" + i + i / 100000 };
temp += "foo";

gcRec(n - 1);
}
};
Expand Up @@ -4,7 +4,7 @@
<link rel="help" href="https://html.spec.whatwg.org/multipage/custom-elements.html#concept-custom-element-definition-lifecycle-callbacks">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/garbage-collect.js"></script>
<script src="/common/gc.js"></script>

<body>
<div id="customElementsRoot"></div>
Expand Down Expand Up @@ -39,13 +39,13 @@
}

promise_test(async t => {
await maybeGarbageCollectAsync();
await garbageCollect();

assert_true(tagNames.every(tagName => typeof customElements.get(tagName) === "function"));
}, "constructor");

promise_test(async t => {
await maybeGarbageCollectAsync();
await garbageCollect();
for (const tagName of tagNames) {
customElementsRoot.append(document.createElement(tagName));
}
Expand All @@ -55,7 +55,7 @@
}, "connectedCallback");

promise_test(async t => {
await maybeGarbageCollectAsync();
await garbageCollect();
for (const xFoo of customElementsRoot.children) {
xFoo.setAttribute("foo", "bar");
}
Expand All @@ -65,15 +65,15 @@
}, "attributeChangedCallback");

promise_test(async t => {
await maybeGarbageCollectAsync();
await garbageCollect();
customElementsRoot.innerHTML = "";

await delay(t, 10);
assert_equals(disconnectedCallbackCalls.size, tagNames.length);
}, "disconnectedCallback");

promise_test(async t => {
await maybeGarbageCollectAsync();
await garbageCollect();
for (const tagName of tagNames) {
emptyIframe.contentDocument.adoptNode(document.createElement(tagName));
}
Expand Down
Expand Up @@ -3,7 +3,7 @@
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/garbage-collect.js"></script>
<script src="/common/gc.js"></script>

<script>
customElements.define("x-foo", class extends HTMLElement {});
Expand All @@ -17,7 +17,7 @@
elementInternals.push(targetElement.attachInternals());
}

await maybeGarbageCollectAsync();
await garbageCollect();
await new Promise(r => t.step_timeout(r, 100));

const allShadowRootsAreAlive = elementInternals.every(eI => eI.shadowRoot instanceof ShadowRoot);
Expand Down
Expand Up @@ -15,13 +15,13 @@ None
------------------------------------------------------------------------
List of files:
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-NotSupportedError.html
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-accessibility.html
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-form.html
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-labels.html
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-reportValidity-bubble-expected.html
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-reportValidity-bubble-ref.html
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-reportValidity-bubble.html
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-setFormValue.html
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-target-element-is-held-strongly.html
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-validation.html
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/fieldset-elements.html
/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/form-associated-callback.html
Expand Down
@@ -0,0 +1,18 @@

PASS ariaActiveDescendantElement in Element must enqueue an attributeChanged reaction when adding aria-activedescendant content attribute
PASS ariaActiveDescendantElement in Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaControlsElements in Element must enqueue an attributeChanged reaction when adding aria-controls content attribute
PASS ariaControlsElements in Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaDescribedByElements in Element must enqueue an attributeChanged reaction when adding aria-describedby content attribute
PASS ariaDescribedByElements in Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaDetailsElements in Element must enqueue an attributeChanged reaction when adding aria-details content attribute
PASS ariaDetailsElements in Element must enqueue an attributeChanged reaction when replacing an existing attribute
FAIL ariaErrorMessageElement in Element must enqueue an attributeChanged reaction when adding aria-errormessage content attribute assert_array_equals: lengths differ, expected array ["attributeChanged"] length 1, got [] length 0
FAIL ariaErrorMessageElement in Element must enqueue an attributeChanged reaction when replacing an existing attribute assert_array_equals: lengths differ, expected array ["constructed", "connected", "attributeChanged"] length 3, got ["constructed", "connected"] length 2
PASS ariaFlowToElements in Element must enqueue an attributeChanged reaction when adding aria-flowto content attribute
PASS ariaFlowToElements in Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaLabelledByElements in Element must enqueue an attributeChanged reaction when adding aria-labelledby content attribute
PASS ariaLabelledByElements in Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaOwnsElements in Element must enqueue an attributeChanged reaction when adding aria-owns content attribute
PASS ariaOwnsElements in Element must enqueue an attributeChanged reaction when replacing an existing attribute

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html>
<head>
<title>Custom Elements: CEReactions on Element interface</title>
<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
<meta name="assert" content="Element attributes of AriaAttributes interface must have CEReactions">
<meta name="help" content="https://dom.spec.whatwg.org/#element">
<meta name="help" content="https://w3c.github.io/DOM-Parsing/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/custom-elements-helpers.js"></script>
<script src="./resources/reactions.js"></script>
</head>
<body>
<div id="log"></div>
<div id="parentElement"></div>
<script>

function testElementReflectAttribute(jsAttributeName, contentAttributeName, validValue1, validValue2, name, getParentElement) {
test(function () {
let element = define_new_custom_element([contentAttributeName]);
let instance = document.createElement(element.name);
assert_array_equals(element.takeLog().types(), ['constructed']);
parentElement.appendChild(instance);
assert_array_equals(element.takeLog().types(), ['connected']);
instance[jsAttributeName] = validValue1;
let logEntries = element.takeLog();
assert_array_equals(logEntries.types(), ['attributeChanged']);

assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: null, newValue: "", namespace: null});
}, name + ' must enqueue an attributeChanged reaction when adding ' + contentAttributeName + ' content attribute');

test(function () {
let element = define_new_custom_element([contentAttributeName]);
let instance = document.createElement(element.name);
parentElement.appendChild(instance);
instance[jsAttributeName] = validValue1;
assert_array_equals(element.takeLog().types(), ['constructed', 'connected', 'attributeChanged']);
instance[jsAttributeName] = validValue2;
var logEntries = element.takeLog();
assert_array_equals(logEntries.types(), ['attributeChanged']);
assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: "", newValue: "", namespace: null});
}, name + ' must enqueue an attributeChanged reaction when replacing an existing attribute');
}

const dummy1 = document.createElement('div');
dummy1.id = 'dummy1';
document.body.appendChild(dummy1);

const dummy2 = document.createElement('div');
dummy2.id = 'dummy2';
document.body.appendChild(dummy2);

testElementReflectAttribute('ariaActiveDescendantElement', 'aria-activedescendant', dummy1, dummy2, 'ariaActiveDescendantElement in Element');
testElementReflectAttribute('ariaControlsElements', 'aria-controls', [dummy1], [dummy2], 'ariaControlsElements in Element');
testElementReflectAttribute('ariaDescribedByElements', 'aria-describedby', [dummy1], [dummy2], 'ariaDescribedByElements in Element');
testElementReflectAttribute('ariaDetailsElements', 'aria-details', [dummy1], [dummy2], 'ariaDetailsElements in Element');
testElementReflectAttribute('ariaErrorMessageElement', 'aria-errormessage', dummy1, dummy2, 'ariaErrorMessageElement in Element');
testElementReflectAttribute('ariaFlowToElements', 'aria-flowto', [dummy1], [dummy2], 'ariaFlowToElements in Element');
testElementReflectAttribute('ariaLabelledByElements', 'aria-labelledby', [dummy1], [dummy2], 'ariaLabelledByElements in Element')
testElementReflectAttribute('ariaOwnsElements', 'aria-owns', [dummy1], [dummy2], 'ariaOwnsElements in Element')

</script>
</body>
</html>
@@ -0,0 +1,78 @@

PASS ariaAtomic on Element must enqueue an attributeChanged reaction when adding aria-atomic content attribute
PASS ariaAtomic on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaAutoComplete on Element must enqueue an attributeChanged reaction when adding aria-autocomplete content attribute
PASS ariaAutoComplete on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaBusy on Element must enqueue an attributeChanged reaction when adding aria-busy content attribute
PASS ariaBusy on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaChecked on Element must enqueue an attributeChanged reaction when adding aria-checked content attribute
PASS ariaChecked on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaColCount on Element must enqueue an attributeChanged reaction when adding aria-colcount content attribute
PASS ariaColCount on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaColIndex on Element must enqueue an attributeChanged reaction when adding aria-colindex content attribute
PASS ariaColIndex on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaColSpan on Element must enqueue an attributeChanged reaction when adding aria-colspan content attribute
PASS ariaColSpan on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaCurrent on Element must enqueue an attributeChanged reaction when adding aria-current content attribute
PASS ariaCurrent on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaDisabled on Element must enqueue an attributeChanged reaction when adding aria-disabled content attribute
PASS ariaDisabled on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaExpanded on Element must enqueue an attributeChanged reaction when adding aria-expanded content attribute
PASS ariaExpanded on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaHasPopup on Element must enqueue an attributeChanged reaction when adding aria-haspopup content attribute
PASS ariaHasPopup on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaHidden on Element must enqueue an attributeChanged reaction when adding aria-hidden content attribute
PASS ariaHidden on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaInvalid on Element must enqueue an attributeChanged reaction when adding aria-invalid content attribute
PASS ariaInvalid on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaKeyShortcuts on Element must enqueue an attributeChanged reaction when adding aria-keyshortcuts content attribute
PASS ariaKeyShortcuts on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaLabel on Element must enqueue an attributeChanged reaction when adding aria-label content attribute
PASS ariaLabel on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaLevel on Element must enqueue an attributeChanged reaction when adding aria-level content attribute
PASS ariaLevel on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaLive on Element must enqueue an attributeChanged reaction when adding aria-live content attribute
PASS ariaLive on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaModal on Element must enqueue an attributeChanged reaction when adding aria-modal content attribute
PASS ariaModal on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaMultiLine on Element must enqueue an attributeChanged reaction when adding aria-multiline content attribute
PASS ariaMultiLine on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaMultiSelectable on Element must enqueue an attributeChanged reaction when adding aria-multiselectable content attribute
PASS ariaMultiSelectable on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaOrientation on Element must enqueue an attributeChanged reaction when adding aria-orientation content attribute
PASS ariaOrientation on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaPlaceholder on Element must enqueue an attributeChanged reaction when adding aria-placeholder content attribute
PASS ariaPlaceholder on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaPosInSet on Element must enqueue an attributeChanged reaction when adding aria-posinset content attribute
PASS ariaPosInSet on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaPressed on Element must enqueue an attributeChanged reaction when adding aria-pressed content attribute
PASS ariaPressed on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaReadOnly on Element must enqueue an attributeChanged reaction when adding aria-readonly content attribute
PASS ariaReadOnly on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaRelevant on Element must enqueue an attributeChanged reaction when adding aria-relevant content attribute
PASS ariaRelevant on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaRequired on Element must enqueue an attributeChanged reaction when adding aria-required content attribute
PASS ariaRequired on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaRoleDescription on Element must enqueue an attributeChanged reaction when adding aria-roledescription content attribute
PASS ariaRoleDescription on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaRowCount on Element must enqueue an attributeChanged reaction when adding aria-rowcount content attribute
PASS ariaRowCount on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaRowIndex on Element must enqueue an attributeChanged reaction when adding aria-rowindex content attribute
PASS ariaRowIndex on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaRowSpan on Element must enqueue an attributeChanged reaction when adding aria-rowspan content attribute
PASS ariaRowSpan on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaSelected on Element must enqueue an attributeChanged reaction when adding aria-selected content attribute
PASS ariaSelected on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaSetSize on Element must enqueue an attributeChanged reaction when adding aria-setsize content attribute
PASS ariaSetSize on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaSort on Element must enqueue an attributeChanged reaction when adding aria-sort content attribute
PASS ariaSort on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaValueMax on Element must enqueue an attributeChanged reaction when adding aria-valuemax content attribute
PASS ariaValueMax on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaValueMin on Element must enqueue an attributeChanged reaction when adding aria-valuemin content attribute
PASS ariaValueMin on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaValueNow on Element must enqueue an attributeChanged reaction when adding aria-valuenow content attribute
PASS ariaValueNow on Element must enqueue an attributeChanged reaction when replacing an existing attribute
PASS ariaValueText on Element must enqueue an attributeChanged reaction when adding aria-valuetext content attribute
PASS ariaValueText on Element must enqueue an attributeChanged reaction when replacing an existing attribute

0 comments on commit 8b06b89

Please sign in to comment.