From 688f5f85cbfa5c56326551753ba86735dcf60393 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 10 Feb 2017 13:14:18 -0500 Subject: [PATCH] Add multi-global tests for service worker URL parsing Follows https://github.com/slightlyoff/ServiceWorker/issues/922. --- .../multi-globals/current/current.https.html | 2 + .../multi-globals/current/test-sw.js | 15 ++++ .../incumbent/incumbent.https.html | 20 ++++++ .../multi-globals/incumbent/test-sw.js | 15 ++++ .../relevant/relevant.https.html | 2 + .../multi-globals/relevant/test-sw.js | 15 ++++ .../service-worker/multi-globals/test-sw.js | 15 ++++ .../multi-globals/url-parsing.https.html | 72 +++++++++++++++++++ 8 files changed, 156 insertions(+) create mode 100644 service-workers/service-worker/multi-globals/current/current.https.html create mode 100644 service-workers/service-worker/multi-globals/current/test-sw.js create mode 100644 service-workers/service-worker/multi-globals/incumbent/incumbent.https.html create mode 100644 service-workers/service-worker/multi-globals/incumbent/test-sw.js create mode 100644 service-workers/service-worker/multi-globals/relevant/relevant.https.html create mode 100644 service-workers/service-worker/multi-globals/relevant/test-sw.js create mode 100644 service-workers/service-worker/multi-globals/test-sw.js create mode 100644 service-workers/service-worker/multi-globals/url-parsing.https.html diff --git a/service-workers/service-worker/multi-globals/current/current.https.html b/service-workers/service-worker/multi-globals/current/current.https.html new file mode 100644 index 00000000000000..82a48d409901b4 --- /dev/null +++ b/service-workers/service-worker/multi-globals/current/current.https.html @@ -0,0 +1,2 @@ + +Current page used as a test helper diff --git a/service-workers/service-worker/multi-globals/current/test-sw.js b/service-workers/service-worker/multi-globals/current/test-sw.js new file mode 100644 index 00000000000000..ca340943068c2b --- /dev/null +++ b/service-workers/service-worker/multi-globals/current/test-sw.js @@ -0,0 +1,15 @@ +'use strict'; + +this.addEventListener('install', event => { + this.skipWaiting(); +}); + +this.addEventListener('activate', event => { + clients.claim(); +}); + +this.addEventListener('fetch', event => { + if (event.request.url.includes('test.txt')) { + event.respondWith(new Response('current')); + } +}); diff --git a/service-workers/service-worker/multi-globals/incumbent/incumbent.https.html b/service-workers/service-worker/multi-globals/incumbent/incumbent.https.html new file mode 100644 index 00000000000000..4585f15b0f45d0 --- /dev/null +++ b/service-workers/service-worker/multi-globals/incumbent/incumbent.https.html @@ -0,0 +1,20 @@ + +Incumbent page used as a test helper + + + + + diff --git a/service-workers/service-worker/multi-globals/incumbent/test-sw.js b/service-workers/service-worker/multi-globals/incumbent/test-sw.js new file mode 100644 index 00000000000000..2f970a25ce6609 --- /dev/null +++ b/service-workers/service-worker/multi-globals/incumbent/test-sw.js @@ -0,0 +1,15 @@ +'use strict'; + +this.addEventListener('install', event => { + this.skipWaiting(); +}); + +this.addEventListener('activate', event => { + clients.claim(); +}); + +this.addEventListener('fetch', event => { + if (event.request.url.includes('test.txt')) { + event.respondWith(new Response('incumbent')); + } +}); diff --git a/service-workers/service-worker/multi-globals/relevant/relevant.https.html b/service-workers/service-worker/multi-globals/relevant/relevant.https.html new file mode 100644 index 00000000000000..44f42eda493c27 --- /dev/null +++ b/service-workers/service-worker/multi-globals/relevant/relevant.https.html @@ -0,0 +1,2 @@ + +Relevant page used as a test helper diff --git a/service-workers/service-worker/multi-globals/relevant/test-sw.js b/service-workers/service-worker/multi-globals/relevant/test-sw.js new file mode 100644 index 00000000000000..3cf80c54cb0ad1 --- /dev/null +++ b/service-workers/service-worker/multi-globals/relevant/test-sw.js @@ -0,0 +1,15 @@ +'use strict'; + +this.addEventListener('install', event => { + this.skipWaiting(); +}); + +this.addEventListener('activate', event => { + clients.claim(); +}); + +this.addEventListener('fetch', event => { + if (event.request.url.includes('test.txt')) { + event.respondWith(new Response('relevant')); + } +}); diff --git a/service-workers/service-worker/multi-globals/test-sw.js b/service-workers/service-worker/multi-globals/test-sw.js new file mode 100644 index 00000000000000..f5a6cc5f9dc880 --- /dev/null +++ b/service-workers/service-worker/multi-globals/test-sw.js @@ -0,0 +1,15 @@ +'use strict'; + +this.addEventListener('install', event => { + this.skipWaiting(); +}); + +this.addEventListener('activate', event => { + clients.claim(); +}); + +this.addEventListener('fetch', event => { + if (event.request.url.includes('test.txt')) { + event.respondWith(new Response('entry')); + } +}); diff --git a/service-workers/service-worker/multi-globals/url-parsing.https.html b/service-workers/service-worker/multi-globals/url-parsing.https.html new file mode 100644 index 00000000000000..1330d07805bb85 --- /dev/null +++ b/service-workers/service-worker/multi-globals/url-parsing.https.html @@ -0,0 +1,72 @@ + +register()/getRegistration() URL parsing, with multiple globals in play + + + + + + + + + + + + +