tor-browser

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

detection-HTMLImageElement-zero-dimension-image.https.html (1063B)


      1 <!DOCTYPE html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script>
      5 // This test verifies *Detector.detect() returns an empty list when fed with
      6 // an HTMLImageElement with an image with 0x0 dimensions.
      7 const zeroDimensionsTests = [
      8  {
      9    createDetector: () => { return new FaceDetector(); },
     10    name: "Face - detect(0x0)"
     11  },
     12  {
     13    createDetector: () => { return new BarcodeDetector(); },
     14    name: "Barcode - detect(0x0)"
     15  },
     16  {
     17    createDetector: () => { return new TextDetector(); },
     18    name: "Text - detect(0x0)"
     19  }
     20 ];
     21 
     22 for (let zeroDimensionsTest of zeroDimensionsTests) {
     23  promise_test(async t => {
     24    const img = new Image();
     25    const imgWatcher = new EventWatcher(t, img, ["load", "error"]);
     26    img.src = "/images/red-zerosize.svg";
     27    await imgWatcher.wait_for("load");
     28 
     29    const detector = zeroDimensionsTest.createDetector();
     30    const detectionResult = await detector.detect(img);
     31    assert_equals(detectionResult.length, 0);
     32  }, zeroDimensionsTest.name);
     33 }
     34 </script>