w3c / hr-time

High Resolution Time
https://w3c.github.io/hr-time/
Other
52 stars 24 forks source link

Expose the "current wall time" #155

Closed jyasskin closed 1 year ago

jyasskin commented 1 year ago

We currently expose an environment settings object's current wall time, which optionally coarsens the time depending on the settings object's state, but the authors of a couple recent specifications (https://github.com/privacycg/nav-tracking-mitigations/pull/37/ and https://github.com/WICG/storage-buckets/pull/78/) have intuitively referred to the [=current wall time=] without providing a settings object. That's a sensible operation, since the point of a wall time is that it doesn't depend on any particular UA state, but we need to make sure that folks don't accidentally expose high-precision timers.

I suggest we define the <dfn export for=/>current wall time</dfn> as the result of calling coarsen time given the wall clock's unsafe current time and the default false value for crossOriginIsolatedCapability. That fails safe (100us resolution) if it's used in a context where it really should have taken a settings object.

yoavweiss commented 1 year ago

SGTM! @noamr - thoughts?

noamr commented 1 year ago

SG! I think in general it will also be ok to have default-false for current high resolution time, so that only places that require hi-res time would have to pass a settings object.

jyasskin commented 1 year ago

current high resolution time is a duration from a settings object's time origin, so we can't make the settings object optional for that one.

noamr commented 1 year ago

current high resolution time is a duration from a settings object's time origin, so we can't make the settings object optional for that one.

Of course, right. So your proposal SGTM as is.

clelland commented 1 year ago

@jyasskin, are you planning on making a PR for this?

jyasskin commented 1 year ago

Sure, I can do that: #161