Bug 1477746 [wpt PR 12144] - [idlharness.js] Assert correct type for original definition of partials, a=testonly
authorLuke Bjerring <lukebjerring@google.com>
Wed, 25 Jul 2018 21:14:46 +0000
changeset 824164 ba1119cfa1c8e06a7c57721c49774b861da57277
parent 824163 5936562ddc8038065b5f166b68c817e774f12bb8
child 824165 d07bf928e22d591daebaf304183f0020a0bc1b7e
push id117837
push userbmo:aryx.bugmail@gmx-topmail.de
push dateMon, 30 Jul 2018 09:42:15 +0000
reviewerstestonly
bugs1477746, 12144
milestone63.0a1
Bug 1477746 [wpt PR 12144] - [idlharness.js] Assert correct type for original definition of partials, a=testonly Automatic update from web-platform-testsAssert correct type for original definition -- wpt-commits: d8567389060ff683dbff2abff560a3fcbeebc064 wpt-pr: 12144
testing/web-platform/tests/resources/idlharness.js
testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlDictionary/test_partial_interface_of.html
testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_partial_interface_of.html
testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_partial_namespace.html
--- a/testing/web-platform/tests/resources/idlharness.js
+++ b/testing/web-platform/tests/resources/idlharness.js
@@ -865,16 +865,26 @@ IdlArray.prototype.collapse_partials = f
             if (testedPartials.has(parsed_idl.name)) {
                 partialTestCount += testedPartials.get(parsed_idl.name);
                 partialTestName = `${partialTestName}[${partialTestCount}]`;
             }
             testedPartials.set(parsed_idl.name, partialTestCount);
 
             test(function () {
                 assert_true(originalExists, `Original ${parsed_idl.type} should be defined`);
+
+                var expected = IdlInterface;
+                switch (parsed_idl.type) {
+                    case 'interface': expected = IdlInterface; break;
+                    case 'dictionary': expected = IdlDictionary; break;
+                    case 'namespace': expected = IdlNamespace; break;
+                }
+                assert_true(
+                    expected.prototype.isPrototypeOf(this.members[parsed_idl.name]),
+                    `Original ${parsed_idl.name} definition should have type ${parsed_idl.type}`);
             }.bind(this), `Partial ${parsed_idl.type} ${partialTestName}: original ${parsed_idl.type} defined`);
         }
         if (!originalExists) {
             // Not good.. but keep calm and carry on.
             return;
         }
 
         if (parsed_idl.extAttrs)
--- a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlDictionary/test_partial_interface_of.html
+++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlDictionary/test_partial_interface_of.html
@@ -30,16 +30,25 @@
       const idlArray = new IdlArray();
       idlArray.add_untested_idls('partial dictionary B {};');
       idlArray.add_idls('partial dictionary B {};');
       idlArray.add_idls('partial dictionary B {};');
       idlArray.add_idls('partial dictionary B {};');
       idlArray.add_idls('dictionary B {};');
       idlArray.test();
     })();
+
+    // Original is a namespace, not a dictionary.
+    (() => {
+      const idlArray = new IdlArray();
+      idlArray.add_idls(`
+        partial dictionary C {};
+        namespace C {};`);
+      idlArray.collapse_partials();
+    })();
   </script>
   <script type="text/json" id="expected">
 {
   "summarized_status": {
     "status_string": "OK",
     "message": null
   },
   "summarized_tests": [
@@ -61,16 +70,22 @@
       "properties": {},
       "message": null
     },
     {
       "name": "Partial dictionary B[3]: original dictionary defined",
       "status_string": "PASS",
       "properties": {},
       "message": null
+    },
+    {
+      "name": "Partial dictionary C: original dictionary defined",
+      "status_string": "FAIL",
+      "properties": {},
+      "message": "assert_true: Original C definition should have type dictionary expected true got false"
     }
   ],
   "type": "complete"
 }
 </script>
 </body>
 
 </html>
--- a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_partial_interface_of.html
+++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_partial_interface_of.html
@@ -49,16 +49,25 @@
       idlArray.add_untested_idls(`
         [Exposed=(Window, ServiceWorker)]
         interface D {};`);
       idlArray.add_idls(`
         [Exposed=(DedicatedWorker)]
         partial interface D {};`);
       idlArray.collapse_partials();
     })();
+
+    // Original is a namespace, not an interface.
+    (() => {
+      const idlArray = new IdlArray();
+      idlArray.add_idls(`
+        partial interface E {};
+        namespace E {};`);
+      idlArray.collapse_partials();
+    })();
   </script>
   <script type="text/json" id="expected">
 {
   "summarized_status": {
     "status_string": "OK",
     "message": null
   },
   "summarized_tests": [
@@ -98,16 +107,22 @@
       "properties": {},
       "message": null
     },
     {
       "name": "Partial interface D: valid exposure set",
       "status_string": "FAIL",
       "properties": {},
       "message": "Partial D interface is exposed to 'DedicatedWorker', the original interface is not."
+    },
+    {
+      "name": "Partial interface E: original interface defined",
+      "status_string": "FAIL",
+      "properties": {},
+      "message": "assert_true: Original E definition should have type interface expected true got false"
     }
   ],
   "type": "complete"
 }
 </script>
 </body>
 
 </html>
--- a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_partial_namespace.html
+++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_partial_namespace.html
@@ -49,16 +49,25 @@
       idlArray.add_untested_idls(`
         [Exposed=(Window, ServiceWorker)]
         namespace D {};`);
       idlArray.add_idls(`
         [Exposed=(DedicatedWorker)]
         partial namespace D {};`);
       idlArray.collapse_partials();
     })();
+
+    // Original is an interface, not a namespace.
+    (() => {
+      const idlArray = new IdlArray();
+      idlArray.add_idls(`
+        partial namespace E {};
+        interface E {};`);
+      idlArray.collapse_partials();
+    })();
   </script>
   <script type="text/json" id="expected">
 {
   "summarized_status": {
     "status_string": "OK",
     "message": null
   },
   "summarized_tests": [
@@ -98,16 +107,22 @@
       "properties": {},
       "message": null
     },
     {
       "name": "Partial namespace D: valid exposure set",
       "status_string": "FAIL",
       "properties": {},
       "message": "Partial D namespace is exposed to 'DedicatedWorker', the original namespace is not."
+    },
+    {
+      "name": "Partial namespace E: original namespace defined",
+      "status_string": "FAIL",
+      "properties": {},
+      "message": "assert_true: Original E definition should have type namespace expected true got false"
     }
   ],
   "type": "complete"
 }
 </script>
 </body>
 
 </html>