Diff
Modified: trunk/LayoutTests/ChangeLog (201851 => 201852)
--- trunk/LayoutTests/ChangeLog 2016-06-09 05:09:42 UTC (rev 201851)
+++ trunk/LayoutTests/ChangeLog 2016-06-09 05:18:38 UTC (rev 201852)
@@ -1,3 +1,15 @@
+2016-06-08 Chris Dumez <[email protected]>
+
+ DedicatedWorkerGlobalScope prototype chain is incorrect
+ https://bugs.webkit.org/show_bug.cgi?id=158544
+
+ Reviewed by Brady Eidson.
+
+ Add test coverage for the DedicatedWorkerGlobalScope prototype chain.
+
+ * fast/workers/DedicatedWorkerGlobalScope-prototype-chain-expected.txt: Added.
+ * fast/workers/DedicatedWorkerGlobalScope-prototype-chain.html: Added.
+
2016-06-08 Adam Bergkvist <[email protected]>
WebRTC: Imlement MediaEndpointPeerConnection::setRemoteDescription()
Added: trunk/LayoutTests/fast/workers/DedicatedWorkerGlobalScope-prototype-chain-expected.txt (0 => 201852)
--- trunk/LayoutTests/fast/workers/DedicatedWorkerGlobalScope-prototype-chain-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/workers/DedicatedWorkerGlobalScope-prototype-chain-expected.txt 2016-06-09 05:18:38 UTC (rev 201852)
@@ -0,0 +1,13 @@
+Tests that DedicatedWorkerGlobalScope's prototype chain is correct.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+DedicatedWorkerGlobalScope.prototype.toString() === "[object DedicatedWorkerGlobalScopePrototype]": true
+Object.getPrototypeOf(DedicatedWorkerGlobalScope.prototype) === WorkerGlobalScope.prototype: true
+WorkerGlobalScope.prototype.toString() === "[object WorkerGlobalScopePrototype]": true
+Object.getPrototypeOf(WorkerGlobalScope.prototype) === EventTarget.prototype: true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/workers/DedicatedWorkerGlobalScope-prototype-chain.html (0 => 201852)
--- trunk/LayoutTests/fast/workers/DedicatedWorkerGlobalScope-prototype-chain.html (rev 0)
+++ trunk/LayoutTests/fast/workers/DedicatedWorkerGlobalScope-prototype-chain.html 2016-06-09 05:18:38 UTC (rev 201852)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<script src=""
+<script src=""
+<script>
+
+var jsTestIsAsync = true;
+
+description("Tests that DedicatedWorkerGlobalScope's prototype chain is correct.");
+
+var worker = createWorker();
+worker.postMessage("eval DedicatedWorkerGlobalScope.prototype.toString() === \"[object DedicatedWorkerGlobalScopePrototype]\"");
+worker.postMessage("eval Object.getPrototypeOf(DedicatedWorkerGlobalScope.prototype) === WorkerGlobalScope.prototype");
+worker.postMessage("eval WorkerGlobalScope.prototype.toString() === \"[object WorkerGlobalScopePrototype]\"");
+worker.postMessage("eval Object.getPrototypeOf(WorkerGlobalScope.prototype) === EventTarget.prototype");
+worker.postMessage("eval DONE");
+
+worker._onmessage_ = function(evt) {
+ if (!/DONE/.test(evt.data))
+ debug(evt.data.replace(new RegExp("/.*LayoutTests"), "<...>"));
+ else
+ finishJSTest();
+};
+
+</script>
+<script src=""
Modified: trunk/Source/WebCore/ChangeLog (201851 => 201852)
--- trunk/Source/WebCore/ChangeLog 2016-06-09 05:09:42 UTC (rev 201851)
+++ trunk/Source/WebCore/ChangeLog 2016-06-09 05:18:38 UTC (rev 201852)
@@ -1,3 +1,43 @@
+2016-06-08 Chris Dumez <[email protected]>
+
+ DedicatedWorkerGlobalScope prototype chain is incorrect
+ https://bugs.webkit.org/show_bug.cgi?id=158544
+
+ Reviewed by Brady Eidson.
+
+ There were several issues with the prototype chain of DedicatedWorkerGlobalScope:
+ 1. Object.getPrototypeOf(DedicatedWorkerGlobalScope.prototype) was not
+ WorkerGlobalScope.prototype.
+ 2. WorkerGlobalScope.prototype was a DedicatedWorkerGlobalScopePrototype
+ object and was equal to DedicatedWorkerGlobalScope.prototype.
+ 3. Object.getPrototypeOf(WorkerGlobalScope.prototype) was not EventTarget.prototype.
+
+ Those issues were identified by the following W3C web-platform-test:
+ http://w3c-test.org/workers/interfaces.worker
+
+ This patch fixes the issue so that the prototype chain is now as per the
+ specification.
+
+ Test: fast/workers/DedicatedWorkerGlobalScope-prototype-chain.html
+
+ * bindings/js/WorkerScriptController.cpp:
+ (WebCore::WorkerScriptController::initScript):
+ - Stop creating the WorkerGlobalScopePrototype and let JSWorkerGlobalScope
+ create it.
+ - Set DedicatedWorkerGlobalScopePrototype's prototype to JSWorkerGlobalScope's
+ prototype after creating the JSDedicatedWorkerGlobalScope object.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (ShouldUseGlobalObjectPrototype):
+ (GenerateHeader):
+ (GenerateImplementation):
+ (GenerateConstructorHelperMethods):
+ - Do not use globalObject.getPrototypeDirect() as 'prototype' property for
+ WorkerGlobalScope. The globalObject is a DedicatedWorkerGlobalScope, not
+ a WorkerGlobalScope.
+ - Generate the code to create / get a prototype object for WorkerGlobalScope.
+
+
2016-06-08 Adam Bergkvist <[email protected]>
WebRTC: Imlement MediaEndpointPeerConnection::setRemoteDescription()
Modified: trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp (201851 => 201852)
--- trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp 2016-06-09 05:09:42 UTC (rev 201851)
+++ trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp 2016-06-09 05:18:38 UTC (rev 201852)
@@ -81,24 +81,19 @@
// Explicitly protect the global object's prototype so it isn't collected
// when we allocate the global object. (Once the global object is fully
// constructed, it can mark its own prototype.)
- Structure* workerGlobalScopePrototypeStructure = JSWorkerGlobalScopePrototype::createStructure(*m_vm, 0, jsNull());
- Strong<JSWorkerGlobalScopePrototype> workerGlobalScopePrototype(*m_vm, JSWorkerGlobalScopePrototype::create(*m_vm, 0, workerGlobalScopePrototypeStructure));
-
if (m_workerGlobalScope->isDedicatedWorkerGlobalScope()) {
- Structure* dedicatedContextPrototypeStructure = JSDedicatedWorkerGlobalScopePrototype::createStructure(*m_vm, 0, workerGlobalScopePrototype.get());
+ Structure* dedicatedContextPrototypeStructure = JSDedicatedWorkerGlobalScopePrototype::createStructure(*m_vm, 0, jsNull());
Strong<JSDedicatedWorkerGlobalScopePrototype> dedicatedContextPrototype(*m_vm, JSDedicatedWorkerGlobalScopePrototype::create(*m_vm, 0, dedicatedContextPrototypeStructure));
Structure* structure = JSDedicatedWorkerGlobalScope::createStructure(*m_vm, 0, dedicatedContextPrototype.get());
auto* proxyStructure = JSProxy::createStructure(*m_vm, nullptr, jsNull(), PureForwardingProxyType);
auto* proxy = JSProxy::create(*m_vm, proxyStructure);
m_workerGlobalScopeWrapper.set(*m_vm, JSDedicatedWorkerGlobalScope::create(*m_vm, structure, static_cast<DedicatedWorkerGlobalScope&>(*m_workerGlobalScope), proxy));
- workerGlobalScopePrototypeStructure->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get());
dedicatedContextPrototypeStructure->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get());
ASSERT(structure->globalObject() == m_workerGlobalScopeWrapper);
ASSERT(m_workerGlobalScopeWrapper->structure()->globalObject() == m_workerGlobalScopeWrapper);
- workerGlobalScopePrototype->structure()->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get());
- workerGlobalScopePrototype->structure()->setPrototypeWithoutTransition(*m_vm, JSEventTarget::prototype(*m_vm, m_workerGlobalScopeWrapper.get()));
dedicatedContextPrototype->structure()->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get());
+ dedicatedContextPrototype->structure()->setPrototypeWithoutTransition(*m_vm, JSWorkerGlobalScope::prototype(*m_vm, m_workerGlobalScopeWrapper.get()));
proxy->setTarget(*m_vm, m_workerGlobalScopeWrapper.get());
proxy->structure()->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get());
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (201851 => 201852)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-06-09 05:09:42 UTC (rev 201851)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-06-09 05:18:38 UTC (rev 201852)
@@ -270,6 +270,16 @@
return $interface->name eq "DOMWindow" || $codeGenerator->InheritsInterface($interface, "WorkerGlobalScope") || $interface->name eq "TestGlobalObject";
}
+sub ShouldUseGlobalObjectPrototype
+{
+ my $interface = shift;
+
+ # For workers, the global object is a DedicatedWorkerGlobalScope.
+ return 0 if $interface->name eq "WorkerGlobalScope";
+
+ return IsDOMGlobalObject($interface);
+}
+
sub GenerateGetOwnPropertySlotBody
{
my ($interface, $className, $inlined) = @_;
@@ -1146,7 +1156,7 @@
}
# Prototype
- unless (IsDOMGlobalObject($interface)) {
+ unless (ShouldUseGlobalObjectPrototype($interface)) {
push(@headerContent, " static JSC::JSObject* createPrototype(JSC::VM&, JSC::JSGlobalObject*);\n");
push(@headerContent, " static JSC::JSObject* prototype(JSC::VM&, JSC::JSGlobalObject*);\n");
}
@@ -2400,11 +2410,14 @@
push(@implContent, "#endif\n") if $conditionalString;
}
push(@implContent, "}\n\n");
- } else {
+ }
+
+ unless (ShouldUseGlobalObjectPrototype($interface)) {
push(@implContent, "JSObject* ${className}::createPrototype(VM& vm, JSGlobalObject* globalObject)\n");
push(@implContent, "{\n");
- if ($hasParent && $parentClassName ne "JSC::DOMNodeFilter") {
- push(@implContent, " return ${className}Prototype::create(vm, globalObject, ${className}Prototype::createStructure(vm, globalObject, ${parentClassName}::prototype(vm, globalObject)));\n");
+ if ($interface->parent) {
+ my $parentClassNameForPrototype = "JS" . $interface->parent;
+ push(@implContent, " return ${className}Prototype::create(vm, globalObject, ${className}Prototype::createStructure(vm, globalObject, ${parentClassNameForPrototype}::prototype(vm, globalObject)));\n");
} else {
my $prototype = $interface->isException ? "errorPrototype" : "objectPrototype";
push(@implContent, " return ${className}Prototype::create(vm, globalObject, ${className}Prototype::createStructure(vm, globalObject, globalObject->${prototype}()));\n");
@@ -5182,7 +5195,7 @@
# There must exist an interface prototype object for every non-callback interface defined, regardless
# of whether the interface was declared with the [NoInterfaceObject] extended attribute.
# https://heycam.github.io/webidl/#interface-prototype-object
- if (IsDOMGlobalObject($interface)) {
+ if (ShouldUseGlobalObjectPrototype($interface)) {
push(@$outputArray, " putDirect(vm, vm.propertyNames->prototype, globalObject.getPrototypeDirect(), DontDelete | ReadOnly | DontEnum);\n");
} elsif ($interface->isCallback) {
push(@$outputArray, " UNUSED_PARAM(globalObject);\n");