tor-browser

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

shapedetection-cross-origin.sub.https.html (2349B)


      1 <!DOCTYPE html>
      2 <script src=/resources/testharness.js></script>
      3 <script src=/resources/testharnessreport.js></script>
      4 <script>
      5 
      6 // cross-origin resources
      7 const IMAGE_URL =
      8    "https://{{domains[www1]}}:{{ports[https][0]}}/images/green.png";
      9 const VIDEO_URL =
     10    "https://{{domains[www1]}}:{{ports[https][0]}}/media/white.webm";
     11 
     12 const crossOriginTests =
     13    [
     14      {
     15        createDetector: () => { return new FaceDetector(); },
     16        detectorType: "FaceDetector"
     17      },
     18      {
     19        createDetector: () => { return new BarcodeDetector(); },
     20        detectorType: "BarcodeDetector"
     21      },
     22      {
     23        createDetector: () => { return new TextDetector(); },
     24        detectorType: "TextDetector"
     25      }
     26    ];
     27 
     28 for (let crossOriginTest of crossOriginTests) {
     29 
     30  // Verifies that Detector rejects a cross-origin HTMLImageElement.
     31  promise_test(async t => {
     32    const img = new Image();
     33    const imgWatcher = new EventWatcher(t, img, ["load", "error"]);
     34    img.src = IMAGE_URL;
     35    await imgWatcher.wait_for("load");
     36    const detector = crossOriginTest.createDetector();
     37    promise_rejects_dom(t, "SecurityError", detector.detect(img));
     38  }, crossOriginTest.detectorType
     39  + " should reject cross-origin HTMLImageElements with a SecurityError.");
     40 
     41  // Verifies that Detector rejects a cross-origin ImageBitmap.
     42  promise_test(async t => {
     43    const img = new Image();
     44    const imgWatcher = new EventWatcher(t, img, ["load", "error"]);
     45    img.src = IMAGE_URL;
     46    await imgWatcher.wait_for("load");
     47    const imgBitmap = await createImageBitmap(img);
     48    const detector = crossOriginTest.createDetector();
     49    promise_rejects_dom(t, "SecurityError", detector.detect(imgBitmap));
     50  }, crossOriginTest.detectorType
     51  + " should reject cross-origin ImageBitmaps with a SecurityError.");
     52 
     53  // Verifies that Detector rejects a cross-origin HTMLVideoElement.
     54  promise_test(async t => {
     55    const video = document.createElement('video');
     56    const videoWatcher = new EventWatcher(t, video, ["loadeddata", "error"]);
     57    video.src = VIDEO_URL;
     58    await videoWatcher.wait_for("loadeddata");
     59    const detector = crossOriginTest.createDetector();
     60    promise_rejects_dom(t, "SecurityError", detector.detect(video));
     61  }, crossOriginTest.detectorType
     62  + " should reject cross-origin HTMLVideoElements with a SecurityError.");
     63 
     64 }
     65 
     66 </script>