From 32b3b885875bac9635bfa6c1ec90e4d7413887a9 Mon Sep 17 00:00:00 2001 From: Josh Karlin Date: Tue, 2 Aug 2016 09:08:13 -0400 Subject: [PATCH] fix --- spec/index.bs | 4 +- spec/index.html | 734 ++++++++++++++++++++++++++++++------------------ 2 files changed, 455 insertions(+), 283 deletions(-) diff --git a/spec/index.bs b/spec/index.bs index 3df08aa..2b59513 100644 --- a/spec/index.bs +++ b/spec/index.bs @@ -331,7 +331,7 @@ spec: WebIDL; urlPrefix: https://heycam.github.io/webidl/# }; - Note: The {{SyncEvent}} interface represents a firing sync registration. If the page (or worker) that registered the event is running, the user agent will fire the sync event as soon as network connectivity is available. Otherwise, the user agent should run at the soonest convenience. If a sync event fails, the user agent may decide to retry it at a time of its choosing. The {{SyncEvent/lastChance}} attribute is true if the user agent will not make further attempts to try this sync after the current attempt. + Note: The {{SyncEvent}} interface represents a firing sync registration. If the page (or worker) that registered the event is running, the user agent will fire the sync event as soon as network connectivity is available. Otherwise, the user agent should run the event at the soonest convenience. If a sync event fails, the user agent may decide to retry it at a time of its choosing. The {{SyncEvent/lastChance}} attribute is true if the user agent will not make further attempts to try this sync after the current attempt.
Reacting to {{SyncEvent/lastChance}}: @@ -356,7 +356,7 @@ spec: WebIDL; urlPrefix: https://heycam.github.io/webidl/# In the above example doImportantThing is a developer-defined function.
- Whenever the user agent changes to online, the user agent SHOULD fire a sync event for each sync registration whose registration state is pending. + Whenever the user agent changes to online, the user agent SHOULD fire a sync event for each sync registration whose registration state is pending. The events may be fired in any order. To fire a sync event for a sync registration registration, the user agent MUST run the following steps:
    diff --git a/spec/index.html b/spec/index.html index 2b1e936..c297d93 100644 --- a/spec/index.html +++ b/spec/index.html @@ -34,6 +34,7 @@ * - .note for informative notes (div, p, span, aside, details) * - .example for informative examples (div, p, pre, span) * - .issue for issues (div, p, span) + * - .assertion for assertions (div, p, span) * - .advisement for loud normative statements (div, p, strong) * - .annoying-warning for spec obsoletion notices (div, aside, details) * @@ -48,9 +49,9 @@ * - ::before styled for CSS-generated issue/example/figure numbers: * -> Documents wishing to use this only need to add * figcaption::before, - * .caption::before { content: "Figure " counter(figure); } - * .example::before { content: "Example " counter(example); } - * .issue::before { content: "Issue " counter(issue); } + * .caption::before { content: "Figure " counter(figure) " "; } + * .example::before { content: "Example " counter(example) " "; } + * .issue::before { content: "Issue " counter(issue) " "; } * * Header Stuff (ignore, just don't conflict with these classes) * - .head for the header @@ -408,15 +409,18 @@ } /* Style for algorithms */ - ol.algorithm ol:not(.algorithm) { + ol.algorithm ol:not(.algorithm), + .algorithm > ol ol:not(.algorithm) { border-left: 0.5em solid #DEF; } /* Style for switch/case
    s */ - dl.switch > dd > ol.only { + dl.switch > dd > ol.only, + dl.switch > dd > .only > ol { margin-left: 0; } - dl.switch > dd > ol.algorithm { + dl.switch > dd > ol.algorithm, + dl.switch > dd > .algorithm > ol { margin-left: -2em; } dl.switch { @@ -594,7 +598,7 @@ /* Colored Boxes */ /******************************************************************************/ - .issue, .note, .example, .advisement, blockquote { + .issue, .note, .example, .assertion, .advisement, blockquote { padding: .5em; border: .5em; border-left-style: solid; @@ -609,6 +613,7 @@ .note, .example, .advisement, + .assertion, blockquote { margin: 1em auto; } @@ -641,7 +646,7 @@ padding-right: 1em; text-transform: uppercase; } - /* Add .issue::before { content: "Issue " counter(issue); } for autogen numbers, + /* Add .issue::before { content: "Issue " counter(issue) " "; } for autogen numbers, or use class="marker" to mark up the issue number in source. */ /** Example *******************************************************************/ @@ -659,7 +664,7 @@ min-width: 7.5em; display: block; } - /* Add .example::before { content: "Example " counter(example); } for autogen numbers, + /* Add .example::before { content: "Example " counter(example) " "; } for autogen numbers, or use class="marker" to mark up the example number in source. */ /** Non-normative Note ********************************************************/ @@ -688,6 +693,14 @@ border-bottom: 1px silver solid; } +/** Assertion Box *************************************************************/ + /* for assertions in algorithms */ + + .assertion { + border-color: #AAA; + background: #EEE; + } + /** Advisement Box ************************************************************/ /* for attention-grabbing normative statements */ @@ -962,10 +975,9 @@ /* ToC not indented until third level, but font style & margins show hierarchy */ .toc > li { font-weight: bold; } .toc > li li { font-weight: normal; } - .toc > li li li { font-style: italic; } - .toc > li li li li { font-style: normal; } - .toc > li li li li li { font-style: italic; - font-size: 85%; } + .toc > li li li { font-size: 95%; } + .toc > li li li li { font-size: 90%; } + .toc > li li li li li { font-size: 85%; } .toc > li { margin: 1.5rem 0; } .toc > li li { margin: 0.3rem 0; } @@ -1148,163 +1160,163 @@ */ } } + + + + + + + - - -

    Web Background Synchronization

    -

    Draft Community Group Report,

    +

    Draft Community Group Report,

    This version: @@ -1471,7 +1484,7 @@

    As this API relies on service workers, functionality provided by this API is only available in a secure context.

    Requesting a background sync opportunity from a browsing context: -
    function sendChatMessage(message) {
    +
    function sendChatMessage(message) {
       return addChatMessageToOutbox(message).then(() => {
         // Wait for the scoped service worker registration to get a
         // service worker with an active state
    @@ -1483,10 +1496,11 @@ 

    }).catch(() => { console.log('Sync registration failed :('); }); -}

    +} +

    In the above example addChatMessageToOutbox is a developer-defined function.

    Reacting to a sync event within a service worker:

    -
    self.addEventListener('sync', event => {
    +
    self.addEventListener('sync', event => {
       if (event.tag == 'send-chats') {
         event.waitUntil(
           getMessagesFromOutbox().then(messages => {
    @@ -1507,21 +1521,22 @@ 

    }) ); } -});

    +}); +

    In the above example getMessagesFromOutbox and removeMessagesFromOutbox are developer-defined functions.

    2. Concepts

    -

    The sync event is considered to run in the background#in-the-backgroundReferenced in:1. Introduction4.2. Location Tracking4.3. History Leaking if no service worker clients whose frame type is top-level or auxiliary exist for the origin of the corresponding service worker registration.

    -

    The user agent is considered to be online#onlineReferenced in:2. Concepts5.2. SyncManager interface (2)5.3. The sync event (2) (3) (4) if the user agent has established a network connection. A user agent MAY use a stricter definition of being online. Such a stricter definition MAY take into account the particular service worker or origin a sync registration is associated with.

    +

    The sync event is considered to run in the background if no service worker clients whose frame type is top-level or auxiliary exist for the origin of the corresponding service worker registration.

    +

    The user agent is considered to be online if the user agent has established a network connection. A user agent MAY use a stricter definition of being online. Such a stricter definition MAY take into account the particular service worker or origin a sync registration is associated with.

    3. Constructs

    - A service worker registration has an associated list of sync registrations#list-of-sync-registrationsReferenced in:3. Constructs5.2. SyncManager interface (2) (3)5.3. The sync event (2) (3) whose element type is a sync registration. -

    A sync registration#sync-registrationReferenced in:2. Concepts3. Constructs (2) (3) (4) (5)5.2. SyncManager interface (2)5.3. The sync event (2) is a tuple consisting of a tag and a state.

    -

    A sync registration has an associated tag#tagReferenced in:3. Constructs (2)5.2. SyncManager interface (2) (3)5.3. The sync event, a DOMString.

    -

    A sync registration has an associated registration state#registration-stateReferenced in:3. Constructs5.2. SyncManager interface (2) (3) (4) (5)5.3. The sync event (2) (3) (4) (5) (6) (7), which is one of pending#pendingReferenced in:3. Constructs5.2. SyncManager interface (2)5.3. The sync event (2) (3) (4) (5), waiting#waitingReferenced in:5.2. SyncManager interface5.3. The sync event (2), firing#firingReferenced in:5.2. SyncManager interface5.3. The sync event (2), or reregisteredWhileFiring#reregisteredwhilefiringReferenced in:5.2. SyncManager interface5.3. The sync event (2). It is initially set to pending.

    + A service worker registration has an associated list of sync registrations whose element type is a sync registration. +

    A sync registration is a tuple consisting of a tag and a state.

    +

    A sync registration has an associated tag, a DOMString.

    +

    A sync registration has an associated registration state, which is one of pending, waiting, firing, or reregisteredWhileFiring. It is initially set to pending.

    A sync registration has an associated service worker registration. It is initially set to null.

    Within one list of sync registrations each sync registration MUST have a unique tag.

    @@ -1545,21 +1560,21 @@

    5. API Description

    5.1. Extensions to the ServiceWorkerRegistration interface

    -
    partial interface ServiceWorkerRegistration {
    -  readonly attribute SyncManager sync;
    +
    partial interface ServiceWorkerRegistration {
    +  readonly attribute SyncManager sync;
     };
     

    The sync attribute exposes a SyncManager, which has an associated service worker registration represented by the ServiceWorkerRegistration on which the attribute is exposed.

    5.2. SyncManager interface

    -
    [Exposed=(Window,Worker)]
    -interface SyncManager#syncmanagerReferenced in:5.1. Extensions to the ServiceWorkerRegistration interface (2)5.2. SyncManager interface (2) (3) {
    -  Promise<void> register(DOMString tag);
    -  Promise<sequence<DOMString>> getTags();
    +
    [Exposed=(Window,Worker)]
    +interface SyncManager {
    +  Promise<void> register(DOMString tag);
    +  Promise<sequence<DOMString>> getTags();
     };
     
    -

    The register(tag)#dom-syncmanager-registerReferenced in:5.2. SyncManager interface method, when invoked, MUST return a new promise promise and run the following steps in parallel:

    +

    The register(tag) method, when invoked, MUST return a new promise promise and run the following steps in parallel:

    1. Let serviceWorkerRegistration be the SyncManager's associated service worker registration.
    2. @@ -1598,7 +1613,7 @@

      If the user agent is currently online, fire a sync event for newRegistration.

-

The getTags()#dom-syncmanager-gettagsReferenced in:5.2. SyncManager interface method when invoked, MUST return a new promise promise and run the following steps in parallel:

+

The getTags() method when invoked, MUST return a new promise promise and run the following steps in parallel:

  1. Let serviceWorkerRegistration be the SyncManager's associated service worker registration.
  2. Let currentTags be a new sequence. @@ -1607,26 +1622,26 @@

    -

    5.3. The sync#syncReferenced in:5.3. The sync event event

    -
    partial interface ServiceWorkerGlobalScope {
    -  attribute EventHandler onsync;
    +     

    5.3. The sync event

    +
    partial interface ServiceWorkerGlobalScope {
    +  attribute EventHandler onsync;
     };
     
    -[Constructor(DOMString type, SyncEventInit init), Exposed=ServiceWorker]
    -interface SyncEvent#synceventReferenced in:5.3. The sync event (2) (3) : ExtendableEvent {
    -  readonly attribute DOMString tag#dom-syncevent-tagReferenced in:5.3. The sync event;
    -  readonly attribute boolean lastChance#dom-syncevent-lastchanceReferenced in:5.3. The sync event (2) (3) (4) (5) (6);
    +[Constructor(DOMString type, SyncEventInit init), Exposed=ServiceWorker]
    +interface SyncEvent : ExtendableEvent {
    +  readonly attribute DOMString tag;
    +  readonly attribute boolean lastChance;
     };
     
    -dictionary SyncEventInit#dictdef-synceventinitReferenced in:5.3. The sync event : ExtendableEventInit {
    -  required DOMString tag;
    -  boolean lastChance = false;
    +dictionary SyncEventInit : ExtendableEventInit {
    +  required DOMString tag;
    +  boolean lastChance = false;
     };
     
    -

    Note: The SyncEvent interface represents a firing sync registration. If the page (or worker) that registered the event is running, the user agent will fire the sync event as soon as network connectivity is available. Otherwise, the user agent should run at the soonest convenience. If a sync event fails, the user agent may decide to retry it at a time of its choosing. The lastChance attribute is true if the user agent will not make further attempts to try this sync after the current attempt.

    +

    Note: The SyncEvent interface represents a firing sync registration. If the page (or worker) that registered the event is running, the user agent will fire the sync event as soon as network connectivity is available. Otherwise, the user agent should run the event at the soonest convenience. If a sync event fails, the user agent may decide to retry it at a time of its choosing. The lastChance attribute is true if the user agent will not make further attempts to try this sync after the current attempt.

    Reacting to lastChance: -
    self.addEventListener('sync', event => {
    +
    self.addEventListener('sync', event => {
       if (event.tag == 'important-thing') {
         event.waitUntil(
           doImportantThing().catch(err => {
    @@ -1637,12 +1652,13 @@ 

    }) ); } -});

    +}); +

    The above example reacts to lastChance by showing a notification to the user. This requires the origin to have permission to show notifications.

    In the above example doImportantThing is a developer-defined function.

    -

    Whenever the user agent changes to online, the user agent SHOULD fire a sync event for each sync registration whose registration state is pending.

    -

    To fire a sync event#fire-a-sync-eventReferenced in:5.2. SyncManager interface (2)5.3. The sync event (2) (3) (4) for a sync registration registration, the user agent MUST run the following steps:

    +

    Whenever the user agent changes to online, the user agent SHOULD fire a sync event for each sync registration whose registration state is pending. The events may be fired in any order.

    +

    To fire a sync event for a sync registration registration, the user agent MUST run the following steps:

    1. Assert: registration’s registration state is pending.
    2. Let serviceWorkerRegistration be the service worker registration associated with registration. @@ -1651,7 +1667,7 @@

      Invoke the Handle Functional Event algorithm with registration and the following substeps as arguments.
        -
      1. Let globalObject be the global object these steps are called with. +
      2. Let globalObject be the global object these steps are called with.
      3. Create a trusted event e that uses the SyncEvent interface, with the event type sync, which does not bubble and has no default action.
      4. Let the tag attribute of e be initialized to the tag associated with registration.
      5. Let the lastChance attribute of e be initialized to false if the user agent will retry this sync event if it fails, or true if no further attempts will be made after the current attempt. @@ -1693,7 +1709,7 @@

      A user agent MAY impose a time limit on the lifetime extension and execution time of a SyncEvent which is stricter than the time limit imposed for ExtendableEvents in general. In particular an event for which lastChance is true MAY have a significantly shortened time limit.

      -

      A user agent will retry#will-retryReferenced in:5.3. The sync event a sync event based on some user agent defined heuristics.

      +

      A user agent will retry a sync event based on some user agent defined heuristics.

    @@ -1888,7 +1904,7 @@

    Terms defined by reference

    • - [WebIDL] defines the following terms: + [WebIDL-1] defines the following terms:
    • - [ECMA-262] defines the following terms: + [ECMASCRIPT] defines the following terms:
    • - [HTML] defines the following terms: + [HTML] defines the following terms:
    • - [powerful-features] defines the following terms: + [secure-contexts] defines the following terms:
    • - [promises-guide] defines the following terms: + [promises-guide] defines the following terms:
    • - [service-workers] defines the following terms: + [service-workers] defines the following terms:
      • ExtendableEvent
      • ExtendableEventInit @@ -1946,60 +1962,202 @@

        References

        Normative References

        -
        [ECMA-262] +
        [ECMASCRIPT]
        ECMAScript Language Specification. URL: https://tc39.github.io/ecma262/
        [HTML]
        Ian Hickson. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/ -
        [POWERFUL-FEATURES] -
        Mike West; Yan Zhu. Privileged Contexts. 24 April 2015. WD. URL: https://w3c.github.io/webappsec/specs/powerfulfeatures/
        [PROMISES-GUIDE]
        Writing Promise-Using Specifications. 24 July 2015. Finding of the W3C TAG. URL: https://www.w3.org/2001/tag/doc/promises-guide
        [RFC2119]
        S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119 +
        [SECURE-CONTEXTS] +
        Mike West. Secure Contexts. 19 July 2016. WD. URL: https://w3c.github.io/webappsec-secure-contexts/
        [SERVICE-WORKERS]
        Alex Russell; Jungkee Song; Jake Archibald. Service Workers. 25 June 2015. WD. URL: https://slightlyoff.github.io/ServiceWorker/spec/service_worker/ -
        [WebIDL] +
        [WebIDL-1]
        Cameron McCormack; Boris Zbarsky. WebIDL Level 1. 8 March 2016. CR. URL: https://heycam.github.io/webidl/

        IDL Index

        -
        partial interface ServiceWorkerRegistration {
        -  readonly attribute SyncManager sync;
        +
        partial interface ServiceWorkerRegistration {
        +  readonly attribute SyncManager sync;
         };
         
        -[Exposed=(Window,Worker)]
        -interface SyncManager {
        -  Promise<void> register(DOMString tag);
        -  Promise<sequence<DOMString>> getTags();
        +[Exposed=(Window,Worker)]
        +interface SyncManager {
        +  Promise<void> register(DOMString tag);
        +  Promise<sequence<DOMString>> getTags();
         };
         
        -partial interface ServiceWorkerGlobalScope {
        -  attribute EventHandler onsync;
        +partial interface ServiceWorkerGlobalScope {
        +  attribute EventHandler onsync;
         };
         
        -[Constructor(DOMString type, SyncEventInit init), Exposed=ServiceWorker]
        -interface SyncEvent : ExtendableEvent {
        -  readonly attribute DOMString tag;
        -  readonly attribute boolean lastChance;
        +[Constructor(DOMString type, SyncEventInit init), Exposed=ServiceWorker]
        +interface SyncEvent : ExtendableEvent {
        +  readonly attribute DOMString tag;
        +  readonly attribute boolean lastChance;
         };
         
        -dictionary SyncEventInit : ExtendableEventInit {
        -  required DOMString tag;
        -  boolean lastChance = false;
        +dictionary SyncEventInit : ExtendableEventInit {
        +  required DOMString tag;
        +  boolean lastChance = false;
         };
         
         
        -