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

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

Issue 318393002: Initial implementation of ServiceWorkerGlobalScope.fetch() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incoroporated dominicc's comment Created 6 years, 6 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: LayoutTests/http/tests/serviceworker/resources/fetch-worker.js
diff --git a/LayoutTests/http/tests/serviceworker/resources/fetch-worker.js b/LayoutTests/http/tests/serviceworker/resources/fetch-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..0484b2322a7559e50969a9f005b3f71984e6335c
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/resources/fetch-worker.js
@@ -0,0 +1,32 @@
+self.onmessage = function(e) {
+ var message = e.data;
+ if ('port' in message) {
+ port = message.port;
+ doNextFetchTest(port);
+ }
+};
+
+var testTargets = [
+ 'other.html',
+ 'http://',
+ 'http://www.example.com/foo'
+];
+
+function doNextFetchTest(port) {
+ if (testTargets.length == 0) {
+ port.postMessage('quit');
+ // Destroying the execution context while fetch is happening should not cause a crash.
+ fetch('dummy.html').then(function() {}).catch(function() {});
+ self.close();
+ return;
+ }
+ var target = testTargets.shift();
+ fetch(target)
+ .then(function() {
+ port.postMessage('Resolved: ' + target);
+ doNextFetchTest(port);
+ }).catch(function(e) {
+ port.postMessage('Rejected: ' + target + ' : '+ e.message);
+ doNextFetchTest(port);
+ });
+};

Powered by Google App Engine
This is Rietveld 408576698