Title: [269847] trunk
Revision
269847
Author
[email protected]
Date
2020-11-16 04:17:49 -0800 (Mon, 16 Nov 2020)

Log Message

TextEncoderStreamEncoder should not be exposed
https://bugs.webkit.org/show_bug.cgi?id=218956

Reviewed by Yusuke Suzuki.

Source/WebCore:

Binding generator correctly handles private identifiers and runtime settings, but not when combined for interfaces.

Test: fast/encoding/stream-visibility.html

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
* bindings/scripts/test/JS/JSTestEnabledBySetting.cpp:
(WebCore::JSTestEnabledBySettingDOMConstructor::prototypeForStructure):
(WebCore::JSTestEnabledBySetting::finishCreation):
(WebCore::jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructorGetter):
(WebCore::JSC_DEFINE_CUSTOM_GETTER):
(WebCore::setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructorSetter):
(WebCore::JSC_DEFINE_CUSTOM_SETTER):
(WebCore::jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructorGetter):
(WebCore::setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructorSetter):
* bindings/scripts/test/TestEnabledBySetting.idl:

LayoutTests:

* fast/encoding/stream-visibility-expected.txt: Added.
* fast/encoding/stream-visibility.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (269846 => 269847)


--- trunk/LayoutTests/ChangeLog	2020-11-16 11:28:40 UTC (rev 269846)
+++ trunk/LayoutTests/ChangeLog	2020-11-16 12:17:49 UTC (rev 269847)
@@ -1,3 +1,13 @@
+2020-11-16  Youenn Fablet  <[email protected]>
+
+        TextEncoderStreamEncoder should not be exposed
+        https://bugs.webkit.org/show_bug.cgi?id=218956
+
+        Reviewed by Yusuke Suzuki.
+
+        * fast/encoding/stream-visibility-expected.txt: Added.
+        * fast/encoding/stream-visibility.html: Added.
+
 2020-11-16  Fujii Hironori  <[email protected]>
 
         [TextureMapper] The edges of blur backdrop-filter look gradient tranparent

Added: trunk/LayoutTests/fast/encoding/stream-visibility-expected.txt (0 => 269847)


--- trunk/LayoutTests/fast/encoding/stream-visibility-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/stream-visibility-expected.txt	2020-11-16 12:17:49 UTC (rev 269847)
@@ -0,0 +1,3 @@
+
+PASS Encoder/decoder exposure
+

Added: trunk/LayoutTests/fast/encoding/stream-visibility.html (0 => 269847)


--- trunk/LayoutTests/fast/encoding/stream-visibility.html	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/stream-visibility.html	2020-11-16 12:17:49 UTC (rev 269847)
@@ -0,0 +1,16 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <script src=""
+        <script src=""
+    </head>
+    <body>
+        <script>
+test(() => {
+    assert_equals(window.TextEncoderStreamEncoder, undefined, "encoder stream");
+    assert_equals(window.TextDecoderStreamDecoder, undefined, "decoder stream");
+}, "Encoder/decoder exposure");
+        </script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (269846 => 269847)


--- trunk/Source/WebCore/ChangeLog	2020-11-16 11:28:40 UTC (rev 269846)
+++ trunk/Source/WebCore/ChangeLog	2020-11-16 12:17:49 UTC (rev 269847)
@@ -1,3 +1,27 @@
+2020-11-16  Youenn Fablet  <[email protected]>
+
+        TextEncoderStreamEncoder should not be exposed
+        https://bugs.webkit.org/show_bug.cgi?id=218956
+
+        Reviewed by Yusuke Suzuki.
+
+        Binding generator correctly handles private identifiers and runtime settings, but not when combined for interfaces.
+
+        Test: fast/encoding/stream-visibility.html
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+        * bindings/scripts/test/JS/JSTestEnabledBySetting.cpp:
+        (WebCore::JSTestEnabledBySettingDOMConstructor::prototypeForStructure):
+        (WebCore::JSTestEnabledBySetting::finishCreation):
+        (WebCore::jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructorGetter):
+        (WebCore::JSC_DEFINE_CUSTOM_GETTER):
+        (WebCore::setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructorSetter):
+        (WebCore::JSC_DEFINE_CUSTOM_SETTER):
+        (WebCore::jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructorGetter):
+        (WebCore::setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructorSetter):
+        * bindings/scripts/test/TestEnabledBySetting.idl:
+
 2020-11-16  Devin Rousso  <[email protected]>
 
         [iPad] nhl.com cannot select new video to play while video is playing with desktop UA

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (269846 => 269847)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2020-11-16 11:28:40 UTC (rev 269846)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2020-11-16 12:17:49 UTC (rev 269847)
@@ -4753,17 +4753,29 @@
         my $getter = GetAttributeGetterName($interface, $className, $attribute);
         my $setter = IsReadonly($attribute) ? "nullptr" : GetAttributeSetterName($interface, $className, $attribute);
         my $jscAttributes = GetJSCAttributesForAttribute($interface, $attribute);
