DedicatedWorkerGlobalScope prototype chain is incorrect
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Jun 2016 05:18:38 +0000 (05:18 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Jun 2016 05:18:38 +0000 (05:18 +0000)
commite655aebea0edced6663232eb6d5d4c0049e3cb52
tree822dd61ed00502a48d3836c6ecc2f05abd6e8d54
parentd7cbbf8ae9c44588d189c0acc9c05c69b29133db
DedicatedWorkerGlobalScope prototype chain is incorrect
https://bugs.webkit.org/show_bug.cgi?id=158544

Reviewed by Brady Eidson.

Source/WebCore:

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.

LayoutTests:

Add test coverage for the DedicatedWorkerGlobalScope prototype chain.

* fast/workers/DedicatedWorkerGlobalScope-prototype-chain-expected.txt: Added.
* fast/workers/DedicatedWorkerGlobalScope-prototype-chain.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/workers/DedicatedWorkerGlobalScope-prototype-chain-expected.txt [new file with mode: 0644]
LayoutTests/fast/workers/DedicatedWorkerGlobalScope-prototype-chain.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/WorkerScriptController.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm