Bug 1622229 [wpt PR 22236] - Correctly test document.all quirks, a=testonly
authorAryeh Gregor <ayg@aryeh.name>
Sat, 14 Mar 2020 11:29:41 +0000
changeset 518854 65eedd9b56ee16dc1b0f23ad5835cb7805dd2d94
parent 518853 42881b0536f855b7d1c08017dbbc37f120502315
child 518855 1109fcdb0f36a03cfe6d1b650f6bc244f9493dc0
push id37217
push userccoroiu@mozilla.com
push dateSun, 15 Mar 2020 21:37:59 +0000
treeherdermozilla-central@f9fc9427476e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1622229, 22236
milestone76.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 1622229 [wpt PR 22236] - Correctly test document.all quirks, a=testonly Automatic update from web-platform-tests Correctly test document.all quirks For legacy compatibility, this property is specified with some willful violations of JS: <https://html.spec.whatwg.org/#dom-document-all>. Prior to this commit, idlharness wasn't accounting for these, so html/dom/interfaces.html was wrong for document.all/HTMLAllCollection tests. It's a bit ugly to include this directly in idlharness.js and testharness.js, but it's the cleanest solution I can think of. Fixes #4207. -- wpt-commits: 687b92d025e32df7f5217bc06b0e510a39953ef9 wpt-pr: 22236
testing/web-platform/tests/resources/idlharness.js
testing/web-platform/tests/resources/testharness.js
--- a/testing/web-platform/tests/resources/idlharness.js
+++ b/testing/web-platform/tests/resources/idlharness.js
@@ -2741,20 +2741,29 @@ IdlInterface.prototype.test_object = fun
     {
         obj = eval(desc);
     }
     catch(e)
     {
         exception = e;
     }
 
-    var expected_typeof =
-        this.members.some(function(member) { return member.legacycaller; })
-        ? "function"
-        : "object";
+    var expected_typeof;
+    if (this.name == "HTMLAllCollection")
+    {
+        // Willful violation of JS.  :(
+        expected_typeof = "undefined";
+    } else if (this.members.some(function(member) { return member.legacycaller; }))
+    {
+        expected_typeof = "function";
+    }
+    else
+    {
+        expected_typeof = "object";
+    }
 
     this.test_primary_interface_of(desc, obj, exception, expected_typeof);
 
     var current_interface = this;
     while (current_interface)
     {
         if (!(current_interface.name in this.array.members))
         {
@@ -2906,17 +2915,25 @@ IdlInterface.prototype.test_interface_of
                             property = obj[member.name];
                         }
                         catch (e)
                         {
                             thrown = true;
                         }
                         if (!thrown)
                         {
-                            this.array.assert_type_is(property, member.idlType);
+                            if (this.name == "Document" && member.name == "all")
+                            {
+                                // Willful violation of JS :(
+                                assert_equals(typeof property, "undefined");
+                            }
+                            else
+                            {
+                                this.array.assert_type_is(property, member.idlType);
+                            }
                         }
                     }
                     if (member.type == "operation")
                     {
                         assert_equals(typeof obj[member.name], "function");
                     }
                 }
             }.bind(this), this.name + " interface: " + desc + ' must inherit property "' + member + '" with the proper type');
--- a/testing/web-platform/tests/resources/testharness.js
+++ b/testing/web-platform/tests/resources/testharness.js
@@ -1478,17 +1478,19 @@ policies and contribution forms [3].
                "assert_not_own_property", description,
                "unexpected property ${p} is found on object", {p:property_name});
     }
     expose(assert_not_own_property, "assert_not_own_property");
 
     function _assert_inherits(name) {
         return function (object, property_name, description)
         {
-            assert(typeof object === "object" || typeof object === "function",
+            assert(typeof object === "object" || typeof object === "function" ||
+                   // Willful violation of JS.  :(
+                   String(object) === "[object HTMLAllCollection]",
                    name, description,
                    "provided value is not an object");
 
             assert("hasOwnProperty" in object,
                    name, description,
                    "provided value is an object but has no hasOwnProperty method");
 
             assert(!object.hasOwnProperty(property_name),