Closed saschanaz closed 3 years ago
The Chrome implementation interestingly silently returns nothing from the methods.
n.locks.request("foo", () => {}); // returns `undefined` instead of a Promise, which violates Web IDL?
n.locks.query(); // same
Should it instead throw?
I suspect both specs and implementations are wildly underspecified/tested here across the platform.
IMHO, I'm happy for the spec to do whatever is most common here, and we can update the Chrome impl. Also, ideally, we'd have somewhere (Infra? WebIDL? dunno) that gives guidance on how APIs should behave in these cases. Maybe even idlharness should be testing these?
Anyway, for web-locks, spec PRs & WPT PRs are very welcome.
@marcoscaceres has recently been quite active on this topic. Hi Marcos, what's your expected behavior here? 👀
Coincidently, the following guidance just got merged into the TAG design guidelines: https://w3ctag.github.io/design-principles/#support-non-fully-active
(it's what I've been following, with some guidance from @rakina)
I've not looked at this API in any depth - but I'd suggest starting there. It may be you need to simply return a promise rejected with an InvalidStateError
.
To the specific question, I think we'd want:
navigator.locks
should still return a LockManager
request()
and query()
methods should throw (reject).Thoughts?
Also... while full active is defined for documents, is there an easy incantation for Workers?
FYI, c/o @domenic https://github.com/whatwg/html/pull/6379
Also... while full active is defined for documents, is there an easy incantation for Workers?
I think for workers there are potentially 2 lifecycle-y things?
self.close()
since the worker's event loop task queues have gone away and your request() can never succeed. So the verbiage might be closing flag is false
.I guess I was wondering what happens in a worker when the owning document goes into BFCache or is in a detached iframe. Does the worker get closed?
The Worker's lifetime covers the general states and the processing model covers when to suspend which is on transition from "active needed worker" to "permissible worker". The processing model also covers "closing orphan workers". And then there's just explicit termination and explicit self.close()
.
Speaking from the hip, detached iframe will terminate the worker, bfcache could potentially suspend (noting that interesting documents may tend to be forbidden from going into bfcache because of what's going on in them), but I am absolutely not up-to-date on changes made to specs resulting from standardization of bfcache, just generally aware of Firefox's implementation ramifications related to bfcache. I will edit this paragraph as I inevitably am proven to be wrong in ways big and small as my saying this compels people to reply with (more) correct answers.