File: image-with-dpr-header.html

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (40 lines) | stat: -rw-r--r-- 2,949 bytes parent folder | download | duplicates (26)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<img id="int_dpr" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0">
<img id="fractional_dpr" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=2.5">
<img id="smaller_than_one" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=0.5">
<img id="srcset" srcset="resources/square.png 4x">
<img id="invalid" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=xx">
<img id="invalid_negative" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=-2">
<img id="invalid_zero" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=0">
<img id="header_and_srcset_invalid" srcset="resources/dpr.py?name=square.png&mimeType=image/png&dpr=xx 4x">
<img id="header_and_srcset_valid" srcset="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0 2x">
<img id="explicit_width" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0" width="100" height="100">
<img id="double_dpr" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0&double=4.0">
<img id="double_dpr_different_values" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0&double=2.5">

<script>
    let run_test = () => {
        test(() => {
            assert_equals(document.getElementById("int_dpr").naturalWidth, 25, "Integer Content-DPR header value")
            assert_equals(document.getElementById("fractional_dpr").naturalWidth, 40, "Fractional Content-DPR header value")
            assert_equals(document.getElementById("smaller_than_one").naturalWidth, 200, "Smaller than one Content-DPR header value")
            assert_equals(document.getElementById("srcset").naturalWidth, 25, "srcset")
            assert_equals(document.getElementById("invalid").naturalWidth, 100, "Invalid Content-DPR header value")
            assert_equals(document.getElementById("invalid_negative").naturalWidth, 100, "Negative Content-DPR header value")
            assert_equals(document.getElementById("invalid_zero").naturalWidth, 100, "Zero Content-DPR header value")
            assert_equals(document.getElementById("header_and_srcset_invalid").naturalWidth, 25, "Invalid Content-DPR header value with valid srcset")
            assert_equals(document.getElementById("header_and_srcset_valid").naturalWidth, 25, "Value Content-DPR header value and srcset")
            assert_equals(document.getElementById("explicit_width").naturalWidth, 25, "Explicit width attribute")
            assert_equals(document.getElementById("double_dpr").naturalWidth, 25, "Double Content-DPR header")
            assert_equals(document.getElementById("double_dpr_different_values").naturalWidth, 40, "Double Content-DPR header different values")

        }, "Test the image dimensions of different DPR sizes");
    }
    window.addEventListener("load", run_test);
</script>

</body>
</html>