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

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

Issue 2443103002: service worker: Implement NavigationPreloadManager.getState (Closed)
Patch Set: reject Created 4 years, 2 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/navigation-preload/resources/get-state-worker.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-preload/resources/get-state-worker.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-preload/resources/get-state-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..93ee461c10d9bb1c2cff5f84ebb314844b89f3e8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-preload/resources/get-state-worker.js
@@ -0,0 +1,19 @@
+// This worker listens for commands from the page and messages back
+// the result.
+
+function handle(message) {
+ const np = self.registration.navigationPreload;
+ switch (message) {
+ case 'getState':
+ return np.getState();
+ case 'enable':
+ return np.enable();
+ case 'disable':
+ return np.disable();
+ }
+ return Promise.reject('bad message');
+}
+
+self.addEventListener('message', e => {
+ e.waitUntil(handle(e.data).then(result => e.source.postMessage(result)));
+ });

Powered by Google App Engine
This is Rietveld 408576698