Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Side by Side Diff: LayoutTests/crypto/crypto-random-values-types.html

Issue 16820007: Expose crypto.getRandomValues() to workers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../fast/js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description("Tests which types are valid for crypto.randomValues.");
11
12 if (!window.ArrayBuffer)
13 debug("This test requres ArrayBuffers to run!");
14
15 shouldBe("'crypto' in window", "true");
16 shouldBe("'getRandomValues' in window.crypto", "true");
17
18 function checkIntegerTypes() {
19 var integerTypes = [
20 "Uint8Array", "Int8Array", "Uint8ClampedArray",
21 "Uint16Array", "Int16Array",
22 "Uint32Array", "Int32Array",
23 ];
24 integerTypes.forEach(function(arrayType) {
25 shouldBeDefined("random = crypto.getRandomValues(new "+arrayType+"(3))") ;
26 shouldBeType("random", arrayType);
27
28 shouldBeDefined("view = new "+arrayType+"(3)");
29 shouldBeDefined("random = crypto.getRandomValues(view)");
30 shouldBe("random", "view");
31 });
32 }
33
34 function checkNonIntegerTypes() {
35 var floatTypes = [
36 "Float32Array", "Float64Array",
37 ];
38 floatTypes.forEach(function(arrayType) {
39 shouldThrow("crypto.getRandomValues(new "+arrayType+"(3))");
40 });
41
42 shouldBeDefined("buffer = new Uint8Array(32)");
43 shouldBeDefined("buffer.buffer");
44 shouldBeDefined("view = new DataView(buffer.buffer)");
45 shouldThrow("crypto.getRandomValues(view)");
46 }
47
48 checkIntegerTypes();
49 checkNonIntegerTypes();
50
51 </script>
52 <script src="../fast/js/resources/js-test-post.js"></script>
53 </body>
54 </html>
55
56
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698