no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / workers / test / atob_worker.js
blobf55ec77e8136754c4da6a2eccf14872b2d0674a7
1 /**
2  * Any copyright is dedicated to the Public Domain.
3  * http://creativecommons.org/publicdomain/zero/1.0/
4  */
5 var data = [
6   -1,
7   0,
8   1,
9   1.5,
10   /* null ,*/ undefined,
11   true,
12   false,
13   "foo",
14   "123456789012345",
15   "1234567890123456",
16   "12345678901234567",
19 var str = "";
20 for (var i = 0; i < 30; i++) {
21   data.push(str);
22   str += i % 2 ? "b" : "a";
25 onmessage = function (event) {
26   data.forEach(function (string) {
27     var encoded = btoa(string);
28     postMessage({ type: "btoa", value: encoded });
29     postMessage({ type: "atob", value: atob(encoded) });
30   });
32   var threw;
33   try {
34     atob();
35   } catch (e) {
36     threw = true;
37   }
39   if (!threw) {
40     throw "atob didn't throw when called without an argument!";
41   }
42   threw = false;
44   try {
45     btoa();
46   } catch (e) {
47     threw = true;
48   }
50   if (!threw) {
51     throw "btoa didn't throw when called without an argument!";
52   }
54   postMessage({ type: "done" });