Changeset 201852 in webkit
- Timestamp:
- Jun 8, 2016 10:18:38 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r201851 r201852 1 2016-06-08 Chris Dumez <cdumez@apple.com> 2 3 DedicatedWorkerGlobalScope prototype chain is incorrect 4 https://bugs.webkit.org/show_bug.cgi?id=158544 5 6 Reviewed by Brady Eidson. 7 8 Add test coverage for the DedicatedWorkerGlobalScope prototype chain. 9 10 * fast/workers/DedicatedWorkerGlobalScope-prototype-chain-expected.txt: Added. 11 * fast/workers/DedicatedWorkerGlobalScope-prototype-chain.html: Added. 12 1 13 2016-06-08 Adam Bergkvist <adam.bergkvist@ericsson.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r201851 r201852 1 2016-06-08 Chris Dumez <cdumez@apple.com> 2 3 DedicatedWorkerGlobalScope prototype chain is incorrect 4 https://bugs.webkit.org/show_bug.cgi?id=158544 5 6 Reviewed by Brady Eidson. 7 8 There were several issues with the prototype chain of DedicatedWorkerGlobalScope: 9 1. Object.getPrototypeOf(DedicatedWorkerGlobalScope.prototype) was not 10 WorkerGlobalScope.prototype. 11 2. WorkerGlobalScope.prototype was a DedicatedWorkerGlobalScopePrototype 12 object and was equal to DedicatedWorkerGlobalScope.prototype. 13 3. Object.getPrototypeOf(WorkerGlobalScope.prototype) was not EventTarget.prototype. 14 15 Those issues were identified by the following W3C web-platform-test: 16 http://w3c-test.org/workers/interfaces.worker 17 18 This patch fixes the issue so that the prototype chain is now as per the 19 specification. 20 21 Test: fast/workers/DedicatedWorkerGlobalScope-prototype-chain.html 22 23 * bindings/js/WorkerScriptController.cpp: 24 (WebCore::WorkerScriptController::initScript): 25 - Stop creating the WorkerGlobalScopePrototype and let JSWorkerGlobalScope 26 create it. 27 - Set DedicatedWorkerGlobalScopePrototype's prototype to JSWorkerGlobalScope's 28 prototype after creating the JSDedicatedWorkerGlobalScope object. 29 30 * bindings/scripts/CodeGeneratorJS.pm: 31 (ShouldUseGlobalObjectPrototype): 32 (GenerateHeader): 33 (GenerateImplementation): 34 (GenerateConstructorHelperMethods): 35 - Do not use globalObject.getPrototypeDirect() as 'prototype' property for 36 WorkerGlobalScope. The globalObject is a DedicatedWorkerGlobalScope, not 37 a WorkerGlobalScope. 38 - Generate the code to create / get a prototype object for WorkerGlobalScope. 39 40 1 41 2016-06-08 Adam Bergkvist <adam.bergkvist@ericsson.com> 2 42 -
trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp
r201808 r201852 82 82 // when we allocate the global object. (Once the global object is fully 83 83 // constructed, it can mark its own prototype.) 84 Structure* workerGlobalScopePrototypeStructure = JSWorkerGlobalScopePrototype::createStructure(*m_vm, 0, jsNull());85 Strong<JSWorkerGlobalScopePrototype> workerGlobalScopePrototype(*m_vm, JSWorkerGlobalScopePrototype::create(*m_vm, 0, workerGlobalScopePrototypeStructure));86 87 84 if (m_workerGlobalScope->isDedicatedWorkerGlobalScope()) { 88 Structure* dedicatedContextPrototypeStructure = JSDedicatedWorkerGlobalScopePrototype::createStructure(*m_vm, 0, workerGlobalScopePrototype.get());85 Structure* dedicatedContextPrototypeStructure = JSDedicatedWorkerGlobalScopePrototype::createStructure(*m_vm, 0, jsNull()); 89 86 Strong<JSDedicatedWorkerGlobalScopePrototype> dedicatedContextPrototype(*m_vm, JSDedicatedWorkerGlobalScopePrototype::create(*m_vm, 0, dedicatedContextPrototypeStructure)); 90 87 Structure* structure = JSDedicatedWorkerGlobalScope::createStructure(*m_vm, 0, dedicatedContextPrototype.get()); … … 93 90 94 91 m_workerGlobalScopeWrapper.set(*m_vm, JSDedicatedWorkerGlobalScope::create(*m_vm, structure, static_cast<DedicatedWorkerGlobalScope&>(*m_workerGlobalScope), proxy)); 95 workerGlobalScopePrototypeStructure->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get());96 92 dedicatedContextPrototypeStructure->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get()); 97 93 ASSERT(structure->globalObject() == m_workerGlobalScopeWrapper); 98 94 ASSERT(m_workerGlobalScopeWrapper->structure()->globalObject() == m_workerGlobalScopeWrapper); 99 workerGlobalScopePrototype->structure()->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get());100 workerGlobalScopePrototype->structure()->setPrototypeWithoutTransition(*m_vm, JSEventTarget::prototype(*m_vm, m_workerGlobalScopeWrapper.get()));101 95 dedicatedContextPrototype->structure()->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get()); 96 dedicatedContextPrototype->structure()->setPrototypeWithoutTransition(*m_vm, JSWorkerGlobalScope::prototype(*m_vm, m_workerGlobalScopeWrapper.get())); 102 97 103 98 proxy->setTarget(*m_vm, m_workerGlobalScopeWrapper.get()); -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r201834 r201852 269 269 my $interface = shift; 270 270 return $interface->name eq "DOMWindow" || $codeGenerator->InheritsInterface($interface, "WorkerGlobalScope") || $interface->name eq "TestGlobalObject"; 271 } 272 273 sub ShouldUseGlobalObjectPrototype 274 { 275 my $interface = shift; 276 277 # For workers, the global object is a DedicatedWorkerGlobalScope. 278 return 0 if $interface->name eq "WorkerGlobalScope"; 279 280 return IsDOMGlobalObject($interface); 271 281 } 272 282 … … 1147 1157 1148 1158 # Prototype 1149 unless ( IsDOMGlobalObject($interface)) {1159 unless (ShouldUseGlobalObjectPrototype($interface)) { 1150 1160 push(@headerContent, " static JSC::JSObject* createPrototype(JSC::VM&, JSC::JSGlobalObject*);\n"); 1151 1161 push(@headerContent, " static JSC::JSObject* prototype(JSC::VM&, JSC::JSGlobalObject*);\n"); … … 2401 2411 } 2402 2412 push(@implContent, "}\n\n"); 2403 } else { 2413 } 2414 2415 unless (ShouldUseGlobalObjectPrototype($interface)) { 2404 2416 push(@implContent, "JSObject* ${className}::createPrototype(VM& vm, JSGlobalObject* globalObject)\n"); 2405 2417 push(@implContent, "{\n"); 2406 if ($hasParent && $parentClassName ne "JSC::DOMNodeFilter") { 2407 push(@implContent, " return ${className}Prototype::create(vm, globalObject, ${className}Prototype::createStructure(vm, globalObject, ${parentClassName}::prototype(vm, globalObject)));\n"); 2418 if ($interface->parent) { 2419 my $parentClassNameForPrototype = "JS" . $interface->parent; 2420 push(@implContent, " return ${className}Prototype::create(vm, globalObject, ${className}Prototype::createStructure(vm, globalObject, ${parentClassNameForPrototype}::prototype(vm, globalObject)));\n"); 2408 2421 } else { 2409 2422 my $prototype = $interface->isException ? "errorPrototype" : "objectPrototype"; … … 5183 5196 # of whether the interface was declared with the [NoInterfaceObject] extended attribute. 5184 5197 # https://heycam.github.io/webidl/#interface-prototype-object 5185 if ( IsDOMGlobalObject($interface)) {5198 if (ShouldUseGlobalObjectPrototype($interface)) { 5186 5199 push(@$outputArray, " putDirect(vm, vm.propertyNames->prototype, globalObject.getPrototypeDirect(), DontDelete | ReadOnly | DontEnum);\n"); 5187 5200 } elsif ($interface->isCallback) {
Note: See TracChangeset
for help on using the changeset viewer.