- From: Marcos Cáceres <notifications@github.com>
- Date: Wed, 19 Oct 2016 23:19:40 -0700
- To: w3c/manifest <manifest@noreply.github.com>
- Message-ID: <w3c/manifest/issues/417/255018962@github.com>
@mgiuca, @dominickng - ok, hopefully N-th time lucky :)
So, I think we actually do want to throw InvalidStateError if "prompting". So this would be cover all cases discussed so far (tested with @mgiuca test above too).
```JS
prompt() {
if (this.isTrusted === false) {
const msg = "Untrusted events can't call prompt().";
throw new DOMException(msg, "NotAllowedError");
}
switch (internalSlots.get(this).promptState) {
case "done":
const msg = ".prompt() has expired.";
throw new DOMException(msg, "InvalidStateError");
case "prompting":
const msg = "Already trying to prompt.";
throw new DOMException(msg, "InvalidStateError");
default:
if (this.defaultPrevented === false) {
const msg = ".prompt() needs to be called after .preventDefault()";
throw new DOMException(msg, "InvalidStateError");
}
internalSlots.get(this).promptState = "prompting";
}
(async function task() {
const promptOutcome = await showInstallPrompt();
internalSlots.get(this).promptState = "done";
internalSlots.get(this).userChoiceHandlers.resolve(promptOutcome);
}.bind(this)())
}
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/manifest/issues/417#issuecomment-255018962
Received on Thursday, 20 October 2016 06:20:19 UTC