Expose crypto.getRandomValues to Web Workers
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Aug 2016 21:08:25 +0000 (21:08 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Aug 2016 21:08:25 +0000 (21:08 +0000)
commitb02df128526006af07b00a0e44e9eb431c426fce
tree2fc77b2d99cf47f45ca032b9eeee2adb274ccdc7
parent60c39392410d0245030773d57209eb9d7e1457f1
Expose crypto.getRandomValues to Web Workers
https://bugs.webkit.org/show_bug.cgi?id=104851
<rdar://problem/27285714>

Reviewed by Darin Adler.

Source/WebCore:

Tests: crypto/webkitSubtle/disallowed-in-worker.html
       crypto/workers/crypto-gc-worker.html
       crypto/workers/crypto-random-values-limits-worker.html
       crypto/workers/crypto-random-values-types-worker.html
       crypto/workers/crypto-random-values-worker.html

Expose both crypto and crypto.getRandomValues to Web Workers. However, webkitSubtle is
disabled in Web Workers. This change also refactors a bit on IDLs related to Crypto
interface.

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
Introduce GlobalCrypto Interface which is used to repalace the partial IDL in both
DOMWindow and WorkerGlobalScope with sub-implememtations.
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::visitAdditionalChildren):
* bindings/js/JSWorkerGlobalScopeCustom.cpp:
(WebCore::JSWorkerGlobalScope::visitAdditionalChildren):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
* bindings/scripts/IDLAttributes.txt:
* dom/Document.idl:
Add support of GenerateIsReachable=ImplScriptExecutionContext, which allow registered
JS Objects to live as long as ScriptExecutionContext lives, i.e. Document and
WorkerGlobalScope.
* page/Crypto.cpp:
(WebCore::Crypto::Crypto):
(WebCore::Crypto::webkitSubtle):
(WebCore::Crypto::document): Deleted.
* page/Crypto.h:
(WebCore::Crypto::create):
* page/Crypto.idl:
Change the opaque root of Crypto to ScriptExecutionContext such that it perserves
the same live time in both Window and Web Worker. And disable WebKitSubtle in Web
Workers.
* page/DOMWindow.idl:
* page/GlobalCrypto.idl: Added.
Replace partial IDL to sub-implementation of crypto attribute.
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::crypto):
* workers/WorkerGlobalScope.h:
* workers/WorkerGlobalScope.idl:
Introduce crypto attribute to Web Workers.

LayoutTests:

* crypto/crypto-random-values-limits.html:
* crypto/crypto-random-values-types.html:
* crypto/crypto-random-values.html:
* crypto/webkitSubtle/disallowed-in-worker-expected.txt: Added.
* crypto/webkitSubtle/disallowed-in-worker.html: Added.
* crypto/webkitSubtle/resources/disallowed-in-worker.js: Added.
* crypto/workers/crypto-gc-worker-expected.txt: Added.
* crypto/workers/crypto-gc-worker.html: Added.
* crypto/workers/crypto-random-values-limits-worker-expected.txt: Added.
* crypto/workers/crypto-random-values-limits-worker.html: Added.
* crypto/workers/crypto-random-values-types-worker-expected.txt: Added.
* crypto/workers/crypto-random-values-types-worker.html: Added.
* crypto/workers/crypto-random-values-worker-expected.txt: Added.
* crypto/workers/crypto-random-values-worker.html: Added.
* crypto/workers/resources/crypto-gc-worker.js: Added.
(startTest):
(continueTest):
(finishTest):
* crypto/workers/resources/crypto-random-limits-worker.js: Added.
(catch):
* crypto/workers/resources/crypto-random-values-types-worker.js: Copied from LayoutTests/crypto/crypto-random-values-types.html.
(checkIntegerTypes):
(checkNonIntegerTypes):
* crypto/workers/resources/crypto-random-values-worker.js: Copied from LayoutTests/crypto/crypto-random-values.html.
(catch):
* js/dom/global-constructors-attributes-dedicated-worker-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204481 268f45cc-cd09-0410-ab3c-d52691b4dbfc
38 files changed:
LayoutTests/ChangeLog
LayoutTests/crypto/crypto-random-values-limits.html
LayoutTests/crypto/crypto-random-values-types.html
LayoutTests/crypto/crypto-random-values.html
LayoutTests/crypto/webkitSubtle/disallowed-in-worker-expected.txt [new file with mode: 0644]
LayoutTests/crypto/webkitSubtle/disallowed-in-worker.html [new file with mode: 0644]
LayoutTests/crypto/webkitSubtle/resources/disallowed-in-worker.js [new file with mode: 0644]
LayoutTests/crypto/workers/crypto-gc-worker-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/crypto-gc-worker.html [new file with mode: 0644]
LayoutTests/crypto/workers/crypto-random-values-limits-worker-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/crypto-random-values-limits-worker.html [new file with mode: 0644]
LayoutTests/crypto/workers/crypto-random-values-types-worker-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/crypto-random-values-types-worker.html [new file with mode: 0644]
LayoutTests/crypto/workers/crypto-random-values-worker-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/crypto-random-values-worker.html [new file with mode: 0644]
LayoutTests/crypto/workers/resources/crypto-gc-worker.js [new file with mode: 0644]
LayoutTests/crypto/workers/resources/crypto-random-limits-worker.js [new file with mode: 0644]
LayoutTests/crypto/workers/resources/crypto-random-values-types-worker.js [new file with mode: 0644]
LayoutTests/crypto/workers/resources/crypto-random-values-worker.js [new file with mode: 0644]
LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.cpp
Source/WebCore/DerivedSources.make
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSDocumentCustom.cpp
Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/dom/Document.idl
Source/WebCore/page/Crypto.cpp
Source/WebCore/page/Crypto.h
Source/WebCore/page/Crypto.idl
Source/WebCore/page/DOMWindow.idl
Source/WebCore/page/GlobalCrypto.idl [new file with mode: 0644]
Source/WebCore/workers/WorkerGlobalScope.cpp
Source/WebCore/workers/WorkerGlobalScope.h
Source/WebCore/workers/WorkerGlobalScope.idl