mirror of
https://github.com/servo/servo.git
synced 2025-08-31 01:58:23 +01:00
Update web-platform-tests to revision 632a3f59238036b6e24b28d47218ba9986ff4c62
This commit is contained in:
parent
cd02ca6c19
commit
fb838278a5
430 changed files with 15017 additions and 508 deletions
|
@ -1,97 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
const srcs = [
|
||||
"/feature-policy/experimental-features/resources/image.svg",
|
||||
"/feature-policy/experimental-features/resources/image.jpg",
|
||||
"/feature-policy/experimental-features/resources/image.png",
|
||||
];
|
||||
|
||||
for (var src of srcs) {
|
||||
async_test(t => {
|
||||
var img = document.createElement('IMG');
|
||||
img.intrinsicSize = '400 x 500';
|
||||
var expected_intrinsic_width = 400;
|
||||
var expected_intrinsic_height = 500;
|
||||
var expected_width = expected_intrinsic_width;
|
||||
var expected_height = expected_intrinsic_height;
|
||||
|
||||
document.body.appendChild(img);
|
||||
img.addEventListener('load', t.step_func(() => {
|
||||
assert_equals(img.width, expected_width, 'width');
|
||||
assert_equals(img.height, expected_height, 'height');
|
||||
assert_equals(img.naturalWidth, expected_intrinsic_width, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, expected_intrinsic_height, 'naturalHeigh');
|
||||
t.done();
|
||||
}));
|
||||
img.srcset = src + ' 3x';
|
||||
}, 'Test image ' + src + ' with no specified sizes, width, or height');
|
||||
|
||||
async_test(t => {
|
||||
var img = document.createElement('IMG');
|
||||
img.intrinsicSize = '400 x 500';
|
||||
img.width = '800'; /* 2x of intrinsic width */
|
||||
var expected_intrinsic_width = 400;
|
||||
var expected_intrinsic_height = 500;
|
||||
var expected_width = expected_intrinsic_width * 2;
|
||||
var expected_height = expected_intrinsic_height * 2;
|
||||
|
||||
document.body.appendChild(img);
|
||||
img.addEventListener('load', t.step_func(() => {
|
||||
assert_equals(img.width, expected_width, 'width');
|
||||
assert_equals(img.height, expected_height, 'height');
|
||||
assert_equals(img.naturalWidth, expected_intrinsic_width, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, expected_intrinsic_height, 'naturalHeigh');
|
||||
t.done();
|
||||
}));
|
||||
img.srcset = src + ' 3x';
|
||||
}, 'Test image ' + src + ' with width = 800, no specified sizes, or height');
|
||||
|
||||
async_test(t => {
|
||||
var img = document.createElement('IMG');
|
||||
img.intrinsicSize = '400 x 500';
|
||||
img.width = '800';
|
||||
img.style = 'height:800px;';
|
||||
var expected_intrinsic_width = 400;
|
||||
var expected_intrinsic_height = 500;
|
||||
var expected_width = 800;
|
||||
var expected_height = 800;
|
||||
|
||||
document.body.appendChild(img);
|
||||
img.addEventListener('load', t.step_func(() => {
|
||||
assert_equals(img.width, expected_width, 'width');
|
||||
assert_equals(img.height, expected_height, 'height');
|
||||
assert_equals(img.naturalWidth, expected_intrinsic_width, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, expected_intrinsic_height, 'naturalHeigh');
|
||||
t.done();
|
||||
}));
|
||||
img.srcset = src + ' 3x';
|
||||
}, 'Test image ' + src + ' with width = 800, height = 800, and no specified sizes');
|
||||
}
|
||||
|
||||
async_test(t => {
|
||||
var img = document.createElement('IMG');
|
||||
img.intrinsicSize = '400 x 500';
|
||||
img.sizes = '100px';
|
||||
var expected_intrinsic_width = 100;
|
||||
var expected_intrinsic_height = 125;
|
||||
var expected_width = 100;
|
||||
var expected_height = 125;
|
||||
|
||||
document.body.appendChild(img);
|
||||
img.addEventListener('load', t.step_func(() => {
|
||||
assert_equals(img.width, expected_width, 'width');
|
||||
assert_equals(img.height, expected_height, 'height');
|
||||
assert_equals(img.naturalWidth, expected_intrinsic_width, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, expected_intrinsic_height, 'naturalHeigh');
|
||||
t.done();
|
||||
}));
|
||||
img.srcset = srcs[2] + ' 32w';
|
||||
}, 'Test image (32 x 32) with sizes = 100 and srcset descriptor = 32w');
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -1,100 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
const srcs = [
|
||||
"/feature-policy/experimental-features/resources/image.svg",
|
||||
"/feature-policy/experimental-features/resources/image.jpg",
|
||||
"/feature-policy/experimental-features/resources/image.png",
|
||||
];
|
||||
|
||||
// Set new attribute, and wait til the media element is repainted.
|
||||
function updateAttribute(e, attribute, value) {
|
||||
return new Promise(resolve => {
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
|
||||
e.setAttribute(attribute, value);
|
||||
});
|
||||
}
|
||||
|
||||
// Test intrinsicSize attribute with image element.
|
||||
for (var src of srcs) {
|
||||
promise_test(async() => {
|
||||
var img = document.createElement('IMG');
|
||||
document.body.appendChild(img);
|
||||
img.src = src;
|
||||
await new Promise(resolve =>
|
||||
img.addEventListener('load', () => resolve(), {once: true}));
|
||||
await updateAttribute(img, 'intrinsicSize', '400 x 500');
|
||||
assert_equals(img.width, 400, 'width');
|
||||
assert_equals(img.height, 500, 'height');
|
||||
assert_equals(img.naturalWidth, 400, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 500, 'naturalHeight');
|
||||
|
||||
await updateAttribute(img, 'width', '800');
|
||||
assert_equals(img.width, 800, 'width');
|
||||
assert_equals(img.height, 1000, 'height');
|
||||
assert_equals(img.naturalWidth, 400, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 500, 'naturalHeight');
|
||||
|
||||
await updateAttribute(img, 'style', 'height:800px;');
|
||||
assert_equals(img.width, 800, 'width');
|
||||
assert_equals(img.height, 800, 'height');
|
||||
assert_equals(img.naturalWidth, 400, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 500, 'naturalHeight');
|
||||
|
||||
await updateAttribute(img, 'width', '');
|
||||
assert_equals(img.width, 640, 'width');
|
||||
assert_equals(img.height, 800, 'height');
|
||||
assert_equals(img.naturalWidth, 400, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 500, 'naturalHeight');
|
||||
|
||||
await updateAttribute(img, 'style', 'height:800px; writing-mode: vertical-rl;');
|
||||
assert_equals(img.width, 640, 'width');
|
||||
assert_equals(img.height, 800, 'height');
|
||||
assert_equals(img.naturalWidth, 400, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 500, 'naturalHeight');
|
||||
|
||||
await updateAttribute(img, 'style', 'height:800px; writing-mode: horizontal-tb;');
|
||||
assert_equals(img.width, 640, 'width');
|
||||
assert_equals(img.height, 800, 'height');
|
||||
assert_equals(img.naturalWidth, 400, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 500, 'naturalHeight');
|
||||
}, 'Test image with src=' + src);
|
||||
}
|
||||
|
||||
// Test intrinsicSize attribute with video element.
|
||||
promise_test(async() => {
|
||||
var video = document.createElement('video');
|
||||
document.body.appendChild(video);
|
||||
video.src = "/feature-policy/experimental-features/resources/video.ogv";
|
||||
await new Promise(resolve =>
|
||||
video.addEventListener('canplaythrough', () => resolve(), {once: true}));
|
||||
video.intrinsicSize = '400 x 500';
|
||||
assert_equals(video.getBoundingClientRect().width, 400, 'width');
|
||||
assert_equals(video.getBoundingClientRect().height, 500, 'height');
|
||||
assert_equals(video.videoWidth, 400, 'naturalWidth');
|
||||
assert_equals(video.videoHeight, 500, 'naturalHeight');
|
||||
|
||||
video.width = '800';
|
||||
assert_equals(video.getBoundingClientRect().width, 800, 'width');
|
||||
assert_equals(video.getBoundingClientRect().height, 1000, 'height');
|
||||
assert_equals(video.videoWidth, 400, 'naturalWidth');
|
||||
assert_equals(video.videoHeight, 500, 'naturalHeight');
|
||||
|
||||
video.style = 'height:800px;';
|
||||
assert_equals(video.getBoundingClientRect().width, 800, 'width');
|
||||
assert_equals(video.getBoundingClientRect().height, 800, 'height');
|
||||
assert_equals(video.videoWidth, 400, 'naturalWidth');
|
||||
assert_equals(video.videoHeight, 500, 'naturalHeight');
|
||||
|
||||
video.removeAttribute('width');
|
||||
assert_equals(video.getBoundingClientRect().width, 640, 'width');
|
||||
assert_equals(video.getBoundingClientRect().height, 800, 'height');
|
||||
assert_equals(video.videoWidth, 400, 'naturalWidth');
|
||||
assert_equals(video.videoHeight, 500, 'naturalHeight');
|
||||
}, 'Test video');
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,122 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
const srcs = [
|
||||
"/feature-policy/experimental-features/resources/image.svg",
|
||||
"/feature-policy/experimental-features/resources/image.jpg",
|
||||
"/feature-policy/experimental-features/resources/image.png",
|
||||
];
|
||||
|
||||
// Set new attribute, and wait til the media element is repainted.
|
||||
function updateAttribute(e, attribute, value) {
|
||||
return new Promise(resolve => {
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
|
||||
e.setAttribute(attribute, value);
|
||||
});
|
||||
}
|
||||
|
||||
// Test intrinsicSize attribute with image element.
|
||||
for (var src of srcs) {
|
||||
promise_test(async() => {
|
||||
var img = document.createElement('IMG');
|
||||
document.body.appendChild(img);
|
||||
img.src = src;
|
||||
await new Promise(resolve =>
|
||||
img.addEventListener('load', () => resolve(), {once: true}));
|
||||
assert_equals(img.width, 300, 'width');
|
||||
assert_equals(img.height, 150, 'height');
|
||||
assert_equals(img.naturalWidth, 300, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 150, 'naturalHeight');
|
||||
|
||||
await updateAttribute(img, 'width', '800');
|
||||
assert_equals(img.width, 800, 'width');
|
||||
assert_equals(img.height, 400, 'height');
|
||||
assert_equals(img.naturalWidth, 300, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 150, 'naturalHeight');
|
||||
|
||||
await updateAttribute(img, 'intrinsicSize', '400 x 500');
|
||||
assert_equals(img.width, 800, 'width');
|
||||
assert_equals(img.height, 1000, 'height');
|
||||
assert_equals(img.naturalWidth, 400, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 500, 'naturalHeight');
|
||||
|
||||
await updateAttribute(img, 'style', 'height:800px;');
|
||||
assert_equals(img.width, 800, 'width');
|
||||
assert_equals(img.height, 800, 'height');
|
||||
assert_equals(img.naturalWidth, 400, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 500, 'naturalHeight');
|
||||
|
||||
await updateAttribute(img, 'width', '');
|
||||
assert_equals(img.width, 640, 'width');
|
||||
assert_equals(img.height, 800, 'height');
|
||||
assert_equals(img.naturalWidth, 400, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 500, 'naturalHeight');
|
||||
|
||||
await updateAttribute(img, 'intrinsicSize', '');
|
||||
assert_equals(img.width, 1600, 'width');
|
||||
assert_equals(img.height, 800, 'height');
|
||||
assert_equals(img.naturalWidth, 300, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 150, 'naturalHeight');
|
||||
|
||||
await updateAttribute(img, 'style', '');
|
||||
assert_equals(img.width, 300, 'width');
|
||||
assert_equals(img.height, 150, 'height');
|
||||
assert_equals(img.naturalWidth, 300, 'naturalWidth');
|
||||
assert_equals(img.naturalHeight, 150, 'naturalHeight');
|
||||
}, 'Test image with src=' + src);
|
||||
}
|
||||
|
||||
// Test intrinsicSize attribute with video element.
|
||||
promise_test(async() => {
|
||||
var video = document.createElement('video');
|
||||
document.body.appendChild(video);
|
||||
video.src = "/feature-policy/experimental-features/resources/video.ogv";
|
||||
await new Promise(resolve =>
|
||||
video.addEventListener('canplaythrough', () => resolve(), {once: true}));
|
||||
assert_equals(video.getBoundingClientRect().width, 300, 'width');
|
||||
assert_equals(video.getBoundingClientRect().height, 150, 'height');
|
||||
assert_equals(video.videoWidth, 300, 'videoWidth');
|
||||
assert_equals(video.videoHeight, 150, 'videoHeight');
|
||||
|
||||
await updateAttribute(video, 'width', '800');
|
||||
assert_equals(video.getBoundingClientRect().width, 800, 'width');
|
||||
assert_equals(video.getBoundingClientRect().height, 400, 'height');
|
||||
assert_equals(video.videoWidth, 300, 'videoWidth');
|
||||
assert_equals(video.videoHeight, 150, 'videoHeight');
|
||||
|
||||
await updateAttribute(video, 'intrinsicSize', '400 x 500');
|
||||
assert_equals(video.getBoundingClientRect().width, 800, 'width');
|
||||
assert_equals(video.getBoundingClientRect().height, 1000, 'width');
|
||||
assert_equals(video.videoWidth, 400, 'videoWidth');
|
||||
assert_equals(video.videoHeight, 500, 'videoHeight');
|
||||
|
||||
await updateAttribute(video, 'style', 'height:800px;');
|
||||
assert_equals(video.getBoundingClientRect().width, 800, 'width');
|
||||
assert_equals(video.getBoundingClientRect().height, 800, 'height');
|
||||
assert_equals(video.videoWidth, 400, 'videoWidth');
|
||||
assert_equals(video.videoHeight, 500, 'videoHeight');
|
||||
|
||||
await updateAttribute(video, 'width', '');
|
||||
assert_equals(video.getBoundingClientRect().width, 640, 'width');
|
||||
assert_equals(video.getBoundingClientRect().height, 800, 'height');
|
||||
assert_equals(video.videoWidth, 400, 'videoWidth');
|
||||
assert_equals(video.videoHeight, 500, 'videoHeight');
|
||||
|
||||
await updateAttribute(video, 'intrinsicSize', '');
|
||||
assert_equals(video.getBoundingClientRect().width, 1600, 'width');
|
||||
assert_equals(video.getBoundingClientRect().height, 800, 'height');
|
||||
assert_equals(video.videoWidth, 300, 'videoWidth');
|
||||
assert_equals(video.videoHeight, 150, 'videoHeight');
|
||||
|
||||
await updateAttribute(video, 'style', '');
|
||||
assert_equals(video.getBoundingClientRect().width, 300, 'width');
|
||||
assert_equals(video.getBoundingClientRect().height, 150, 'height');
|
||||
assert_equals(video.videoWidth, 300, 'videoWidth');
|
||||
assert_equals(video.videoHeight, 150, 'videoHeight');
|
||||
}, 'Test video');
|
||||
</script>
|
||||
</body>
|
|
@ -1 +0,0 @@
|
|||
Feature-Policy: unsized-media *
|
|
@ -17,12 +17,12 @@ const test_cases = [
|
|||
{expected_width: default_width, expected_height: default_height},
|
||||
// Test when only one dimension is specified, img/video uses the default length for
|
||||
// the other dimension.
|
||||
{attribute: "width", value: 500, expected_width: 500, expected_height: default_height},
|
||||
{attribute: "height", value: 800, expected_width: default_width, expected_height: 800},
|
||||
{attribute: "width", value: 500, expected_width: 500, expected_height: 500 / 2},
|
||||
{attribute: "height", value: 800, expected_width: 800 * 2, expected_height: 800},
|
||||
// Test when only one dimension is specified by CSS style, img/video uses the
|
||||
// default length for the other dimension.
|
||||
{attribute: "style", value: "width:500px;", expected_width: 500, expected_height: default_height},
|
||||
{attribute: "style", value: "height:800px;", expected_width: default_width, expected_height: 800},
|
||||
{attribute: "style", value: "width:500px;", expected_width: 500, expected_height: 500 / 2},
|
||||
{attribute: "style", value: "height:800px;", expected_width: 800 * 2, expected_height: 800},
|
||||
// Test when the size of the image is specified, img/video is laid out by the
|
||||
// specified size.
|
||||
{attribute: "width", value: 500, attribute1: "height", value1: 800, expected_width: 500, expected_height:800},
|
|
@ -0,0 +1 @@
|
|||
Feature-Policy: unsized-media 'none'
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src='/resources/testharness.js'></script>
|
||||
<script src='/resources/testharnessreport.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var check_report_format = (reports, observer) => {
|
||||
let report = reports[0];
|
||||
assert_equals(report.type, "feature-policy");
|
||||
assert_equals(report.url, document.location.href);
|
||||
assert_equals(report.body.feature, "vr");
|
||||
assert_equals(report.body.sourceFile, document.location.href);
|
||||
assert_equals(typeof report.body.message, "string");
|
||||
assert_equals(typeof report.body.lineNumber, "number");
|
||||
assert_equals(typeof report.body.columnNumber, "number");
|
||||
};
|
||||
|
||||
promise_test(async (t) => {
|
||||
const report = new Promise(resolve => {
|
||||
new ReportingObserver((reports, observer) => resolve([reports, observer]),
|
||||
{types: ['feature-policy']}).observe();
|
||||
});
|
||||
await promise_rejects(t, 'SecurityError', navigator.getVRDisplays(),
|
||||
"VR device access should not be allowed in this document.");
|
||||
const [reports, observer] = await report;
|
||||
check_report_format(reports, observer);
|
||||
}, "VR Report Format");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1 @@
|
|||
Feature-Policy: vr 'none'
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src='/resources/testharness.js'></script>
|
||||
<script src='/resources/testharnessreport.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var check_report_format = (reports, observer) => {
|
||||
let report = reports[0];
|
||||
assert_equals(report.type, "feature-policy");
|
||||
assert_equals(report.url, document.location.href);
|
||||
assert_equals(report.body.feature, "vr");
|
||||
assert_equals(report.body.sourceFile, document.location.href);
|
||||
assert_equals(typeof report.body.message, "string");
|
||||
assert_equals(typeof report.body.lineNumber, "number");
|
||||
assert_equals(typeof report.body.columnNumber, "number");
|
||||
};
|
||||
|
||||
promise_test(async (t) => {
|
||||
const report = new Promise(resolve => {
|
||||
new ReportingObserver((reports, observer) => resolve([reports, observer]),
|
||||
{types: ['feature-policy']}).observe();
|
||||
});
|
||||
await promise_rejects(t, 'SecurityError', navigator.xr.requestDevice(),
|
||||
"XR device access should not be allowed in this document.");
|
||||
const [reports, observer] = await report;
|
||||
check_report_format(reports, observer);
|
||||
}, "XR Report Format");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1 @@
|
|||
Feature-Policy: vr 'none'
|
Loading…
Add table
Add a link
Reference in a new issue