dom/workers/test/errorwarning_worker.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /**
michael@0 2 * Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 4 */
michael@0 5
michael@0 6 function errorHandler() {
michael@0 7 postMessage({ type: 'error' });
michael@0 8 }
michael@0 9
michael@0 10 onmessage = function(event) {
michael@0 11 if (event.data.errors) {
michael@0 12 try {
michael@0 13 // This is an error:
michael@0 14 postMessage({ type: 'ignore', value: b.aaa });
michael@0 15 } catch(e) {
michael@0 16 errorHandler();
michael@0 17 }
michael@0 18 } else {
michael@0 19 var a = {};
michael@0 20 // This is a warning:
michael@0 21 postMessage({ type: 'ignore', value: a.foo });
michael@0 22 }
michael@0 23
michael@0 24 if (event.data.loop != 0) {
michael@0 25 var worker = new Worker('errorwarning_worker.js');
michael@0 26 worker.onerror = errorHandler;
michael@0 27 worker.postMessage({ loop: event.data.loop - 1, errors: event.data.errors });
michael@0 28
michael@0 29 worker.onmessage = function(e) {
michael@0 30 postMessage(e.data);
michael@0 31 }
michael@0 32
michael@0 33 } else {
michael@0 34 postMessage({ type: 'finish' });
michael@0 35 }
michael@0 36 }
michael@0 37
michael@0 38 onerror = errorHandler;
michael@0 39 onerror = onerror;
michael@0 40 if (!onerror || onerror != onerror) {
michael@0 41 throw "onerror wasn't set properly";
michael@0 42 }

mercurial