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

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

Powered by Google App Engine
This is Rietveld 408576698