+        my $isPrivateAndPublic = $attribute->extendedAttributes->{PublicIdentifier} && $attribute->extendedAttributes->{PrivateIdentifier};
 
         my $conditionalString = $codeGenerator->GenerateConditionalString($attribute);
         push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
-        push(@implContent, "    if (${runtimeEnableConditionalString})\n");
+        push(@implContent, "    if (${runtimeEnableConditionalString})");
+        push(@implContent, " {") if $isPrivateAndPublic;
+        push(@implContent, "\n");
         assert("CustomGetterSetter is not allowed for DOMAttribute. DOMAttributeGetterSetter must be used.") if IsAcceleratedDOMAttribute($interface, $attribute);
-        push(@implContent, "        putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames()." . $attributeName . "PublicName(), CustomGetterSetter::create(vm, $getter, $setter), attributesForStructure($jscAttributes));\n");
+
+        if ($attribute->extendedAttributes->{PublicIdentifier} || !$attribute->extendedAttributes->{PrivateIdentifier}) {
+            push(@implContent, "        putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames()." . $attributeName . "PublicName(), CustomGetterSetter::create(vm, $getter, $setter), attributesForStructure($jscAttributes));\n");
+        }
+        if ($attribute->extendedAttributes->{PrivateIdentifier}) {
+            push(@implContent, "        putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames()." . $attributeName . "PrivateName(), CustomGetterSetter::create(vm, $getter, $setter), attributesForStructure($jscAttributes));\n");
+        }
+
+        push(@implContent, "    }\n") if $isPrivateAndPublic;
         push(@implContent, "#endif\n") if $conditionalString;
     }
 
     # Support PrivateIdentifier attributes on instances.
     foreach my $attribute (@{$interface->attributes}) {
+        next if NeedsRuntimeCheck($interface, $attribute);
         next unless $attribute->extendedAttributes->{PrivateIdentifier};
         next unless AttributeShouldBeOnInstance($interface, $attribute);
 

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEnabledBySetting.cpp (269846 => 269847)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEnabledBySetting.cpp	2020-11-16 11:28:40 UTC (rev 269846)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEnabledBySetting.cpp	2020-11-16 12:17:49 UTC (rev 269847)
@@ -60,6 +60,10 @@
 static JSC_DECLARE_CUSTOM_GETTER(jsTestEnabledBySettingConstructor);
 static JSC_DECLARE_CUSTOM_GETTER(jsTestEnabledBySetting_TestSubObjEnabledBySettingConstructor);
 static JSC_DECLARE_CUSTOM_SETTER(setJSTestEnabledBySetting_TestSubObjEnabledBySettingConstructor);
+static JSC_DECLARE_CUSTOM_GETTER(jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructor);
+static JSC_DECLARE_CUSTOM_SETTER(setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructor);
+static JSC_DECLARE_CUSTOM_GETTER(jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructor);
+static JSC_DECLARE_CUSTOM_SETTER(setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructor);
 #if ENABLE(TEST_FEATURE)
 static JSC_DECLARE_CUSTOM_GETTER(jsTestEnabledBySetting_enabledBySettingAttribute);
 static JSC_DECLARE_CUSTOM_SETTER(setJSTestEnabledBySetting_enabledBySettingAttribute);
@@ -105,6 +109,20 @@
 
 using JSTestEnabledBySettingDOMConstructor = JSDOMConstructorNotConstructable<JSTestEnabledBySetting>;
 
+/* Hash table */
+
+static const struct CompactHashIndex JSTestEnabledBySettingTableIndex[2] = {
+    { -1, -1 },
+    { -1, -1 },
+};
+
+
+static const HashTableValue JSTestEnabledBySettingTableValues[] =
+{
+    { 0, 0, NoIntrinsic, { 0, 0 } }
+};
+
+static const HashTable JSTestEnabledBySettingTable = { 0, 1, false, JSTestEnabledBySetting::info(), JSTestEnabledBySettingTableValues, JSTestEnabledBySettingTableIndex };
 /* Hash table for constructor */
 
 static const HashTableValue JSTestEnabledBySettingConstructorTableValues[] =
@@ -213,7 +231,7 @@
     JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
 }
 
-const ClassInfo JSTestEnabledBySetting::s_info = { "TestEnabledBySetting", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestEnabledBySetting) };
+const ClassInfo JSTestEnabledBySetting::s_info = { "TestEnabledBySetting", &Base::s_info, &JSTestEnabledBySettingTable, nullptr, CREATE_METHOD_TABLE(JSTestEnabledBySetting) };
 
 JSTestEnabledBySetting::JSTestEnabledBySetting(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestEnabledBySetting>&& impl)
     : JSDOMWrapper<TestEnabledBySetting>(structure, globalObject, WTFMove(impl))
