From 876cf829f3bc9a03d67087ee91a95cf1ea4de096 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 30 Jun 2015 13:14:59 -0400 Subject: [PATCH 1/7] defaultCacheStrategy -> default-cache-strategy --- test/platinum-sw-cache/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/platinum-sw-cache/index.html b/test/platinum-sw-cache/index.html index a56b66f..1a95028 100644 --- a/test/platinum-sw-cache/index.html +++ b/test/platinum-sw-cache/index.html @@ -22,7 +22,7 @@ - From a7d8fa7bbfd9b6f7c080e9ba23317942fb95737f Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 30 Jun 2015 13:16:26 -0400 Subject: [PATCH 2/7] Test for cross-origin fetch handlers. --- .../platinum-sw-fetch/custom-fetch-handler.js | 9 ++++++++- test/platinum-sw-fetch/index.html | 19 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/test/platinum-sw-fetch/custom-fetch-handler.js b/test/platinum-sw-fetch/custom-fetch-handler.js index 732233f..a47886c 100644 --- a/test/platinum-sw-fetch/custom-fetch-handler.js +++ b/test/platinum-sw-fetch/custom-fetch-handler.js @@ -1,6 +1,13 @@ -self.customFetchHandler = function(request) { +self.custom204FetchHandler = function(request) { return new Response('', { status: 204, statusText: 'Via customFetchHandler' }); }; + +self.custom410FetchHandler = function(request) { + return new Response('', { + status: 410, + statusText: 'Via customFetchHandler' + }); +}; diff --git a/test/platinum-sw-fetch/index.html b/test/platinum-sw-fetch/index.html index bb8e8ca..ac3c95c 100644 --- a/test/platinum-sw-fetch/index.html +++ b/test/platinum-sw-fetch/index.html @@ -23,14 +23,17 @@ - + + From e8054d3eaba96bea882db33b65e05f53de45904c Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 30 Jun 2015 13:36:02 -0400 Subject: [PATCH 3/7] Clarify docs re: local vs. cross-origin effects. --- platinum-sw-cache.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platinum-sw-cache.html b/platinum-sw-cache.html index d3569d5..d008ec3 100644 --- a/platinum-sw-cache.html +++ b/platinum-sw-cache.html @@ -21,7 +21,8 @@ * * * - * This is enough to have all of the (local) resources your site uses cached at runtime. + * This is enough to have all of the resources your site uses cached at runtime, both local and + * cross-origin. * (It uses the default `defaultCacheStrategy` of "networkFirst".) * When there's a network available, visits to your site will go against the network copy of the * resources, but if someone visits your site when they're offline, all the cached resources will @@ -34,7 +35,7 @@ properties: { /** - * The caching strategy used for all local (i.e. same-origin) requests. + * The caching strategy used for all requests, both for local and cross-origin resources. * * For a list of strategies, see the [`sw-toolbox` documentation](https://github.com/GoogleChrome/sw-toolbox#built-in-handlers). * Specify a strategy as a string, without the "toolbox" prefix. E.g., for From 05212a4a925ed05290c1b37645240330be818f4a Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 30 Jun 2015 13:42:01 -0400 Subject: [PATCH 4/7] Docs fixes --- platinum-sw-fetch.html | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/platinum-sw-fetch.html b/platinum-sw-fetch.html index 0a255e6..d4a9530 100644 --- a/platinum-sw-fetch.html +++ b/platinum-sw-fetch.html @@ -48,6 +48,10 @@ * and it's possible to have multiple `` elements that each define different * paths and different handlers. The path matching is performed top-down, starting with the first * `` element. + * + * The `path` will, by default, only match same-origin requests. If you'd like to define a custom + * handler for requests on a specific cross-origin domain, you must use the `origin` parameter + * in conjunction with `path` to match the domains you'd like to handle. */ Polymer({ is: 'platinum-sw-fetch', @@ -75,16 +79,15 @@ * * `origin` is a `String`, but it is used internally to construct a * [`RegExp` object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), - * which is used for the matching. To properly escape RegExp sequences like `\.`, it's - * necessary to add in an extra level of string-escaping first ('\\.'). + * which is used for the matching. * * Note that the `origin` value will be matched against the full domain name and the protocol. * If you want to match 'http' and 'https', then use 'https?://' at the start of your string. * * Some examples: - * - `origin="https?://.+\\.google\\.com"` → a RegExp that matches `http` or `https` requests - * made to any domain, as long as it ends in `.google.com`. - * - `origin="https://www\\.example\\.com" → a RegExp that will only match `https` requests to + * - `origin="https?://.+\.google\.com"` → a RegExp that matches `http` or `https` requests + * made to any domain that ends in `.google.com`. + * - `origin="https://www\.example\.com" → a RegExp that will only match `https` requests to * one domain, `www.example.com`. * * @see {@link https://github.com/googlechrome/sw-toolbox#toolboxrouterheadurlpattern-handler-options} From a862dc5717295d1141bfa570761e534c4a2c2722 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 30 Jun 2015 13:42:30 -0400 Subject: [PATCH 5/7] console.log a message if there is an incorrect combination of attributes --- platinum-sw-fetch.html | 3 +++ platinum-sw-import-script.html | 3 +++ 2 files changed, 6 insertions(+) diff --git a/platinum-sw-fetch.html b/platinum-sw-fetch.html index d4a9530..032fbe9 100644 --- a/platinum-sw-fetch.html +++ b/platinum-sw-fetch.html @@ -125,6 +125,9 @@ }; if (this.path && this.handler) { params.route = [this.path, this.handler, this.origin]; + } else { + console.log('The following platinum-sw-fetch element will not have any effect. ' + + 'Both the "path" and "handler" attributes must be set.', this); } resolve(params); }.bind(this)); diff --git a/platinum-sw-import-script.html b/platinum-sw-import-script.html index dc7364a..054d08a 100644 --- a/platinum-sw-import-script.html +++ b/platinum-sw-import-script.html @@ -49,6 +49,9 @@ var params = {}; if (this.href) { params.importscript = this.href; + } else { + console.log('The following platinum-sw-import-script element will not have any effect. ' + + 'The "href" attribute must be set.', this); } resolve(params); }.bind(this)); From 72b284a29a3230ac079bcfde2b4747399cd029f1 Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 30 Jun 2015 13:48:15 -0400 Subject: [PATCH 6/7] Bump to 1.0.2 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index d221037..2b43677 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "platinum-sw", "private": true, - "version": "1.0.1", + "version": "1.0.2", "license": "http://polymer.github.io/LICENSE.txt", "authors": [ "The Polymer Authors" From 876de38f743dcb9c7b71d1c5c94a82f5185afbef Mon Sep 17 00:00:00 2001 From: Jeff Posnick Date: Tue, 30 Jun 2015 14:18:38 -0400 Subject: [PATCH 7/7] console.log -> console.warn --- platinum-sw-fetch.html | 2 +- platinum-sw-import-script.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platinum-sw-fetch.html b/platinum-sw-fetch.html index 032fbe9..ba5a50d 100644 --- a/platinum-sw-fetch.html +++ b/platinum-sw-fetch.html @@ -126,7 +126,7 @@ if (this.path && this.handler) { params.route = [this.path, this.handler, this.origin]; } else { - console.log('The following platinum-sw-fetch element will not have any effect. ' + + console.warn('The following platinum-sw-fetch element will not have any effect. ' + 'Both the "path" and "handler" attributes must be set.', this); } resolve(params); diff --git a/platinum-sw-import-script.html b/platinum-sw-import-script.html index 054d08a..9cb4755 100644 --- a/platinum-sw-import-script.html +++ b/platinum-sw-import-script.html @@ -50,8 +50,8 @@ if (this.href) { params.importscript = this.href; } else { - console.log('The following platinum-sw-import-script element will not have any effect. ' + - 'The "href" attribute must be set.', this); + console.warn('The following platinum-sw-import-script element will not have any effect.' + + ' The "href" attribute must be set.', this); } resolve(params); }.bind(this));