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

Side by Side Diff: LayoutTests/crypto/worker-subtle-crypto-concurrent.html

Issue 222553007: [webcrypto] Expose crypto.subtle to web workers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: check if changes... Created 6 years, 8 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="../resources/js-test.js"></script>
5 <script src="resources/common.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10
11 <script>
12 description("Tests concurrent calls to many crypto operations happening on w orkers as well as main thread.");
13
14 // This test runs web crypto operations on 11 "threads".
15 // * The main thread (this page)
16 // * 10 web workers
17 //
18 // The code for each thread is in "resources/subtle-crypto-concurrent.js"
19 // and runs multiple parallel crypto operations.
20 //
21 // The intent of this test is to try an exercise any races in the WebCrypto
22 // code, and make sure operations work from workers.
23
24 jsTestIsAsync = true;
25
26 function createPromiseForThread(thread, hookOnError) {
27 return new Promise(function(resolve, reject) {
28 thread.onmessage = function(event)
29 {
30 if (event.data == "TEST_FINISHED") {
31 debug("Thread completed successfully");
32 resolve();
33 resolve = null;
34 } else {
35 debug("Unexpected message: " + event.data);
36 reject();
37 }
38 };
39
40 if (hookOnError) {
41 thread.onerror = function(event)
42 {
43 debug("Thread failed: " + event.data);
44 reject();
45 };
46 }
47 });
48 }
49
50 function createPromiseForWorker()
51 {
52 var worker = new Worker("resources/subtle-crypto-concurrent.js");
53 return createPromiseForThread(worker, true);
54 }
55
56 function createPromiseForMainThread()
57 {
58 return createPromiseForThread(self, false);
59 }
60
61 var allPromises = [];
62 for (var i = 0; i < 10; ++i)
63 allPromises.push(createPromiseForWorker());
64
65 // The worker script is included at the end of this page too, so it
66 // performs the same work as the workers.
67 allPromises.push(createPromiseForMainThread(self));
68
69 Promise.all(allPromises).then(finishJSTest, failAndFinishJSTest);
70 </script>
71 <script src="resources/subtle-crypto-concurrent.js"></script>
72 </body>
73 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698