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

Unified Diff: LayoutTests/http/tests/serviceworker/chromium/resources/fetch-script-onerror-worker.js

Issue 1151433002: Add LayoutTest for the script error sanitization for ServiceWorker fetched scripts. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: s/messageCallback/message_callback Created 5 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 | « LayoutTests/http/tests/serviceworker/chromium/resources/fetch-script-onerror-iframe.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/chromium/resources/fetch-script-onerror-worker.js
diff --git a/LayoutTests/http/tests/serviceworker/chromium/resources/fetch-script-onerror-worker.js b/LayoutTests/http/tests/serviceworker/chromium/resources/fetch-script-onerror-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..9b33a830699d6b8ad758d8bb02a732abc3fa2b30
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/chromium/resources/fetch-script-onerror-worker.js
@@ -0,0 +1,34 @@
+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;
+}
+
+function get_request_init(params) {
+ var init = {};
+ if (params['mode']) {
+ init['mode'] = params['mode'];
+ }
+ return init;
+}
+
+self.addEventListener('fetch', function(event) {
+ var params = get_query_params(event.request.url);
+ var init = get_request_init(params);
+ var url = params['url'];
+ event.respondWith(new Promise(function(resolve, reject) {
+ var request = event.request;
+ if (url) {
+ request = new Request(url, init);
+ }
+ fetch(request).then(resolve, reject);
+ }));
+ });
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/resources/fetch-script-onerror-iframe.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698