haikuwebkit/LayoutTests/fast/workers/self-hasOwnProperty-expecte...

14 lines
369 B
Plaintext
Raw Permalink Normal View History

self.hasOwnProperty() does not work inside Web workers https://bugs.webkit.org/show_bug.cgi?id=158446 <rdar://problem/26638397> Reviewed by Geoffrey Garen. Source/JavaScriptCore: Add a factory function to JSProxy to create a JSProxy without a target. Also make the setTarget() method public so that the target can now be set after creation. This is needed so that we can create a proxy for JSWorkerGlobalScope, then create the JSWorkerGlobalScope object, passing it the proxy and finally set the target on the proxy. * runtime/JSProxy.h: (JSC::JSProxy::create): Source/WebCore: W3C tests for workers were severely broken on WebKit because self.hasOwnProperty() did not work inside workers. The reason is that hasOwnProperty() (and other methods like toString()) call toThis() in StrictMode on thisValue. However, in the case of 'self' in workers, self was a DedicatedWorkerGlobalScope, which is a JSGlobalObject. JSGlobalObject::toThis() returns jsUndefined() when called in strict mode. As a result, we would end up with exceptions such as "undefined is not an object" when calling self.hasOwnProperty() in workers. To address the problem, this patch introduces a JSProxy whose proxy type is PureForwardingProxyType and whose target is the WorkerGlobalScope. This JSProxy is what we expose to the JavaScript, instead of the JSWorkerGlobalScope itself. As a result, toThis() now behaves as expected and self.hasOwnProperty() works inside workers. This patch greatly improves our pass rate on several W3C tests: http://w3c-test.org/workers/interfaces.worker: 20 passes -> 50 passes (out of 128) http://w3c-test.org/IndexedDB/interfaces.worker 0 passes -> 145 passes (out of 156) Tests: fast/workers/self-hasOwnProperty.html fast/workers/self-toString.html * bindings/js/JSWorkerGlobalScopeBase.cpp: (WebCore::JSWorkerGlobalScopeBase::finishCreation): (WebCore::JSWorkerGlobalScopeBase::visitChildren): (WebCore::toJS): * bindings/js/JSWorkerGlobalScopeBase.h: (WebCore::JSWorkerGlobalScopeBase::proxy): * bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::initScript): * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GenerateImplementation): LayoutTests: Add tests to make sure that self.toString() and self.hasOwnProperty() now work in workers. * fast/workers/self-hasOwnProperty-expected.txt: Added. * fast/workers/self-hasOwnProperty.html: Added. * fast/workers/self-toString-expected.txt: Added. * fast/workers/self-toString.html: Added. Canonical link: https://commits.webkit.org/176591@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201808 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-08 17:31:12 +00:00
Tests that self.hasOwnProperty() works in workers
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
self.hasOwnProperty('DedicatedWorkerGlobalScope'): true
self.hasOwnProperty('WorkerGlobalScope'): true
WorkerGlobalScope attributes / operations should be on the prototype https://bugs.webkit.org/show_bug.cgi?id=158568 <rdar://problem/26720079> Reviewed by Geoffrey Garen. Source/WebCore: WorkerGlobalScope attributes / operations should be on the prototype because WorkerGlobalScope is not marked as [Global] / [PrimaryGlobal]: - https://html.spec.whatwg.org/multipage/workers.html#the-workerglobalscope-common-interface - http://heycam.github.io/webidl/#es-attributes - http://heycam.github.io/webidl/#es-operations DedicatedWorkerGlobalScope is the interface that is marked as [Global] and whose attributes / operations should be on the instance. This brings the number of failures on http://w3c-test.org/workers/interfaces.worker from 65 to 34. It also aligns our behavior with Firefox and Chrome. Test: fast/workers/WorkerGlobalScope-properties-prototype.html * bindings/scripts/CodeGeneratorJS.pm: (InterfaceRequiresAttributesOnInstance): (OperationShouldBeOnInstance): LayoutTests: * fast/workers/WorkerGlobalScope-properties-prototype-expected.txt: Added. * fast/workers/WorkerGlobalScope-properties-prototype.html: Added. Add layout test coverage. * fast/workers/self-hasOwnProperty-expected.txt: * fast/workers/self-hasOwnProperty.html: Update test I added a couple of days ago because it wrongly expected the 'navigator' property to be on the instance. This check was failing in other browsers (Firefox and Chrome). Canonical link: https://commits.webkit.org/176658@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201876 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-09 18:47:21 +00:00
self.hasOwnProperty('postMessage'): true
WorkerGlobalScope's indexedDB property should be on the prototype, not the instance https://bugs.webkit.org/show_bug.cgi?id=164644 Reviewed by Brady Eidson. Source/WebCore: WorkerGlobalScope's indexedDB property should be on the prototype, not the instance as per: - https://heycam.github.io/webidl/#es-attributes This is because WorkerGlobalScope is not marked as [Global] or [PrimaryGlobal] in the IDL: - https://html.spec.whatwg.org/multipage/workers.html#the-workerglobalscope-common-interface DedicatedWorkerGlobalScope is the one that is marked as [Global] and that should have its attributes on the instance: - https://html.spec.whatwg.org/multipage/workers.html#dedicated-workers-and-the-dedicatedworkerglobalscope-interface We were getting this mostly right, except for runtime-enabled attributes / operations which would end up on the instance instead of the prototype. This patch adds support for [PrimaryGlobal] / [Global] IDL extended attributes which determine the location of properties. It also improves support for runtime-enabled properties so that they can now be on either the instance or the prototype, exactly as if they were not runtimed-enabled. This gives us 100% pass rate on: - http://w3c-test.org/IndexedDB/interfaces.worker.html No new tests, updated existing test. * bindings/scripts/CodeGeneratorJS.pm: (IsGlobalOrPrimaryGlobalInterface): (InterfaceRequiresAttributesOnInstance): (AttributeShouldBeOnInstance): (OperationShouldBeOnInstance): (GenerateHeader): (GeneratePropertiesHashTable): (GenerateImplementation): * bindings/scripts/IDLAttributes.txt: * bindings/scripts/test/JS/JSInterfaceName.cpp: (WebCore::JSInterfaceName::finishCreation): * bindings/scripts/test/JS/JSInterfaceName.h: * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: (WebCore::JSTestActiveDOMObject::finishCreation): * bindings/scripts/test/JS/JSTestActiveDOMObject.h: * bindings/scripts/test/JS/JSTestCEReactions.cpp: (WebCore::JSTestCEReactions::finishCreation): * bindings/scripts/test/JS/JSTestCEReactions.h: * bindings/scripts/test/JS/JSTestCEReactionsStringifier.cpp: (WebCore::JSTestCEReactionsStringifier::finishCreation): * bindings/scripts/test/JS/JSTestCEReactionsStringifier.h: * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.cpp: (WebCore::JSTestClassWithJSBuiltinConstructor::finishCreation): * bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.h: * bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.cpp: (WebCore::JSTestCustomConstructorWithNoInterfaceObject::finishCreation): * bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.h: * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp: (WebCore::JSTestCustomNamedGetter::finishCreation): * bindings/scripts/test/JS/JSTestCustomNamedGetter.h: * bindings/scripts/test/JS/JSTestDOMJIT.cpp: (WebCore::JSTestDOMJIT::finishCreation): * bindings/scripts/test/JS/JSTestDOMJIT.h: * bindings/scripts/test/JS/JSTestEventConstructor.cpp: (WebCore::JSTestEventConstructor::finishCreation): * bindings/scripts/test/JS/JSTestEventConstructor.h: * bindings/scripts/test/JS/JSTestEventTarget.cpp: (WebCore::JSTestEventTarget::finishCreation): * bindings/scripts/test/JS/JSTestEventTarget.h: * bindings/scripts/test/JS/JSTestException.cpp: (WebCore::JSTestException::finishCreation): * bindings/scripts/test/JS/JSTestException.h: * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp: (WebCore::JSTestGenerateIsReachable::finishCreation): * bindings/scripts/test/JS/JSTestGenerateIsReachable.h: * bindings/scripts/test/JS/JSTestGlobalObject.cpp: (WebCore::JSTestGlobalObject::finishCreation): * bindings/scripts/test/JS/JSTestGlobalObject.h: * bindings/scripts/test/JS/JSTestInterface.cpp: (WebCore::JSTestInterface::finishCreation): * bindings/scripts/test/JS/JSTestInterface.h: * bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.cpp: (WebCore::JSTestInterfaceLeadingUnderscore::finishCreation): * bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.h: * bindings/scripts/test/JS/JSTestIterable.cpp: (WebCore::JSTestIterable::finishCreation): * bindings/scripts/test/JS/JSTestIterable.h: * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp: (WebCore::JSTestJSBuiltinConstructor::finishCreation): * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.h: * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp: (WebCore::JSTestMediaQueryListListener::finishCreation): * bindings/scripts/test/JS/JSTestMediaQueryListListener.h: * bindings/scripts/test/JS/JSTestNamedConstructor.cpp: (WebCore::JSTestNamedConstructor::finishCreation): * bindings/scripts/test/JS/JSTestNamedConstructor.h: * bindings/scripts/test/JS/JSTestNode.cpp: (WebCore::JSTestNode::finishCreation): * bindings/scripts/test/JS/JSTestNode.h: * bindings/scripts/test/JS/JSTestNondeterministic.cpp: (WebCore::JSTestNondeterministic::finishCreation): * bindings/scripts/test/JS/JSTestNondeterministic.h: * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObj::finishCreation): * bindings/scripts/test/JS/JSTestObj.h: * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp: (WebCore::JSTestOverloadedConstructors::finishCreation): * bindings/scripts/test/JS/JSTestOverloadedConstructors.h: * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp: (WebCore::JSTestOverloadedConstructorsWithSequence::finishCreation): * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.h: * bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp: (WebCore::JSTestOverrideBuiltins::finishCreation): * bindings/scripts/test/JS/JSTestOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestSerialization.cpp: (WebCore::JSTestSerialization::finishCreation): * bindings/scripts/test/JS/JSTestSerialization.h: * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp: (WebCore::JSTestSerializedScriptValueInterface::finishCreation): * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h: * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::JSTestTypedefs::finishCreation): * bindings/scripts/test/JS/JSTestTypedefs.h: * bindings/scripts/test/TestGlobalObject.idl: * page/DOMWindow.idl: * workers/DedicatedWorkerGlobalScope.idl: LayoutTests: Extend layout test coverage to check that: - WorkerGlobalScope.indexedDB is on the prototype. - WorkerGlobalScope.IDBDatabase constructor is on the instance Both are enabled at runtime properties. * fast/workers/WorkerGlobalScope-properties-prototype-expected.txt: * fast/workers/WorkerGlobalScope-properties-prototype.html: * fast/workers/self-hasOwnProperty-expected.txt: * fast/workers/self-hasOwnProperty.html: Canonical link: https://commits.webkit.org/182336@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208613 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-11 22:53:24 +00:00
self.hasOwnProperty('IDBDatabase'): true
self.hasOwnProperty() does not work inside Web workers https://bugs.webkit.org/show_bug.cgi?id=158446 <rdar://problem/26638397> Reviewed by Geoffrey Garen. Source/JavaScriptCore: Add a factory function to JSProxy to create a JSProxy without a target. Also make the setTarget() method public so that the target can now be set after creation. This is needed so that we can create a proxy for JSWorkerGlobalScope, then create the JSWorkerGlobalScope object, passing it the proxy and finally set the target on the proxy. * runtime/JSProxy.h: (JSC::JSProxy::create): Source/WebCore: W3C tests for workers were severely broken on WebKit because self.hasOwnProperty() did not work inside workers. The reason is that hasOwnProperty() (and other methods like toString()) call toThis() in StrictMode on thisValue. However, in the case of 'self' in workers, self was a DedicatedWorkerGlobalScope, which is a JSGlobalObject. JSGlobalObject::toThis() returns jsUndefined() when called in strict mode. As a result, we would end up with exceptions such as "undefined is not an object" when calling self.hasOwnProperty() in workers. To address the problem, this patch introduces a JSProxy whose proxy type is PureForwardingProxyType and whose target is the WorkerGlobalScope. This JSProxy is what we expose to the JavaScript, instead of the JSWorkerGlobalScope itself. As a result, toThis() now behaves as expected and self.hasOwnProperty() works inside workers. This patch greatly improves our pass rate on several W3C tests: http://w3c-test.org/workers/interfaces.worker: 20 passes -> 50 passes (out of 128) http://w3c-test.org/IndexedDB/interfaces.worker 0 passes -> 145 passes (out of 156) Tests: fast/workers/self-hasOwnProperty.html fast/workers/self-toString.html * bindings/js/JSWorkerGlobalScopeBase.cpp: (WebCore::JSWorkerGlobalScopeBase::finishCreation): (WebCore::JSWorkerGlobalScopeBase::visitChildren): (WebCore::toJS): * bindings/js/JSWorkerGlobalScopeBase.h: (WebCore::JSWorkerGlobalScopeBase::proxy): * bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::initScript): * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GenerateImplementation): LayoutTests: Add tests to make sure that self.toString() and self.hasOwnProperty() now work in workers. * fast/workers/self-hasOwnProperty-expected.txt: Added. * fast/workers/self-hasOwnProperty.html: Added. * fast/workers/self-toString-expected.txt: Added. * fast/workers/self-toString.html: Added. Canonical link: https://commits.webkit.org/176591@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201808 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-08 17:31:12 +00:00
PASS successfullyParsed is true
TEST COMPLETE