|
2 | 2 | <body>
|
3 | 3 | <script src="/resources/testharness.js"></script>
|
4 | 4 | <script src="/resources/testharnessreport.js"></script>
|
| 5 | +<script src="./resources/piexif.js"></script> |
| 6 | +<script src="./resources/exify.js"></script> |
5 | 7 | <link rel=" author" title=" Noam Rosenthal" href=" [email protected]" >
|
6 |
| -<img src="resources/exif-resolution-invalid-cm.jpg" data-width="100" data-height="50" class="test-img" /> |
7 |
| -<img src="resources/exif-resolution-invalid-no-match.jpg" data-width="100" data-height="50" class="test-img" /> |
8 |
| -<img src="resources/exif-resolution-invalid-partial.jpg" data-width="100" data-height="50" class="test-img" /> |
9 |
| -<img src="resources/exif-resolution-no-change.jpg" data-width="100" data-height="50" class="test-img" /> |
10 |
| -<img src="resources/exif-resolution-none.jpg" data-width="100" data-height="50" class="test-img" /> |
11 |
| -<img src="resources/exif-resolution-valid-hires.jpg" data-width="50" data-height="25" class="test-img" /> |
12 |
| -<img src="resources/exif-resolution-valid-lores.jpg" data-width="200" data-height="100" class="test-img" /> |
13 |
| -<img src="resources/exif-resolution-valid-non-uniform.jpg" data-width="50" data-height="100" class="test-img" /> |
14 |
| -<img src="resources/exif-resolution-with-orientation.jpg" data-width="100" data-height="200" class="test-img" /> |
15 | 8 | <script>
|
16 |
| - let run_test = () => { |
17 |
| - test(() => { |
18 |
| - [...document.querySelectorAll('.test-img')].forEach(img => { |
19 |
| - assert_equals(img.naturalWidth, +img.dataset.width, `Density size correction for ${img.src}`); |
20 |
| - assert_equals(img.naturalHeight, +img.dataset.height, `Density size correction for ${img.src}`); |
21 |
| - }) |
22 |
| - }, "Test the image dimensions of different EXIF scenarios"); |
| 9 | + async function test_valid(input) { |
| 10 | + const image = await createImageWithMetadata(input) |
| 11 | + assert_equals(image.naturalWidth, input.preferredWidth) |
| 12 | + assert_equals(image.naturalHeight, input.preferredHeight) |
23 | 13 | }
|
24 |
| - window.addEventListener("load", run_test); |
| 14 | + async function test_invalid(input) { |
| 15 | + const image = await createImageWithMetadata(input) |
| 16 | + assert_equals(image.naturalWidth, input.width) |
| 17 | + assert_equals(image.naturalHeight, input.height) |
| 18 | + } |
| 19 | + |
| 20 | + async function test() { |
| 21 | + await test_valid({width: 10, height: 20, preferredWidth: 20, preferredHeight: 40, resolutionX: 36, resolutionY: 36, resolutionUnit: 2}) |
| 22 | + await test_valid({width: 10, height: 20, preferredWidth: 2, preferredHeight: 4, resolutionX: 360, resolutionY: 360, resolutionUnit: 2}) |
| 23 | + await test_valid({width: 10, height: 20, preferredWidth: 20, preferredHeight: 10, resolutionX: 36, resolutionY: 144, resolutionUnit: 2}) |
| 24 | + await test_valid({width: 10, height: 20, preferredWidth: 10, preferredHeight: 40, resolutionX: 72, resolutionY: 36, resolutionUnit: 2}) |
| 25 | + await test_valid({width: 30, height: 30, preferredWidth: 90, preferredHeight: 30, resolutionX: 24, resolutionY: 72, resolutionUnit: 2}) |
| 26 | + |
| 27 | + await test_valid({width: 10, height: 20, preferredWidth: 20, preferredHeight: 40, resolutionX: 36, resolutionY: 36, resolutionUnit: 2}) |
| 28 | + await test_valid({width: 10, height: 20, preferredWidth: 20, preferredHeight: 40, resolutionX: 36, resolutionY: 36, resolutionUnit: 2}) |
| 29 | + await test_valid({width: 10, height: 20, preferredWidth: 20, preferredHeight: 40, resolutionX: 36, resolutionY: 36, resolutionUnit: 2}) |
| 30 | + await test_valid({width: 10, height: 20, preferredWidth: 20, preferredHeight: 40, resolutionX: 36, resolutionY: 36, resolutionUnit: 2}) |
| 31 | + } |
| 32 | + |
| 33 | + promise_test(test) |
| 34 | + |
25 | 35 | </script>
|
26 | 36 |
|
27 | 37 | </body>
|
|
0 commit comments