tor-browser

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

file_promise_xrays.html (1133B)


      1 <!DOCTYPE html>
      2 <html>
      3  <script>
      4    function vendGetter(name) {
      5      // eslint-disable-next-line no-throw-literal
      6      return function() { throw "Getting " + String(name); };
      7    }
      8    function vendSetter(name) {
      9      // eslint-disable-next-line no-throw-literal
     10      return function() { throw "Setting " + String(name); };
     11    }
     12    var setupThrew = false;
     13    try {
     14      // Neuter everything we can think of on Promise.
     15      for (var obj of [Promise, Promise.prototype]) {
     16        let propNames = Object.getOwnPropertyNames(obj);
     17        propNames = propNames.concat(Object.getOwnPropertySymbols(obj));
     18        for (var propName of propNames) {
     19          if ((propName == "prototype" ||
     20               propName == Symbol.hasInstance) &&
     21              obj == Promise) {
     22            // They're not configurable.
     23            continue;
     24          }
     25          Object.defineProperty(obj, propName,
     26            { get: vendGetter(propName), set: vendSetter(propName) });
     27        }
     28      }
     29    } catch (e) {
     30      // Something went wrong.  Save that info so the test can check for it.
     31      setupThrew = e;
     32    }
     33  </script>
     34 </html>