Commit be84a7a3 authored by ap@apple.com's avatar ap@apple.com

Add an empty window.crypto.webkitSubtle

https://bugs.webkit.org/show_bug.cgi?id=122778

Reviewed by Mark Hahnenberg.

Source/WebCore:

Tests: security/crypto-subtle-gc-2.html
       security/crypto-subtle-gc-3.html
       security/crypto-subtle-gc.html

* DerivedSources.make: Process SubtleCrypto.idl.

* crypto: Added.
* WebCore.xcodeproj/project.pbxproj:
* CMakeLists.txt:
* DerivedSources.make:
* GNUmakefile.am:
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj.filters:

* bindings/js/JSSubtleCryptoCustom.cpp: Added. Empty for now, but we'll certainly
need custom bindings code here.

* crypto/SubtleCrypto.cpp: Added.
(WebCore::SubtleCrypto::SubtleCrypto):
(WebCore::SubtleCrypto::document):
* crypto/SubtleCrypto.h: Added.
* crypto/SubtleCrypto.idl: Added.
* page/Crypto.cpp:
(WebCore::Crypto::subtle):
* page/Crypto.h:
* page/Crypto.idl:

LayoutTests:

* TestExpectations: The feature isn't enabled anywhere yet, so skipping the new tests.

* security/crypto-subtle-gc-2-expected.txt: Added.
* security/crypto-subtle-gc-2.html: Added.
* security/crypto-subtle-gc-3-expected.txt: Added.
* security/crypto-subtle-gc-3.html: Added.
* security/crypto-subtle-gc-expected.txt: Added.
* security/crypto-subtle-gc.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157430 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 67e54e97
2013-10-14 Alexey Proskuryakov <ap@apple.com>
Add an empty window.crypto.webkitSubtle
https://bugs.webkit.org/show_bug.cgi?id=122778
Reviewed by Mark Hahnenberg.
* TestExpectations: The feature isn't enabled anywhere yet, so skipping the new tests.
* security/crypto-subtle-gc-2-expected.txt: Added.
* security/crypto-subtle-gc-2.html: Added.
* security/crypto-subtle-gc-3-expected.txt: Added.
* security/crypto-subtle-gc-3.html: Added.
* security/crypto-subtle-gc-expected.txt: Added.
* security/crypto-subtle-gc.html: Added.
2013-10-14 Alexandru Chiculita <achicu@adobe.com>
The content of the DOM panel for iframes is not updated until the "onload" event
......
......@@ -65,3 +65,7 @@ fast/mediastream/MediaStream-clone.html [ Skip ]
# Skipping it for now, then put it again when the spec decides it
fast/mediastream/MediaStream-onended.html [ Skip ]
# crypto.subtle is not yet enabled on any ports
webkit.org/b/122679 security/crypto-subtle-gc.html [ Skip ]
webkit.org/b/122679 security/crypto-subtle-gc-2.html [ Skip ]
webkit.org/b/122679 security/crypto-subtle-gc-3.html [ Skip ]
Test that window.crypto.subtle wrapper preserves custom properties.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS [object Crypto] is defined.
PASS [object WebKitSubtleCrypto] is defined.
PASS anotherWindowCrypto.webkitSubtle.foo is "bar"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Test that window.crypto.subtle wrapper preserves custom properties.");
jsTestIsAsync = true;
var anotherWindowCrypto;
function startTest()
{
anotherWindowCrypto = frames[0].crypto;
shouldBeDefined(anotherWindowCrypto);
shouldBeDefined(anotherWindowCrypto.webkitSubtle);
anotherWindowCrypto.webkitSubtle.foo = "bar";
document.body.removeChild(document.getElementsByTagName("iframe")[0]);
gc();
setTimeout(continueTest, 10);
}
function continueTest()
{
gc();
setTimeout(finishTest, 10);
}
function finishTest()
{
gc();
shouldBe('anotherWindowCrypto.webkitSubtle.foo', '"bar"');
finishJSTest();
}
window.onload = startTest;
</script>
<iframe src="about:blank"></iframe>
<script src="../resources/js-test-post.js"></script>
</body>
</html>
Test that window.crypto wrapper protects all dependencies, so it can always be used to create crypto.subtle.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS [object Crypto] is defined.
PASS [object WebKitSubtleCrypto] is defined.
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Test that window.crypto wrapper protects all dependencies, so it can always be used to create crypto.subtle.");
jsTestIsAsync = true;
var anotherWindowCrypto;
function startTest()
{
anotherWindowCrypto = frames[0].crypto;
shouldBeDefined(anotherWindowCrypto);
document.body.removeChild(document.getElementsByTagName("iframe")[0]);
gc();
setTimeout(continueTest, 10);
}
function continueTest()
{
gc();
setTimeout(finishTest, 10);
}
function finishTest()
{
gc();
shouldBeDefined(anotherWindowCrypto.webkitSubtle);
finishJSTest();
}
window.onload = startTest;
</script>
<iframe src="about:blank"></iframe>
<script src="../resources/js-test-post.js"></script>
</body>
</html>
Test that window.crypto.subtle wrapper preserves custom properties.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS window.crypto.webkitSubtle.foo is "bar"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Test that window.crypto.subtle wrapper preserves custom properties.");
jsTestIsAsync = true;
function startTest()
{
window.crypto.webkitSubtle.foo = "bar";
gc();
setTimeout(continueTest, 10);
}
function continueTest()
{
gc();
setTimeout(finishTest, 10);
}
function finishTest()
{
gc();
shouldBe('window.crypto.webkitSubtle.foo', '"bar"');
finishJSTest();
}
window.onload = startTest;
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>
......@@ -22,6 +22,7 @@ set(WebCore_INCLUDE_DIRECTORIES
"${WEBCORE_DIR}/bindings/generic"
"${WEBCORE_DIR}/bridge"
"${WEBCORE_DIR}/bridge/c"
"${WEBCORE_DIR}/crypto"
"${WEBCORE_DIR}/css"
"${WEBCORE_DIR}/dom"
"${WEBCORE_DIR}/dom/default"
......@@ -282,6 +283,8 @@ set(WebCore_IDL_FILES
Modules/websockets/CloseEvent.idl
Modules/websockets/WebSocket.idl
crypto/SubtleCrypto.idl
css/CSSCharsetRule.idl
css/CSSFontFaceLoadEvent.idl
css/CSSFontFaceRule.idl
......
2013-10-14 Alexey Proskuryakov <ap@apple.com>
Add an empty window.crypto.webkitSubtle
https://bugs.webkit.org/show_bug.cgi?id=122778
Reviewed by Mark Hahnenberg.
Tests: security/crypto-subtle-gc-2.html
security/crypto-subtle-gc-3.html
security/crypto-subtle-gc.html
* DerivedSources.make: Process SubtleCrypto.idl.
* crypto: Added.
* WebCore.xcodeproj/project.pbxproj:
* CMakeLists.txt:
* DerivedSources.make:
* GNUmakefile.am:
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* bindings/js/JSSubtleCryptoCustom.cpp: Added. Empty for now, but we'll certainly
need custom bindings code here.
* crypto/SubtleCrypto.cpp: Added.
(WebCore::SubtleCrypto::SubtleCrypto):
(WebCore::SubtleCrypto::document):
* crypto/SubtleCrypto.h: Added.
* crypto/SubtleCrypto.idl: Added.
* page/Crypto.cpp:
(WebCore::Crypto::subtle):
* page/Crypto.h:
* page/Crypto.idl:
2013-10-14 Nick Diego Yamane <nick.yamane@openbossa.org>
Remove GestureEvent leftovers from WebCore
......
......@@ -44,6 +44,7 @@ VPATH = \
$(WebCore)/bindings/generic \
$(WebCore)/bindings/js \
$(WebCore)/bindings/objc \
$(WebCore)/crypto \
$(WebCore)/css \
$(WebCore)/dom \
$(WebCore)/editing \
......@@ -197,6 +198,7 @@ BINDING_IDLS = \
$(WebCore)/Modules/webdatabase/WorkerGlobalScopeWebDatabase.idl \
$(WebCore)/Modules/websockets/CloseEvent.idl \
$(WebCore)/Modules/websockets/WebSocket.idl \
$(WebCore)/crypto/SubtleCrypto.idl \
$(WebCore)/css/CSSCharsetRule.idl \
$(WebCore)/css/CSSFontFaceLoadEvent.idl \
$(WebCore)/css/CSSFontFaceRule.idl \
......
......@@ -31,6 +31,7 @@ webcore_cppflags += \
-I$(srcdir)/Source/WebCore/bridge \
-I$(srcdir)/Source/WebCore/bridge/c \
-I$(srcdir)/Source/WebCore/bridge/jsc \
-I$(srcdir)/Source/WebCore/crypto \
-I$(srcdir)/Source/WebCore/css \
-I$(srcdir)/Source/WebCore/dom \
-I$(srcdir)/Source/WebCore/dom/default \
......
......@@ -1295,6 +1295,7 @@ dom_binding_idls += \
$(WebCore)/Modules/webdatabase/WorkerGlobalScopeWebDatabase.idl \
$(WebCore)/Modules/websockets/CloseEvent.idl \
$(WebCore)/Modules/websockets/WebSocket.idl \
$(WebCore)/crypto/SubtleCrypto.idl \
$(WebCore)/css/CSSCharsetRule.idl \
$(WebCore)/css/CSSFontFaceLoadEvent.idl \
$(WebCore)/css/CSSFontFaceRule.idl \
......@@ -2476,6 +2477,7 @@ webcore_sources += \
Source/WebCore/bridge/runtime_root.cpp \
Source/WebCore/bridge/runtime_root.h \
Source/WebCore/config.h \
Source/WebCore/crypto/SubtleCrypto.h \
Source/WebCore/css/BasicShapeFunctions.cpp \
Source/WebCore/css/BasicShapeFunctions.h \
Source/WebCore/css/Counter.h \
......
......@@ -172,6 +172,9 @@
<Filter Include="platform\mock">
<UniqueIdentifier>{35a67667-1c77-4199-bdd3-a0627946846a}</UniqueIdentifier>
</Filter>
<Filter Include="crypto">
<UniqueIdentifier>{02334427-19d6-44c8-a5d1-e1a67a9c4997}</UniqueIdentifier>
</Filter>
<Filter Include="css">
<UniqueIdentifier>{353b76ca-c49a-41da-88da-33dc422325ef}</UniqueIdentifier>
</Filter>
......@@ -8805,6 +8808,9 @@
<ClInclude Include="..\platform\mock\ScrollbarThemeMock.h">
<Filter>platform\mock</Filter>
</ClInclude>
<ClInclude Include="..\crypto\SubtleCrypto.h">
<Filter>crypto</Filter>
</ClInclude>
<ClInclude Include="..\css\BasicShapeFunctions.h">
<Filter>css</Filter>
</ClInclude>
......
......@@ -5593,6 +5593,11 @@
E1F1E8300C3C2BB9006DB391 /* XSLTExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F1E82E0C3C2BB9006DB391 /* XSLTExtensions.h */; };
E1FF57A30F01255B00891EBB /* ThreadGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */; };
E1FF8F5F1807442100132674 /* SubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F5D1807442100132674 /* SubtleCrypto.cpp */; };
E1FF8F601807442100132674 /* SubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F5E1807442100132674 /* SubtleCrypto.h */; };
E1FF8F64180745D800132674 /* JSSubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F62180745D800132674 /* JSSubtleCrypto.cpp */; };
E1FF8F65180745D800132674 /* JSSubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F63180745D800132674 /* JSSubtleCrypto.h */; };
E1FF8F681807460800132674 /* JSSubtleCryptoCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F661807460800132674 /* JSSubtleCryptoCustom.cpp */; };
E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; };
E4295FA412B0614E00D1ACE0 /* ResourceLoadPriority.h in Headers */ = {isa = PBXBuildFile; fileRef = E4295FA312B0614E00D1ACE0 /* ResourceLoadPriority.h */; settings = {ATTRIBUTES = (Private, ); }; };
E43105B816750F0C00DB2FB8 /* NodeTraversal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43105B716750F0C00DB2FB8 /* NodeTraversal.cpp */; };
......@@ -12557,6 +12562,12 @@
E1F1E82E0C3C2BB9006DB391 /* XSLTExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSLTExtensions.h; sourceTree = "<group>"; };
E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadGlobalData.h; sourceTree = "<group>"; };
E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGlobalData.cpp; sourceTree = "<group>"; };
E1FF8F5C1807364B00132674 /* SubtleCrypto.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = SubtleCrypto.idl; sourceTree = "<group>"; };
E1FF8F5D1807442100132674 /* SubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SubtleCrypto.cpp; sourceTree = "<group>"; };
E1FF8F5E1807442100132674 /* SubtleCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubtleCrypto.h; sourceTree = "<group>"; };
E1FF8F62180745D800132674 /* JSSubtleCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSubtleCrypto.cpp; sourceTree = "<group>"; };
E1FF8F63180745D800132674 /* JSSubtleCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSubtleCrypto.h; sourceTree = "<group>"; };
E1FF8F661807460800132674 /* JSSubtleCryptoCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSubtleCryptoCustom.cpp; sourceTree = "<group>"; };
E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIteratorAssertions.h; sourceTree = "<group>"; };
E406F3FB1198307D009D59D6 /* ColorData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColorData.cpp; sourceTree = "<group>"; };
E41EA038119836DB00710BC5 /* CSSPropertyNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPropertyNames.cpp; sourceTree = "<group>"; };
......@@ -13559,6 +13570,7 @@
29A812040FBB9B4100510293 /* accessibility */,
BC1A3790097C6F970019F3D8 /* bindings */,
1A569CC40D7E2B60007C3983 /* bridge */,
E1FF8F5B1807362B00132674 /* crypto */,
F523D18402DE42E8018635CA /* css */,
F523D32402DE4478018635CA /* dom */,
93309D86099E64910056E581 /* editing */,
......@@ -13778,6 +13790,7 @@
isa = PBXGroup;
children = (
A83B79100CCB001B000B0825 /* Core */,
E1FF8F61180745C600132674 /* Crypto */,
A83B790E0CCAFF97000B0825 /* CSS */,
CDA98DCD1601515C00FEA3B1 /* EncryptedMedia */,
A83B79120CCB003F000B0825 /* Events */,
......@@ -19370,6 +19383,7 @@
08A48A6D0E86CF6D00E225DD /* JSSVGElementInstanceCustom.cpp */,
08E4FE450E2BD41400F4CAE0 /* JSSVGLengthCustom.cpp */,
B2C96D8C0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp */,
E1FF8F661807460800132674 /* JSSubtleCryptoCustom.cpp */,
1A2C40AA0DEB55AA005AF19E /* JSTextCustom.cpp */,
07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */,
07E116B01489C9A100EC5ACE /* JSTextTrackCustom.cpp */,
......@@ -20101,6 +20115,25 @@
tabWidth = 4;
usesTabs = 0;
};
E1FF8F5B1807362B00132674 /* crypto */ = {
isa = PBXGroup;
children = (
E1FF8F5C1807364B00132674 /* SubtleCrypto.idl */,
E1FF8F5D1807442100132674 /* SubtleCrypto.cpp */,
E1FF8F5E1807442100132674 /* SubtleCrypto.h */,
);
path = crypto;
sourceTree = "<group>";
};
E1FF8F61180745C600132674 /* Crypto */ = {
isa = PBXGroup;
children = (
E1FF8F62180745D800132674 /* JSSubtleCrypto.cpp */,
E1FF8F63180745D800132674 /* JSSubtleCrypto.h */,
);
name = Crypto;
sourceTree = "<group>";
};
E46E97860DAAD61B0071E894 /* animation */ = {
isa = PBXGroup;
children = (
......@@ -21499,6 +21532,7 @@
E1CDE9221501916900862CC5 /* AsyncFileStream.h in Headers */,
7C5343FD17B74B63004232F0 /* JSMediaQueryListListener.h in Headers */,
37C61F0112095C87007A3C67 /* AtomicStringKeyedMRUCache.h in Headers */,
E1FF8F601807442100132674 /* SubtleCrypto.h in Headers */,
A8C4A80D09D563270003AC8D /* Attr.h in Headers */,
A8C4A80B09D563270003AC8D /* Attribute.h in Headers */,
FD31607A12B026F700C1A359 /* AudioArray.h in Headers */,
......@@ -22469,6 +22503,7 @@
A12705C31656BD6500C2E27C /* GridPosition.h in Headers */,
A12A1050166444FD008FA311 /* GridTrackSize.h in Headers */,
C50B561712119D23008B46E0 /* GroupSettings.h in Headers */,
E1FF8F65180745D800132674 /* JSSubtleCrypto.h in Headers */,
078E094017D16E1C00420AA1 /* RTCIceCandidateDescriptor.h in Headers */,
8482B7461198C35400BFB005 /* HashChangeEvent.h in Headers */,
A8748BE012CBF2DC001FBA41 /* HashTools.h in Headers */,
......@@ -25076,6 +25111,7 @@
49484FC1102CF23C00187DD3 /* CanvasGradient.cpp in Sources */,
FB91392716AE4C34001FE682 /* CanvasPathMethods.cpp in Sources */,
49484FC4102CF23C00187DD3 /* CanvasPattern.cpp in Sources */,
E1FF8F681807460800132674 /* JSSubtleCryptoCustom.cpp in Sources */,
49C7B9DC1042D32F0009D447 /* CanvasRenderingContext.cpp in Sources */,
49484FCA102CF23C00187DD3 /* CanvasRenderingContext2D.cpp in Sources */,
49484FCD102CF23C00187DD3 /* CanvasStyle.cpp in Sources */,
......@@ -25898,6 +25934,7 @@
7AA51DD5148506A900AD2752 /* InspectorMemoryAgent.cpp in Sources */,
7C522D4B15B477E8009B7C95 /* InspectorOverlay.cpp in Sources */,
4F6FDD641341DEDD001F8EE3 /* InspectorPageAgent.cpp in Sources */,
E1FF8F5F1807442100132674 /* SubtleCrypto.cpp in Sources */,
9F0D6B2E121BFEBA006C0288 /* InspectorProfilerAgent.cpp in Sources */,
82AB1775125C826700C5069D /* InspectorResourceAgent.cpp in Sources */,
7AA365EE12E7265400DCA242 /* InspectorRuntimeAgent.cpp in Sources */,
......@@ -27412,6 +27449,7 @@
078E090F17D14CEE00420AA1 /* RTCStatsRequestImpl.cpp in Sources */,
51DF6D800B92A18E00C2DC85 /* ThreadCheck.mm in Sources */,
E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */,
E1FF8F64180745D800132674 /* JSSubtleCrypto.cpp in Sources */,
185BCF280F3279CE000EA262 /* ThreadTimers.cpp in Sources */,
1AA7160A149BC4DB0016EC19 /* TileController.mm in Sources */,
498770F21242C535002226BA /* TilingData.cpp in Sources */,
/*
* Copyright (C) 2013 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.
*/
#include "config.h"
#include "JSSubtleCrypto.h"
#if ENABLE(SUBTLE_CRYPTO)
namespace WebCore {
}
#endif
/*
* Copyright (C) 2013 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.
*/
#include "config.h"
#include "SubtleCrypto.h"
#if ENABLE(SUBTLE_CRYPTO)
#include "Document.h"
namespace WebCore {
SubtleCrypto::SubtleCrypto(Document& document)
: ContextDestructionObserver(&document)
{
}
Document* SubtleCrypto::document() const
{
return toDocument(scriptExecutionContext());
}
}
#endif
/*
* Copyright (C) 2013 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.
*/
#ifndef SubtleCrypto_h
#define SubtleCrypto_h
#include "ContextDestructionObserver.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#if ENABLE(SUBTLE_CRYPTO)
namespace WebCore {
class Document;
class SubtleCrypto : public ContextDestructionObserver, public RefCounted<SubtleCrypto> {
public:
static PassRefPtr<SubtleCrypto> create(Document& document) { return adoptRef(new SubtleCrypto(document)); }
Document* document() const;
private:
SubtleCrypto(Document&);
};
}
#endif
#endif // SubtleCrypto_h
/*
* Copyright (C) 2013 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.
*/
[
Conditional=SUBTLE_CRYPTO,
InterfaceName=WebKitSubtleCrypto,
GenerateIsReachable=ImplDocument,
NoInterfaceObject,
OperationsNotDeletable
] interface SubtleCrypto {
};
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -32,6 +33,7 @@
#include "Document.h"
#include "ExceptionCode.h"
#include "SubtleCrypto.h"
#include <runtime/ArrayBufferView.h>
#include <wtf/CryptographicallyRandomNumber.h>
......@@ -73,4 +75,15 @@ void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
cryptographicallyRandomValues(array->baseAddress(), array->byteLength());
}
#if ENABLE(SUBTLE_CRYPTO)
SubtleCrypto* Crypto::subtle()
{
ASSERT(isMainThread());
if (!m_subtle)
m_subtle = SubtleCrypto::create(*document());
return m_subtle.get();
}
#endif
}
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
* Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -33,6 +34,7 @@
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>