Bug 1593889 [wpt PR 20080] - [AOM] Remove validation upon getting element refs, a=testonly
authorMeredith Lane <meredithl@chromium.org>
Mon, 25 Nov 2019 17:41:23 +0000
changeset 504468 887502d04d1cb7e8ce0d631c1089ca18b9cc546c
parent 504467 d4a9e1a5fe4cb94c2522c1c82c6c485c1ec724f7
child 504469 6d6466cca7f789609489f7ec7c24ce767e51d27c
push id101897
push userwptsync@mozilla.com
push dateFri, 29 Nov 2019 11:10:32 +0000
treeherderautoland@47be1b3fdda6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1593889, 20080, 981423, 1898889, 714126
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1593889 [wpt PR 20080] - [AOM] Remove validation upon getting element refs, a=testonly Automatic update from web-platform-tests [AOM] Remove validation upon getting element refs In order to comply with the current version of the spec, elements are no longer validated on retrieval or getting. This means that explicitly set elements are still able to be the attr-associated-element, even if they have been moved into an invalid scope, such as a deeper shadow root, or a different tree scope or removed entirely. This is likely to change in future, but as the spec is still being actively discussed it is better to comply with the current version. BUG=981423 Change-Id: I496c06cfad5f056c49dedb3e9821781c755538b5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898889 Reviewed-by: Kent Tamura <tkent@chromium.org> Reviewed-by: Alice Boxhall <aboxhall@chromium.org> Commit-Queue: Meredith Lane <meredithl@chromium.org> Cr-Commit-Position: refs/heads/master@{#714126} -- wpt-commits: 7cef27a0411cc87dccf0165c7e868e4008143daa wpt-pr: 20080
testing/web-platform/tests/dom/nodes/aria-element-reflection.tentative.html
--- a/testing/web-platform/tests/dom/nodes/aria-element-reflection.tentative.html
+++ b/testing/web-platform/tests/dom/nodes/aria-element-reflection.tentative.html
@@ -159,30 +159,37 @@
   <div id="deletionParent" role="listbox" aria-activedescendant="contentAttrElement">
     <div role="option" id="contentAttrElement">Item 1</div>
     <div role="option" id="idlAttrElement">Item 2</div>
   </div>
 
   <script>
 
   test(function(t) {
-    // Deleting an element set via the content attribute.
+    const idlAttrElement = document.getElementById("idlAttrElement");
+
     assert_equals(deletionParent.getAttribute("aria-activedescendant"), "contentAttrElement");
     assert_equals(deletionParent.ariaActiveDescendantElement, contentAttrElement);
 
+    // Deleting an element set via the content attribute.
     deletionParent.removeChild(contentAttrElement);
     assert_equals(deletionParent.getAttribute("aria-activedescendant"), "contentAttrElement");
+
+    // As it was not explitly set, the attr-associated-element is computed from the content attribute,
+    // and since descendant1 has been removed from the DOM, it is not valid.
     assert_equals(deletionParent.ariaActiveDescendantElement, null);
 
     // Deleting an element set via the IDL attribute.
     deletionParent.ariaActiveDescendantElement = idlAttrElement;
     assert_equals(deletionParent.getAttribute("aria-activedescendant"), "idlAttrElement");
 
+    // The element is still retrieved because it was explicitly set, and was at that point
+    // in a valid scope.
     deletionParent.removeChild(idlAttrElement);
-    assert_equals(deletionParent.ariaActiveDescendantElement, null);
+    assert_equals(deletionParent.ariaActiveDescendantElement, idlAttrElement);
 
     // The content attribute will still reflect the id.
     assert_equals(deletionParent.getAttribute("aria-activedescendant"), "idlAttrElement");
   }, "Deleting a reflected element should return null for the IDL attribute and cause the content attribute to become stale.");
   </script>
 
   <div id="parentNode" role="listbox" aria-activedescendant="changingIdElement">
     <div role="option" id="changingIdElement">Item 1</div>
@@ -222,48 +229,53 @@
   <script>
   test(function(t) {
     const lightElement = document.getElementById("lightElement");
     const shadowRoot = shadowHostElement.attachShadow({mode: "open"});
 
     lightParent.ariaActiveDescendantElement = lightElement;
     assert_equals(lightParent.ariaActiveDescendantElement, lightElement);
 
-    // Move the referenced element into shadow DOM.
+    // Move the referenced element into shadow DOM. As it was explicitly set,
+    // it is still able to be gotten even though it is in a different scope.
     shadowRoot.appendChild(lightElement);
-    assert_equals(lightParent.ariaActiveDescendantElement, null);
+    assert_equals(lightParent.ariaActiveDescendantElement, lightElement);
     assert_equals(lightParent.getAttribute("aria-activedescendant"), "lightElement");
 
     // Move the referenced element back into light DOM.
     lightParent.appendChild(lightElement);
     assert_equals(lightParent.ariaActiveDescendantElement, lightElement);
+    assert_equals(lightParent.getAttribute("aria-activedescendant"), "lightElement");
   }, "Reparenting an element into a descendant shadow scope nullifies the element reference.");
   </script>
 
   <div id="billingElement">Billing</div>
   <div>
       <div id="nameElement">Name</div>
       <input type="text" id="input1" aria-labelledby="billingElement nameElement"/>
   </div>
   <div>
       <div id="addressElement">Address</div>
       <input type="text" id="input2"/>
   </div>
 
   <script>
   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.");
 
     input2.ariaLabelledByElements = [billingElement, addressElement];
     assert_array_equals(input2.ariaLabelledByElements, [billingElement, addressElement], "Testing IDL setter/getter.");
     assert_equals(input2.getAttribute("aria-labelledby"), "billingElement addressElement");
 
+    // Remove the element from the DOM, but as it was explicitly set whilst in a valid scope
+    // it can still be retrieved.
     billingElement.remove();
-    assert_array_equals(input2.ariaLabelledByElements, [addressElement]);
+    assert_array_equals(input2.ariaLabelledByElements, [billingElement, addressElement]);
 
     input2.ariaLabelledByElements = [];
     assert_array_equals(input2.ariaLabelledByElements, [], "Testing IDL setter/getter for empty array.");
     assert_equals(input2.getAttribute("aria-labelledby"), "");
 
     input1.removeAttribute("aria-labelledby");
     assert_equals(input1.ariaLabelledByElements, null);
   }, "aria-labelledby.");
