1 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/publicdomain/zero/1.0/
4 // Worker-side wrapper script for the worker_driver.js helper code. See
5 // the comments at the top of worker_driver.js for more information.
8 dump("OK: " + !!a + " => " + a + ": " + msg + "\n");
9 postMessage({type: 'status', status: !!a, msg: a + ": " + msg });
12 function is(a, b, msg) {
13 dump("IS: " + (a===b) + " => " + a + " | " + b + ": " + msg + "\n");
14 postMessage({type: 'status', status: a === b, msg: a + " === " + b + ": " + msg });
17 function workerTestArrayEquals(a, b) {
18 if (!Array.isArray(a) || !Array.isArray(b) || a.length != b.length) {
21 for (var i = 0, n = a.length; i < n; ++i) {
29 function workerTestDone() {
30 postMessage({ type: 'finish' });
33 function workerTestGetPrefs(prefs, cb) {
34 addEventListener('message', function workerTestGetPrefsCB(e) {
35 if (e.data.type != 'returnPrefs' ||
36 !workerTestArrayEquals(prefs, e.data.prefs)) {
39 removeEventListener('message', workerTestGetPrefsCB);
48 function workerTestGetPermissions(permissions, cb) {
49 addEventListener('message', function workerTestGetPermissionsCB(e) {
50 if (e.data.type != 'returnPermissions' ||
51 !workerTestArrayEquals(permissions, e.data.permissions)) {
54 removeEventListener('message', workerTestGetPermissionsCB);
58 type: 'getPermissions',
59 permissions: permissions
63 function workerTestGetVersion(cb) {
64 addEventListener('message', function workerTestGetVersionCB(e) {
65 if (e.data.type !== 'returnVersion') {
68 removeEventListener('message', workerTestGetVersionCB);
76 function workerTestGetUserAgent(cb) {
77 addEventListener('message', function workerTestGetUserAgentCB(e) {
78 if (e.data.type !== 'returnUserAgent') {
81 removeEventListener('message', workerTestGetUserAgentCB);
89 function workerTestGetOSCPU(cb) {
90 addEventListener('message', function workerTestGetOSCPUCB(e) {
91 if (e.data.type !== 'returnOSCPU') {
94 removeEventListener('message', workerTestGetOSCPUCB);
102 addEventListener('message', function workerWrapperOnMessage(e) {
103 removeEventListener('message', workerWrapperOnMessage);
106 importScripts(data.script);
111 msg: 'worker failed to import ' + data.script + "; error: " + e.message