Bug 1449717 [wpt PR 10159] - Support partial dictionaries, a=testonly
authorLuke Bjerring <lukebjerring@users.noreply.github.com>
Mon, 09 Apr 2018 18:26:30 +0000
changeset 413624 f33779c9c5725285f27d1a3c4ce565b4392b1768
parent 413623 c5d8e8a1bde77ee37963d564ed1b880799a827ff
child 413625 eda85938b492be300093ab3c1dbe98fde78d2bfc
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
bugs1449717, 10159
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 1449717 [wpt PR 10159] - Support partial dictionaries, a=testonly Automatic update from web-platform-testsSupport partial dictionaries (#10159) * Support partial dictionaries wpt-commits: bc7c640b39c4a9ba70e916f44271ea8edab6014e wpt-pr: 10159 wpt-commits: bc7c640b39c4a9ba70e916f44271ea8edab6014e wpt-pr: 10159
testing/web-platform/tests/resources/idlharness.js
testing/web-platform/tests/resources/test/conftest.py
testing/web-platform/tests/resources/test/tests/idlharness/IdlDictionary/test_partial_dictionary.html
testing/web-platform/tests/resources/test/tests/idlharness/basic.html
--- a/testing/web-platform/tests/resources/idlharness.js
+++ b/testing/web-platform/tests/resources/idlharness.js
@@ -252,17 +252,17 @@ IdlArray.prototype.internal_add_idls = f
         {
             return true;
         }
         return false;
     }
 
     parsed_idls.forEach(function(parsed_idl)
     {
-        if (parsed_idl.type == "interface" && parsed_idl.partial)
+        if (parsed_idl.partial && ["interface", "dictionary"].includes(parsed_idl.type))
         {
             if (should_skip(parsed_idl.name))
             {
                 return;
             }
             this.partials.push(parsed_idl);
             return;
         }
@@ -624,19 +624,20 @@ IdlArray.prototype.test = function()
 {
     /** Entry point.  See documentation at beginning of file. */
 
     // First merge in all the partial interfaces and implements statements we
     // encountered.
     this.partials.forEach(function(parsed_idl)
     {
         if (!(parsed_idl.name in this.members)
-        || !(this.members[parsed_idl.name] instanceof IdlInterface))
+            || !(this.members[parsed_idl.name] instanceof IdlInterface
+                 || this.members[parsed_idl.name] instanceof IdlDictionary))
         {
-            throw new IdlHarnessError("Partial interface " + parsed_idl.name + " with no original interface");
+            throw new IdlHarnessError(`Partial ${parsed_idl.type} ${parsed_idl.name} with no original ${parsed_idl.type}`);
         }
         if (parsed_idl.extAttrs)
         {
             parsed_idl.extAttrs.forEach(function(extAttr)
             {
                 this.members[parsed_idl.name].extAttrs.push(extAttr);
             }.bind(this));
         }
--- a/testing/web-platform/tests/resources/test/conftest.py
+++ b/testing/web-platform/tests/resources/test/conftest.py
@@ -82,17 +82,18 @@ class HTMLItem(pytest.Item, pytest.Colle
             for test in summarized[u'summarized_tests']:
                 msg = "%s\n%s:\n%s" % (test[u'name'], test[u'message'], test[u'stack'])
                 assert test[u'status_string'] == u'PASS', msg
         else:
             assert summarized == self.expected
 
     @staticmethod
     def _assert_sequence(nums):
-        assert nums == range(1, nums[-1] + 1)
+        if nums and len(nums) > 0:
+            assert nums == range(1, nums[-1] + 1)
 
     @staticmethod
     def _scrub_stack(test_obj):
         copy = dict(test_obj)
 
         assert 'stack' in copy
 
         if copy['stack'] is not None:
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/resources/test/tests/idlharness/IdlDictionary/test_partial_dictionary.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html>
+
+<head>
+  <meta charset="utf-8">
+  <title>idlharness: partial dictionaries</title>
+  <script src="/resources/testharness.js"></script>
+  <script src="/resources/testharnessreport.js"></script>
+  <script src="/resources/WebIDLParser.js"></script>
+  <script src="/resources/idlharness.js"></script>
+  <script src="../helper.js"></script>
+</head>
+
+<body>
+<pre id='idl'>
+dictionary A {};
+partial dictionary A {
+  boolean B;
+};
+partial dictionary A {
+  boolean C;
+};
+</pre>
+
+<script>
+'use strict';
+
+test(() => {
+  let idlArray = new IdlArray();
+  idlArray.add_idls(document.getElementById('idl').textContent);
+  idlArray.test();
+
+  let members = idlArray.members["A"].members.map(m => m.name);
+  assert_array_equals(members, ["B", "C"], 'A should contain B, C');
+}, 'Partial dictionaries');
+
+test(() => {
+  let idlArray = new IdlArray();
+  idlArray.add_idls('partial dictionary D {};');
+  idlArray.assert_throws('Partial dictionary D with no original dictionary', i => i.test());
+}, 'Partial-only dictionary definition')
+</script>
+
+</body>
+</html>
--- a/testing/web-platform/tests/resources/test/tests/idlharness/basic.html
+++ b/testing/web-platform/tests/resources/test/tests/idlharness/basic.html
@@ -24,31 +24,33 @@
         assert_equals(typeof WebIDL2.parse, "function");
     }, 'WebIDL2 namespace should have a parse method');
     test(function() {
         assert_throws(new TypeError(), function() {  WebIDL2.parse("I'm a syntax error"); });
     }, 'WebIDL2 parse method should bail on incorrect WebIDL');
     test(function() {
         assert_equals(typeof WebIDL2.parse("interface Foo {};"), "object");
     }, 'WebIDL2 parse method should produce an AST for correct WebIDL');
-    test(function() {
-        let i = new IdlArray();
-        i.add_untested_idls('partial interface A {};');
-        i.assert_throws( new IdlHarnessError("Partial interface A with no original interface"), i.test);
-    }, 'assert_throws should handle IdlHarnessError');
-    test(function() {
-        let i = new IdlArray();
-        i.add_untested_idls('partial interface A {};');
-        i.assert_throws( "Partial interface A with no original interface", i.test);
-    }, 'assert_throws should handle IdlHarnessError from message');
-    test(function () {
-        try {
+    for (let type of ['dictionary', 'interface']) {
+        test(function() {
+            let i = new IdlArray();
+            i.add_untested_idls(`partial ${type} A {};`);
+            i.assert_throws(new IdlHarnessError(`Partial ${type} A with no original ${type}`), i => i.test());
+        }, `assert_throws should handle ${type} IdlHarnessError`);
+        test(function() {
             let i = new IdlArray();
-            i.add_untested_idls('interface A {};');
-            i.assert_throws( "Partial interface A with no original interface", i.test);
-        } catch (e) {
-            assert_true(e instanceof IdlHarnessError);
-        }
-    }, 'assert_throws should throw if no IdlHarnessError thrown');
+            i.add_untested_idls(`partial ${type} A {};`);
+            i.assert_throws(`Partial ${type} A with no original ${type}`, i => i.test());
+        }, `assert_throws should handle ${type} IdlHarnessError from message`);
+        test(function () {
+            try {
+                let i = new IdlArray();
+                i.add_untested_idls(`${type} A {};`);
+                i.assert_throws(`Partial ${type} A with no original ${type}`, i => i.test());
+            } catch (e) {
+                assert_true(e instanceof IdlHarnessError);
+            }
+        }, `assert_throws should throw if no ${type} IdlHarnessError thrown`);
+    }
 </script>
 </body>
 </html>