From c24481ab9c9a7e7e944c91673532578f8c121e0f Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 8 Apr 2020 23:13:59 -0700 Subject: [PATCH 1/2] Do not filter out platform objects when doing dictionary conversions https://heycam.github.io/webidl/#es-overloads In step 12, the platform object check is for substep 4, but importantly it only matters if `V` implements the matching interface. If not, it should be able to fall back to substep 10 and attempt conversion to a dictionary. --- components/script/dom/bindings/codegen/CodegenRust.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 96947d83ec7..d4b103cc21b 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -429,8 +429,8 @@ class CGMethodCall(CGThing): # Check for vanilla JS objects # XXXbz Do we need to worry about security wrappers? - pickFirstSignature("%s.get().is_object() && !is_platform_object(%s.get().to_object(), *cx)" % - (distinguishingArg, distinguishingArg), + pickFirstSignature("%s.get().is_object()" % + distinguishingArg, lambda s: (s[1][distinguishingIndex].type.isCallback() or s[1][distinguishingIndex].type.isCallbackInterface() or s[1][distinguishingIndex].type.isDictionary() or From 58bab8a7e9b4e61e11694accbf5caf24886cc217 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 9 Apr 2020 09:01:37 -0700 Subject: [PATCH 2/2] Add test for overloading with interface and dict --- components/script/dom/testbinding.rs | 11 ++++++++++- .../script/dom/webidls/TestBinding.webidl | 8 ++++++++ .../mozilla/overload_dict.html.ini | 3 +++ tests/wpt/mozilla/meta/MANIFEST.json | 7 +++++++ .../meta/mozilla/overload_dict.html.ini | 3 +++ .../mozilla/tests/mozilla/overload_dict.html | 18 ++++++++++++++++++ 6 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/mozilla/meta-layout-2020/mozilla/overload_dict.html.ini create mode 100644 tests/wpt/mozilla/meta/mozilla/overload_dict.html.ini create mode 100644 tests/wpt/mozilla/tests/mozilla/overload_dict.html diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index e44983ea3a3..1ac5d8db31a 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -12,7 +12,7 @@ use crate::dom::bindings::codegen::Bindings::TestBindingBinding::{ TestBindingMethods, TestDictionary, }; use crate::dom::bindings::codegen::Bindings::TestBindingBinding::{ - TestDictionaryDefaults, TestEnum, + TestDictionaryDefaults, TestEnum, TestURLLike, }; use crate::dom::bindings::codegen::UnionTypes; use crate::dom::bindings::codegen::UnionTypes::{ @@ -45,6 +45,7 @@ use crate::dom::bindings::trace::RootedTraceableBox; use crate::dom::bindings::weakref::MutableWeakRef; use crate::dom::blob::Blob; use crate::dom::globalscope::GlobalScope; +use crate::dom::node::Node; use crate::dom::promise::Promise; use crate::dom::promisenativehandler::{Callback, PromiseNativeHandler}; use crate::dom::url::URL; @@ -679,6 +680,14 @@ impl TestBindingMethods for TestBinding { fn PassOverloaded(&self, _: CustomAutoRooterGuard) {} fn PassOverloaded_(&self, _: DOMString) {} + fn PassOverloadedDict(&self, _: &Node) -> DOMString { + "node".into() + } + + fn PassOverloadedDict_(&self, u: &TestURLLike) -> DOMString { + u.href.clone() + } + fn PassNullableBoolean(&self, _: Option) {} fn PassNullableByte(&self, _: Option) {} fn PassNullableOctet(&self, _: Option) {} diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl index 9c3fdc02638..6aa748e502f 100644 --- a/components/script/dom/webidls/TestBinding.webidl +++ b/components/script/dom/webidls/TestBinding.webidl @@ -86,6 +86,10 @@ dictionary TestDictionaryDefaults { object? nullableObjectValue = null; }; +dictionary TestURLLike { + required DOMString href; +}; + [Pref="dom.testbinding.enabled", Exposed=(Window,Worker) ] @@ -279,6 +283,10 @@ interface TestBinding { void passOverloaded(ArrayBuffer arg); void passOverloaded(DOMString arg); + // https://github.com/servo/servo/pull/26154 + DOMString passOverloadedDict(Node arg); + DOMString passOverloadedDict(TestURLLike arg); + void passNullableBoolean(boolean? arg); void passNullableByte(byte? arg); void passNullableOctet(octet? arg); diff --git a/tests/wpt/mozilla/meta-layout-2020/mozilla/overload_dict.html.ini b/tests/wpt/mozilla/meta-layout-2020/mozilla/overload_dict.html.ini new file mode 100644 index 00000000000..646813bf83c --- /dev/null +++ b/tests/wpt/mozilla/meta-layout-2020/mozilla/overload_dict.html.ini @@ -0,0 +1,3 @@ +[overload_dict.html] + type: testharness + prefs: [dom.testbinding.enabled:true] diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 770fb31f3a8..ecf75a68e87 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -14088,6 +14088,13 @@ {} ] ], + "overload_dict.html": [ + "cd42fd97331753fc0580a47a39814cff57911638", + [ + null, + {} + ] + ], "paint_timing.html": [ "0c1798ec565a77d20d9550b5cec352a0b286c415", [ diff --git a/tests/wpt/mozilla/meta/mozilla/overload_dict.html.ini b/tests/wpt/mozilla/meta/mozilla/overload_dict.html.ini new file mode 100644 index 00000000000..646813bf83c --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/overload_dict.html.ini @@ -0,0 +1,3 @@ +[overload_dict.html] + type: testharness + prefs: [dom.testbinding.enabled:true] diff --git a/tests/wpt/mozilla/tests/mozilla/overload_dict.html b/tests/wpt/mozilla/tests/mozilla/overload_dict.html new file mode 100644 index 00000000000..cd42fd97331 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/overload_dict.html @@ -0,0 +1,18 @@ + + +Test for overload with dictionary object + + +