mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Update web-platform-tests to revision 87398b8448f699e3e324148795891658f2fa16dd
This commit is contained in:
parent
836463b9e0
commit
3fb5197361
72 changed files with 1293 additions and 348 deletions
41
tests/wpt/web-platform-tests/WebCryptoAPI/getRandomValues.js
Normal file
41
tests/wpt/web-platform-tests/WebCryptoAPI/getRandomValues.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
function run_test() {
|
||||
// Step 1.
|
||||
test(function() {
|
||||
assert_throws("TypeMismatchError", function() {
|
||||
self.crypto.getRandomValues(new Float32Array(6))
|
||||
}, "Float32Array")
|
||||
assert_throws("TypeMismatchError", function() {
|
||||
self.crypto.getRandomValues(new Float64Array(6))
|
||||
}, "Float64Array")
|
||||
|
||||
assert_throws("TypeMismatchError", function() {
|
||||
self.crypto.getRandomValues(new Float32Array(65537))
|
||||
}, "Float32Array (too long)")
|
||||
assert_throws("TypeMismatchError", function() {
|
||||
self.crypto.getRandomValues(new Float64Array(65537))
|
||||
}, "Float64Array (too long)")
|
||||
}, "Float arrays")
|
||||
|
||||
test(function() {
|
||||
assert_equals(self.crypto.getRandomValues(new Int8Array(8)).constructor,
|
||||
Int8Array, "crypto.getRandomValues(new Int8Array(8))")
|
||||
assert_equals(self.crypto.getRandomValues(new Uint8Array(8)).constructor,
|
||||
Uint8Array, "crypto.getRandomValues(new Uint8Array(8))")
|
||||
|
||||
assert_equals(self.crypto.getRandomValues(new Int16Array(8)).constructor,
|
||||
Int16Array, "crypto.getRandomValues(new Int16Array(8))")
|
||||
assert_equals(self.crypto.getRandomValues(new Uint16Array(8)).constructor,
|
||||
Uint16Array, "crypto.getRandomValues(new Uint16Array(8))")
|
||||
|
||||
assert_equals(self.crypto.getRandomValues(new Int32Array(8)).constructor,
|
||||
Int32Array, "crypto.getRandomValues(new Int32Array(8))")
|
||||
assert_equals(self.crypto.getRandomValues(new Uint32Array(8)).constructor,
|
||||
Uint32Array, "crypto.getRandomValues(new Uint32Array(8))")
|
||||
}, "Integer arrays")
|
||||
|
||||
test(function() {
|
||||
assert_throws("QuotaExceededError", function() {
|
||||
self.crypto.getRandomValues(new Int8Array(65537))
|
||||
}, "crypto.getRandomValues length over 65536")
|
||||
}, "Large length")
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
importScripts("/resources/testharness.js");
|
||||
importScripts("getRandomValues.js");
|
||||
run_test();
|
||||
done();
|
|
@ -5,43 +5,8 @@
|
|||
<link rel="help" href="https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#dfn-Crypto-method-getRandomValues">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="getRandomValues.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
// Step 1.
|
||||
test(function() {
|
||||
assert_throws("TypeMismatchError", function() {
|
||||
window.crypto.getRandomValues(new Float32Array(6))
|
||||
}, "Float32Array")
|
||||
assert_throws("TypeMismatchError", function() {
|
||||
window.crypto.getRandomValues(new Float64Array(6))
|
||||
}, "Float64Array")
|
||||
|
||||
assert_throws("TypeMismatchError", function() {
|
||||
window.crypto.getRandomValues(new Float32Array(65537))
|
||||
}, "Float32Array (too long)")
|
||||
assert_throws("TypeMismatchError", function() {
|
||||
window.crypto.getRandomValues(new Float64Array(65537))
|
||||
}, "Float64Array (too long)")
|
||||
}, "Float arrays")
|
||||
|
||||
test(function() {
|
||||
assert_equals(window.crypto.getRandomValues(new Int8Array(8)).constructor,
|
||||
Int8Array, "crypto.getRandomValues(new Int8Array(8))")
|
||||
assert_equals(window.crypto.getRandomValues(new Uint8Array(8)).constructor,
|
||||
Uint8Array, "crypto.getRandomValues(new Uint8Array(8))")
|
||||
|
||||
assert_equals(window.crypto.getRandomValues(new Int16Array(8)).constructor,
|
||||
Int16Array, "crypto.getRandomValues(new Int16Array(8))")
|
||||
assert_equals(window.crypto.getRandomValues(new Uint16Array(8)).constructor,
|
||||
Uint16Array, "crypto.getRandomValues(new Uint16Array(8))")
|
||||
|
||||
assert_equals(window.crypto.getRandomValues(new Int32Array(8)).constructor,
|
||||
Int32Array, "crypto.getRandomValues(new Int32Array(8))")
|
||||
assert_equals(window.crypto.getRandomValues(new Uint32Array(8)).constructor,
|
||||
Uint32Array, "crypto.getRandomValues(new Uint32Array(8))")
|
||||
|
||||
assert_throws("QuotaExceededError", function() {
|
||||
window.crypto.getRandomValues(new Int8Array(65537))
|
||||
}, "crypto.getRandomValues length over 65536")
|
||||
})
|
||||
run_test();
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue