Diff
Modified: trunk/LayoutTests/ChangeLog (204480 => 204481)
--- trunk/LayoutTests/ChangeLog 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/LayoutTests/ChangeLog 2016-08-15 21:08:25 UTC (rev 204481)
@@ -1,3 +1,38 @@
+2016-08-15 Jiewen Tan <[email protected]>
+
+ Expose crypto.getRandomValues to Web Workers
+ https://bugs.webkit.org/show_bug.cgi?id=104851
+ <rdar://problem/27285714>
+
+ Reviewed by Darin Adler.
+
+ * 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:
+
2016-08-15 Ryan Haddad <[email protected]>
Rebaseline js/dom/global-constructors-attributes.html for mac-wk1, mark as failing on Yosemite.
Modified: trunk/LayoutTests/crypto/crypto-random-values-limits.html (204480 => 204481)
--- trunk/LayoutTests/crypto/crypto-random-values-limits.html 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/LayoutTests/crypto/crypto-random-values-limits.html 2016-08-15 21:08:25 UTC (rev 204481)
@@ -2,7 +2,6 @@
<html>
<head>
<script src=""
-<script src=""
</head>
<body>
<p id="description"></p>
Modified: trunk/LayoutTests/crypto/crypto-random-values-types.html (204480 => 204481)
--- trunk/LayoutTests/crypto/crypto-random-values-types.html 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/LayoutTests/crypto/crypto-random-values-types.html 2016-08-15 21:08:25 UTC (rev 204481)
@@ -2,7 +2,6 @@
<html>
<head>
<script src=""
-<script src=""
</head>
<body>
<p id="description"></p>
Modified: trunk/LayoutTests/crypto/crypto-random-values.html (204480 => 204481)
--- trunk/LayoutTests/crypto/crypto-random-values.html 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/LayoutTests/crypto/crypto-random-values.html 2016-08-15 21:08:25 UTC (rev 204481)
@@ -2,7 +2,6 @@
<html>
<head>
<script src=""
-<script src=""
</head>
<body>
<p id="description"></p>
Added: trunk/LayoutTests/crypto/webkitSubtle/disallowed-in-worker-expected.txt (0 => 204481)
--- trunk/LayoutTests/crypto/webkitSubtle/disallowed-in-worker-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/webkitSubtle/disallowed-in-worker-expected.txt 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,11 @@
+[Worker] Tests that crypto.webkitSubtle will throw in workers.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/disallowed-in-worker.js
+PASS [Worker] crypto.webkitSubtle threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/webkitSubtle/disallowed-in-worker.html (0 => 204481)
--- trunk/LayoutTests/crypto/webkitSubtle/disallowed-in-worker.html (rev 0)
+++ trunk/LayoutTests/crypto/webkitSubtle/disallowed-in-worker.html 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/disallowed-in-worker.js');
+ </script>
+ <script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/webkitSubtle/resources/disallowed-in-worker.js (0 => 204481)
--- trunk/LayoutTests/crypto/webkitSubtle/resources/disallowed-in-worker.js (rev 0)
+++ trunk/LayoutTests/crypto/webkitSubtle/resources/disallowed-in-worker.js 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,7 @@
+importScripts('../../../resources/js-test-pre.js');
+
+description("Tests that crypto.webkitSubtle will throw in workers.");
+
+shouldThrow("crypto.webkitSubtle", "'NotSupportedError (DOM Exception 9): The operation is not supported.'");
+
+finishJSTest();
Added: trunk/LayoutTests/crypto/workers/crypto-gc-worker-expected.txt (0 => 204481)
--- trunk/LayoutTests/crypto/workers/crypto-gc-worker-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/workers/crypto-gc-worker-expected.txt 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,11 @@
+[Worker] Test that self.crypto wrapper preserves custom properties.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/crypto-gc-worker.js
+PASS [Worker] self.crypto.foo is "bar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/workers/crypto-gc-worker.html (0 => 204481)
--- trunk/LayoutTests/crypto/workers/crypto-gc-worker.html (rev 0)
+++ trunk/LayoutTests/crypto/workers/crypto-gc-worker.html 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/crypto-gc-worker.js');
+ </script>
+ <script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/workers/crypto-random-values-limits-worker-expected.txt (0 => 204481)
--- trunk/LayoutTests/crypto/workers/crypto-random-values-limits-worker-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/workers/crypto-random-values-limits-worker-expected.txt 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,14 @@
+[Worker] Tests the limits of crypto.randomValues.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/crypto-random-limits-worker.js
+PASS [Worker] 'crypto' in self is true
+PASS [Worker] 'getRandomValues' in self.crypto is true
+PASS [Worker] crypto.getRandomValues(almostTooLargeArray) did not throw exception.
+PASS [Worker] crypto.getRandomValues(tooLargeArray) threw exception QuotaExceededError (DOM Exception 22): The quota has been exceeded..
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/workers/crypto-random-values-limits-worker.html (0 => 204481)
--- trunk/LayoutTests/crypto/workers/crypto-random-values-limits-worker.html (rev 0)
+++ trunk/LayoutTests/crypto/workers/crypto-random-values-limits-worker.html 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/crypto-random-limits-worker.js');
+ </script>
+ <script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/workers/crypto-random-values-types-worker-expected.txt (0 => 204481)
--- trunk/LayoutTests/crypto/workers/crypto-random-values-types-worker-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/workers/crypto-random-values-types-worker-expected.txt 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,53 @@
+[Worker] Tests which types are valid for crypto.randomValues.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/crypto-random-values-types-worker.js
+PASS [Worker] 'crypto' in self is true
+PASS [Worker] 'getRandomValues' in self.crypto is true
+PASS [Worker] random = crypto.getRandomValues(new Uint8Array(3)) is defined.
+PASS [Worker] random is an instance of Uint8Array
+PASS [Worker] view = new Uint8Array(3) is defined.
+PASS [Worker] random = crypto.getRandomValues(view) is defined.
+PASS [Worker] random is view
+PASS [Worker] random = crypto.getRandomValues(new Int8Array(3)) is defined.
+PASS [Worker] random is an instance of Int8Array
+PASS [Worker] view = new Int8Array(3) is defined.
+PASS [Worker] random = crypto.getRandomValues(view) is defined.
+PASS [Worker] random is view
+PASS [Worker] random = crypto.getRandomValues(new Uint8ClampedArray(3)) is defined.
+PASS [Worker] random is an instance of Uint8ClampedArray
+PASS [Worker] view = new Uint8ClampedArray(3) is defined.
+PASS [Worker] random = crypto.getRandomValues(view) is defined.
+PASS [Worker] random is view
+PASS [Worker] random = crypto.getRandomValues(new Uint16Array(3)) is defined.
+PASS [Worker] random is an instance of Uint16Array
+PASS [Worker] view = new Uint16Array(3) is defined.
+PASS [Worker] random = crypto.getRandomValues(view) is defined.
+PASS [Worker] random is view
+PASS [Worker] random = crypto.getRandomValues(new Int16Array(3)) is defined.
+PASS [Worker] random is an instance of Int16Array
+PASS [Worker] view = new Int16Array(3) is defined.
+PASS [Worker] random = crypto.getRandomValues(view) is defined.
+PASS [Worker] random is view
+PASS [Worker] random = crypto.getRandomValues(new Uint32Array(3)) is defined.
+PASS [Worker] random is an instance of Uint32Array
+PASS [Worker] view = new Uint32Array(3) is defined.
+PASS [Worker] random = crypto.getRandomValues(view) is defined.
+PASS [Worker] random is view
+PASS [Worker] random = crypto.getRandomValues(new Int32Array(3)) is defined.
+PASS [Worker] random is an instance of Int32Array
+PASS [Worker] view = new Int32Array(3) is defined.
+PASS [Worker] random = crypto.getRandomValues(view) is defined.
+PASS [Worker] random is view
+PASS [Worker] crypto.getRandomValues(new Float32Array(3)) threw exception TypeMismatchError (DOM Exception 17): The type of an object was incompatible with the expected type of the parameter associated to the object..
+PASS [Worker] crypto.getRandomValues(new Float64Array(3)) threw exception TypeMismatchError (DOM Exception 17): The type of an object was incompatible with the expected type of the parameter associated to the object..
+PASS [Worker] buffer = new Uint8Array(32) is defined.
+PASS [Worker] buffer.buffer is defined.
+PASS [Worker] view = new DataView(buffer.buffer) is defined.
+PASS [Worker] crypto.getRandomValues(view) threw exception TypeMismatchError (DOM Exception 17): The type of an object was incompatible with the expected type of the parameter associated to the object..
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/workers/crypto-random-values-types-worker.html (0 => 204481)
--- trunk/LayoutTests/crypto/workers/crypto-random-values-types-worker.html (rev 0)
+++ trunk/LayoutTests/crypto/workers/crypto-random-values-types-worker.html 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/crypto-random-values-types-worker.js');
+ </script>
+ <script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/workers/crypto-random-values-worker-expected.txt (0 => 204481)
--- trunk/LayoutTests/crypto/workers/crypto-random-values-worker-expected.txt (rev 0)
+++ trunk/LayoutTests/crypto/workers/crypto-random-values-worker-expected.txt 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,13 @@
+[Worker] Tests crypto.randomValues.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/crypto-random-values-worker.js
+PASS [Worker] 'crypto' in self is true
+PASS [Worker] 'getRandomValues' in self.crypto is true
+PASS [Worker] matchingBytes < 100 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/crypto/workers/crypto-random-values-worker.html (0 => 204481)
--- trunk/LayoutTests/crypto/workers/crypto-random-values-worker.html (rev 0)
+++ trunk/LayoutTests/crypto/workers/crypto-random-values-worker.html 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/crypto-random-values-worker.js');
+ </script>
+ <script src=""
+</body>
+</html>
Added: trunk/LayoutTests/crypto/workers/resources/crypto-gc-worker.js (0 => 204481)
--- trunk/LayoutTests/crypto/workers/resources/crypto-gc-worker.js (rev 0)
+++ trunk/LayoutTests/crypto/workers/resources/crypto-gc-worker.js 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,26 @@
+importScripts('../../../resources/js-test-pre.js');
+
+description("Test that self.crypto wrapper preserves custom properties.");
+jsTestIsAsync = true;
+
+function startTest()
+{
+ self.crypto.foo = "bar";
+ gc();
+ setTimeout(continueTest, 10);
+}
+
+function continueTest()
+{
+ gc();
+ setTimeout(finishTest, 10);
+}
+
+function finishTest()
+{
+ gc();
+ shouldBe('self.crypto.foo', '"bar"');
+ finishJSTest();
+}
+
+startTest();
Added: trunk/LayoutTests/crypto/workers/resources/crypto-random-limits-worker.js (0 => 204481)
--- trunk/LayoutTests/crypto/workers/resources/crypto-random-limits-worker.js (rev 0)
+++ trunk/LayoutTests/crypto/workers/resources/crypto-random-limits-worker.js 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,18 @@
+importScripts('../../../resources/js-test-pre.js');
+
+description("Tests the limits of crypto.randomValues.");
+
+shouldBe("'crypto' in self", "true");
+shouldBe("'getRandomValues' in self.crypto", "true");
+
+try {
+ var almostTooLargeArray = new Uint8Array(65536);
+ var tooLargeArray = new Uint8Array(65537);
+
+ shouldNotThrow("crypto.getRandomValues(almostTooLargeArray)");
+ shouldThrow("crypto.getRandomValues(tooLargeArray)");
+} catch(ex) {
+ debug(ex);
+}
+
+finishJSTest();
Copied: trunk/LayoutTests/crypto/workers/resources/crypto-random-values-types-worker.js (from rev 204480, trunk/LayoutTests/crypto/crypto-random-values-types.html) (0 => 204481)
--- trunk/LayoutTests/crypto/workers/resources/crypto-random-values-types-worker.js (rev 0)
+++ trunk/LayoutTests/crypto/workers/resources/crypto-random-values-types-worker.js 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,41 @@
+importScripts('../../../resources/js-test-pre.js');
+
+description("Tests which types are valid for crypto.randomValues.");
+
+shouldBe("'crypto' in self", "true");
+shouldBe("'getRandomValues' in self.crypto", "true");
+
+function checkIntegerTypes() {
+ var integerTypes = [
+ "Uint8Array", "Int8Array", "Uint8ClampedArray",
+ "Uint16Array", "Int16Array",
+ "Uint32Array", "Int32Array",
+ ];
+ integerTypes.forEach(function(arrayType) {
+ shouldBeDefined("random = crypto.getRandomValues(new "+arrayType+"(3))");
+ shouldBeType("random", arrayType);
+
+ shouldBeDefined("view = new "+arrayType+"(3)");
+ shouldBeDefined("random = crypto.getRandomValues(view)");
+ shouldBe("random", "view");
+ });
+}
+
+function checkNonIntegerTypes() {
+ var floatTypes = [
+ "Float32Array", "Float64Array",
+ ];
+ floatTypes.forEach(function(arrayType) {
+ shouldThrow("crypto.getRandomValues(new "+arrayType+"(3))");
+ });
+
+ shouldBeDefined("buffer = new Uint8Array(32)");
+ shouldBeDefined("buffer.buffer");
+ shouldBeDefined("view = new DataView(buffer.buffer)");
+ shouldThrow("crypto.getRandomValues(view)");
+}
+
+checkIntegerTypes();
+checkNonIntegerTypes();
+
+finishJSTest();
Copied: trunk/LayoutTests/crypto/workers/resources/crypto-random-values-worker.js (from rev 204480, trunk/LayoutTests/crypto/crypto-random-values.html) (0 => 204481)
--- trunk/LayoutTests/crypto/workers/resources/crypto-random-values-worker.js (rev 0)
+++ trunk/LayoutTests/crypto/workers/resources/crypto-random-values-worker.js 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,31 @@
+importScripts('../../../resources/js-test-pre.js');
+
+description("Tests crypto.randomValues.");
+
+shouldBe("'crypto' in self", "true");
+shouldBe("'getRandomValues' in self.crypto", "true");
+
+try {
+ // FIXME: This test is flaky. If we ran this test every second since the
+ // beginning of the universe, on average, it would have failed
+ // 2^{-748} times.
+
+ var reference = new Uint8Array(100);
+ var sample = new Uint8Array(100);
+
+ crypto.getRandomValues(reference);
+ crypto.getRandomValues(sample);
+
+ var matchingBytes = 0;
+
+ for (var i = 0; i < reference.length; i++) {
+ if (reference[i] == sample[i])
+ matchingBytes++;
+ }
+
+ shouldBe("matchingBytes < 100", "true");
+} catch(ex) {
+ debug(ex);
+}
+
+finishJSTest();
Modified: trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt (204480 => 204481)
--- trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/LayoutTests/js/dom/global-constructors-attributes-dedicated-worker-expected.txt 2016-08-15 21:08:25 UTC (rev 204481)
@@ -34,6 +34,11 @@
PASS [Worker] Object.getOwnPropertyDescriptor(global, 'CountQueuingStrategy').hasOwnProperty('set') is false
PASS [Worker] Object.getOwnPropertyDescriptor(global, 'CountQueuingStrategy').enumerable is false
PASS [Worker] Object.getOwnPropertyDescriptor(global, 'CountQueuingStrategy').configurable is true
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Crypto').value is Crypto
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Crypto').hasOwnProperty('get') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Crypto').hasOwnProperty('set') is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Crypto').enumerable is false
+PASS [Worker] Object.getOwnPropertyDescriptor(global, 'Crypto').configurable is true
PASS [Worker] Object.getOwnPropertyDescriptor(global, 'DOMException').value is DOMException
PASS [Worker] Object.getOwnPropertyDescriptor(global, 'DOMException').hasOwnProperty('get') is false
PASS [Worker] Object.getOwnPropertyDescriptor(global, 'DOMException').hasOwnProperty('set') is false
Modified: trunk/Source/WebCore/CMakeLists.txt (204480 => 204481)
--- trunk/Source/WebCore/CMakeLists.txt 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-08-15 21:08:25 UTC (rev 204481)
@@ -604,6 +604,7 @@
page/DOMSelection.idl
page/DOMWindow.idl
page/EventSource.idl
+ page/GlobalCrypto.idl
page/History.idl
page/Location.idl
page/Navigator.idl
Modified: trunk/Source/WebCore/ChangeLog (204480 => 204481)
--- trunk/Source/WebCore/ChangeLog 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/ChangeLog 2016-08-15 21:08:25 UTC (rev 204481)
@@ -1,3 +1,57 @@
+2016-08-15 Jiewen Tan <[email protected]>
+
+ Expose crypto.getRandomValues to Web Workers
+ https://bugs.webkit.org/show_bug.cgi?id=104851
+ <rdar://problem/27285714>
+
+ Reviewed by Darin Adler.
+
+ 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.
+
2016-08-15 Joseph Pecoraro <[email protected]>
Use #pragma once in inspector headers
Modified: trunk/Source/WebCore/DerivedSources.cpp (204480 => 204481)
--- trunk/Source/WebCore/DerivedSources.cpp 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/DerivedSources.cpp 2016-08-15 21:08:25 UTC (rev 204481)
@@ -210,6 +210,7 @@
#endif
#include "JSGeolocation.cpp"
#include "JSGeoposition.cpp"
+#include "JSGlobalCrypto.cpp"
#include "JSGlobalEventHandlers.cpp"
#include "JSHashChangeEvent.cpp"
#include "JSHistory.cpp"
Modified: trunk/Source/WebCore/DerivedSources.make (204480 => 204481)
--- trunk/Source/WebCore/DerivedSources.make 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/DerivedSources.make 2016-08-15 21:08:25 UTC (rev 204481)
@@ -513,6 +513,7 @@
$(WebCore)/page/DOMSelection.idl \
$(WebCore)/page/DOMWindow.idl \
$(WebCore)/page/EventSource.idl \
+ $(WebCore)/page/GlobalCrypto.idl \
$(WebCore)/page/History.idl \
$(WebCore)/page/Location.idl \
$(WebCore)/page/Navigator.idl \
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (204480 => 204481)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-08-15 21:08:25 UTC (rev 204481)
@@ -9709,6 +9709,7 @@
5709E8CC1D413CE3003244AC /* WebKitSubtleCrypto.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebKitSubtleCrypto.idl; sourceTree = "<group>"; };
572A7F201C6E5719009C6149 /* SimulatedClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedClick.h; sourceTree = "<group>"; };
572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedClick.cpp; sourceTree = "<group>"; };
+ 574D42791D594FF6002CF50E /* GlobalCrypto.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = GlobalCrypto.idl; sourceTree = "<group>"; };
57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecReplacement.h; sourceTree = "<group>"; };
57EF5E611D20D28700171E60 /* TextCodecReplacement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCodecReplacement.cpp; sourceTree = "<group>"; };
5803715F1A66F00A00BAF519 /* ClipRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClipRect.cpp; sourceTree = "<group>"; };
@@ -18199,6 +18200,7 @@
65A21483097A3F5300B9050A /* FrameTree.h */,
65CBFEF70974F607001DAC25 /* FrameView.cpp */,
65CBFEF80974F607001DAC25 /* FrameView.h */,
+ 574D42791D594FF6002CF50E /* GlobalCrypto.idl */,
BC94D1500C275C8B006BC617 /* History.cpp */,
BC94D1510C275C8B006BC617 /* History.h */,
BC94D1520C275C8B006BC617 /* History.idl */,
Modified: trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp (204480 => 204481)
--- trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp 2016-08-15 21:08:25 UTC (rev 204481)
@@ -141,4 +141,9 @@
}
#endif
+void JSDocument::visitAdditionalChildren(SlotVisitor& visitor)
+{
+ visitor.addOpaqueRoot(wrapped().scriptExecutionContext());
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp (204480 => 204481)
--- trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp 2016-08-15 21:08:25 UTC (rev 204481)
@@ -57,6 +57,7 @@
visitor.addOpaqueRoot(location);
if (WorkerNavigator* navigator = wrapped().optionalNavigator())
visitor.addOpaqueRoot(navigator);
+ visitor.addOpaqueRoot(wrapped().scriptExecutionContext());
}
JSValue JSWorkerGlobalScope::importScripts(ExecState& state)
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (204480 => 204481)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-08-15 21:08:25 UTC (rev 204481)
@@ -3534,6 +3534,10 @@
$implIncludes{"Element.h"} = 1;
$implIncludes{"JSNodeCustom.h"} = 1;
$rootString = " void* root = WebCore::root(js${interfaceName}->wrapped().ownerNode());\n";
+ } elsif (GetGenerateIsReachable($interface) eq "ImplScriptExecutionContext") {
+ $rootString = " ScriptExecutionContext* root = WTF::getPtr(js${interfaceName}->wrapped().scriptExecutionContext());\n";
+ $rootString .= " if (!root)\n";
+ $rootString .= " return false;\n";
} else {
$rootString = " void* root = WebCore::root(&js${interfaceName}->wrapped());\n";
}
Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (204480 => 204481)
--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2016-08-15 21:08:25 UTC (rev 204481)
@@ -62,7 +62,7 @@
ExportMacro=WEBCORE_EXPORT|WEBCORE_TESTSUPPORT_EXPORT
Exposed=*
ForwardDeclareInHeader
-GenerateIsReachable=|Impl|ImplWebGLRenderingContext|ImplDocument|ImplElementRoot|ImplFrame|ImplOwnerNodeRoot
+GenerateIsReachable=|Impl|ImplWebGLRenderingContext|ImplDocument|ImplElementRoot|ImplFrame|ImplOwnerNodeRoot|ImplScriptExecutionContext
GetterRaisesException
GetterRaisesExceptionWithMessage
Immutable
Modified: trunk/Source/WebCore/dom/Document.idl (204480 => 204481)
--- trunk/Source/WebCore/dom/Document.idl 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/dom/Document.idl 2016-08-15 21:08:25 UTC (rev 204481)
@@ -22,9 +22,10 @@
Constructor,
ConstructorCallWith=ScriptExecutionContext,
CustomToJSObject,
+ ExportMacro=WEBCORE_EXPORT,
JSCustomHeader,
+ JSCustomMarkFunction,
JSGenerateToNativeObject,
- ExportMacro=WEBCORE_EXPORT,
] interface Document : Node {
// DOM Level 1 Core
Modified: trunk/Source/WebCore/page/Crypto.cpp (204480 => 204481)
--- trunk/Source/WebCore/page/Crypto.cpp 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/page/Crypto.cpp 2016-08-15 21:08:25 UTC (rev 204481)
@@ -39,8 +39,8 @@
namespace WebCore {
-Crypto::Crypto(Document& document)
- : ContextDestructionObserver(&document)
+Crypto::Crypto(ScriptExecutionContext& context)
+ : ContextDestructionObserver(&context)
{
}
@@ -48,11 +48,6 @@
{
}
-Document* Crypto::document() const
-{
- return downcast<Document>(scriptExecutionContext());
-}
-
void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
{
if (!array || !JSC::isInt(array->getType())) {
@@ -67,11 +62,15 @@
}
#if ENABLE(SUBTLE_CRYPTO)
-WebKitSubtleCrypto* Crypto::webkitSubtle()
+WebKitSubtleCrypto* Crypto::webkitSubtle(ExceptionCode& ec)
{
- ASSERT(isMainThread());
+ if (!isMainThread()) {
+ ec = NOT_SUPPORTED_ERR;
+ return 0;
+ }
+
if (!m_webkitSubtle)
- m_webkitSubtle = WebKitSubtleCrypto::create(*document());
+ m_webkitSubtle = WebKitSubtleCrypto::create(*downcast<Document>(scriptExecutionContext()));
return m_webkitSubtle.get();
}
Modified: trunk/Source/WebCore/page/Crypto.h (204480 => 204481)
--- trunk/Source/WebCore/page/Crypto.h 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/page/Crypto.h 2016-08-15 21:08:25 UTC (rev 204481)
@@ -48,19 +48,17 @@
class Crypto : public ContextDestructionObserver, public RefCounted<Crypto> {
public:
- static Ref<Crypto> create(Document& document) { return adoptRef(*new Crypto(document)); }
+ static Ref<Crypto> create(ScriptExecutionContext& context) { return adoptRef(*new Crypto(context)); }
virtual ~Crypto();
- Document* document() const;
-
void getRandomValues(JSC::ArrayBufferView*, ExceptionCode&);
#if ENABLE(SUBTLE_CRYPTO)
- WebKitSubtleCrypto* webkitSubtle();
+ WebKitSubtleCrypto* webkitSubtle(ExceptionCode&);
#endif
private:
- Crypto(Document&);
+ Crypto(ScriptExecutionContext&);
#if ENABLE(SUBTLE_CRYPTO)
RefPtr<WebKitSubtleCrypto> m_webkitSubtle;
Modified: trunk/Source/WebCore/page/Crypto.idl (204480 => 204481)
--- trunk/Source/WebCore/page/Crypto.idl 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/page/Crypto.idl 2016-08-15 21:08:25 UTC (rev 204481)
@@ -28,9 +28,10 @@
*/
[
- GenerateIsReachable=ImplDocument,
+ Exposed=(Window,Worker),
+ GenerateIsReachable=ImplScriptExecutionContext,
] interface Crypto {
[Custom, RaisesException] ArrayBufferView getRandomValues(ArrayBufferView array);
- [Conditional=SUBTLE_CRYPTO] readonly attribute WebKitSubtleCrypto webkitSubtle;
+ [Conditional=SUBTLE_CRYPTO, GetterRaisesException] readonly attribute WebKitSubtleCrypto webkitSubtle;
};
Modified: trunk/Source/WebCore/page/DOMWindow.idl (204480 => 204481)
--- trunk/Source/WebCore/page/DOMWindow.idl 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/page/DOMWindow.idl 2016-08-15 21:08:25 UTC (rev 204481)
@@ -50,7 +50,6 @@
[Replaceable] readonly attribute BarProp toolbar;
readonly attribute Navigator navigator;
[Replaceable] readonly attribute Navigator clientInformation;
- readonly attribute Crypto crypto;
[DoNotCheckSecurity, CustomSetter, Unforgeable] attribute Location location;
[Replaceable, CustomGetter] readonly attribute Event event;
@@ -234,6 +233,7 @@
unrestricted double top;
};
+DOMWindow implements GlobalCrypto;
DOMWindow implements GlobalEventHandlers;
DOMWindow implements WindowEventHandlers;
DOMWindow implements WindowOrWorkerGlobalScope;
Added: trunk/Source/WebCore/page/GlobalCrypto.idl (0 => 204481)
--- trunk/Source/WebCore/page/GlobalCrypto.idl (rev 0)
+++ trunk/Source/WebCore/page/GlobalCrypto.idl 2016-08-15 21:08:25 UTC (rev 204481)
@@ -0,0 +1,30 @@
+/*
+* Copyright (C) 2016 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+[
+ NoInterfaceObject,
+] interface GlobalCrypto {
+ readonly attribute Crypto crypto;
+};
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (204480 => 204481)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2016-08-15 21:08:25 UTC (rev 204481)
@@ -30,6 +30,7 @@
#include "ActiveDOMObject.h"
#include "ContentSecurityPolicy.h"
+#include "Crypto.h"
#include "DOMTimer.h"
#include "DOMURL.h"
#include "DOMWindow.h"
@@ -390,4 +391,11 @@
}
#endif // ENABLE(SUBTLE_CRYPTO)
+Crypto& WorkerGlobalScope::crypto() const
+{
+ if (!m_crypto)
+ m_crypto = Crypto::create(*scriptExecutionContext());
+ return *m_crypto;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.h (204480 => 204481)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.h 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.h 2016-08-15 21:08:25 UTC (rev 204481)
@@ -48,6 +48,7 @@
class Blob;
class ContentSecurityPolicyResponseHeaders;
+class Crypto;
class ScheduledAction;
class WorkerLocation;
class WorkerNavigator;
@@ -148,6 +149,8 @@
bool unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) override;
#endif
+ Crypto& crypto() const;
+
protected:
WorkerGlobalScope(const URL&, const String& userAgent, WorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, RefPtr<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
void applyContentSecurityPolicyResponseHeaders(const ContentSecurityPolicyResponseHeaders&);
@@ -193,6 +196,8 @@
#if ENABLE(WEB_SOCKETS)
RefPtr<SocketProvider> m_socketProvider;
#endif
+
+ mutable RefPtr<Crypto> m_crypto;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.idl (204480 => 204481)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.idl 2016-08-15 21:04:49 UTC (rev 204480)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.idl 2016-08-15 21:08:25 UTC (rev 204481)
@@ -64,4 +64,5 @@
[Conditional=INDEXED_DATABASE_IN_WORKERS, EnabledAtRuntime=IndexedDBWorkers] attribute IDBVersionChangeEventConstructor IDBVersionChangeEvent;
};
+WorkerGlobalScope implements GlobalCrypto;
WorkerGlobalScope implements WindowOrWorkerGlobalScope;