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

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: Rebase on master 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 description("Tests crypto.randomValues.");
5
6 if (!self.ArrayBuffer)
7 debug("This test requres ArrayBuffers to run!");
8
9 shouldBe("'crypto' in self", "true");
10 shouldBe("'getRandomValues' in self.crypto", "true");
11
12 // Although the spec defines Crypto in terms of "RandomSource", it is NOT
13 // inheritance. The RandomSource interface should not be visible to
14 // javascript.
15 shouldBe("self.crypto.__proto__.hasOwnProperty('getRandomValues')", "true");
16
17 try {
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
20 // 2^{-748} times.
21
22 var reference = new Uint8Array(100);
23 var sample = new Uint8Array(100);
24
25 crypto.getRandomValues(reference);
26 crypto.getRandomValues(sample);
27
28 var matchingBytes = 0;
29
30 for (var i = 0; i < reference.length; i++) {
31 if (reference[i] == sample[i])
32 matchingBytes++;
33 }
34
35 shouldBe("matchingBytes < 100", "true");
36 } catch(ex) {
37 debug(ex);
38 }
39
40 finishJSTest();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698