| OLD | NEW |
| 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 Loading... |
| 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 | |
| OLD | NEW |