OLD | NEW |
(Empty) | |
| 1 if (self.importScripts) { |
| 2 importScripts('../../fast/js/resources/js-test-pre.js'); |
| 3 } |
| 4 |
| 5 description("Tests crypto.randomValues."); |
| 6 |
| 7 if (!self.ArrayBuffer) |
| 8 debug("This test requres ArrayBuffers to run!"); |
| 9 |
| 10 shouldBe("'crypto' in self", "true"); |
| 11 shouldBe("'getRandomValues' in self.crypto", "true"); |
| 12 |
| 13 try { |
| 14 // NOTE: This test is flaky. If we ran this test every second since the |
| 15 // beginning of the universe, on average, it would have failed |
| 16 // 2^{-748} times. |
| 17 |
| 18 var reference = new Uint8Array(100); |
| 19 var sample = new Uint8Array(100); |
| 20 |
| 21 crypto.getRandomValues(reference); |
| 22 crypto.getRandomValues(sample); |
| 23 |
| 24 var matchingBytes = 0; |
| 25 |
| 26 for (var i = 0; i < reference.length; i++) { |
| 27 if (reference[i] == sample[i]) |
| 28 matchingBytes++; |
| 29 } |
| 30 |
| 31 shouldBe("matchingBytes < 100", "true"); |
| 32 } catch(ex) { |
| 33 debug(ex); |
| 34 } |
| 35 |
| 36 finishJSTest(); |
OLD | NEW |