-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1234 from zcorpan/img-picture
Some tests for <img>/<picture>
- Loading branch information
Showing
9 changed files
with
922 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
html/semantics/embedded-content/the-img-element/current-pixel-density/basic.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!doctype html> | ||
<title>img current pixel density basic</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id=log></div> | ||
<img src="/images/green-256x256.png" data-expect="256"> | ||
<img srcset="/images/green-256x256.png 1x" data-expect="256"> | ||
<img srcset="/images/green-256x256.png 1.6x" data-expect="160"> | ||
<img srcset="/images/green-256x256.png 2x" data-expect="128"> | ||
<img srcset="/images/green-256x256.png 10000x" data-expect="0"> | ||
<img srcset="/images/green-256x256.png 9e99999999999999999999999x" data-expect="0"> | ||
<img srcset="/images/green-256x256.png 256w" sizes="256px" data-expect="256"> | ||
<img srcset="/images/green-256x256.png 512w" sizes="256px" data-expect="128"> | ||
<img srcset="/images/green-256x256.png 256w" sizes="512px" data-expect="512"> | ||
<img srcset="/images/green-256x256.png 256w" sizes="1px" data-expect="1"> | ||
<img srcset="/images/green-256x256.png 256w" sizes="0px" data-expect="0"> | ||
<script> | ||
setup({explicit_done:true}); | ||
onload = function() { | ||
[].forEach.call(document.images, function(img) { | ||
var expected = parseFloat(img.dataset.expect); | ||
test(function() { | ||
assert_equals(img.width, expected, 'width'); | ||
assert_equals(img.height, expected, 'height'); | ||
assert_equals(img.clientWidth, expected, 'clientWidth'); | ||
assert_equals(img.clientHeight, expected, 'clientHeight'); | ||
assert_equals(img.naturalWidth, 256, 'naturalWidth'); | ||
assert_equals(img.naturalHeight, 256, 'naturalHeight'); | ||
}, img.outerHTML); | ||
}); | ||
done(); | ||
}; | ||
</script> |
30 changes: 30 additions & 0 deletions
30
html/semantics/embedded-content/the-img-element/current-pixel-density/error.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!doctype html> | ||
<title>img current pixel density error</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id=log></div> | ||
<img id=ref src="404" alt="testing"> | ||
<img srcset="404" alt="testing"> | ||
<img srcset="404 0.5x" alt="testing"> | ||
<img srcset="404 2x" alt="testing"> | ||
<img srcset="404 100w" alt="testing"> | ||
<img srcset="404 100w" sizes="500px" alt="testing"> | ||
<picture><img src="404 100w" sizes="500px" alt="testing"></picture> | ||
<script> | ||
setup({explicit_done:true}); | ||
onload = function() { | ||
var expected_width = ref.width; | ||
var expected_height = ref.height; | ||
[].forEach.call(document.images, function(img) { | ||
test(function() { | ||
assert_not_equals(expected_width, 0, 'expected_width'); | ||
assert_not_equals(expected_height, 0, 'expected_height'); | ||
assert_equals(img.width, expected_width, 'width'); | ||
assert_equals(img.height, expected_height, 'height'); | ||
assert_equals(img.naturalWidth, 0, 'naturalWidth'); | ||
assert_equals(img.naturalHeight, 0, 'naturalHeight'); | ||
}, img.outerHTML); | ||
}); | ||
done(); | ||
}; | ||
</script> |
Oops, something went wrong.