tor-browser

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

image-with-dpr-header.html (2949B)


      1 <!DOCTYPE html>
      2 <body>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <img id="int_dpr" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0">
      6 <img id="fractional_dpr" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=2.5">
      7 <img id="smaller_than_one" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=0.5">
      8 <img id="srcset" srcset="resources/square.png 4x">
      9 <img id="invalid" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=xx">
     10 <img id="invalid_negative" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=-2">
     11 <img id="invalid_zero" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=0">
     12 <img id="header_and_srcset_invalid" srcset="resources/dpr.py?name=square.png&mimeType=image/png&dpr=xx 4x">
     13 <img id="header_and_srcset_valid" srcset="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0 2x">
     14 <img id="explicit_width" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0" width="100" height="100">
     15 <img id="double_dpr" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0&double=4.0">
     16 <img id="double_dpr_different_values" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0&double=2.5">
     17 
     18 <script>
     19    let run_test = () => {
     20        test(() => {
     21            assert_equals(document.getElementById("int_dpr").naturalWidth, 25, "Integer Content-DPR header value")
     22            assert_equals(document.getElementById("fractional_dpr").naturalWidth, 40, "Fractional Content-DPR header value")
     23            assert_equals(document.getElementById("smaller_than_one").naturalWidth, 200, "Smaller than one Content-DPR header value")
     24            assert_equals(document.getElementById("srcset").naturalWidth, 25, "srcset")
     25            assert_equals(document.getElementById("invalid").naturalWidth, 100, "Invalid Content-DPR header value")
     26            assert_equals(document.getElementById("invalid_negative").naturalWidth, 100, "Negative Content-DPR header value")
     27            assert_equals(document.getElementById("invalid_zero").naturalWidth, 100, "Zero Content-DPR header value")
     28            assert_equals(document.getElementById("header_and_srcset_invalid").naturalWidth, 25, "Invalid Content-DPR header value with valid srcset")
     29            assert_equals(document.getElementById("header_and_srcset_valid").naturalWidth, 25, "Value Content-DPR header value and srcset")
     30            assert_equals(document.getElementById("explicit_width").naturalWidth, 25, "Explicit width attribute")
     31            assert_equals(document.getElementById("double_dpr").naturalWidth, 25, "Double Content-DPR header")
     32            assert_equals(document.getElementById("double_dpr_different_values").naturalWidth, 40, "Double Content-DPR header different values")
     33 
     34        }, "Test the image dimensions of different DPR sizes");
     35    }
     36    window.addEventListener("load", run_test);
     37 </script>
     38 
     39 </body>
     40 </html>