tor-browser

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

generic-sensor.https.html (1281B)


      1 <!DOCTYPE html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="/speculation-rules/prerender/resources/utils.js"></script>
      5 <script src="/speculation-rules/prerender/resources/deferred-promise-utils.js"></script>
      6 <script>
      7 
      8 const params = new URLSearchParams(location.search);
      9 
     10 // The main test page (restriction-sensor-*-https.html) loads the initiator
     11 // page, then the initiator page will prerender itself with the `prerendering`
     12 // parameter.
     13 const isPrerendering = params.has('prerendering');
     14 
     15 if (!isPrerendering) {
     16  const rule_extras = {'target_hint': getTargetHint()};
     17  loadInitiatorPage(rule_extras);
     18 } else {
     19  const sensorName = params.get('sensorName');
     20  const sensorType = window[sensorName];
     21  const sensor = new sensorType;
     22  sensor.start();
     23 
     24  const promise = new Promise((resolve) => {
     25    // Sensor TCs only test the async result for Sensor.start() regardless of
     26    // success/fail results, because sensors can vary depending on the device.
     27    sensor.onactivate = function () { resolve(); }
     28    sensor.onerror = function (e) { resolve(); }
     29  });
     30 
     31  const prerenderEventCollector = new PrerenderEventCollector();
     32  prerenderEventCollector.start(promise, sensorName + " test");
     33 }
     34 
     35 </script>