Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * worker_helper.js |
michael@0 | 3 | * bug 764234 tests |
michael@0 | 4 | */ |
michael@0 | 5 | function runTestInWorker(files) { |
michael@0 | 6 | function workerRun() { |
michael@0 | 7 | var tests = []; |
michael@0 | 8 | var asserts; |
michael@0 | 9 | test = function(func, msg) { |
michael@0 | 10 | asserts = []; |
michael@0 | 11 | tests.push({asserts: asserts, msg: msg}); |
michael@0 | 12 | } |
michael@0 | 13 | assert_equals = function(result, expected, msg) { |
michael@0 | 14 | asserts.push(["assert_equals", result, expected, msg]); |
michael@0 | 15 | }; |
michael@0 | 16 | assert_true = function(condition, msg) { |
michael@0 | 17 | asserts.push(["assert_true", condition, msg]); |
michael@0 | 18 | }; |
michael@0 | 19 | assert_unreached = function(condition, msg) { |
michael@0 | 20 | asserts.push(["assert_unreached", condition, msg]); |
michael@0 | 21 | }; |
michael@0 | 22 | onmessage = function(event) { |
michael@0 | 23 | importScripts.apply(self, event.data); |
michael@0 | 24 | runTest(); |
michael@0 | 25 | postMessage(tests); |
michael@0 | 26 | }; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | var url = URL.createObjectURL(new Blob([ |
michael@0 | 30 | runTest.toString(), "\n\n", |
michael@0 | 31 | "(", workerRun.toString(), ")();" |
michael@0 | 32 | ])); |
michael@0 | 33 | var worker = new Worker(url); |
michael@0 | 34 | var base = location.toString().replace(/\/[^\/]*$/,"/"); |
michael@0 | 35 | worker.postMessage(files.map(function(f) { return base + f; })); |
michael@0 | 36 | worker.onmessage = function(event) { |
michael@0 | 37 | URL.revokeObjectURL(url); |
michael@0 | 38 | event.data.forEach(function(t) { |
michael@0 | 39 | test(function() { |
michael@0 | 40 | t.asserts.forEach(function(a) { |
michael@0 | 41 | func = a.shift(); |
michael@0 | 42 | self[func].apply(self, a); |
michael@0 | 43 | }); |
michael@0 | 44 | }, "worker " + t.msg); |
michael@0 | 45 | }); |
michael@0 | 46 | done(); |
michael@0 | 47 | }; |
michael@0 | 48 | } |