haikuwebkit/Source/WebCore/bindings/scripts/test
Alexey Shvayka 1e336abec3 [WebIDL] Properly validate and merge descriptors in [Replaceable] setter
https://bugs.webkit.org/show_bug.cgi?id=227662

Reviewed by Sam Weinig.

Source/JavaScriptCore:

Extracts createDataProperty() method to keep WebIDL code generator as simple as possible,
and also to emphasize a subtle difference between
{ [[Value]]: X } and
{ [[Value]]: X, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.

* runtime/JSONObject.cpp:
(JSC::Walker::walk):
* runtime/JSObject.cpp:
(JSC::definePropertyOnReceiverSlow):
* runtime/JSObject.h:
* runtime/JSObjectInlines.h:
(JSC::JSObject::createDataProperty):
* runtime/Lookup.h:
(JSC::replaceStaticPropertySlot): Deleted.

Source/WebCore:

The previous implementation relied on an invariant that structure property is absent
when [Replaceable] setter is called, which is no longer guaranteed after the introduction
of Object.defineProperty.

This patch replaces putDirect() with defineOwnProperty(), fixing the compliance with
invariants of internal methods [1]: an accessor property once observed as non-configurable
can't be reconfigured to have [[Value]]. Both Chrome and Firefox properly validate descriptors.

Although [[DefineOwnProperty]] failure is silently ignored by Chrome and the spec [2], WebKit now
throws a TypeError, which is a desired behavior for built-ins and was proven to be web-compatible
by Firefox. With WebKit being the second implementation that throws, the spec can be tightened.

After r264574, attributeChangeTransition() is called during defineOwnProperty(), ensuring inline
caching is correct. Also, this change adjusts `window.opener` setter [3].

[1] https://tc39.es/ecma262/#sec-invariants-of-the-essential-internal-methods
[2] https://heycam.github.io/webidl/#dfn-attribute-setter (step 4.5.5)
[3] https://html.spec.whatwg.org/multipage/browsers.html#dom-opener

Tests: fast/dom/replaceable-setter-throws-if-defineownproperty-fails.html
       fast/dom/window-opener-setter-throws-if-defineownproperty-fails-1.html
       fast/dom/window-opener-setter-throws-if-defineownproperty-fails-2.html

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::setOpener):
(WebCore::JSDOMWindow::setOpenDatabase):
* bindings/scripts/CodeGeneratorJS.pm:
(AttributeSetterNeedsPropertyName):
(GenerateAttributeSetterBodyDefinition):
(GenerateAttributeSetterTrampolineDefinition):
* bindings/scripts/test/JS/JSTestObj.cpp:

LayoutTests:

* fast/dom/replaceable-setter-throws-if-defineownproperty-fails-expected.txt: Added.
* fast/dom/replaceable-setter-throws-if-defineownproperty-fails.html: Added.
* fast/dom/window-opener-setter-throws-if-defineownproperty-fails-1-expected.txt: Added.
* fast/dom/window-opener-setter-throws-if-defineownproperty-fails-1.html: Added.
* fast/dom/window-opener-setter-throws-if-defineownproperty-fails-2-expected.txt: Added.
* fast/dom/window-opener-setter-throws-if-defineownproperty-fails-2.html: Added.


