Open Bug 1260141 Opened 5 years ago Updated 6 months ago

[Background Sync] Implement sync event handler logic

Categories

(Core :: DOM: Service Workers, defect, P3)

defect

Tracking

()

People

(Reporter: ferjm, Unassigned)

References

(Depends on 1 open bug, )

Details

(Whiteboard: btpp-fixlater)

For now, bug 1217544 is directly removing every sync event registration right after triggering the sync event. We need to implement this logic instead:

" Invoke the Handle Functional Event algorithm with registration and the following substeps as arguments.

    Let globalObject be the global object these steps are called with.
    Create a trusted event e that uses the SyncEvent interface, with the event type sync, which does not bubble and has no default action.
    Let the tag attribute of e be initialized to the tag associated with registration.
    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.
    Dispatch e at globalObject.
    Let waitUntilPromise be the result of waiting for all of e’s extended lifetime promises.
    Upon fulfillment of waitUntilPromise, perform the following steps atomically:
        If registration’s state is reregisteredWhileFiring:
            Set registration’s state to pending.
            If the user agent is currently online, fire a sync event for registration.
            Abort the rest of these steps. 
        Assert: registration’s registration state is firing.
        Remove registration from serviceWorkerRegistration’s list of sync registration. 
    Upon rejection of waitUntilPromise, or if the script has been aborted by the termination of the service worker, perform the following steps atomically:
        If registration’s state is reregisteredWhileFiring:
            Set registration’s state to pending.
            If the user agent is currently online, fire a sync event for registration.
            Abort the rest of these steps. 
        If the lastChance attribute of e is false, set registration’s registration state to waiting, and perform the following steps in parallel:
            Wait a user agent defined length of time.
            If registration’s registration state is not waiting, abort these substeps.
            Set registration’s registration state to pending.
            If the user agent is currently online, fire a sync event for registration. 
        Else remove registration from serviceWorkerRegistration’s list of sync registrations. "
Blocks: 1217544
No longer blocks: 1217544
Depends on: 1217544
Whiteboard: btpp-fixlater
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.