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 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | Components.utils.import("resource://gre/modules/Promise.jsm"); |
michael@0 | 5 | |
michael@0 | 6 | let WORKER_SOURCE_URI = |
michael@0 | 7 | "chrome://test_sqlite_internal/content/worker_sqlite_internal.js"; |
michael@0 | 8 | do_load_manifest("data/chrome.manifest"); |
michael@0 | 9 | |
michael@0 | 10 | function run_test() { |
michael@0 | 11 | run_next_test(); |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | add_task(function() { |
michael@0 | 15 | let worker = new ChromeWorker(WORKER_SOURCE_URI); |
michael@0 | 16 | let deferred = Promise.defer(); |
michael@0 | 17 | worker.onmessage = function(event) { |
michael@0 | 18 | let data = event.data; |
michael@0 | 19 | switch (data.kind) { |
michael@0 | 20 | case "do_check_true": |
michael@0 | 21 | try { |
michael@0 | 22 | do_check_true(data.args[0]); |
michael@0 | 23 | } catch (ex) { |
michael@0 | 24 | // Ignore errors |
michael@0 | 25 | } |
michael@0 | 26 | break; |
michael@0 | 27 | case "do_test_complete": |
michael@0 | 28 | deferred.resolve(); |
michael@0 | 29 | worker.terminate(); |
michael@0 | 30 | break; |
michael@0 | 31 | case "do_print": |
michael@0 | 32 | do_print(data.args[0]); |
michael@0 | 33 | break; |
michael@0 | 34 | } |
michael@0 | 35 | }; |
michael@0 | 36 | worker.onerror = function(event) { |
michael@0 | 37 | let error = new Error(event.message, event.filename, event.lineno); |
michael@0 | 38 | worker.terminate(); |
michael@0 | 39 | deferred.reject(error); |
michael@0 | 40 | }; |
michael@0 | 41 | worker.postMessage("START"); |
michael@0 | 42 | return deferred.promise; |
michael@0 | 43 | }); |