Canonical link: https://commits.webkit.org/239938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280280 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-24 01:56:31 +00:00
..
JS [WebIDL] Properly validate and merge descriptors in [Replaceable] setter 2021-07-24 01:56:31 +00:00
AudioWorkletGlobalScopeConstructors.idl
BindingTestGlobalConstructors.idl RemotePlayback must keep its media element alive when there is a pending activity 2021-06-30 23:53:16 +00:00
DOMWindow.idl
DOMWindowConstructors.idl Unreviewed, reverting r279546, r279554, r279558 and r279567. 2021-07-07 03:12:05 +00:00
DedicatedWorkerGlobalScope.idl
DedicatedWorkerGlobalScopeConstructors.idl
ExposedToWorkerAndWindow.idl
PaintWorkletGlobalScope.idl
PaintWorkletGlobalScopeConstructors.idl
ServiceWorkerGlobalScope.idl
ServiceWorkerGlobalScopeConstructors.idl
SupplementalDependencies.dep RemotePlayback must keep its media element alive when there is a pending activity 2021-06-30 23:53:16 +00:00
TestCEReactions.idl
TestCEReactionsStringifier.idl
TestCallTracer.idl Web Inspector: `RecordCanvasActionVariant` causes a huge symbol to be created in WebCore 2021-03-04 01:34:21 +00:00
TestCallbackFunction.idl
TestCallbackFunctionRethrow.idl
TestCallbackFunctionWithThisObject.idl
TestCallbackFunctionWithTypedefs.idl
TestCallbackInterface.idl
TestClassWithJSBuiltinConstructor.idl
TestConditionalIncludes.idl
TestConditionallyReadWrite.idl
TestDOMJIT.idl
TestDefaultToJSON.idl
TestDefaultToJSONEnum.idl
TestDefaultToJSONFilteredByExposed.idl
TestDefaultToJSONIndirectInheritance.idl
TestDefaultToJSONInherit.idl
TestDefaultToJSONInheritFinal.idl
TestDelegateToSharedSyntheticAttribute.idl Reduce compile time and binary size cost of enabling proper CSSStyleDeclaration property access behavior 2021-04-11 17:06:47 +00:00
TestDerivedDictionary.idl
TestDerivedDictionary2.idl
TestDictionary.idl [WebIDL] includes for `Conditional` dictionary members should also be guarded 2021-04-13 20:38:03 +00:00
TestDictionaryWithOnlyConditionalMembers.idl [WebIDL] includes for `Conditional` dictionary members should also be guarded 2021-04-13 20:38:03 +00:00
TestDomainSecurity.idl
TestEmptyDictionary.idl [Payment Request] add an `object data` to `PaymentItem` so that data specific to Apple Pay can be provided 2021-02-19 00:37:33 +00:00
TestEnabledBySetting.idl Unreviewed, reverting r279546, r279554, r279558 and r279567. 2021-07-07 03:12:05 +00:00
TestEnabledBySettingSupplemental.idl
TestEnabledForContext.idl
TestEventConstructor.idl
TestEventTarget.idl
TestException.idl
TestGenerateAddOpaqueRoot.idl RemotePlayback must keep its media element alive when there is a pending activity 2021-06-30 23:53:16 +00:00
TestGenerateIsReachable.idl
TestGlobalObject.idl
TestIndexedSetterNoIdentifier.idl
TestIndexedSetterThrowingException.idl
TestIndexedSetterWithIdentifier.idl
TestInheritedDictionary.idl
TestInheritedDictionary2.idl
TestInterface.idl [WebIDL] Remove the need to specify [MayThrowException] 2021-03-23 00:49:01 +00:00
TestInterfaceLeadingUnderscore.idl
TestIterable.idl
TestJSBuiltinConstructor.idl
TestLegacyFactoryFunction.idl
TestLegacyNoInterfaceObject.idl [WebIDL] Remove [Reflect] support for constants 2021-04-29 22:09:09 +00:00
TestLegacyOverrideBuiltIns.idl
TestMapLike.idl
TestMapLikeWithOverriddenOperations.idl
TestMixinInterface.idl [WebIDL] Remove [Reflect] support for constants 2021-04-29 22:09:09 +00:00
TestNamedAndIndexedSetterNoIdentifier.idl
TestNamedAndIndexedSetterThrowingException.idl
TestNamedAndIndexedSetterWithIdentifier.idl
TestNamedDeleterNoIdentifier.idl
TestNamedDeleterThrowingException.idl
TestNamedDeleterWithIdentifier.idl
TestNamedDeleterWithIndexedGetter.idl
TestNamedGetterCallWith.idl
TestNamedGetterNoIdentifier.idl
TestNamedGetterWithIdentifier.idl
TestNamedSetterNoIdentifier.idl
TestNamedSetterThrowingException.idl
TestNamedSetterWithIdentifier.idl
TestNamedSetterWithIndexedGetter.idl
TestNamedSetterWithIndexedGetterAndSetter.idl
TestNamedSetterWithLegacyOverrideBuiltIns.idl
TestNamedSetterWithLegacyUnforgeableProperties.idl
TestNamedSetterWithLegacyUnforgeablePropertiesAndLegacyOverrideBuiltIns.idl
TestNamespaceObject.idl [WebIDL] `window.CSS` should be non-callable object with correct Symbol.toStringTag 2021-04-27 20:04:28 +00:00
TestNode.idl
TestObj.idl [JSC] Call custom accessors / values with their holder's global object 2021-07-23 20:13:31 +00:00
TestOperationBase.idl
TestOperationConditional.idl
TestOverloadedConstructors.idl
TestOverloadedConstructorsWithSequence.idl
TestPartialMixinInterface.idl
TestPartialNamespaceObject.idl [WebIDL] `window.CSS` should be non-callable object with correct Symbol.toStringTag 2021-04-27 20:04:28 +00:00
TestPluginInterface.idl
TestPromiseRejectionEvent.idl
TestReadOnlyMapLike.idl
TestReadOnlySetLike.idl
TestReportExtraMemoryCost.idl
TestSerializedScriptValueInterface.idl
TestSetLike.idl
TestSetLikeWithOverriddenOperations.idl
TestStandaloneDictionary.idl
TestStandaloneEnumeration.idl
TestStringifier.idl
TestStringifierAnonymousOperation.idl
TestStringifierNamedOperation.idl
TestStringifierOperationImplementedAs.idl
TestStringifierOperationNamedToString.idl
TestStringifierReadOnlyAttribute.idl
TestStringifierReadWriteAttribute.idl
TestSupplemental.idl [WebIDL] Remove [Reflect] support for constants 2021-04-29 22:09:09 +00:00
TestTypedefs.idl [WebIDL] Remove the need to specify [MayThrowException] 2021-03-23 00:49:01 +00:00
TestVoidCallbackFunction.idl
WorkerGlobalScope.idl
WorkerGlobalScopeConstructors.idl
WorkletGlobalScope.idl
WorkletGlobalScopeConstructors.idl