Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: LayoutTests/crypto/resources/random-values.js

Issue 16820007: Expose crypto.getRandomValues() to workers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698