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

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

Issue 16280013: Create LayoutTests/crypto for WebCrypto tests. (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
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../fast/js/resources/js-test-pre.js"></script>
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.");
12
13 if (!window.ArrayBuffer)
14 debug("This test requres ArrayBuffers to run!");
15
16 shouldBe("'crypto' in window", "true");
17 shouldBe("'getRandomValues' in window.crypto", "true");
18
19 function checkIntegerTypes() {
20 var integerTypes = [
21 "Uint8Array", "Int8Array", "Uint8ClampedArray",
22 "Uint16Array", "Int16Array",
23 "Uint32Array", "Int32Array",
24 ];
25 integerTypes.forEach(function(arrayType) {
26 shouldBeDefined("random = crypto.getRandomValues(new "+arrayType+"(3))") ;
27 shouldBeType("random", arrayType);
28
29 shouldBeDefined("view = new "+arrayType+"(3)");
30 shouldBeDefined("random = crypto.getRandomValues(view)");
31 shouldBe("random", "view");
32 });
33 }
34
35 function checkNonIntegerTypes() {
36 var floatTypes = [
37 "Float32Array", "Float64Array",
38 ];
39 floatTypes.forEach(function(arrayType) {
40 shouldThrow("crypto.getRandomValues(new "+arrayType+"(3))");
41 });
42
43 shouldBeDefined("buffer = new Uint8Array(32)");
44 shouldBeDefined("buffer.buffer");
45 shouldBeDefined("view = new DataView(buffer.buffer)");
46 shouldThrow("crypto.getRandomValues(view)");
47 }
48
49 checkIntegerTypes();
50 checkNonIntegerTypes();
51
52 </script>
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