Skip to content

Commit

Permalink
Bug 1705011 [wpt PR 28465] - [Element Reflection] Null vs Empty-list …
Browse files Browse the repository at this point in the history
…differentiation., a=testonly

Automatic update from web-platform-tests
[Element Reflection] Null vs Empty-list differentiation.

If the content-attribute is not present, then we return null.

If the content attribute is present, and there are no explicitly set
attr-elements, and the content attribute doesn't yield any valid
elements, then we return an empty array.

This makes the interface more consistent, as a caller could already
to the attribute to null to clear.

This brings the implementation in-line with the update here
whatwg/html#3917 (comment)

This also updates/clarifies code comments and adds descriptive strings
to existing tests.

This is a subset of the work Alice did for https://crrev.com/c/2796854

Change-Id: I3dcc8492fdb5467f82468bbc3d4b7e4a87c5d48e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2825017
Reviewed-by: Alice Boxhall <aboxhall@chromium.org>
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Chris Hall <chrishall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#872329}

--

wpt-commits: 82660010e10bbed4d383c2f040cdf3a12274fe9c
wpt-pr: 28465
  • Loading branch information
Chris Hall authored and moz-wptsync-bot committed Apr 23, 2021
1 parent 247fbe0 commit 3cbe5aa
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
<script>

test(function(t) {
assert_equals(passwordField.ariaDetailsElements, null);
assert_array_equals(passwordField.ariaDetailsElements, []);
passwordField.ariaDetailsElements = [ listItem1 ];
assert_equals(passwordField.getAttribute("aria-details"), "listItem1");

Expand Down Expand Up @@ -341,7 +341,7 @@
test(function(t) {
const billingElement = document.getElementById("billingElement")
assert_array_equals(input1.ariaLabelledByElements, [billingElement, nameElement], "parsed content attribute sets element references.");
assert_equals(input2.ariaLabelledByElements, null, "Testing empty content attribute after parsing.");
assert_equals(input2.ariaLabelledByElements, null, "Testing missing content attribute after parsing.");

input2.ariaLabelledByElements = [billingElement, addressElement];
assert_array_equals(input2.ariaLabelledByElements, [billingElement, addressElement], "Testing IDL setter/getter.");
Expand All @@ -351,12 +351,12 @@
// As it was explicitly set the underlying association will remain intact,
// but it will be hidden until the element is moved back into a valid scope.
billingElement.remove();
assert_array_equals(input2.ariaLabelledByElements, [addressElement]);
assert_array_equals(input2.ariaLabelledByElements, [addressElement], "Computed ariaLabelledByElements shouldn't include billing when out of scope.");

// Insert the billingElement back into the DOM and check that it is visible
// again, as the underlying association should have been kept intact.
billingElementContainer.appendChild(billingElement);
assert_array_equals(input2.ariaLabelledByElements, [billingElement, addressElement]);
assert_array_equals(input2.ariaLabelledByElements, [billingElement, addressElement], "Billing element back in scope.");

input2.ariaLabelledByElements = [];
assert_array_equals(input2.ariaLabelledByElements, [], "Testing IDL setter/getter for empty array.");
Expand All @@ -366,7 +366,8 @@
assert_equals(input1.ariaLabelledByElements, null);

input1.setAttribute("aria-labelledby", "nameElement addressElement");
assert_array_equals(input1.ariaLabelledByElements, [nameElement, addressElement]);
assert_array_equals(input1.ariaLabelledByElements, [nameElement, addressElement],
"computed value after setting attribute directly");

input1.ariaLabelledByElements = null;
assert_false(input1.hasAttribute("aria-labelledby", "Nullifying the IDL attribute should remove the content attribute."));
Expand Down Expand Up @@ -516,7 +517,7 @@ <h2 id="lightDomHeading" aria-flowto="shadowChild1 shadowChild2">Light DOM Headi

// The elements in the content attribute are in a "darker" tree - they
// enter a shadow encapsulation boundary, so not be associated any more.
assert_equals(lightDomHeading.ariaFlowToElements, null);
assert_array_equals(lightDomHeading.ariaFlowToElements, []);

// These elements are in a shadow including ancestor, i.e "lighter" tree.
// Valid for the IDL attribute, but content attribute should be null.
Expand All @@ -526,7 +527,7 @@ <h2 id="lightDomHeading" aria-flowto="shadowChild1 shadowChild2">Light DOM Headi
// These IDs belong to a different scope, so the attr-associated-element
// cannot be computed.
shadowChild2.setAttribute("aria-flowto", "lightDomText1 lightDomText2");
assert_equals(shadowChild2.ariaFlowToElements, null);
assert_array_equals(shadowChild2.ariaFlowToElements, []);

// Elements that cross into shadow DOM are dropped, only reflect the valid
// elements in IDL and in the content attribute.
Expand Down Expand Up @@ -661,8 +662,6 @@ <h2 id="lightDomHeading" aria-flowto="shadowChild1 shadowChild2">Light DOM Headi
input.ariaActiveDescendantElement = first;
first.parentElement.appendChild(first);

// This behaviour is currently under discussion by WHATWG.
// See: https://github.com/whatwg/html/pull/3917#issuecomment-527263562
assert_equals(input.ariaActiveDescendantElement, first);
}, "Reparenting.");
</script>
Expand Down

0 comments on commit 3cbe5aa

Please sign in to comment.