@@ -229,6 +247,12 @@
 
     if (downcast<Document>(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext())->settings().testSettingEnabled())
         putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TestSubObjEnabledBySettingPublicName(), CustomGetterSetter::create(vm, jsTestEnabledBySetting_TestSubObjEnabledBySettingConstructor, setJSTestEnabledBySetting_TestSubObjEnabledBySettingConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
+    if (downcast<Document>(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext())->settings().testSettingEnabled())
+        putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TestSubObjEnabledBySettingPrivatePrivateName(), CustomGetterSetter::create(vm, jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructor, setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
+    if (downcast<Document>(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext())->settings().testSettingEnabled()) {
+        putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TestSubObjEnabledBySettingPrivatePublicPublicName(), CustomGetterSetter::create(vm, jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructor, setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
+        putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TestSubObjEnabledBySettingPrivatePublicPrivateName(), CustomGetterSetter::create(vm, jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructor, setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
+    }
 }
 
 JSObject* JSTestEnabledBySetting::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
@@ -295,6 +319,52 @@
     return IDLAttribute<JSTestEnabledBySetting>::set<setJSTestEnabledBySetting_TestSubObjEnabledBySettingConstructorSetter>(*lexicalGlobalObject, thisValue, encodedValue, "TestSubObjEnabledBySetting");
 }
 
+static inline JSValue jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructorGetter(JSGlobalObject& lexicalGlobalObject, JSTestEnabledBySetting& thisObject)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    return JSTestSubObj::getConstructor(JSC::getVM(&lexicalGlobalObject), thisObject.globalObject());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+    return IDLAttribute<JSTestEnabledBySetting>::get<jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructorGetter>(*lexicalGlobalObject, thisValue, "TestSubObjEnabledBySettingPrivate");
+}
+
+static inline bool setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructorSetter(JSGlobalObject& lexicalGlobalObject, JSTestEnabledBySetting& thisObject, JSValue value)
+{
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    // Shadowing a built-in constructor.
+    return thisObject.putDirect(vm, Identifier::fromString(vm, reinterpret_cast<const LChar*>("TestSubObjEnabledBySettingPrivate"), strlen("TestSubObjEnabledBySettingPrivate")), value);
+}
+
+JSC_DEFINE_CUSTOM_SETTER(setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue))
+{
+    return IDLAttribute<JSTestEnabledBySetting>::set<setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivateConstructorSetter>(*lexicalGlobalObject, thisValue, encodedValue, "TestSubObjEnabledBySettingPrivate");
+}
+
+static inline JSValue jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructorGetter(JSGlobalObject& lexicalGlobalObject, JSTestEnabledBySetting& thisObject)
+{
+    UNUSED_PARAM(lexicalGlobalObject);
+    return JSTestSubObj::getConstructor(JSC::getVM(&lexicalGlobalObject), thisObject.globalObject());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+    return IDLAttribute<JSTestEnabledBySetting>::get<jsTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructorGetter>(*lexicalGlobalObject, thisValue, "TestSubObjEnabledBySettingPrivatePublic");
+}
+
+static inline bool setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructorSetter(JSGlobalObject& lexicalGlobalObject, JSTestEnabledBySetting& thisObject, JSValue value)
+{
+    auto& vm = JSC::getVM(&lexicalGlobalObject);
+    // Shadowing a built-in constructor.
+    return thisObject.putDirect(vm, Identifier::fromString(vm, reinterpret_cast<const LChar*>("TestSubObjEnabledBySettingPrivatePublic"), strlen("TestSubObjEnabledBySettingPrivatePublic")), value);
+}
+
+JSC_DEFINE_CUSTOM_SETTER(setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue))
+{
+    return IDLAttribute<JSTestEnabledBySetting>::set<setJSTestEnabledBySetting_TestSubObjEnabledBySettingPrivatePublicConstructorSetter>(*lexicalGlobalObject, thisValue, encodedValue, "TestSubObjEnabledBySettingPrivatePublic");
+}
+
 #if ENABLE(TEST_FEATURE)
 static inline JSValue jsTestEnabledBySetting_enabledBySettingAttributeGetter(JSGlobalObject& lexicalGlobalObject, JSTestEnabledBySetting& thisObject)
 {

Modified: trunk/Source/WebCore/bindings/scripts/test/TestEnabledBySetting.idl (269846 => 269847)


--- trunk/Source/WebCore/bindings/scripts/test/TestEnabledBySetting.idl	2020-11-16 11:28:40 UTC (rev 269846)
+++ trunk/Source/WebCore/bindings/scripts/test/TestEnabledBySetting.idl	2020-11-16 12:17:49 UTC (rev 269847)
@@ -27,6 +27,8 @@
     Exposed=Window
 ] interface TestEnabledBySetting {
     [EnabledBySetting=TestSetting] attribute TestSubObjConstructor TestSubObjEnabledBySetting;
+    [EnabledBySetting=TestSetting, PrivateIdentifier] attribute TestSubObjConstructor TestSubObjEnabledBySettingPrivate;
+    [EnabledBySetting=TestSetting, PrivateIdentifier, PublicIdentifier] attribute TestSubObjConstructor TestSubObjEnabledBySettingPrivatePublic;
 
     // [EnabledBySetting] attributes and operations.
     [Conditional=TEST_FEATURE, EnabledBySetting=TestSetting] attribute DOMString enabledBySettingAttribute;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to