Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / url / tests / url_worker.js
blob8a697446033eaf22db4507a438e31cc633e4253a
1 /* eslint-env worker */
3 onmessage = function (event) {
4   if (event.data != 0) {
5     var worker = new Worker("url_worker.js");
6     worker.onmessage = function (ev) {
7       postMessage(ev.data);
8     };
10     worker.postMessage(event.data - 1);
11     return;
12   }
14   let status = false;
15   try {
16     if (URL instanceof Object) {
17       status = true;
18     }
19   } catch (e) {}
21   postMessage({ type: "status", status, msg: "URL object:" + URL });
23   status = false;
24   var blob = null;
25   try {
26     blob = new Blob([]);
27     status = true;
28   } catch (e) {}
30   postMessage({ type: "status", status, msg: "Blob:" + blob });
32   status = false;
33   let url = null;
34   try {
35     url = URL.createObjectURL(blob);
36     status = true;
37   } catch (e) {}
39   postMessage({ type: "status", status, msg: "Blob URL:" + url });
41   status = false;
42   try {
43     URL.revokeObjectURL(url);
44     status = true;
45   } catch (e) {}
47   postMessage({ type: "status", status, msg: "Blob Revoke URL" });
49   status = false;
50   url = null;
51   try {
52     url = URL.createObjectURL(true);
53   } catch (e) {
54     status = true;
55   }
57   postMessage({
58     type: "status",
59     status,
60     msg: "CreateObjectURL should fail if the arg is not a blob",
61   });
63   status = false;
64   url = null;
65   try {
66     url = URL.createObjectURL(blob);
67     status = true;
68   } catch (e) {}
70   postMessage({ type: "status", status, msg: "Blob URL2:" + url });
71   postMessage({ type: "url", url });
73   status = false;
74   try {
75     URL.createObjectURL({});
76   } catch (e) {
77     status = true;
78   }
80   postMessage({ type: "status", status, msg: "Exception wanted" });
82   blob = new Blob([123]);
83   var uri = URL.createObjectURL(blob);
84   postMessage({
85     type: "status",
86     status: !!uri,
87     msg: "The URI has been generated from the blob",
88   });
90   var u = new URL(uri);
91   postMessage({
92     type: "status",
93     status: u.origin == location.origin,
94     msg: "The URL generated from a blob URI has an origin.",
95   });
97   postMessage({ type: "finish" });