| Yoav Weiss | 700ace6 | 2018-10-15 18:02:17 | [diff] [blame] | 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="header_and_srcset_invalid" srcset="resources/dpr.py?name=square.png&mimeType=image/png&dpr=xx 4x"> |
| 11 | <img id="header_and_srcset_valid" srcset="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0 2x"> |
| 12 | <img id="explicit_width" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0" width="100" height="100"> |
| 13 | <img id="double_dpr" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0&double=4.0"> |
| 14 | <img id="double_dpr_different_values" src="resources/dpr.py?name=square.png&mimeType=image/png&dpr=4.0&double=2.5"> |
| 15 | |
| 16 | <script> |
| 17 | let run_test = () => { |
| 18 | test(() => { |
| 19 | assert_equals(document.getElementById("int_dpr").naturalWidth, 25, "Integer Content-DPR header value") |
| 20 | assert_equals(document.getElementById("fractional_dpr").naturalWidth, 40, "Fractional Content-DPR header value") |
| 21 | assert_equals(document.getElementById("smaller_than_one").naturalWidth, 200, "Smaller than one Content-DPR header value") |
| 22 | assert_equals(document.getElementById("srcset").naturalWidth, 25, "srcset") |
| 23 | assert_equals(document.getElementById("invalid").naturalWidth, 100, "Invalid Content-DPR header value") |
| 24 | assert_equals(document.getElementById("header_and_srcset_invalid").naturalWidth, 25, "Invalid Content-DPR header value with valid srcset") |
| 25 | assert_equals(document.getElementById("header_and_srcset_valid").naturalWidth, 25, "Value Content-DPR header value and srcset") |
| 26 | assert_equals(document.getElementById("explicit_width").naturalWidth, 25, "Explicit width attribute") |
| 27 | assert_equals(document.getElementById("double_dpr").naturalWidth, 25, "Double Content-DPR header") |
| 28 | assert_equals(document.getElementById("double_dpr_different_values").naturalWidth, 40, "Double Content-DPR header different values") |
| 29 | |
| 30 | }, "Test the image dimensions of different DPR sizes"); |
| 31 | } |
| 32 | window.addEventListener("load", run_test); |
| 33 | </script> |
| 34 | |
| 35 | </body> |
| 36 | </html> |