tor-browser

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

navigator_worker.js (2381B)


      1 /**
      2 * Any copyright is dedicated to the Public Domain.
      3 * http://creativecommons.org/publicdomain/zero/1.0/
      4 */
      5 
      6 importScripts("../../tests/mochitest/general/interface_exposure_checker.js");
      7 
      8 // IMPORTANT: Do not change the list below without review from a DOM peer!
      9 var supportedProps = [
     10  { name: "appCodeName", insecureContext: true },
     11  { name: "appName", insecureContext: true },
     12  { name: "appVersion", insecureContext: true },
     13  { name: "globalPrivacyControl", insecureContext: true },
     14  { name: "gpu", earlyBetaOrEarlier: true },
     15  { name: "gpu", windows: true },
     16  { name: "gpu", mac: true, aarch64: true },
     17  { name: "platform", insecureContext: true },
     18  { name: "product", insecureContext: true },
     19  { name: "userAgent", insecureContext: true },
     20  { name: "onLine", insecureContext: true },
     21  { name: "language", insecureContext: true },
     22  { name: "languages", insecureContext: true },
     23  "locks",
     24  { name: "mediaCapabilities", insecureContext: true },
     25  { name: "hardwareConcurrency", insecureContext: true },
     26  "storage",
     27  { name: "connection", insecureContext: true },
     28  { name: "permissions", insecureContext: true },
     29  "serviceWorker",
     30 ];
     31 
     32 self.onmessage = function (event) {
     33  if (!event || !event.data) {
     34    return;
     35  }
     36 
     37  startTest(event.data);
     38 };
     39 
     40 function startTest(channelData) {
     41  // Prepare the interface map showing if a property should exist in this build.
     42  // For example, if interfaceMap[foo] = true means navigator.foo should exist.
     43  var interfaceMap = {};
     44 
     45  for (var prop of supportedProps) {
     46    if (typeof prop === "string") {
     47      interfaceMap[prop] = !channelData.isInsecureContext;
     48      continue;
     49    }
     50 
     51    interfaceMap[prop.name] ||= !entryDisabled(prop, channelData);
     52  }
     53 
     54  for (var prop in navigator) {
     55    // Make sure the list is current!
     56    if (!interfaceMap[prop]) {
     57      throw "Navigator has the '" + prop + "' property that isn't in the list!";
     58    }
     59  }
     60 
     61  var obj;
     62 
     63  for (var prop in interfaceMap) {
     64    // Skip the property that is not supposed to exist in this build.
     65    if (!interfaceMap[prop]) {
     66      continue;
     67    }
     68 
     69    if (typeof navigator[prop] == "undefined") {
     70      throw "Navigator has no '" + prop + "' property!";
     71    }
     72 
     73    obj = { name: prop };
     74    obj.value = navigator[prop];
     75 
     76    postMessage(JSON.stringify(obj));
     77  }
     78 
     79  obj = {
     80    name: "testFinished",
     81  };
     82 
     83  postMessage(JSON.stringify(obj));
     84 }