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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-worker.js

Issue 2872363002: Upstream service worker navigation tests to WPT (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-to-http-worker.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-worker.js
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 69ddbed451abc9d3fd5fc4599d522cfe1c65898c..0000000000000000000000000000000000000000
--- 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); }));
- }
- });
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/navigation-redirect-to-http-worker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698