From c565ecf9b21e028b3a0fbf4df38d88db9c00aee6 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 26 Aug 2016 16:11:39 -0400 Subject: [PATCH] Parse URLs relative to the relevant settings object, not entry Fixes #922. Web platform tests at https://github.com/w3c/web-platform-tests/pull/3449. Part of the overall effort in https://github.com/whatwg/html/issues/1431. In the process, fixes some ambiguity about how to parse URLs in the Link header, as previous it parsed relative to the entry settings object, which did not exist during this algorithm. --- spec/service_worker/index.bs | 28 +++++++++++++--------------- spec/service_worker/index.html | 29 +++++++++++++++-------------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/spec/service_worker/index.bs b/spec/service_worker/index.bs index 21c48790..2ba24199 100644 --- a/spec/service_worker/index.bs +++ b/spec/service_worker/index.bs @@ -61,8 +61,6 @@ spec: html; type: dfn text: browsing context text: discard a document text: document base url - text: effective script origin - text: entry settings object text: environment settings object text: event handler text: event handler event type @@ -212,7 +210,7 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/ text: origin; for: resource; url: origin-2 text: browsing context is discarded urlPrefix: infrastructure.html - text: read only array; url: dfn-read-only-array + text: inserted into a document; url: insert-an-element-into-a-document text: StructuredCloneWithTransfer urlPrefix: interaction.html text: has focus steps @@ -784,9 +782,9 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
  1. Let p be a promise.
  2. Let client be the context object's service worker client.
  3. -
  4. Let scriptURL be the result of parsing scriptURL with entry settings object's API base URL.
  5. +
  6. Let scriptURL be the result of parsing scriptURL with the context object's relevant settings object's API base URL.
  7. Let scopeURL be null.
  8. -
  9. If options.{{RegistrationOptions/scope}} is present, set scopeURL to options.{{RegistrationOptions/scope}}.
  10. +
  11. If options.{{RegistrationOptions/scope}} is present, set scopeURL to the result of parsing options.{{RegistrationOptions/scope}} with the context object's relevant settings object's API base URL.
  12. Invoke [[#start-register-algorithm]] with scopeURL, scriptURL, p, client, client's creation URL and options.{{RegistrationOptions/type}}.
  13. Return p.
@@ -799,7 +797,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
  1. Let client be the context object's service worker client.
  2. -
  3. Let clientURL be the result of parsing clientURL with entry settings object's API base URL.
  4. +
  5. Let clientURL be the result of parsing clientURL with the context object's relevant settings object's API base URL.
  6. If clientURL is failure, return a promise rejected with a TypeError.
  7. If the origin of clientURL is not client's origin, return a promise rejected with a "{{SecurityError}}" exception.
  8. Let promise be a new promise.
  9. @@ -2125,20 +2123,22 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
  10. Let request be the request for which this header was received in the response.
  11. If request's client is not a secure context, abort these steps.
  12. Let scriptURL be the result of parsing the target IRI of the Link header.
  13. -
  14. Let scopeURL be the "scope" target attribute of the Link header, or null if no such attribute is present.
  15. +
  16. Let scopeURL be null. +
  17. If the "scope" target attribute of the Link header is present, set scopeURL to the result of parsing the "scope" target attribute with scriptURL.
  18. Let workerType be the "workertype" target attribute of the Link header, or "classic" if no such attribute is present.
  19. If workerType is not a valid {{WorkerType}} value, abort these steps.
  20. Invoke [[#start-register-algorithm]] with scopeURL, scriptURL, a new promise, null, contextURL and workerType.
-

When a serviceworker link's <{link}> element is inserted into a document, a serviceworker link is created on a <{link}> element that is already in a Document, or the <{link/href}> or <{link/scope}> attributes of the <{link}> element of a serviceworker link is changed, the user agent should run these steps:

+

When a serviceworker link's <{link}> element is inserted into a document, a serviceworker link is created on a <{link}> element that is already in a document tree, or the <{link/href}> or <{link/scope}> attributes of the <{link}> element of a serviceworker link is changed, the user agent should run these steps:

  1. If the <{link/href}> attribute is the empty string, abort these steps.
  2. Let client be the document's service worker client.
  3. If client is not a secure context, queue a task to fire a simple event named error at the <{link}> element, and abort these steps.
  4. -
  5. Let scriptURL be the result of parsing the <{link/href}> attribute with document's document base URL.
  6. -
  7. Let scopeURL be the <{link/scope}> attribute, or null if the <{link/scope}> attribute is omitted.
  8. +
  9. Let scriptURL be the result of parsing the <{link/href}> attribute with the <{link}> element's node document's document base URL.
  10. +
  11. Let scopeURL null. +
  12. If the <{link/scope}> attribute is present, set scopeURL to the result of parsing the <{link/scope}> attribute with the <{link}> element's node document's document base URL.
  13. Let workerType be the <{link/workertype}> attribute, or "classic" if the <{link/workertype}> attribute is omitted.
  14. If workerType is not a valid {{WorkerType}} value, queue a task to fire a simple event named error at the <{link}> element, and abort these steps.
  15. Let promise be a new promise.
  16. @@ -3141,8 +3141,8 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
    Input
    -
    scopeURLString, a string
    -
    scriptURL, a URL
    +
    scopeURL, a URL or failure or null
    +
    scriptURL, a URL or failure
    promise, a promise
    client, a service worker client
    referrer, a URL
    @@ -3154,11 +3154,9 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
  17. If scriptURL is failure, reject promise with a TypeError and abort these steps.
  18. If scriptURL's scheme is not one of "http" and "https", reject promise with a TypeError and abort these steps.
  19. If any of the strings in scriptURL's path contains either ASCII case-insensitive "%2f" or ASCII case-insensitive "%5c", reject promise with a TypeError and abort these steps.
  20. -
  21. Let scopeURL be null.
  22. -
  23. If scopeURLString is null, set scopeURL to the result of parsing a string "./" with scriptURL. +
  24. If scopeURL is null, set scopeURL to the result of parsing the string "./" with scriptURL.

    The scope url for the registration is set to the location of the service worker script by default.

  25. -
  26. Else, set scopeURL to the result of parsing scopeURLString with entry settings object's API base URL.
  27. If scopeURL is failure, reject promise with a TypeError and abort these steps.
  28. If scopeURL's scheme is not one of "http" and "https", reject promise with a TypeError and abort these steps.
  29. If any of the strings in scopeURL's path contains either ASCII case-insensitive "%2f" or ASCII case-insensitive "%5c", reject promise with a TypeError and abort these steps.
  30. diff --git a/spec/service_worker/index.html b/spec/service_worker/index.html index d320ee41..33ce34c8 100644 --- a/spec/service_worker/index.html +++ b/spec/service_worker/index.html @@ -2081,9 +2081,9 @@
@@ -2093,7 +2093,7 @@