blob: 68fc206fd52b38150c355e415b36a6faa2004497 [file] [log] [blame]
<!DOCTYPE HTML><!-- webkit-test-runner [ dumpJSConsoleLogInStdErr=true ] -->
<html>
<head>
<meta charset="utf-8">
<script src="../resources/js-test.js"></script>
</head>
<body>
<script>
description("Test crypto.getRandomValues behavior in oom situation.")
let exceptionString = undefined;
function useAllMemory() {
const a = [0];
a.__proto__ = {};
Object.defineProperty(a, 0, {get: foo});
Object.defineProperty(a, 80000000, {});
function foo() {
new Uint8Array(a);
}
new Promise(foo);
try {
for (let i = 0; i < 2**32; i++) {
new ArrayBuffer(1000);
}
} catch {
}
}
useAllMemory();
try {
crypto.getRandomValues(new Uint8Array());
} catch (e) {
gc();
exceptionString = e.toString();
}
gc();
shouldBeTrue("exceptionString == undefined || exceptionString === \"TypeError: Argument 1 ('array') to Crypto.getRandomValues must be an instance of ArrayBufferView\"");
testPassed("crypto.getRandomValues didn't crash");
</script>
</body>
</html>