Bug 1449957 [wpt PR 10240] - Check inherited interfaces exist, a=testonly
authorLuke Bjerring <lukebjerring@users.noreply.github.com>
Mon, 09 Apr 2018 18:33:06 +0000
changeset 413639 82a3b68b0a585db261b7bf4ddc8516616a776303
parent 413638 00e7c87b8fb52ca7a87f77d64f848cce84f5cddd
child 413640 febe2a9b5189fcafcddd96ad10f865cea1b48859
push id102161
push userjames@hoppipolla.co.uk
push dateSun, 15 Apr 2018 09:10:16 +0000
treeherdermozilla-inbound@ebfad4be630d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1449957, 10240
milestone61.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 1449957 [wpt PR 10240] - Check inherited interfaces exist, a=testonly Automatic update from web-platform-testsCheck inherited interfaces exist (#10240) * Check inherited interfaces exist * Re-jig IdlHarness error capture + report ordering wpt-commits: 3adbaa2470fc796c189ad98a7363f43df83b42b1 wpt-pr: 10240 wpt-commits: 3adbaa2470fc796c189ad98a7363f43df83b42b1 wpt-pr: 10240
testing/web-platform/tests/resources/idlharness.js
testing/web-platform/tests/resources/test/tests/idlharness/IdlInterface/test_primary_interface_of_undefined.html
--- a/testing/web-platform/tests/resources/idlharness.js
+++ b/testing/web-platform/tests/resources/idlharness.js
@@ -598,29 +598,30 @@ function exposed_in(globals) {
  * @param {string|IdlHarnessError} error Expected Error message.
  * @param {Function} idlArrayFunc Function operating on an IdlArray that should throw.
  */
 IdlArray.prototype.assert_throws = function(error, idlArrayFunc)
 //@{
 {
     try {
         idlArrayFunc.call(this, this);
-        throw new IdlHarnessError(`${idlArrayFunc} did not throw the expected IdlHarnessError`);
     } catch (e) {
         if (e instanceof AssertionError) {
             throw e;
         }
         // Assertions for behaviour of the idlharness.js engine.
         if (error instanceof IdlHarnessError) {
             error = error.message;
         }
         if (e.message !== error) {
-            throw new IdlHarnessError(`${idlArrayFunc} threw ${e}, not the expected IdlHarnessError`);
+            throw new IdlHarnessError(`${idlArrayFunc} threw "${e}", not the expected IdlHarnessError "${error}"`);
         }
+        return;
     }
+    throw new IdlHarnessError(`${idlArrayFunc} did not throw the expected IdlHarnessError`);
 }
 
 //@}
 IdlArray.prototype.test = function()
 //@{
 {
     /** Entry point.  See documentation at beginning of file. */
 
@@ -677,16 +678,26 @@ IdlArray.prototype.test = function()
             this.members[rhs].members.forEach(function(member)
             {
                 this.members[lhs].members.push(new IdlInterfaceMember(member));
             }.bind(this));
         }.bind(this));
     }
     this["includes"] = {};
 
+    // Assert B defined for A : B
+    for (var member of Object.values(this.members).filter(m => m.base)) {
+        let lhs = member.name;
+        let rhs = member.base;
+        if (!(lhs in this.members)) throw new IdlHarnessError(`${lhs} inherits ${rhs}, but ${lhs} is undefined.`);
+        if (!(this.members[lhs] instanceof IdlInterface)) throw new IdlHarnessError(`${lhs} inherits ${rhs}, but ${lhs} is not an interface.`);
+        if (!(rhs in this.members)) throw new IdlHarnessError(`${lhs} inherits ${rhs}, but ${rhs} is undefined.`);
+        if (!(this.members[rhs] instanceof IdlInterface)) throw new IdlHarnessError(`${lhs} inherits ${rhs}, but ${rhs} is not an interface.`);
+    }
+
     Object.getOwnPropertyNames(this.members).forEach(function(memberName) {
         var member = this.members[memberName];
         if (!(member instanceof IdlInterface)) {
             return;
         }
 
         var globals = exposure_set(member, ["Window"]);
         member.exposed = exposed_in(globals);
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resources/test/tests/idlharness/IdlInterface/test_primary_interface_of_undefined.html
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML>
+<html>
+
+<head>
+  <title>idlharness test_primary_interface_of_undefined</title>
+</head>
+
+<body>
+  <script src="/resources/testharness.js"></script>
+  <script src="/resources/WebIDLParser.js"></script>
+  <script src="/resources/idlharness.js"></script>
+  <script>
+    'use strict';
+
+    test(function () {
+      let i = new IdlArray();
+      i.add_untested_idls('interface A : B {};');
+      i.assert_throws(new IdlHarnessError('A inherits B, but B is undefined.'), i => i.test());
+    }, 'A : B with B undeclared should throw IdlHarnessError');
+  </script>
+</body>
+
+</html>