mirror of
https://github.com/servo/servo.git
synced 2025-08-22 13:55:34 +01:00
Update web-platform-tests to revision cf261625e2d230ab219eec966f4abe26e3401b64
This commit is contained in:
parent
11a89bcc47
commit
8f98acd0e7
297 changed files with 3396 additions and 1555 deletions
|
@ -7,6 +7,10 @@
|
|||
<script>
|
||||
const worker = '../resources/cache-keys-attributes-for-service-worker.js';
|
||||
|
||||
function wait(ms) {
|
||||
return new Promise(resolve => step_timeout(resolve, ms));
|
||||
}
|
||||
|
||||
promise_test(async (t) => {
|
||||
const scope = '../resources/blank.html?name=isReloadNavigation';
|
||||
let frame;
|
||||
|
@ -33,4 +37,39 @@ promise_test(async (t) => {
|
|||
}
|
||||
}
|
||||
}, 'Request.IsReloadNavigation should persist.');
|
||||
|
||||
promise_test(async (t) => {
|
||||
const scope = '../resources/blank.html?name=isHistoryNavigation';
|
||||
let frame;
|
||||
let reg;
|
||||
|
||||
try {
|
||||
reg = await service_worker_unregister_and_register(t, worker, scope);
|
||||
await wait_for_state(t, reg.installing, 'activated');
|
||||
frame = await with_iframe(scope);
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'original: false, stored: false');
|
||||
// Use step_timeout(0) to ensure the history entry is created for Blink
|
||||
// and WebKit. See https://bugs.webkit.org/show_bug.cgi?id=42861.
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.onload = resolve;
|
||||
frame.src = '../resources/blank.html?ignore';
|
||||
});
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.onload = resolve;
|
||||
frame.contentWindow.history.go(-1);
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'original: true, stored: true');
|
||||
} finally {
|
||||
if (frame) {
|
||||
frame.remove();
|
||||
}
|
||||
if (reg) {
|
||||
await reg.unregister();
|
||||
}
|
||||
}
|
||||
}, 'Request.IsHistoryNavigation should persist.');
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<p>Click <a href="resources/install-worker.html?isHistoryNavigation&script=fetch-event-test-worker.js">this link</a>.
|
||||
Once you see "method = GET,..." in the page, go to another page, and then go back to the page using the Backward button.
|
||||
You should see "method = GET, isHistoryNavigation = true".
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<p>Click <a href="resources/install-worker.html?isHistoryNavigation&script=fetch-event-test-worker.js">this link</a>.
|
||||
Once you see "method = GET,..." in the page, go back to this page using the Backward button, and then go to the second page using the Forward button.
|
||||
You should see "method = GET, isHistoryNavigation = true".
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -770,5 +770,311 @@ promise_test(async (t) => {
|
|||
}
|
||||
}, 'FetchEvent#request.isReloadNavigation is true (with history traversal)');
|
||||
|
||||
promise_test(async (t) => {
|
||||
const scope = 'resources/simple.html?isHistoryNavigation';
|
||||
const anotherUrl = new Request('resources/simple.html').url;
|
||||
let frame;
|
||||
let reg;
|
||||
|
||||
try {
|
||||
reg = await service_worker_unregister_and_register(t, worker, scope);
|
||||
await wait_for_state(t, reg.installing, 'activated');
|
||||
frame = await with_iframe(scope);
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = false');
|
||||
// Use step_timeout(0) to ensure the history entry is created for Blink
|
||||
// and WebKit. See https://bugs.webkit.org/show_bug.cgi?id=42861.
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.src = anotherUrl;
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent, "Here's a simple html file.\n");
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(-1);
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = true');
|
||||
} finally {
|
||||
if (frame) {
|
||||
frame.remove();
|
||||
}
|
||||
if (reg) {
|
||||
await reg.unregister();
|
||||
}
|
||||
}
|
||||
}, 'FetchEvent#request.isHistoryNavigation is true (with history.go(-1))');
|
||||
|
||||
promise_test(async (t) => {
|
||||
const scope = 'resources/simple.html?isHistoryNavigation';
|
||||
const anotherUrl = new Request('resources/simple.html').url;
|
||||
let frame;
|
||||
let reg;
|
||||
|
||||
try {
|
||||
reg = await service_worker_unregister_and_register(t, worker, scope);
|
||||
await wait_for_state(t, reg.installing, 'activated');
|
||||
frame = await with_iframe(anotherUrl);
|
||||
assert_equals(frame.contentDocument.body.textContent, "Here's a simple html file.\n");
|
||||
// Use step_timeout(0) to ensure the history entry is created for Blink
|
||||
// and WebKit. See https://bugs.webkit.org/show_bug.cgi?id=42861.
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.src = scope;
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = false');
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(-1);
|
||||
});
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(1);
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = true');
|
||||
} finally {
|
||||
if (frame) {
|
||||
frame.remove();
|
||||
}
|
||||
if (reg) {
|
||||
await reg.unregister();
|
||||
}
|
||||
}
|
||||
}, 'FetchEvent#request.isHistoryNavigation is true (with history.go(1))');
|
||||
|
||||
promise_test(async (t) => {
|
||||
const scope = 'resources/simple.html?isHistoryNavigation';
|
||||
const anotherUrl = new Request('resources/simple.html').url;
|
||||
let frame;
|
||||
let reg;
|
||||
|
||||
try {
|
||||
reg = await service_worker_unregister_and_register(t, worker, scope);
|
||||
await wait_for_state(t, reg.installing, 'activated');
|
||||
frame = await with_iframe(anotherUrl);
|
||||
assert_equals(frame.contentDocument.body.textContent, "Here's a simple html file.\n");
|
||||
// Use step_timeout(0) to ensure the history entry is created for Blink
|
||||
// and WebKit. See https://bugs.webkit.org/show_bug.cgi?id=42861.
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.src = scope;
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = false');
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(-1);
|
||||
});
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(1);
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = true');
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(0);
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = false');
|
||||
} finally {
|
||||
if (frame) {
|
||||
frame.remove();
|
||||
}
|
||||
if (reg) {
|
||||
await reg.unregister();
|
||||
}
|
||||
}
|
||||
}, 'FetchEvent#request.isHistoryNavigation is false (with history.go(0))');
|
||||
|
||||
promise_test(async (t) => {
|
||||
const scope = 'resources/simple.html?isHistoryNavigation';
|
||||
const anotherUrl = new Request('resources/simple.html').url;
|
||||
let frame;
|
||||
let reg;
|
||||
|
||||
try {
|
||||
reg = await service_worker_unregister_and_register(t, worker, scope);
|
||||
await wait_for_state(t, reg.installing, 'activated');
|
||||
frame = await with_iframe(anotherUrl);
|
||||
assert_equals(frame.contentDocument.body.textContent, "Here's a simple html file.\n");
|
||||
// Use step_timeout(0) to ensure the history entry is created for Blink
|
||||
// and WebKit. See https://bugs.webkit.org/show_bug.cgi?id=42861.
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.src = scope;
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = false');
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(-1);
|
||||
});
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(1);
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = true');
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.location.reload();
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = false');
|
||||
} finally {
|
||||
if (frame) {
|
||||
frame.remove();
|
||||
}
|
||||
if (reg) {
|
||||
await reg.unregister();
|
||||
}
|
||||
}
|
||||
}, 'FetchEvent#request.isHistoryNavigation is false (with location.reload)');
|
||||
|
||||
promise_test(async (t) => {
|
||||
const scope = 'resources/simple.html?isHistoryNavigation';
|
||||
const anotherUrl = new Request('resources/simple.html').url;
|
||||
const oneAnotherUrl = new Request('resources/simple.html?').url;
|
||||
let frame;
|
||||
let reg;
|
||||
|
||||
try {
|
||||
reg = await service_worker_unregister_and_register(t, worker, scope);
|
||||
await wait_for_state(t, reg.installing, 'activated');
|
||||
frame = await with_iframe(scope);
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = false');
|
||||
// Use step_timeout(0) to ensure the history entry is created for Blink
|
||||
// and WebKit. See https://bugs.webkit.org/show_bug.cgi?id=42861.
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.src = anotherUrl;
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent, "Here's a simple html file.\n");
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.src = oneAnotherUrl;
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent, "Here's a simple html file.\n");
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(-2);
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = true');
|
||||
} finally {
|
||||
if (frame) {
|
||||
frame.remove();
|
||||
}
|
||||
if (reg) {
|
||||
await reg.unregister();
|
||||
}
|
||||
}
|
||||
}, 'FetchEvent#request.isHistoryNavigation is true (with history.go(-2))');
|
||||
|
||||
promise_test(async (t) => {
|
||||
const scope = 'resources/simple.html?isHistoryNavigation';
|
||||
const anotherUrl = new Request('resources/simple.html').url;
|
||||
const oneAnotherUrl = new Request('resources/simple.html?').url;
|
||||
let frame;
|
||||
let reg;
|
||||
|
||||
try {
|
||||
reg = await service_worker_unregister_and_register(t, worker, scope);
|
||||
await wait_for_state(t, reg.installing, 'activated');
|
||||
frame = await with_iframe(anotherUrl);
|
||||
assert_equals(frame.contentDocument.body.textContent, "Here's a simple html file.\n");
|
||||
// Use step_timeout(0) to ensure the history entry is created for Blink
|
||||
// and WebKit. See https://bugs.webkit.org/show_bug.cgi?id=42861.
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.src = oneAnotherUrl;
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent, "Here's a simple html file.\n");
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.src = scope;
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = false');
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(-2);
|
||||
});
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(2);
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = true');
|
||||
} finally {
|
||||
if (frame) {
|
||||
frame.remove();
|
||||
}
|
||||
if (reg) {
|
||||
await reg.unregister();
|
||||
}
|
||||
}
|
||||
}, 'FetchEvent#request.isHistoryNavigation is true (with history.go(2))');
|
||||
|
||||
promise_test(async (t) => {
|
||||
const scope = 'resources/simple.html?isHistoryNavigation';
|
||||
const anotherUrl = new Request('resources/simple.html').url;
|
||||
let frame;
|
||||
let reg;
|
||||
|
||||
try {
|
||||
reg = await service_worker_unregister_and_register(t, worker, scope);
|
||||
await wait_for_state(t, reg.installing, 'activated');
|
||||
frame = await with_iframe(scope);
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = GET, isHistoryNavigation = false');
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
const form = frame.contentDocument.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.name = 'form';
|
||||
form.action = new Request(scope).url;
|
||||
frame.contentDocument.body.appendChild(form);
|
||||
form.submit();
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = POST, isHistoryNavigation = false');
|
||||
// Use step_timeout(0) to ensure the history entry is created for Blink
|
||||
// and WebKit. See https://bugs.webkit.org/show_bug.cgi?id=42861.
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.src = anotherUrl;
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent, "Here's a simple html file.\n");
|
||||
await wait(0);
|
||||
await new Promise((resolve) => {
|
||||
frame.addEventListener('load', resolve);
|
||||
frame.contentWindow.history.go(-1);
|
||||
});
|
||||
assert_equals(frame.contentDocument.body.textContent,
|
||||
'method = POST, isHistoryNavigation = true');
|
||||
} finally {
|
||||
if (frame) {
|
||||
frame.remove();
|
||||
}
|
||||
if (reg) {
|
||||
await reg.unregister();
|
||||
}
|
||||
}
|
||||
}, 'FetchEvent#request.isHistoryNavigation is true (POST + history.go(-1))');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -16,7 +16,7 @@ promise_test(t => {
|
|||
// TODO: return the Promise created by `r.unregister`once
|
||||
// `testharness.js` has been updated to honor thenables returned by
|
||||
// cleanup functions.
|
||||
// See https://github.com/w3c/web-platform-tests/pull/8748
|
||||
// See https://github.com/web-platform-tests/wpt/pull/8748
|
||||
t.add_cleanup(() => { r.unregister(); });
|
||||
registration = r;
|
||||
worker = registration.installing;
|
||||
|
@ -69,7 +69,7 @@ promise_test(t => {
|
|||
// TODO: return the Promise created by `r.unregister`once
|
||||
// `testharness.js` has been updated to honor thenables returned by
|
||||
// cleanup functions.
|
||||
// See https://github.com/w3c/web-platform-tests/pull/8748
|
||||
// See https://github.com/web-platform-tests/wpt/pull/8748
|
||||
t.add_cleanup(() => { r.unregister(); });
|
||||
|
||||
var ab = text_encoder.encode(message);
|
||||
|
@ -113,7 +113,7 @@ promise_test(t => {
|
|||
// TODO: return the Promise created by `r.unregister`once
|
||||
// `testharness.js` has been updated to honor thenables returned by
|
||||
// cleanup functions.
|
||||
// See https://github.com/w3c/web-platform-tests/pull/8748
|
||||
// See https://github.com/web-platform-tests/wpt/pull/8748
|
||||
t.add_cleanup(() => { r.unregister(); });
|
||||
|
||||
var channel = new MessageChannel;
|
||||
|
|
|
@ -137,6 +137,14 @@ function handleIsReloadNavigation(event) {
|
|||
event.respondWith(new Response(body));
|
||||
}
|
||||
|
||||
function handleIsHistoryNavigation(event) {
|
||||
const request = event.request;
|
||||
const body =
|
||||
`method = ${request.method}, ` +
|
||||
`isHistoryNavigation = ${request.isHistoryNavigation}`;
|
||||
event.respondWith(new Response(body));
|
||||
}
|
||||
|
||||
self.addEventListener('fetch', function(event) {
|
||||
var url = event.request.url;
|
||||
var handlers = [
|
||||
|
@ -160,6 +168,7 @@ self.addEventListener('fetch', function(event) {
|
|||
{ pattern: '?request-body', fn: handleRequestBody },
|
||||
{ pattern: '?keepalive', fn: handleKeepalive },
|
||||
{ pattern: '?isReloadNavigation', fn: handleIsReloadNavigation },
|
||||
{ pattern: '?isHistoryNavigation', fn: handleIsHistoryNavigation },
|
||||
];
|
||||
|
||||
var handler = null;
|
||||
|
|
|
@ -46,9 +46,14 @@ function unreached_rejection(test, prefix) {
|
|||
});
|
||||
}
|
||||
|
||||
// Adds an iframe to the document and returns a promise that resolves to the
|
||||
// iframe when it finishes loading. The caller is responsible for removing the
|
||||
// iframe later if needed.
|
||||
/**
|
||||
* Adds an iframe to the document and returns a promise that resolves to the
|
||||
* iframe when it finishes loading. The caller is responsible for removing the
|
||||
* iframe later if needed.
|
||||
*
|
||||
* @param {string} url
|
||||
* @returns {HTMLIFrameElement}
|
||||
*/
|
||||
function with_iframe(url) {
|
||||
return new Promise(function(resolve) {
|
||||
var frame = document.createElement('iframe');
|
||||
|
|
|
@ -166,7 +166,7 @@ function navigate_test(override_parameters) {
|
|||
// executes. `Test#add_cleanup` cannot be used for this purpose because the
|
||||
// operation is asynchronous, and `add_cleanup` does not support
|
||||
// asynchronous operations at the time of this writing. See
|
||||
// https://github.com/w3c/web-platform-tests/issues/6075
|
||||
// https://github.com/web-platform-tests/wpt/issues/6075
|
||||
// Ensure also that test failure is not hidden by successful cleanup
|
||||
// operation.
|
||||
return test_body
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue