dom/workers/test/atob_worker.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 /**
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/publicdomain/zero/1.0/
     4  */
     5 var data = [ -1, 0, 1, 1.5, /* null ,*/ undefined, true, false, "foo",
     6              "123456789012345", "1234567890123456", "12345678901234567"];
     8 var str = "";
     9 for (var i = 0; i < 30; i++) {
    10   data.push(str);
    11   str += i % 2 ? "b" : "a";
    12 }
    14 onmessage = function(event) {
    15   data.forEach(function(string) {
    16     var encoded = btoa(string);
    17     postMessage({ type: "btoa", value: encoded });
    18     postMessage({ type: "atob", value: atob(encoded) });
    19   });
    21   var threw;
    22   try {
    23     atob();
    24   }
    25   catch(e) {
    26     threw = true;
    27   }
    29   if (!threw) {
    30     throw "atob didn't throw when called without an argument!";
    31   }
    32   threw = false;
    34   try {
    35     btoa();
    36   }
    37   catch(e) {
    38     threw = true;
    39   }
    41   if (!threw) {
    42     throw "btoa didn't throw when called without an argument!";
    43   }
    45   postMessage({ type: "done" });
    46 }

mercurial