dom/workers/test/xpcshell/test_workers.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 Components.utils.import("resource://gre/modules/Promise.jsm");
     6 // Worker must be loaded from a chrome:// uri, not a file://
     7 // uri, so we first need to load it.
     8 let WORKER_SOURCE_URI = "chrome://workers/content/worker.js";
     9 do_load_manifest("data/chrome.manifest");
    11 function run_test() {
    12   run_next_test();
    13 }
    15 function talk_with_worker(worker) {
    16   let deferred = Promise.defer();
    17   worker.onmessage = function(event) {
    18     let success = true;
    19     if (event.data == "OK") {
    20       deferred.resolve();
    21     } else {
    22       success = false;
    23       deferred.reject(event);
    24     }
    25     do_check_true(success);
    26     worker.terminate();
    27   };
    28   worker.onerror = function(event) {
    29     let error = new Error(event.message, event.filename, event.lineno);
    30     worker.terminate();
    31     deferred.reject(error);
    32   };
    33   worker.postMessage("START");
    34   return deferred.promise;
    35 }
    38 add_task(function test_chrome_worker() {
    39   return talk_with_worker(new ChromeWorker(WORKER_SOURCE_URI));
    40 });
    42 add_task(function test_worker() {
    43   return talk_with_worker(new Worker(WORKER_SOURCE_URI));
    44 });

mercurial