1 if (self.importScripts)
2 importScripts('../resources/js-test.js');
4 description("Tests crypto.randomValues.");
7 debug("This test requres ArrayBuffers to run!");
9 shouldBe("'crypto' in self", "true");
10 shouldBe("'getRandomValues' in self.crypto", "true");
12 // Although the spec defines Crypto in terms of "RandomSource", it is NOT
13 // inheritance. The RandomSource interface should not be visible to
15 shouldBe("self.crypto.__proto__.hasOwnProperty('getRandomValues')", "true");
18 // NOTE: This test is flaky. If we ran this test every second since the
19 // beginning of the universe, on average, it would have failed
22 var reference = new Uint8Array(100);
23 var sample = new Uint8Array(100);
25 crypto.getRandomValues(reference);
26 crypto.getRandomValues(sample);
28 var matchingBytes = 0;
30 for (var i = 0; i < reference.length; i++) {
31 if (reference[i] == sample[i])
35 shouldBe("matchingBytes < 100", "true");