diff options
author | Josh Matthews <josh@joshmatthews.net> | 2020-07-09 20:03:03 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2020-07-09 23:22:48 -0400 |
commit | 63528f6fdf192542cd811a2a3ef5f0cb2fecbc6b (patch) | |
tree | c5f8b49b5c754cf7c08467ace15e11c1ec4c64c4 | |
parent | aa80f9139909b451d434093e0ef38266f56bda3e (diff) | |
download | servo-63528f6fdf192542cd811a2a3ef5f0cb2fecbc6b.tar.gz servo-63528f6fdf192542cd811a2a3ef5f0cb2fecbc6b.zip |
dom: Generate iterator symbol for interfaces with indexed getters.
5 files changed, 65 insertions, 5 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index c80fec57b5b..4d1a3972d7b 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -1672,8 +1672,27 @@ class MethodDefiner(PropertyDefiner): "condition": PropertyDefiner.getControllingCondition(m, descriptor)} for m in methods] - # FIXME Check for an existing iterator on the interface first. - if any(m.isGetter() and m.isIndexed() for m in methods): + # TODO: Once iterable is implemented, use tiebreak rules instead of + # failing. Also, may be more tiebreak rules to implement once spec bug + # is resolved. + # https://www.w3.org/Bugs/Public/show_bug.cgi?id=28592 + def hasIterator(methods, regular): + return (any("@@iterator" in m.aliases for m in methods) + or any("@@iterator" == r["name"] for r in regular)) + + # Check whether we need to output an @@iterator due to having an indexed + # getter. We only do this while outputting non-static and + # non-unforgeable methods, since the @@iterator function will be + # neither. + if (not static + and not unforgeable + and descriptor.supportsIndexedProperties()): # noqa + if hasIterator(methods, self.regular): # noqa + raise TypeError("Cannot have indexed getter/attr on " + "interface %s with other members " + "that generate @@iterator, such as " + "maplike/setlike or aliased functions." % + self.descriptor.interface.identifier.name) self.regular.append({"name": '@@iterator', "methodInfo": False, "selfHostedName": "$ArrayValues", diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py index 98fce57afe4..4f47a737706 100644 --- a/components/script/dom/bindings/codegen/Configuration.py +++ b/components/script/dom/bindings/codegen/Configuration.py @@ -401,6 +401,9 @@ class Descriptor(DescriptorProvider): parent = parent.parent return None + def supportsIndexedProperties(self): + return self.operations['IndexedGetter'] is not None + def hasDescendants(self): return (self.interface.getUserData("hasConcreteDescendant", False) or self.interface.getUserData("hasProxyDescendant", False)) diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 3b6a51280eb..eefb5e32cbb 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -528290,6 +528290,13 @@ {} ] ], + "xrInputSourceArray_iterable.html": [ + "de784d5d1a60fc15c0bea92e65a8a2a3ef0acf97", + [ + null, + {} + ] + ], "xrInputSource_add_remove.https.html": [ "7764017910d2e5ada78febe954e9543aca89226b", [ diff --git a/tests/wpt/metadata/webxr/idlharness.https.window.js.ini b/tests/wpt/metadata/webxr/idlharness.https.window.js.ini index e3306e70483..741b29951e1 100644 --- a/tests/wpt/metadata/webxr/idlharness.https.window.js.ini +++ b/tests/wpt/metadata/webxr/idlharness.https.window.js.ini @@ -2,9 +2,6 @@ [XR interface: attribute ondevicechange] expected: FAIL - [XRInputSourceArray interface: iterable<XRInputSource>] - expected: FAIL - [XR interface: calling supportsSession(XRSessionMode) on navigator.xr with too few arguments must throw TypeError] expected: FAIL diff --git a/tests/wpt/web-platform-tests/webxr/xrInputSourceArray_iterable.html b/tests/wpt/web-platform-tests/webxr/xrInputSourceArray_iterable.html new file mode 100644 index 00000000000..de784d5d1a6 --- /dev/null +++ b/tests/wpt/web-platform-tests/webxr/xrInputSourceArray_iterable.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/webxr_util.js"></script> +<script src="resources/webxr_test_constants.js"></script> +<canvas id="webgl-canvas"></canvas> +<script> +let testName = "XRInputSourceArray is iterable"; +let testFunction = function(session, fakeDeviceController, t) { + return new Promise((resolve) => { + let input_source = fakeDeviceController.simulateInputSourceConnection({ + handedness: "right", + targetRayMode: "tracked-pointer", + pointerOrigin: VALID_POINTER_TRANSFORM, + gripOrigin: VALID_GRIP_TRANSFORM, + profiles: ["foo", "bar"] + }); + + requestSkipAnimationFrame(session, (time, xrFrame) => { + let sources = []; + t.step(() => { + for (const source of session.inputSources) { + sources.push(source); + } + assert_equals(sources.length, 1); + }); + resolve(); + }); + }); +}; + +xr_session_promise_test( + testName, testFunction, TRACKED_IMMERSIVE_DEVICE, 'immersive-vr'); +</script> |