tor-browser

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

plugins.html (1287B)


      1 <!DOCTYPE html>
      2 <script>
      3  var obj, embed;
      4 
      5  function ok(v, msg) {
      6    window.opener.postMessage({status: "ok", result: !!v, message: msg}, "*");
      7  }
      8 
      9  function finish() {
     10    document.documentElement.removeChild(obj);
     11    document.documentElement.removeChild(embed);
     12    window.opener.postMessage({status: "done"}, "*");
     13  }
     14 
     15  function test_object() {
     16    obj = document.createElement("object");
     17    obj.setAttribute('data', "object");
     18    document.documentElement.appendChild(obj);
     19  }
     20 
     21  function test_embed() {
     22    embed = document.createElement("embed");
     23    embed.setAttribute('src', "embed");
     24    document.documentElement.appendChild(embed);
     25  }
     26 
     27  navigator.serviceWorker.addEventListener("message", function onMessage(e) {
     28    if (e.data.destination === "object") {
     29      ok(false, "<object> should not be intercepted");
     30    } else if (e.data.destination === "embed") {
     31      ok(false, "<embed> should not be intercepted");
     32    } else if (e.data.destination === "" && e.data.resource === "foo.txt") {
     33      navigator.serviceWorker.removeEventListener("message", onMessage);
     34      finish();
     35    }
     36  });
     37 
     38  test_object();
     39  test_embed();
     40  // SW will definitely intercept fetch API, use this to see if plugins are
     41  // intercepted before fetch().
     42  fetch("foo.txt");
     43 </script>