diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index e7d4d1a9cff..6dfe66a9d75 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -347,11 +347,15 @@ impl TestBindingMethods for TestBinding { unsignedLongValue: None, unsignedShortValue: None, usvstringValue: None, + nonRequiredNullable: None, + nonRequiredNullable2: Some(None), // null } } - fn TypeKeywordIsSuccess(&self, arg: &TestDictionary) -> bool { - arg.type_.as_ref().map(|s| s == "success").unwrap_or(false) + fn DictMatchesPassedValues(&self, arg: &TestDictionary) -> bool { + arg.type_.as_ref().map(|s| s == "success").unwrap_or(false) && + arg.nonRequiredNullable.is_none() && + arg.nonRequiredNullable2 == Some(None) } fn PassBoolean(&self, _: bool) {} diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl index e9d94509473..6706ccfdaa9 100644 --- a/components/script/dom/webidls/TestBinding.webidl +++ b/components/script/dom/webidls/TestBinding.webidl @@ -32,6 +32,11 @@ dictionary TestDictionary { sequence seqDict; // Reserved rust keyword DOMString type; + // These are used to test bidirectional conversion + // and differentiation of non-required and nullable types + // in dictionaries. + DOMString? nonRequiredNullable; + DOMString? nonRequiredNullable2; }; dictionary TestDictionaryDefaults { @@ -199,7 +204,7 @@ interface TestBinding { (unsigned long or boolean)? receiveNullableUnion5(); sequence? receiveNullableSequence(); TestDictionary receiveTestDictionaryWithSuccessOnKeyword(); - boolean typeKeywordIsSuccess(TestDictionary arg); + boolean dictMatchesPassedValues(TestDictionary arg); void passBoolean(boolean arg); void passByte(byte arg); diff --git a/tests/wpt/mozilla/tests/mozilla/binding_keyword.html b/tests/wpt/mozilla/tests/mozilla/binding_keyword.html index 2faa1ccc8f3..818d2aa2947 100644 --- a/tests/wpt/mozilla/tests/mozilla/binding_keyword.html +++ b/tests/wpt/mozilla/tests/mozilla/binding_keyword.html @@ -9,8 +9,9 @@ test(function() { var dict = t.receiveTestDictionaryWithSuccessOnKeyword(); assert_equals(dict.type, "success"); + assert_equals(dict.nonRequiredNullable, undefined); + assert_equals(dict.nonRequiredNullable2, null); - var is_success = t.typeKeywordIsSuccess(dict); - assert_true(is_success); -}, "Conversion of dictionary elements with rust keywords works") + assert_true(t.dictMatchesPassedValues(dict)); +}, "Conversion of dictionary elements with rust keywords, and null non-required nullable properties works")