Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-with-redirect.html

Issue 2245063003: ServiceWorker: Call SyncMatchingRegistration when document_url is changed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-with-redirect.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-with-redirect.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-with-redirect.html
new file mode 100644
index 0000000000000000000000000000000000000000..e9cb8ef9cf3b09fbd32175227df0296616fb0eff
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/claim-with-redirect.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<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>

Powered by Google App Engine
This is Rietveld 408576698