Instantly share code, notes, and snippets.
Created
May 10, 2017 19:16
-
Save jugglinmike/4eb7e998561ce0c9d995f7f278d10138 to your computer and use it in GitHub Desktop.
sw-migration-navigation.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 1f87d6e0278f8fa1fab7fa742d09d973ae1313e2 | |
Author: Mike Pennisi <mike@mikepennisi.com> | |
Date: Wed May 10 10:48:11 2017 -0400 | |
Upstream service worker navigation tests to WPT | |
**navigation-redirect** | |
Update existing assertions to adhere to the latest version of the Fetch | |
specification. The relevant change from that document [1] is explained | |
as follows: | |
> [...] | |
> * Only when redirects are automatically followed should we set the | |
> skip-service-worker flag, otherwise we negatively affect navigations. | |
> [...] | |
(Note that the Request's "skip-service-worker flag" was subsequently | |
re-implemented as "service-workers mode" in [2].) | |
Insert two additional tests introduced by Chromium project commit | |
cb6838f5badc8c2df03f387f4aa726629214179a, whose message reads: | |
> Make no-location redirect response to be "opaque redirect" when | |
> redirect mode is manual. | |
> | |
> According to the spec, even if location header is not set, we should | |
> treat the redirect response as "opaqueredirect" if the redirect mode | |
> of the fetch request is "manual". | |
> | |
> This behavior was changed by this commit on the spec. | |
> https://github.com/whatwg/fetch/commit/3e501f29eceff41eb81c60fb9937e33e23cf5492 | |
Remove the "-expectations.txt" file for this test since Chromium passes | |
the corrected version. Remove the Chromium-specific version of the test. | |
**navigation-redirect-body** | |
Re-locate test file to Web Platform Test directory for eventual | |
automated upstreaming. Simplify test body by constructing necessary DOM | |
declaratively with HTML. Schedule frame removal to occur following test | |
completion. | |
**navigation-redirect-to-http** | |
Re-locate test file to Web Platform Test directory for eventual | |
automated upstreaming. Prefer the generalized `redirect.py` script over | |
a test-specific script defining equivalent functionality. Correct typo | |
in test title. | |
[1] https://github.com/whatwg/fetch/commit/ec6f5ef5f99cb6b0dd6c701b49791810fb380b04 | |
[2] https://github.com/whatwg/fetch/commit/d41c2380dc828e7a23c6196a344b42b2d0e9beec | |
BUG=688116 | |
R=mek@chromium.org | |
diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG b/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG | |
index 620454d..e911ef5 100644 | |
--- a/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG | |
+++ b/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG | |
@@ -18005,7 +18005,6 @@ crbug.com/591099 http/tests/serviceworker/chromium/window-close-during-registrat | |
crbug.com/591099 http/tests/serviceworker/fetch-request-xhr.html [ Failure Pass ] | |
crbug.com/591099 http/tests/serviceworker/indexeddb.html [ Pass Timeout ] | |
crbug.com/591099 http/tests/serviceworker/navigation-preload/chromium/navigation-preload-resource-timing.html [ Failure Pass ] | |
-crbug.com/591099 http/tests/serviceworker/navigation-redirect.html [ Pass Timeout ] | |
crbug.com/591099 http/tests/serviceworker/sandbox-iframe-register-link-element.html [ Crash ] | |
crbug.com/591099 http/tests/serviceworker/ServiceWorkerGlobalScope/registration-attribute.html [ Failure Pass ] | |
crbug.com/591099 http/tests/shapes/shape-outside-image-shape-margin.html [ Failure ] | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect-body.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect-body.https.html | |
similarity index 57% | |
rename from third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect-body.html | |
rename to third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect-body.https.html | |
index b06649d..0441c61 100644 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect-body.html | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect-body.https.html | |
@@ -1,34 +1,32 @@ | |
<!DOCTYPE html> | |
<title>Service Worker: Navigation redirection must clear body</title> | |
-<script src="../resources/testharness.js"></script> | |
-<script src="../resources/testharnessreport.js"></script> | |
-<script src="../resources/get-host-info.js?pipe=sub"></script> | |
-<script src="resources/test-helpers.js"></script> | |
+<script src="/resources/testharness.js"></script> | |
+<script src="/resources/testharnessreport.js"></script> | |
+<script src="/common/get-host-info.sub.js"></script> | |
+<script src="resources/test-helpers.sub.js"></script> | |
+<meta charset="utf-8"> | |
<body> | |
+<form id="test-form" method="POST" style="display: none;"> | |
+ <input type="submit" id="submit-button" /> | |
+</form> | |
<script> | |
promise_test(function(t) { | |
- var scope = 'resources/navigation-redirect-body.php'; | |
+ var scope = 'resources/navigation-redirect-body.py'; | |
var script = 'resources/navigation-redirect-body-worker.js'; | |
var registration; | |
var frame = document.createElement('frame'); | |
+ var form = document.getElementById('test-form'); | |
+ var submit_button = document.getElementById('submit-button'); | |
+ | |
frame.src = 'about:blank'; | |
frame.name = 'target_frame'; | |
frame.id = 'frame'; | |
document.body.appendChild(frame); | |
- var form = document.createElement('form'); | |
- form.method = 'POST'; | |
+ t.add_cleanup(function() { document.body.removeChild(frame); }); | |
+ | |
form.action = scope; | |
form.target = 'target_frame'; | |
- var hidden_input = document.createElement('input'); | |
- hidden_input.type = 'hidden'; | |
- hidden_input.name = 'data'; | |
- hidden_input.value = 'test data'; | |
- var submit_button = document.createElement('input'); | |
- submit_button.type = 'submit'; | |
- submit_button.value = 'submit'; | |
- form.appendChild(hidden_input); | |
- form.appendChild(submit_button); | |
- document.body.appendChild(form); | |
+ | |
return service_worker_unregister_and_register(t, script, scope) | |
.then(function(r) { | |
registration = r; | |
@@ -44,12 +42,10 @@ promise_test(function(t) { | |
return frame_load_promise; | |
}) | |
.then(function(text) { | |
- document.body.removeChild(form); | |
- document.body.removeChild(frame); | |
var request_uri = decodeURIComponent(text); | |
assert_equals( | |
request_uri, | |
- '/serviceworker/resources/navigation-redirect-body.php?redirect'); | |
+ '/service-workers/service-worker/resources/navigation-redirect-body.py?redirect'); | |
return registration.unregister(); | |
}); | |
}, 'Navigation redirection must clear body'); | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect-to-http.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect-to-http.https.html | |
similarity index 37% | |
rename from third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect-to-http.html | |
rename to third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect-to-http.https.html | |
index 879c729..d4d2788 100644 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect-to-http.html | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect-to-http.https.html | |
@@ -1,20 +1,25 @@ | |
<!DOCTYPE html> | |
<title>Service Worker: Service Worker can receive HTTP opaqueredirect response.</title> | |
-<script src="../resources/testharness.js"></script> | |
-<script src="../resources/testharnessreport.js"></script> | |
-<script src="../resources/get-host-info.js?pipe=sub"></script> | |
-<script src="resources/test-helpers.js"></script> | |
+<script src="/resources/testharness.js"></script> | |
+<script src="/resources/testharnessreport.js"></script> | |
+<script src="/common/get-host-info.sub.js"></script> | |
+<script src="resources/test-helpers.sub.js"></script> | |
+<meta charset="utf-8"> | |
<body></body> | |
<script> | |
async_test(function(t) { | |
- var host_info = get_host_info(); | |
- window.addEventListener('message', t.step_func(on_message), false); | |
- with_iframe( | |
- host_info['HTTPS_ORIGIN'] + base_path() + | |
- 'resources/navigation-redirect-to-http-iframe.html'); | |
+ var frame_src = get_host_info()['HTTPS_ORIGIN'] + base_path() + | |
+ 'resources/navigation-redirect-to-http-iframe.html'; | |
function on_message(e) { | |
assert_equals(e.data.results, 'OK'); | |
t.done(); | |
} | |
- }, 'Verify Service Worker can recieve HTTP opaqueredirect response.'); | |
+ | |
+ window.addEventListener('message', t.step_func(on_message), false); | |
+ | |
+ with_iframe(frame_src) | |
+ .then(function(frame) { | |
+ t.add_cleanup(function() { frame.remove(); }); | |
+ }); | |
+ }, 'Verify Service Worker can receive HTTP opaqueredirect response.'); | |
</script> | |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect.https-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect.https-expected.txt | |
deleted file mode 100644 | |
index b83a9ab..0000000 | |
--- a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect.https-expected.txt | |
+++ /dev/null | |
@@ -1,30 +0,0 @@ | |
-This is a testharness.js-based test. | |
-PASS Normal redirect to same-origin scope. | |
-PASS Normal redirect to other-origin scope. | |
-PASS SW-fallbacked redirect to same-origin out-scope. | |
-FAIL SW-fallbacked redirect to same-origin same-scope. assert_object_equals: Intercepted URLs should match. unexpected property "1" | |
-FAIL SW-fallbacked redirect to same-origin other-scope. assert_object_equals: Intercepted URLs should match. unexpected property "0" | |
-PASS SW-fallbacked redirect to other-origin out-scope. | |
-FAIL SW-fallbacked redirect to other-origin in-scope. assert_object_equals: Intercepted URLs should match. unexpected property "0" | |
-PASS SW-generated redirect to same-origin out-scope. | |
-PASS SW-generated redirect to same-origin same-scope. | |
-PASS SW-generated redirect to same-origin other-scope. | |
-PASS SW-generated redirect to other-origin out-scope. | |
-PASS SW-generated redirect to other-origin in-scope. | |
-PASS SW-fetched redirect to same-origin out-scope. | |
-PASS SW-fetched redirect to same-origin same-scope. | |
-PASS SW-fetched redirect to same-origin other-scope. | |
-PASS SW-fetched redirect to other-origin out-scope. | |
-PASS SW-fetched redirect to other-origin in-scope. | |
-PASS Redirect to same-origin out-scope with opaque redirect response. | |
-PASS Redirect to same-origin same-scope with opaque redirect response. | |
-PASS Redirect to same-origin other-scope with opaque redirect response. | |
-PASS Redirect to other-origin out-scope with opaque redirect response. | |
-PASS Redirect to other-origin in-scope with opaque redirect response. | |
-PASS Redirect to same-origin out-scope with opaque redirect response which is passed through Cache. | |
-PASS Redirect to same-origin same-scope with opaque redirect response which is passed through Cache. | |
-PASS Redirect to same-origin other-scope with opaque redirect response which is passed through Cache. | |
-PASS Redirect to other-origin out-scope with opaque redirect response which is passed through Cache. | |
-PASS Redirect to other-origin in-scope with opaque redirect response which is passed through Cache. | |
-Harness: the test ran to completion. | |
- | |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect.https.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect.https.html | |
index 586e903..e311bb6 100644 | |
--- a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect.https.html | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-redirect.https.html | |
@@ -176,7 +176,7 @@ promise_test(function(t) { | |
return test_redirect( | |
SCOPE1 + 'url=' + encodeURIComponent(SCOPE1), | |
SCOPE1, | |
- [[SCOPE1 + 'url=' + encodeURIComponent(SCOPE1)], [], []]); | |
+ [[SCOPE1 + 'url=' + encodeURIComponent(SCOPE1), SCOPE1], [], []]); | |
}); | |
}, 'SW-fallbacked redirect to same-origin same-scope.'); | |
promise_test(function(t) { | |
@@ -184,7 +184,7 @@ promise_test(function(t) { | |
return test_redirect( | |
SCOPE1 + 'url=' + encodeURIComponent(SCOPE2), | |
SCOPE2, | |
- [[SCOPE1 + 'url=' + encodeURIComponent(SCOPE2)], [], []]); | |
+ [[SCOPE1 + 'url=' + encodeURIComponent(SCOPE2)], [SCOPE2], []]); | |
}); | |
}, 'SW-fallbacked redirect to same-origin other-scope.'); | |
promise_test(function(t) { | |
@@ -204,7 +204,7 @@ promise_test(function(t) { | |
OTHER_ORIGIN_SCOPE, | |
[[SCOPE1 + 'url=' + encodeURIComponent(OTHER_ORIGIN_SCOPE)], | |
[], | |
- []]); | |
+ [OTHER_ORIGIN_SCOPE]]); | |
}); | |
}, 'SW-fallbacked redirect to other-origin in-scope.'); | |
@@ -372,6 +372,16 @@ promise_test(function(t) { | |
[OTHER_ORIGIN_SCOPE]]); | |
}); | |
}, 'Redirect to other-origin in-scope with opaque redirect response.'); | |
+promise_test(function(t) { | |
+ return setup_environment(t).then(function() { | |
+ return test_redirect( | |
+ SCOPE1 + 'sw=opaque&noLocationRedirect', | |
+ SCOPE1 + 'sw=opaque&noLocationRedirect', | |
+ [[SCOPE1 + 'sw=opaque&noLocationRedirect'], | |
+ [], | |
+ []]); | |
+ }); | |
+ }, 'No location redirect response.'); | |
// Opaque redirect passed through Cache. | |
// SW responds with an opaque redirectresponse from the Cache API. | |
@@ -445,5 +455,15 @@ promise_test(function(t) { | |
}, | |
'Redirect to other-origin in-scope with opaque redirect response which ' + | |
'is passed through Cache.'); | |
+promise_test(function(t) { | |
+ return setup_environment(t).then(function() { | |
+ return test_redirect( | |
+ SCOPE1 + 'sw=opaqueThroughCache&noLocationRedirect', | |
+ SCOPE1 + 'sw=opaqueThroughCache&noLocationRedirect', | |
+ [[SCOPE1 + 'sw=opaqueThroughCache&noLocationRedirect'], | |
+ [], | |
+ []]); | |
+ }); | |
+ }, 'No location redirect response via Cache.'); | |
</script> | |
</body> | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-body-worker.js b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-body-worker.js | |
similarity index 100% | |
rename from third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-body-worker.js | |
rename to third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-body-worker.js | |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-body.py b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-body.py | |
new file mode 100644 | |
index 0000000..601f818 | |
--- /dev/null | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-body.py | |
@@ -0,0 +1,9 @@ | |
+import os | |
+ | |
+filename = os.path.basename(__file__) | |
+ | |
+def main(request, response): | |
+ if request.method == 'POST': | |
+ return 302, [('Location', './%s?redirect' % filename)], '' | |
+ | |
+ return [('Content-Type', 'text/plain')], request.request_path | |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-out-scope.py b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-out-scope.py | |
index 4b40762..0cd5ef1 100644 | |
--- a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-out-scope.py | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-out-scope.py | |
@@ -3,7 +3,12 @@ def main(request, response): | |
headers = [("Location", request.GET["url"])] | |
return 302, headers, '' | |
- return [], ''' | |
+ status = 200 | |
+ | |
+ if "noLocationRedirect" in request.GET: | |
+ status = 302 | |
+ | |
+ return status, [], ''' | |
<!DOCTYPE html> | |
<script> | |
window.parent.postMessage( | |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-scope1.py b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-scope1.py | |
index 4b40762..0cd5ef1 100644 | |
--- a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-scope1.py | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-scope1.py | |
@@ -3,7 +3,12 @@ def main(request, response): | |
headers = [("Location", request.GET["url"])] | |
return 302, headers, '' | |
- return [], ''' | |
+ status = 200 | |
+ | |
+ if "noLocationRedirect" in request.GET: | |
+ status = 302 | |
+ | |
+ return status, [], ''' | |
<!DOCTYPE html> | |
<script> | |
window.parent.postMessage( | |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-scope2.py b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-scope2.py | |
index 4b40762..0cd5ef1 100644 | |
--- a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-scope2.py | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-scope2.py | |
@@ -3,7 +3,12 @@ def main(request, response): | |
headers = [("Location", request.GET["url"])] | |
return 302, headers, '' | |
- return [], ''' | |
+ status = 200 | |
+ | |
+ if "noLocationRedirect" in request.GET: | |
+ status = 302 | |
+ | |
+ return status, [], ''' | |
<!DOCTYPE html> | |
<script> | |
window.parent.postMessage( | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-to-http-iframe.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-to-http-iframe.html | |
similarity index 80% | |
rename from third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-to-http-iframe.html | |
rename to third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-to-http-iframe.html | |
index 234ba15..40e27c6 100644 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-to-http-iframe.html | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-to-http-iframe.html | |
@@ -1,8 +1,8 @@ | |
<!DOCTYPE html> | |
-<script src="../../resources/get-host-info.js?pipe=sub"></script> | |
-<script src="test-helpers.js"></script> | |
+<script src="/common/get-host-info.sub.js"></script> | |
+<script src="test-helpers.sub.js"></script> | |
<script> | |
-var SCOPE = './navigation-redirect-to-http.php'; | |
+var SCOPE = './redirect.py?Redirect=' + encodeURI('http://example.com'); | |
var SCRIPT = 'navigation-redirect-to-http-worker.js'; | |
var host_info = get_host_info(); | |
@@ -26,7 +26,7 @@ navigator.serviceWorker.getRegistration(SCOPE) | |
}) | |
.catch(function(reason) { | |
window.parent.postMessage({results: 'FAILURE: ' + reason.message}, | |
- host_info['HTTP_ORIGIN']); | |
+ host_info['HTTPS_ORIGIN']); | |
}); | |
function on_state_change(event) { | |
@@ -36,8 +36,7 @@ function on_state_change(event) { | |
.then(function(frame) { | |
window.parent.postMessage( | |
{results: frame.contentDocument.body.textContent}, | |
- host_info['HTTP_ORIGIN']); | |
+ host_info['HTTPS_ORIGIN']); | |
}); | |
} | |
- | |
</script> | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-to-http-worker.js b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-to-http-worker.js | |
similarity index 100% | |
rename from third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-to-http-worker.js | |
rename to third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/navigation-redirect-to-http-worker.js | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect.html | |
deleted file mode 100644 | |
index 1ba7f87..0000000 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect.html | |
+++ /dev/null | |
@@ -1,468 +0,0 @@ | |
-<!DOCTYPE html> | |
-<title>Service Worker: Navigation redirection</title> | |
-<script src="../resources/testharness.js"></script> | |
-<script src="../resources/testharnessreport.js"></script> | |
-<script src="../resources/get-host-info.js?pipe=sub"></script> | |
-<script src="resources/test-helpers.js"></script> | |
-<body> | |
-<script> | |
- | |
-var host_info = get_host_info(); | |
- | |
-// This test registers three Service Workers at SCOPE1, SCOPE2 and | |
-// OTHER_ORIGIN_SCOPE. And checks the redirected page's URL and the requests | |
-// which are intercepted by Service Worker while loading redirect page. | |
-var BASE_URL = host_info['HTTP_ORIGIN'] + base_path(); | |
-var OTHER_BASE_URL = host_info['HTTP_REMOTE_ORIGIN'] + base_path(); | |
- | |
-var SCOPE1 = BASE_URL + 'resources/navigation-redirect-scope1.php?'; | |
-var SCOPE2 = BASE_URL + 'resources/navigation-redirect-scope2.php?'; | |
-var OUT_SCOPE = BASE_URL + 'resources/navigation-redirect-out-scope.php?'; | |
-var SCRIPT = 'resources/navigation-redirect-worker.js'; | |
- | |
-var OTHER_ORIGIN_IFRAME_URL = | |
- OTHER_BASE_URL + 'resources/navigation-redirect-other-origin.html'; | |
-var OTHER_ORIGIN_SCOPE = | |
- OTHER_BASE_URL + 'resources/navigation-redirect-scope1.php?'; | |
-var OTHER_ORIGIN_OUT_SCOPE = | |
- OTHER_BASE_URL + 'resources/navigation-redirect-out-scope.php?'; | |
- | |
-var workers; | |
-var other_origin_frame; | |
-var setup_environment_promise; | |
-var message_resolvers = {}; | |
-var next_message_id = 0; | |
- | |
-function setup_environment(t) { | |
- if (setup_environment_promise) | |
- return setup_environment_promise; | |
- setup_environment_promise = | |
- with_iframe(OTHER_ORIGIN_IFRAME_URL) | |
- .then(function(f) { | |
- // In this frame we register a Service Worker at OTHER_ORIGIN_SCOPE. | |
- // And will use this frame to communicate with the worker. | |
- other_origin_frame = f; | |
- return Promise.all( | |
- [service_worker_unregister_and_register(t, SCRIPT, SCOPE1), | |
- service_worker_unregister_and_register(t, SCRIPT, SCOPE2)]); | |
- }) | |
- .then(function(registrations) { | |
- add_completion_callback(function() { | |
- registrations[0].unregister(); | |
- registrations[1].unregister(); | |
- send_to_iframe(other_origin_frame, 'unregister') | |
- .then(function() { other_origin_frame.remove(); }); | |
- }); | |
- workers = registrations.map(get_effective_worker); | |
- return Promise.all([ | |
- wait_for_state(t, workers[0], 'activated'), | |
- wait_for_state(t, workers[1], 'activated'), | |
- // This promise will resolve when |wait_for_worker_promise| | |
- // in OTHER_ORIGIN_IFRAME_URL resolves. | |
- send_to_iframe(other_origin_frame, 'wait_for_worker')]); | |
- }); | |
- return setup_environment_promise; | |
-} | |
- | |
-function get_effective_worker(registration) { | |
- if (registration.active) | |
- return registration.active; | |
- if (registration.waiting) | |
- return registration.waiting; | |
- if (registration.installing) | |
- return registration.installing; | |
-} | |
- | |
-function check_all_intercepted_urls(expected_urls) { | |
- return Promise.all( | |
- [ | |
- // Gets the request URLs which are intercepted by SCOPE1's SW. | |
- get_intercepted_urls(workers[0]), | |
- // Gets the request URLs which are intercepted by SCOPE2's SW. | |
- get_intercepted_urls(workers[1]), | |
- // Gets the request URLs which are intercepted by OTHER_ORIGIN_SCOPE's | |
- // SW. This promise will resolve when get_intercepted_urls() in | |
- // OTHER_ORIGIN_IFRAME_URL resolves. | |
- send_to_iframe(other_origin_frame, 'get_intercepted_urls') | |
- ]) | |
- .then(function(urls) { | |
- assert_object_equals( | |
- urls, expected_urls, | |
- 'Intercepted URLs should match.'); | |
- }); | |
-} | |
- | |
-function test_redirect(url, expected_last_url, | |
- expected_intercepted_urls) { | |
- var message_promise = new Promise(function(resolve) { | |
- // A message which ID is 'last_url' will be sent from the iframe. | |
- message_resolvers['last_url'] = resolve; | |
- }); | |
- return with_iframe(url) | |
- .then(function(f) { | |
- f.remove(); | |
- return check_all_intercepted_urls(expected_intercepted_urls); | |
- }) | |
- .then(function() { return message_promise; }) | |
- .then(function(last_url) { | |
- assert_equals( | |
- last_url, expected_last_url, | |
- 'Last URL should match.'); | |
- }); | |
-} | |
- | |
-window.addEventListener('message', on_message, false); | |
- | |
-function on_message(e) { | |
- if (e.origin != host_info['HTTP_REMOTE_ORIGIN'] && | |
- e.origin != host_info['HTTP_ORIGIN'] ) { | |
- console.error('invalid origin: ' + e.origin); | |
- return; | |
- } | |
- var resolve = message_resolvers[e.data.id]; | |
- delete message_resolvers[e.data.id]; | |
- resolve(e.data.result); | |
-} | |
- | |
-function send_to_iframe(frame, message) { | |
- var message_id = next_message_id++; | |
- return new Promise(function(resolve) { | |
- message_resolvers[message_id] = resolve; | |
- frame.contentWindow.postMessage( | |
- {id: message_id, message: message}, | |
- host_info['HTTP_REMOTE_ORIGIN']); | |
- }); | |
-} | |
- | |
-function get_intercepted_urls(worker) { | |
- return new Promise(function(resolve) { | |
- var channel = new MessageChannel(); | |
- channel.port1.onmessage = function(msg) { resolve(msg.data.urls); }; | |
- worker.postMessage({port: channel.port2}, [channel.port2]); | |
- }); | |
-} | |
- | |
-// Normal redirect. | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- OUT_SCOPE + 'url=' + encodeURIComponent(SCOPE1), | |
- SCOPE1, | |
- [[SCOPE1], [], []]); | |
- }); | |
- }, 'Normal redirect to same-origin scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- OUT_SCOPE + 'url=' + encodeURIComponent(OTHER_ORIGIN_SCOPE), | |
- OTHER_ORIGIN_SCOPE, | |
- [[], [], [OTHER_ORIGIN_SCOPE]]); | |
- }); | |
- }, 'Normal redirect to other-origin scope.'); | |
- | |
-// SW fallbacked redirect. SW doesn't handle the fetch request. | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'url=' + encodeURIComponent(OUT_SCOPE), | |
- OUT_SCOPE, | |
- [[SCOPE1 + 'url=' + encodeURIComponent(OUT_SCOPE)], [], []]); | |
- }); | |
- }, 'SW-fallbacked redirect to same-origin out-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'url=' + encodeURIComponent(SCOPE1), | |
- SCOPE1, | |
- [[SCOPE1 + 'url=' + encodeURIComponent(SCOPE1), SCOPE1], [], []]); | |
- }); | |
- }, 'SW-fallbacked redirect to same-origin same-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'url=' + encodeURIComponent(SCOPE2), | |
- SCOPE2, | |
- [[SCOPE1 + 'url=' + encodeURIComponent(SCOPE2)], [SCOPE2], []]); | |
- }); | |
- }, 'SW-fallbacked redirect to same-origin other-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'url=' + encodeURIComponent(OTHER_ORIGIN_OUT_SCOPE), | |
- OTHER_ORIGIN_OUT_SCOPE, | |
- [[SCOPE1 + 'url=' + encodeURIComponent(OTHER_ORIGIN_OUT_SCOPE)], | |
- [], | |
- []]); | |
- }); | |
- }, 'SW-fallbacked redirect to other-origin out-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'url=' + encodeURIComponent(OTHER_ORIGIN_SCOPE), | |
- OTHER_ORIGIN_SCOPE, | |
- [[SCOPE1 + 'url=' + encodeURIComponent(OTHER_ORIGIN_SCOPE)], | |
- [], | |
- [OTHER_ORIGIN_SCOPE]]); | |
- }); | |
- }, 'SW-fallbacked redirect to other-origin in-scope.'); | |
- | |
-// SW generated redirect. | |
-// SW: event.respondWith(Response.redirect(params['url'])); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=gen&url=' + encodeURIComponent(OUT_SCOPE), | |
- OUT_SCOPE, | |
- [[SCOPE1 + 'sw=gen&url=' + encodeURIComponent(OUT_SCOPE)], [], []]); | |
- }); | |
- }, 'SW-generated redirect to same-origin out-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=gen&url=' + encodeURIComponent(SCOPE1), | |
- SCOPE1, | |
- [[SCOPE1 + 'sw=gen&url=' + encodeURIComponent(SCOPE1), SCOPE1], | |
- [], | |
- []]); | |
- }); | |
- }, 'SW-generated redirect to same-origin same-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=gen&url=' + encodeURIComponent(SCOPE2), | |
- SCOPE2, | |
- [[SCOPE1 + 'sw=gen&url=' + encodeURIComponent(SCOPE2)], | |
- [SCOPE2], | |
- []]); | |
- }); | |
- }, 'SW-generated redirect to same-origin other-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=gen&url=' + encodeURIComponent(OTHER_ORIGIN_OUT_SCOPE), | |
- OTHER_ORIGIN_OUT_SCOPE, | |
- [[SCOPE1 + 'sw=gen&url=' + | |
- encodeURIComponent(OTHER_ORIGIN_OUT_SCOPE)], | |
- [], | |
- []]); | |
- }); | |
- }, 'SW-generated redirect to other-origin out-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=gen&url=' + encodeURIComponent(OTHER_ORIGIN_SCOPE), | |
- OTHER_ORIGIN_SCOPE, | |
- [[SCOPE1 + 'sw=gen&url=' + encodeURIComponent(OTHER_ORIGIN_SCOPE)], | |
- [], | |
- [OTHER_ORIGIN_SCOPE]]); | |
- }); | |
- }, 'SW-generated redirect to other-origin in-scope.'); | |
- | |
-// SW fetched redirect. | |
-// SW: event.respondWith(fetch(event.request)); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=fetch&url=' + encodeURIComponent(OUT_SCOPE), | |
- OUT_SCOPE, | |
- [[SCOPE1 + 'sw=fetch&url=' + encodeURIComponent(OUT_SCOPE)], | |
- [], | |
- []]); | |
- }); | |
- }, 'SW-fetched redirect to same-origin out-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=fetch&url=' + encodeURIComponent(SCOPE1), | |
- SCOPE1, | |
- [[SCOPE1 + 'sw=fetch&url=' + encodeURIComponent(SCOPE1), SCOPE1], | |
- [], | |
- []]); | |
- }); | |
- }, 'SW-fetched redirect to same-origin same-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=fetch&url=' + encodeURIComponent(SCOPE2), | |
- SCOPE2, | |
- [[SCOPE1 + 'sw=fetch&url=' + encodeURIComponent(SCOPE2)], | |
- [SCOPE2], | |
- []]); | |
- }); | |
- }, 'SW-fetched redirect to same-origin other-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=fetch&url=' + | |
- encodeURIComponent(OTHER_ORIGIN_OUT_SCOPE), | |
- OTHER_ORIGIN_OUT_SCOPE, | |
- [[SCOPE1 + 'sw=fetch&url=' + | |
- encodeURIComponent(OTHER_ORIGIN_OUT_SCOPE)], | |
- [], | |
- []]); | |
- }); | |
- }, 'SW-fetched redirect to other-origin out-scope.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=fetch&url=' + encodeURIComponent(OTHER_ORIGIN_SCOPE), | |
- OTHER_ORIGIN_SCOPE, | |
- [[SCOPE1 + 'sw=fetch&url=' + | |
- encodeURIComponent(OTHER_ORIGIN_SCOPE)], | |
- [], | |
- [OTHER_ORIGIN_SCOPE]]); | |
- }); | |
- }, 'SW-fetched redirect to other-origin in-scope.'); | |
- | |
-// Opaque redirect. | |
-// SW: event.respondWith(fetch( | |
-// new Request(event.request.url, {redirect: 'manual'}))); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaque&url=' + encodeURIComponent(OUT_SCOPE), | |
- OUT_SCOPE, | |
- [[SCOPE1 + 'sw=opaque&url=' + encodeURIComponent(OUT_SCOPE)], | |
- [], | |
- []]); | |
- }); | |
- }, 'Redirect to same-origin out-scope with opaque redirect response.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaque&url=' + encodeURIComponent(SCOPE1), | |
- SCOPE1, | |
- [[SCOPE1 + 'sw=opaque&url=' + encodeURIComponent(SCOPE1), SCOPE1], | |
- [], | |
- []]); | |
- }); | |
- }, 'Redirect to same-origin same-scope with opaque redirect response.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaque&url=' + encodeURIComponent(SCOPE2), | |
- SCOPE2, | |
- [[SCOPE1 + 'sw=opaque&url=' + encodeURIComponent(SCOPE2)], | |
- [SCOPE2], | |
- []]); | |
- }); | |
- }, 'Redirect to same-origin other-scope with opaque redirect response.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaque&url=' + | |
- encodeURIComponent(OTHER_ORIGIN_OUT_SCOPE), | |
- OTHER_ORIGIN_OUT_SCOPE, | |
- [[SCOPE1 + 'sw=opaque&url=' + | |
- encodeURIComponent(OTHER_ORIGIN_OUT_SCOPE)], | |
- [], | |
- []]); | |
- }); | |
- }, 'Redirect to other-origin out-scope with opaque redirect response.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaque&url=' + encodeURIComponent(OTHER_ORIGIN_SCOPE), | |
- OTHER_ORIGIN_SCOPE, | |
- [[SCOPE1 + 'sw=opaque&url=' + | |
- encodeURIComponent(OTHER_ORIGIN_SCOPE)], | |
- [], | |
- [OTHER_ORIGIN_SCOPE]]); | |
- }); | |
- }, 'Redirect to other-origin in-scope with opaque redirect response.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaque&noLocationRedirect', | |
- SCOPE1 + 'sw=opaque&noLocationRedirect', | |
- [[SCOPE1 + 'sw=opaque&noLocationRedirect'], | |
- [], | |
- []]); | |
- }); | |
- }, 'No location redirect response.'); | |
- | |
-// Opaque redirect passed through Cache. | |
-// SW responds with an opaque redirectresponse from the Cache API. | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaqueThroughCache&url=' + | |
- encodeURIComponent(OUT_SCOPE), | |
- OUT_SCOPE, | |
- [[SCOPE1 + 'sw=opaqueThroughCache&url=' + | |
- encodeURIComponent(OUT_SCOPE)], | |
- [], | |
- []]); | |
- }); | |
- }, | |
- 'Redirect to same-origin out-scope with opaque redirect response which ' + | |
- 'is passed through Cache.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaqueThroughCache&url=' + | |
- encodeURIComponent(SCOPE1), | |
- SCOPE1, | |
- [[SCOPE1 + 'sw=opaqueThroughCache&url=' + | |
- encodeURIComponent(SCOPE1), SCOPE1], | |
- [], | |
- []]); | |
- }); | |
- }, | |
- 'Redirect to same-origin same-scope with opaque redirect response which ' + | |
- 'is passed through Cache.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaqueThroughCache&url=' + | |
- encodeURIComponent(SCOPE2), | |
- SCOPE2, | |
- [[SCOPE1 + 'sw=opaqueThroughCache&url=' + | |
- encodeURIComponent(SCOPE2)], | |
- [SCOPE2], | |
- []]); | |
- }); | |
- }, | |
- 'Redirect to same-origin other-scope with opaque redirect response which ' + | |
- 'is passed through Cache.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaqueThroughCache&url=' + | |
- encodeURIComponent(OTHER_ORIGIN_OUT_SCOPE), | |
- OTHER_ORIGIN_OUT_SCOPE, | |
- [[SCOPE1 + 'sw=opaqueThroughCache&url=' + | |
- encodeURIComponent(OTHER_ORIGIN_OUT_SCOPE)], | |
- [], | |
- []]); | |
- }); | |
- }, | |
- 'Redirect to other-origin out-scope with opaque redirect response which ' + | |
- 'is passed through Cache.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaqueThroughCache&url=' + | |
- encodeURIComponent(OTHER_ORIGIN_SCOPE), | |
- OTHER_ORIGIN_SCOPE, | |
- [[SCOPE1 + 'sw=opaqueThroughCache&url=' + | |
- encodeURIComponent(OTHER_ORIGIN_SCOPE)], | |
- [], | |
- [OTHER_ORIGIN_SCOPE]]); | |
- }); | |
- }, | |
- 'Redirect to other-origin in-scope with opaque redirect response which ' + | |
- 'is passed through Cache.'); | |
-promise_test(function(t) { | |
- return setup_environment(t).then(function() { | |
- return test_redirect( | |
- SCOPE1 + 'sw=opaqueThroughCache&noLocationRedirect', | |
- SCOPE1 + 'sw=opaqueThroughCache&noLocationRedirect', | |
- [[SCOPE1 + 'sw=opaqueThroughCache&noLocationRedirect'], | |
- [], | |
- []]); | |
- }); | |
- }, 'No location redirect response via Cache.'); | |
- | |
-</script> | |
-</body> | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-body.php b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-body.php | |
deleted file mode 100644 | |
index 91aa295..0000000 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-body.php | |
+++ /dev/null | |
@@ -1,8 +0,0 @@ | |
-<?php | |
- if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
- header ("HTTP/1.1 302"); | |
- header("Location: ./navigation-redirect-body.php?redirect"); | |
- } else { | |
- echo urlencode($_SERVER['REQUEST_URI']); | |
- } | |
-?> | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-other-origin.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-other-origin.html | |
deleted file mode 100644 | |
index fbff9f6..0000000 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-other-origin.html | |
+++ /dev/null | |
@@ -1,66 +0,0 @@ | |
-<!DOCTYPE html> | |
-<script src="../../resources/get-host-info.js?pipe=sub"></script> | |
-<script src="test-helpers.js"></script> | |
-<script> | |
-var host_info = get_host_info(); | |
-var SCOPE = 'navigation-redirect-scope1.php'; | |
-var SCRIPT = 'navigation-redirect-worker.js'; | |
- | |
-var registration; | |
-var worker; | |
-var wait_for_worker_promise = navigator.serviceWorker.getRegistration(SCOPE) | |
- .then(function(reg) { | |
- if (reg) | |
- return reg.unregister(); | |
- }) | |
- .then(function() { | |
- return navigator.serviceWorker.register(SCRIPT, {scope: SCOPE}); | |
- }) | |
- .then(function(reg) { | |
- registration = reg; | |
- worker = reg.installing; | |
- return new Promise(function(resolve) { | |
- worker.addEventListener('statechange', function() { | |
- if (worker.state == 'activated') | |
- resolve(); | |
- }); | |
- }); | |
- }); | |
- | |
-function send_result(message_id, result) { | |
- window.parent.postMessage( | |
- {id: message_id, result: result}, | |
- host_info['HTTP_ORIGIN']); | |
-} | |
- | |
-function get_intercepted_urls(worker) { | |
- return new Promise(function(resolve) { | |
- var channel = new MessageChannel(); | |
- channel.port1.onmessage = function(msg) { resolve(msg.data.urls); }; | |
- worker.postMessage({port: channel.port2}, [channel.port2]); | |
- }); | |
-} | |
- | |
-window.addEventListener('message', on_message, false); | |
- | |
-function on_message(e) { | |
- if (e.origin != host_info['HTTP_ORIGIN']) { | |
- console.error('invalid origin: ' + e.origin); | |
- return; | |
- } | |
- if (e.data.message == 'wait_for_worker') { | |
- wait_for_worker_promise.then(function() { send_result(e.data.id, 'ok'); }); | |
- } else if (e.data.message == 'get_intercepted_urls') { | |
- get_intercepted_urls(worker) | |
- .then(function(urls) { | |
- send_result(e.data.id, urls); | |
- }); | |
- } else if (e.data.message == 'unregister') { | |
- registration.unregister() | |
- .then(function() { | |
- send_result(e.data.id, 'ok'); | |
- }); | |
- } | |
-} | |
- | |
-</script> | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-out-scope.php b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-out-scope.php | |
deleted file mode 100644 | |
index b6af2d7..0000000 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-out-scope.php | |
+++ /dev/null | |
@@ -1,3 +0,0 @@ | |
-<?php | |
- @include("./navigation-redirect-scope1.php"); | |
-?> | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-scope1.php b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-scope1.php | |
deleted file mode 100644 | |
index 39a9fab..0000000 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-scope1.php | |
+++ /dev/null | |
@@ -1,19 +0,0 @@ | |
-<?php | |
-if (isset($_GET['url'])) { | |
- header("HTTP/1.1 302"); | |
- $url = $_GET['url']; | |
- header("Location: $url"); | |
- exit; | |
-} | |
-if (isset($_GET['noLocationRedirect'])) { | |
- header("HTTP/1.1 302"); | |
-} | |
-?> | |
-<!DOCTYPE html> | |
-<script> | |
- window.parent.postMessage( | |
- { | |
- id: 'last_url', | |
- result: location.href | |
- }, '*'); | |
-</script> | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-scope2.php b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-scope2.php | |
deleted file mode 100644 | |
index b6af2d7..0000000 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-scope2.php | |
+++ /dev/null | |
@@ -1,3 +0,0 @@ | |
-<?php | |
- @include("./navigation-redirect-scope1.php"); | |
-?> | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-to-http.php b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-to-http.php | |
deleted file mode 100644 | |
index 597784f..0000000 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-to-http.php | |
+++ /dev/null | |
@@ -1,4 +0,0 @@ | |
-<?php | |
-header("HTTP/1.1 302"); | |
-header("Location: http://www.example.com/"); | |
-?> | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-worker.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-worker.js | |
deleted file mode 100644 | |
index 69ddbed..0000000 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-worker.js | |
+++ /dev/null | |
@@ -1,47 +0,0 @@ | |
-// TODO(horo): Service worker can be killed at some point during the test. So we | |
-// should use storage API instead of this global variable. | |
-var urls = []; | |
- | |
-self.addEventListener('message', function(event) { | |
- event.data.port.postMessage({urls: urls}); | |
- urls = []; | |
- }); | |
- | |
-function get_query_params(url) { | |
- var search = (new URL(url)).search; | |
- if (!search) { | |
- return {}; | |
- } | |
- var ret = {}; | |
- var params = search.substring(1).split('&'); | |
- params.forEach(function(param) { | |
- var element = param.split('='); | |
- ret[decodeURIComponent(element[0])] = decodeURIComponent(element[1]); | |
- }); | |
- return ret; | |
-} | |
- | |
-self.addEventListener('fetch', function(event) { | |
- urls.push(event.request.url) | |
- var params = get_query_params(event.request.url); | |
- if (params['sw'] == 'gen') { | |
- event.respondWith(Response.redirect(params['url'])); | |
- } else if (params['sw'] == 'fetch') { | |
- event.respondWith(fetch(event.request)); | |
- } else if (params['sw'] == 'opaque') { | |
- event.respondWith(fetch( | |
- new Request(event.request.url, {redirect: 'manual'}))); | |
- } else if (params['sw'] == 'opaqueThroughCache') { | |
- var url = event.request.url; | |
- var cache; | |
- event.respondWith( | |
- self.caches.delete(url) | |
- .then(function() { return self.caches.open(url); }) | |
- .then(function(c) { | |
- cache = c; | |
- return fetch(new Request(url, {redirect: 'manual'})); | |
- }) | |
- .then(function(res) { return cache.put(event.request, res); }) | |
- .then(function() { return cache.match(url); })); | |
- } | |
- }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment