tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

url_worker.js (1964B)


      1 /* eslint-env worker */
      2 
      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    };
      9 
     10    worker.postMessage(event.data - 1);
     11    return;
     12  }
     13 
     14  let status = false;
     15  try {
     16    if (URL instanceof Object) {
     17      status = true;
     18    }
     19  } catch (e) {}
     20 
     21  postMessage({ type: "status", status, msg: "URL object:" + URL });
     22 
     23  status = false;
     24  var blob = null;
     25  try {
     26    blob = new Blob([]);
     27    status = true;
     28  } catch (e) {}
     29 
     30  postMessage({ type: "status", status, msg: "Blob:" + blob });
     31 
     32  status = false;
     33  let url = null;
     34  try {
     35    url = URL.createObjectURL(blob);
     36    status = true;
     37  } catch (e) {}
     38 
     39  postMessage({ type: "status", status, msg: "Blob URL:" + url });
     40 
     41  status = false;
     42  try {
     43    URL.revokeObjectURL(url);
     44    status = true;
     45  } catch (e) {}
     46 
     47  postMessage({ type: "status", status, msg: "Blob Revoke URL" });
     48 
     49  status = false;
     50  url = null;
     51  try {
     52    url = URL.createObjectURL(true);
     53  } catch (e) {
     54    status = true;
     55  }
     56 
     57  postMessage({
     58    type: "status",
     59    status,
     60    msg: "CreateObjectURL should fail if the arg is not a blob",
     61  });
     62 
     63  status = false;
     64  url = null;
     65  try {
     66    url = URL.createObjectURL(blob);
     67    status = true;
     68  } catch (e) {}
     69 
     70  postMessage({ type: "status", status, msg: "Blob URL2:" + url });
     71  postMessage({ type: "url", url });
     72 
     73  status = false;
     74  try {
     75    URL.createObjectURL({});
     76  } catch (e) {
     77    status = true;
     78  }
     79 
     80  postMessage({ type: "status", status, msg: "Exception wanted" });
     81 
     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  });
     89 
     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  });
     96 
     97  postMessage({ type: "finish" });
     98 };