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