Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / workers / simultaneous-errors.html
blobc5cb306d1a39a68d45d7e62e8c0b51e2e44ea5ad
1 <!doctype html>
2 <script src="../../resources/js-test.js"></script>
3 <script>
4 window.jsTestIsAsync = true;
6 var workers = 4;
7 var errorsInWorker = 0;
8 var promises = [];
9 for (i = 0; i < workers; ++i) {
10 var worker = new Worker('resources/throw-on-message-worker.js');
11 promises.push(new Promise(function(resolve, reject) {
12 worker.onmessage = function(event) {
13 if (event.data === 'second')
14 resolve();
15 else if (event.data === 'error')
16 ++errorsInWorker;
18 }));
19 worker.postMessage('first');
20 worker.postMessage('second');
23 Promise.all(promises).then(function() {
24 if (errorsInWorker === workers)
25 testPassed('all worker errors were reported.');
26 else
27 testFailed('only ' + errorsInWorker + ' errors reported in ' + workers + ' workers');
28 finishJSTest();
29 });
30 </script>