crypto-random-values-limits.html 782 Bytes
Newer Older
1 2 3
<!DOCTYPE html>
<html>
<head>
4
<script src="../resources/js-test-pre.js"></script>
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<script src="resources/utilities.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Tests the limits of crypto.randomValues.");

if (!window.ArrayBuffer)
    debug("This test requres ArrayBuffers to run!");

shouldBe("'crypto' in window", "true");
shouldBe("'getRandomValues' in window.crypto", "true");

try {
20 21
    var almostTooLargeArray = new Uint8Array(65536);
    var tooLargeArray = new Uint8Array(65537);
22

23 24
    shouldNotThrow("crypto.getRandomValues(almostTooLargeArray)");
    shouldThrow("crypto.getRandomValues(tooLargeArray)");
25 26 27 28 29
} catch(ex) {
    debug(ex);
}

</script>
30
<script src="../resources/js-test-post.js"></script>
31 32 33 34
</body>
</html>