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

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

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
1 <!DOCTYPE html> 1 if (self.importScripts)
2 <html> 2 importScripts('../../fast/js/resources/js-test-pre.js');
3 <head> 3
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."); 4 description("Tests which types are valid for crypto.randomValues.");
11 5
12 if (!window.ArrayBuffer) 6 if (!self.ArrayBuffer)
13 debug("This test requres ArrayBuffers to run!"); 7 debug("This test requres ArrayBuffers to run!");
14 8
15 shouldBe("'crypto' in window", "true"); 9 shouldBe("'crypto' in self", "true");
16 shouldBe("'getRandomValues' in window.crypto", "true"); 10 shouldBe("'getRandomValues' in self.crypto", "true");
17 11
18 function checkIntegerTypes() { 12 function checkIntegerTypes() {
19 var integerTypes = [ 13 var integerTypes = [
20 "Uint8Array", "Int8Array", "Uint8ClampedArray", 14 "Uint8Array", "Int8Array", "Uint8ClampedArray",
21 "Uint16Array", "Int16Array", 15 "Uint16Array", "Int16Array",
22 "Uint32Array", "Int32Array", 16 "Uint32Array", "Int32Array",
23 ]; 17 ];
24 integerTypes.forEach(function(arrayType) { 18 integerTypes.forEach(function(arrayType) {
25 shouldBeDefined("random = crypto.getRandomValues(new "+arrayType+"(3))") ; 19 shouldBeDefined("random = crypto.getRandomValues(new "+arrayType+"(3))") ;
26 shouldBeType("random", arrayType); 20 shouldBeType("random", arrayType);
(...skipping 14 matching lines...) Expand all
41 35
42 shouldBeDefined("buffer = new Uint8Array(32)"); 36 shouldBeDefined("buffer = new Uint8Array(32)");
43 shouldBeDefined("buffer.buffer"); 37 shouldBeDefined("buffer.buffer");
44 shouldBeDefined("view = new DataView(buffer.buffer)"); 38 shouldBeDefined("view = new DataView(buffer.buffer)");
45 shouldThrow("crypto.getRandomValues(view)"); 39 shouldThrow("crypto.getRandomValues(view)");
46 } 40 }
47 41
48 checkIntegerTypes(); 42 checkIntegerTypes();
49 checkNonIntegerTypes(); 43 checkNonIntegerTypes();
50 44
51 </script> 45 finishJSTest();
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