[whatwg/storage] Feedback on the persist() algorithm. (#26)

Not necessarily bugs, but a couple things I noticed.

If |permission| is "prompt" on entry, there is no way the promise can resolve without setting |permission| to either "grant" or "deny". If a user agent should wish to implement a "Not Now" dismissal of the prompt, the only spec compliant implementation would be to not resolve the promise. I think a resolution to false in that case would be more helpful so logic in the page would not be expecting user input that will never arrive.

Is the ASSERT added between 4 and 5 below expected to always hold true? The steps below may allow the promise to resolve to "true" despite the user having just chosen "deny". That seems wrong.

```
1. Let origin be settingsObject’s origin.

2. Let permission be permission for origin.

3. If permission is "prompt", then ask the user whether turning origin’s site storageunit’s box
   into a persistent box is acceptable. If it is, then set permission to "granted", and "denied" otherwise.

4. Let persisted be true if origin’s site storage unit’s box is a persistent box, and false otherwise.

  if (permission == "denied") ASSERT(!persisted);

5. Queue a task to run these subsubsteps:

    1., Set permission for origin to permission.

    2. If persisted is false and permission is "granted", set persisted to true and set origin’s
       site storage unit’s box’s mode to "persistent".

    3. Resolve promise with persisted.
```


---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/storage/issues/26

Received on Wednesday, 27 April 2016 22:18:06 UTC