Update web-platform-tests to revision 332b7c4e711d75ead4c0dfbf7f6f0b683206756d

This commit is contained in:
WPT Sync Bot 2019-09-25 10:24:05 +00:00
parent 46611b012e
commit b60afa18f5
389 changed files with 7767 additions and 2421 deletions

View file

@ -0,0 +1,30 @@
<!doctype html>
<title>Canvas width and height attributes are used to infer aspect-ratio</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
canvas {
width: 100%;
max-width: 100px;
height: auto;
}
</style>
<body>
<script>
let t = async_test("Canvas width and height attributes are used to infer aspect-ratio");
function assert_ratio(img, expected) {
let epsilon = 0.001;
assert_approx_equals(parseInt(getComputedStyle(img).width, 10) / parseInt(getComputedStyle(img).height, 10), expected, epsilon);
}
// Create and append a new canvas and immediately check the ratio.
t.step(function() {
var canvas = document.createElement("canvas");
canvas.setAttribute("width", "250");
canvas.setAttribute("height", "100");
document.body.appendChild(canvas);
// Canvases always use the aspect ratio from their surface size.
assert_ratio(canvas, 2.5);
t.done();
});
</script>

View file

@ -9,7 +9,6 @@
height: auto;
}
</style>
<img src=broken width=100 height=125>
<img src="/images/green.png">
<img src="/images/green.png" width=100 height=125>
<script>
@ -18,10 +17,37 @@ function assert_ratio(img, expected) {
let epsilon = 0.001;
assert_approx_equals(parseInt(getComputedStyle(img).width, 10) / parseInt(getComputedStyle(img).height, 10), expected, epsilon);
}
// Create and append a new image and immediately check the ratio.
// This is not racy because the spec requires the user agent to queue a task:
// https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data
t.step(function() {
var img = new Image();
img.width = 250;
img.height = 100;
img.src = "/images/blue.png";
document.body.appendChild(img);
assert_ratio(img, 2.5);
img = new Image();
img.setAttribute("width", "0.8");
img.setAttribute("height", "0.2");
img.src = "/images/blue.png";
document.body.appendChild(img);
assert_ratio(img, 4);
img = new Image();
img.setAttribute("width", "50%");
img.setAttribute("height", "25%");
img.src = "/images/blue.png";
document.body.appendChild(img);
// Percentages should be ignored.
assert_equals(getComputedStyle(img).height, "0px");
});
onload = t.step_func_done(function() {
let images = document.querySelectorAll("img");
assert_ratio(images[0], 0.8);
assert_ratio(images[2], 2.0); // 2.0 is the original aspect ratio of green.png
assert_ratio(images[1], 2.0); // Loaded image's aspect ratio, at least by default, overrides width / height ratio.
assert_ratio(images[2], 1.266); // 1.266 is the original aspect ratio of blue.png
assert_ratio(images[1], 2.0); // 2.0 is the original aspect ratio of green.png
assert_ratio(images[0], 2.0); // Loaded image's aspect ratio, at least by default, overrides width / height ratio.
});
</script>

View file

@ -0,0 +1,39 @@
<!doctype html>
<title>Video width and height attributes are not used to infer aspect-ratio</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
<style>
video {
width: 100%;
max-width: 100px;
height: auto;
}
</style>
<body>
<script>
let t = async_test("Video width and height attributes are not used to infer aspect-ratio");
function assert_ratio(img, expected) {
let epsilon = 0.001;
assert_approx_equals(parseInt(getComputedStyle(img).width, 10) / parseInt(getComputedStyle(img).height, 10), expected, epsilon);
}
// Create and append a new video and immediately check the ratio.
// This is not racy because the spec requires the user agent to queue a task:
// https://html.spec.whatwg.org/multipage/media.html#concept-media-load-algorithm
t.step(function() {
var video = document.createElement("video");
video.setAttribute("width", "250");
video.setAttribute("height", "100");
video.src = getVideoURI('/media/2x2-green');
document.body.appendChild(video);
// Videos default to a size of 300x150px and calculate their aspect ratio
// based on that before the video is loaded. So this should be 2, ignoring
// the 2.5 that it would be based on the attributes.
assert_ratio(video, 2);
video.onloadeddata = t.step_func_done(function() {
// When loaded this video is square.
assert_ratio(video, 1);
});
});
</script>