| Index: LayoutTests/crypto/resources/random-values.js
|
| diff --git a/LayoutTests/crypto/resources/random-values.js b/LayoutTests/crypto/resources/random-values.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e4bc2f79f663957ede753629c81909b4b2509670
|
| --- /dev/null
|
| +++ b/LayoutTests/crypto/resources/random-values.js
|
| @@ -0,0 +1,36 @@
|
| +if (self.importScripts) {
|
| + importScripts('../../fast/js/resources/js-test-pre.js');
|
| +}
|
| +
|
| +description("Tests crypto.randomValues.");
|
| +
|
| +if (!self.ArrayBuffer)
|
| + debug("This test requres ArrayBuffers to run!");
|
| +
|
| +shouldBe("'crypto' in self", "true");
|
| +shouldBe("'getRandomValues' in self.crypto", "true");
|
| +
|
| +try {
|
| + // NOTE: This test is flaky. If we ran this test every second since the
|
| + // beginning of the universe, on average, it would have failed
|
| + // 2^{-748} times.
|
| +
|
| + var reference = new Uint8Array(100);
|
| + var sample = new Uint8Array(100);
|
| +
|
| + crypto.getRandomValues(reference);
|
| + crypto.getRandomValues(sample);
|
| +
|
| + var matchingBytes = 0;
|
| +
|
| + for (var i = 0; i < reference.length; i++) {
|
| + if (reference[i] == sample[i])
|
| + matchingBytes++;
|
| + }
|
| +
|
| + shouldBe("matchingBytes < 100", "true");
|
| +} catch(ex) {
|
| + debug(ex);
|
| +}
|
| +
|
| +finishJSTest();
|
|
|