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

Side by Side Diff: LayoutTests/security/crypto-random-values.html

Issue 16280013: Create LayoutTests/crypto for WebCrypto tests. (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 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../fast/js/resources/js-test-pre.js"></script>
5 <script src="resources/utilities.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10 <script>
11 description("Tests crypto.randomValues.");
12
13 if (!window.ArrayBuffer)
14 debug("This test requres ArrayBuffers to run!");
15
16 shouldBe("'crypto' in window", "true");
17 shouldBe("'getRandomValues' in window.crypto", "true");
18
19 try {
20 // FIXME: This test is flaky. If we ran this test every second since the
21 // beginning of the universe, on average, it would have failed
22 // 2^{-748} times.
23
24 var reference = new Uint8Array(100);
25 var sample = new Uint8Array(100);
26
27 crypto.getRandomValues(reference);
28 crypto.getRandomValues(sample);
29
30 var matchingBytes = 0;
31
32 for (var i = 0; i < reference.length; i++) {
33 if (reference[i] == sample[i])
34 matchingBytes++;
35 }
36
37 shouldBe("matchingBytes < 100", "true");
38 } catch(ex) {
39 debug(ex);
40 }
41
42 </script>
43 <script src="../fast/js/resources/js-test-post.js"></script>
44 </body>
45 </html>
46
47
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698