Commit e9455026 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

service worker: Enable 'claim-with-redirect' WPT test.

The test was disabled because Chrome didn't implement updateViaCache and
the expected default behavior, but that has been enabled as an
experimental feature for a while.

Also, delete the corresponding version in http/tests, which used
cache-control headers to workaround the lack of updateViaCache/expected
behavior.

Bug: 675540
Change-Id: Id95750c5c3a6d4c4d86d307bbce4477b9ee53df1
Reviewed-on: https://chromium-review.googlesource.com/1056755Reviewed-by: default avatarHan Leon <leon.han@intel.com>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558223}
parent cb08c0af
......@@ -3566,7 +3566,6 @@ crbug.com/655458 external/wpt/workers/semantics/structured-clone/dedicated.html
crbug.com/655458 external/wpt/workers/semantics/structured-clone/shared.html [ Crash Failure Timeout ]
crbug.com/490511 external/wpt/html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document-networkState.html [ Timeout ]
crbug.com/675540 external/wpt/service-workers/service-worker/claim-with-redirect.https.html [ Skip ]
crbug.com/435547 http/tests/cachestorage/serviceworker/ignore-search-with-credentials.html [ Skip ]
......
<!DOCTYPE html>
<!-- This test cannot be upstreamed to WPT because it relies on caching headers in the Service
Worker script's response which are no longer necessary.
Spec change: https://github.com/w3c/ServiceWorker/pull/1020
Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=675540 -->
<title>Service Worker: Claim() when update happens after redirect</title>
<script src="/resources/get-host-info.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.js"></script>
<body>
<script>
var host_info = get_host_info();
var BASE_URL = host_info['HTTP_ORIGIN'] + base_path();
var OTHER_BASE_URL = host_info['HTTP_REMOTE_ORIGIN'] + base_path();
var WORKER_URL = OTHER_BASE_URL + 'resources/update-claim-worker.php'
var SCOPE_URL = OTHER_BASE_URL + 'resources/redirect.php'
var OTHER_IFRAME_URL = OTHER_BASE_URL +
'resources/claim-with-redirect-iframe.html';
// Different origin from the registration
var REDIRECT_TO_URL = BASE_URL +
'resources/claim-with-redirect-iframe.html?redirected';
var REGISTER_IFRAME_URL = OTHER_IFRAME_URL + '?register=' +
encodeURIComponent(WORKER_URL) + '&' +
'scope=' + encodeURIComponent(SCOPE_URL);
var REDIRECT_IFRAME_URL = SCOPE_URL + '?Redirect=' +
encodeURIComponent(REDIRECT_TO_URL);
var UPDATE_IFRAME_URL = OTHER_IFRAME_URL + '?update=' +
encodeURIComponent(SCOPE_URL);
var UNREGISTER_IFRAME_URL = OTHER_IFRAME_URL + '?unregister=' +
encodeURIComponent(SCOPE_URL);
var waiting_resolver = undefined;
addEventListener('message', e => {
if (waiting_resolver !== undefined) {
waiting_resolver(e.data);
}
});
function assert_with_iframe(url, expected_message) {
return new Promise(resolve => {
waiting_resolver = resolve;
with_iframe(url);
})
.then(data => assert_equals(data.message, expected_message));
}
// This test checks behavior when browser got a redirect header from in-scope
// page and navigated to out-of-scope page which has a different origin from any
// registrations.
promise_test(t => {
return assert_with_iframe(REGISTER_IFRAME_URL, 'registered')
.then(() => assert_with_iframe(REDIRECT_IFRAME_URL, 'redirected'))
.then(() => assert_with_iframe(UPDATE_IFRAME_URL, 'updated'))
.then(() => assert_with_iframe(UNREGISTER_IFRAME_URL, 'unregistered'));
}, 'Claim works after redirection to another origin');
</script>
</body>
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/test-helpers.js"></script>
<script src="/resources/get-host-info.js"></script>
<body>
<script>
var host_info = get_host_info();
function send_result(result) {
window.parent.postMessage({message: result},
host_info['HTTP_ORIGIN']);
}
function executeTask(params) {
// Execute task for each parameter
if (params.has('register')) {
var worker_url = decodeURIComponent(params.get('register'));
var scope = decodeURIComponent(params.get('scope'));
navigator.serviceWorker.register(worker_url, {scope: scope})
.then(r => send_result('registered'));
} else if (params.has('redirected')) {
send_result('redirected');
} else if (params.has('update')) {
var scope = decodeURIComponent(params.get('update'));
navigator.serviceWorker.getRegistration(scope)
.then(r => r.update())
.then(() => send_result('updated'));
} else if (params.has('unregister')) {
var scope = decodeURIComponent(params.get('unregister'));
navigator.serviceWorker.getRegistration(scope)
.then(r => r.unregister())
.then(succeeded => {
if (succeeded) {
send_result('unregistered');
} else {
send_result('failure: unregister');
}
});
} else {
send_result('unknown parameter: ' + params.toString());
}
}
var params = new URLSearchParams(location.search.slice(1));
executeTask(params);
</script>
</body>
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header('Content-Type:application/javascript');
echo '// ', microtime();
?>
// This no-op fetch handler is necessary to bypass explicitly the no fetch
// handler optimization by which this service worker script can be skipped.
addEventListener('fetch', event => {
return;
});
addEventListener('install', event => {
event.waitUntil(self.skipWaiting());
});
addEventListener('activate', event => {
event.waitUntil(self.clients.claim());
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment