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