window.crypto.getRandomValues should return the input ArrayBufferView
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2012 22:12:40 +0000 (22:12 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2012 22:12:40 +0000 (22:12 +0000)
commit02d1b144b5bc9c729cd5bcd23f7581b97149679b
tree108db7269e5b33fcb96181c6c7d8b7a810e64a44
parentbe96180612d87dbfcb07ac6004389980eb4cd456
window.crypto.getRandomValues should return the input ArrayBufferView
https://bugs.webkit.org/show_bug.cgi?id=104845

Source/WebCore:

The W3C Web Crypto API FPWD, as well as the WHATWG February 2012 draft,
define crypto.getRandomValues() as returning the input ArrayBufferView,
to allow function call chaining. Update the implementation to match
the current spec, rather than the old spec of void/undefined.

Patch by Ryan Sleevi <rsleevi@chromium.org> on 2012-12-20
Reviewed by Kentaro Hara.

Test: security/crypto-random-values-types.html

* GNUmakefile.list.am:
* Target.pri:
* UseJSC.cmake:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSBindingsAllInOne.cpp:
* bindings/js/JSCryptoCustom.cpp: Added.
(WebCore):
(WebCore::JSCrypto::getRandomValues):
Added custom getRandomValues implementation so that the input wrapped
ArrayBufferView can be returned directly to the caller. This is to
preserve the underlying type and indexing accessor for the TypedArray
subclass.
* bindings/v8/custom/V8CryptoCustom.cpp: Added.
(WebCore):
(WebCore::V8Crypto::getRandomValuesCallback):
Added custom getRandomValues implementation so that the input wrapped
ArrayBufferView can be returned directly to the caller. This is to
preserve the underlying type and indexing accessor for the TypedArray
subclass.
* page/Crypto.idl:

LayoutTests:

Patch by Ryan Sleevi <rsleevi@chromium.org> on 2012-12-20
Reviewed by Kentaro Hara.

* fast/js/resources/js-test-pre.js:
(shouldBeType):
Added helper to assert that an expression returns an object of the
correct type.
* security/crypto-random-values-types-expected.txt:
* security/crypto-random-values-types.html:
Test all possible TypedArray integer types and ensure that both the
correct TypedArray type is returned and that it is equal to the input
type; that is, that the input type is modified in place, rather then
copied.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/js/resources/js-test-pre.js
LayoutTests/security/crypto-random-values-types-expected.txt
LayoutTests/security/crypto-random-values-types.html
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/UseJSC.cmake
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSCryptoCustom.cpp [new file with mode: 0644]
Source/WebCore/bindings/v8/custom/V8CryptoCustom.cpp [new file with mode: 0644]
Source/WebCore/page/Crypto.idl