mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
Update web-platform-tests to revision 687b6cba3385c4c2ca85f44fe072961e651621b5
This commit is contained in:
parent
cd579f6746
commit
1a4444a557
45 changed files with 594 additions and 259 deletions
|
@ -20,6 +20,7 @@ const ResourceType = {
|
|||
WORKER: "worker",
|
||||
WORKLET: "worklet",
|
||||
WEBSOCKET: "websocket",
|
||||
FETCH: "fetch",
|
||||
};
|
||||
|
||||
// These tests rely on some unintuitive cleverness due to WPT's test setup:
|
||||
|
@ -27,22 +28,24 @@ const ResourceType = {
|
|||
// in the form `http://[domain]:[https-port]`. If the upgrade fails, the load will fail,
|
||||
// as we don't serve HTTP over the secure port.
|
||||
function generateURL(host, protocol, resourceType) {
|
||||
var url = new URL("http://{{host}}:{{ports[https][0]}}/upgrade-insecure-requests/support/");
|
||||
var url = new URL("http://{{host}}:{{ports[https][0]}}/common/security-features/subresource/");
|
||||
url.protocol = protocol == Protocol.INSECURE ? "http" : "https";
|
||||
url.hostname = host == Host.SAME_ORIGIN ? "{{host}}" : "{{domains[天気の良い日]}}";
|
||||
|
||||
if (resourceType == ResourceType.IMAGE) {
|
||||
url.pathname += "pass.png";
|
||||
url.pathname += "image.py";
|
||||
} else if (resourceType == ResourceType.FRAME) {
|
||||
url.pathname += "post-origin-to-parent.html";
|
||||
url.pathname += "document.py";
|
||||
} else if (resourceType == ResourceType.WEBSOCKET) {
|
||||
url.port = {{ports[wss][0]}};
|
||||
url.protocol = protocol == Protocol.INSECURE ? "ws" : "wss";
|
||||
url.pathname = "echo";
|
||||
} else if (resourceType == ResourceType.WORKER) {
|
||||
url.pathname += "worker.js";
|
||||
url.pathname += "worker.py";
|
||||
} else if (resourceType == ResourceType.WORKLET) {
|
||||
url.pathname = "/worklets/resources/empty-worklet-script-with-cors-header.js";
|
||||
url.pathname += "worker.py";
|
||||
} else if (resourceType == ResourceType.FETCH) {
|
||||
url.pathname += "xhr.py";
|
||||
}
|
||||
return {
|
||||
name: protocol + "/" + host + " " + resourceType,
|
||||
|
@ -110,24 +113,24 @@ function generateModuleImportTests(target, sameOriginOnly) {
|
|||
return tests;
|
||||
}
|
||||
|
||||
function assert_image_loads(test, url, height, width) {
|
||||
function assert_image_loads(test, url) {
|
||||
var i = document.createElement('img');
|
||||
i.onload = test.step_func_done(_ => {
|
||||
assert_equals(i.naturalHeight, height, "Height.");
|
||||
assert_equals(i.naturalWidth, width, "Width.");
|
||||
assert_greater_than(i.naturalHeight, 0, "Height.");
|
||||
assert_greater_than(i.naturalWidth, 0, "Width.");
|
||||
});
|
||||
i.onerror = test.unreached_func(url + " should load successfully.");
|
||||
i.src = url;
|
||||
}
|
||||
|
||||
function assert_image_loads_in_srcdoc(test, url, height, width) {
|
||||
function assert_image_loads_in_srcdoc(test, url) {
|
||||
var frame = document.createElement('iframe');
|
||||
frame.srcdoc = "yay!";
|
||||
frame.onload = _ => {
|
||||
var i = frame.contentDocument.createElement('img');
|
||||
i.onload = test.step_func_done(_ => {
|
||||
assert_equals(i.naturalHeight, height, "Height.");
|
||||
assert_equals(i.naturalWidth, width, "Width.");
|
||||
assert_greater_than(i.naturalHeight, 0, "Height.");
|
||||
assert_greater_than(i.naturalWidth, 0, "Width.");
|
||||
frame.remove();
|
||||
});
|
||||
i.onerror = test.unreached_func(url + " should load successfully.");
|
||||
|
@ -137,13 +140,13 @@ function assert_image_loads_in_srcdoc(test, url, height, width) {
|
|||
document.body.appendChild(frame);
|
||||
}
|
||||
|
||||
function assert_image_loads_in_blank(test, url, height, width) {
|
||||
function assert_image_loads_in_blank(test, url) {
|
||||
var frame = document.createElement('iframe');
|
||||
frame.onload = _ => {
|
||||
var i = frame.contentDocument.createElement('img');
|
||||
i.onload = test.step_func_done(_ => {
|
||||
assert_equals(i.naturalHeight, height, "Height.");
|
||||
assert_equals(i.naturalWidth, width, "Width.");
|
||||
assert_greater_than(i.naturalHeight, 0, "Height.");
|
||||
assert_greater_than(i.naturalWidth, 0, "Width.");
|
||||
frame.remove();
|
||||
});
|
||||
i.onerror = test.unreached_func(url + " should load successfully.");
|
||||
|
@ -153,20 +156,6 @@ function assert_image_loads_in_blank(test, url, height, width) {
|
|||
document.body.appendChild(frame);
|
||||
}
|
||||
|
||||
function assert_frame_loads(test, url) {
|
||||
var i = document.createElement('iframe');
|
||||
|
||||
window.addEventListener('message', test.step_func(e => {
|
||||
if (e.source == i.contentWindow) {
|
||||
i.remove();
|
||||
test.done();
|
||||
}
|
||||
}));
|
||||
|
||||
i.src = url;
|
||||
document.body.appendChild(i);
|
||||
}
|
||||
|
||||
function assert_websocket_loads(test, url) {
|
||||
var w = new WebSocket(url, "echo");
|
||||
w.onopen = test.step_func(_ => {
|
||||
|
@ -178,12 +167,12 @@ function assert_websocket_loads(test, url) {
|
|||
|
||||
const testMap = {
|
||||
"image": test => {
|
||||
async_test(t => assert_image_loads(t, test.url, 64, 168), test.name);
|
||||
async_test(t => assert_image_loads_in_srcdoc(t, test.url, 64, 168), test.name + " in <iframe srcdoc>");
|
||||
async_test(t => assert_image_loads_in_blank(t, test.url, 64, 168), test.name + " in <iframe>");
|
||||
async_test(t => assert_image_loads(t, test.url), test.name);
|
||||
async_test(t => assert_image_loads_in_srcdoc(t, test.url), test.name + " in <iframe srcdoc>");
|
||||
async_test(t => assert_image_loads_in_blank(t, test.url), test.name + " in <iframe>");
|
||||
},
|
||||
"iframe":
|
||||
test => async_test(t => assert_frame_loads(t, test.url), test.name),
|
||||
test => promise_test(t => requestViaIframe(test.url), test.name),
|
||||
|
||||
"worker":
|
||||
test => promise_test(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue