Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify ServiceWorker time origin #1

Closed
igrigorik opened this issue Nov 7, 2014 · 1 comment · Fixed by #2
Closed

Clarify ServiceWorker time origin #1

igrigorik opened this issue Nov 7, 2014 · 1 comment · Fixed by #2

Comments

@igrigorik
Copy link
Member

(as discussed at TPAC...)

@slightlyoff I believe current language should be sufficient for ServiceWorker, correct?

That said, I think we may need to refine workerStart:

The workerStart attribute MUST return a DOMHighResTimeStamp representing the difference between the time origin of the SharedWorkerGlobalScope associated with the SharedWorker and the time origin of the current document. - source

Since there is no "current document" (there can be multiple) for ServiceWorker, above doesn't really work. Perhaps add a clause for "if there is no current document, or there are multiple, then report time from worker start"?

@igrigorik
Copy link
Member Author

Current spec:

For a dedicated worker, the time origin must be equal to the time of the start of navigation of the document where it was created.
For a shared worker, the time origin must be equal to the time of creation of the shared worker.

Feedback from Kinuko Yasuda and Jake Archibald:

Why don't we simply define it as 'the time of creation of the dedicated worker'? Is that because developers would want to compare timings in workers and that in the parent documents? Dedicated worker can also create a nested dedicated worker (though it's not implemented in chrome), in that case the latter (the time of creation of the worker) should be applied?

Agree with +kinuko@google.com. Dedicated workers are children of the environment that created them, but they have their own CSP and form their own service worker client. I guess their closest relative is an iframe, and they get their own start time.

https://w3c.github.io/hr-time/#sec-examples seems to imply that current difference in definitions is born out of convenience: "A developer may wish to construct a timeline of their entire application, including workers. With a dedicated worker, this is easy. All DOMHighResTimeStamps recorded in the worker use the same time origin as the document."

Perhaps we can/should simplify the time origin to be consistent between Dedicated and Shared Workers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant