Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some tests for <img>/<picture> #1234

Merged
merged 7 commits into from
Sep 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
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>
Loading