@@ -446,19 +458,19 @@
     // The content attr still reflects the ids from the explicit elements because they were in a valid scope at the time of setting.
     assert_array_equals(describedElement.ariaDescribedByElements, [description1, description2]);
     assert_equals(describedElement.getAttribute("aria-describedby"), "buttonDescription1 buttonDescription2");
 
     // Move the explicitly set elements into a deeper shadow DOM to test the relationship should not be gettable.
     innerShadowRoot.appendChild(description1);
     innerShadowRoot.appendChild(description2);
 
-    // Explicitly set elements are still present, but are not retrieved.
-    // content attribute is still stale because all elements were in a valid scope when they were set.
-    assert_array_equals(describedElement.ariaDescribedByElements, []);
+    // Explicitly set elements are still retrieved, because they were in a valid scope when they were set.
+    // The content attribute still reflects the ids.
+    assert_array_equals(describedElement.ariaDescribedByElements, [description1, description2]);
     assert_equals(describedElement.getAttribute("aria-describedby"), "buttonDescription1 buttonDescription2");
 
     // Move into the same shadow scope as the explicitly set elements to test that the elements are gettable
     // and reflect the correct IDs onto the content attribute.
     innerShadowRoot.appendChild(describedElement);
     assert_array_equals(describedElement.ariaDescribedByElements, [description1, description2]);
     assert_equals(describedElement.getAttribute("aria-describedby"), "buttonDescription1 buttonDescription2");
   }, "Moving explicitly set elements across shadow DOM boundaries.");
@@ -489,31 +501,30 @@
       sameScopeContainer.appendChild(headingElement);
       assert_array_equals(headingElement.ariaLabelledByElements, [headingLabel1, headingLabel2], "Elements are all in same scope, so gettable.");
       assert_equals(headingElement.getAttribute("aria-labelledby"), "", "Content attribute is empty, as on setting the explicitly set elements they were in a different scope.");
 
       // Reset the association, to update the content attribute.
       headingElement.ariaLabelledByElements = [headingLabel1, headingLabel2];
       assert_equals(headingElement.getAttribute("aria-labelledby"), "headingLabel1 headingLabel2", "Elements are set again, so the content attribute is updated.");
 
-      // Remove the referring element from the DOM, elements are not gettable.
-      // This behaviour is still under discussion.
+      // Remove the referring element from the DOM, elements are gettable.
       headingElement.remove();
-      assert_array_equals(headingElement.ariaLabelledByElements, [], "Element is no longer in the document, so references should not be gettable.");
+      assert_array_equals(headingElement.ariaLabelledByElements, [headingLabel1, headingLabel2], "Element is no longer in the document, but references should be gettable.");
       assert_equals(headingElement.getAttribute("aria-labelledby"), "headingLabel1 headingLabel2");
 
       // Insert it back in.
       sameScopeContainer.appendChild(headingElement);
       assert_array_equals(headingElement.ariaLabelledByElements, [headingLabel1, headingLabel2]);
       assert_equals(headingElement.getAttribute("aria-labelledby"), "headingLabel1 headingLabel2");
 
-      // Remove everything from the DOM, nothing should be gettable.
+      // Remove everything from the DOM, everything is still gettable.
       headingLabel1.remove();
       headingLabel2.remove();
-      assert_array_equals(headingElement.ariaLabelledByElements, []);
+      assert_array_equals(headingElement.ariaLabelledByElements, [headingLabel1, headingLabel2]);
       assert_equals(headingElement.getAttribute("aria-labelledby"), "headingLabel1 headingLabel2");
       assert_equals(document.getElementById("headingLabel1"), null);
       assert_equals(document.getElementById("headingLabel2"), null);
 
       // Reset the association to update the content attribute.
       headingElement.ariaLabelledByElements = [headingLabel1, headingLabel2];
       assert_array_equals(headingElement.ariaLabelledByElements, []);
       assert_equals(headingElement.getAttribute("aria-labelledby"), "");