diff --git a/storage.bs b/storage.bs index 6208890..f91665e 100644 --- a/storage.bs +++ b/storage.bs @@ -22,12 +22,6 @@ urlPrefix: https://html.spec.whatwg.org/multipage/ type: dfn urlPrefix: browsers.html text: origin - text: host; url: concept-origin-host - urlPrefix: webappapis.html - text: environment settings object -urlPrefix: https://w3c.github.io/webappsec/specs/powerfulfeatures/# - type: dfn - text: a secure context; url: settings-secure @@ -49,7 +43,7 @@ APIs gets lost without the user being able to intervene. However, persistent box without consent by the user. This thus brings data guarantees users have enjoyed on native platforms to the web. -
+

A simple way to make storage persistent is through invoking the {{persist()}} method. It simultaneously requests the end user for permission and changes the storage to be persistent once granted:

@@ -79,14 +73,16 @@ Promise.all([

The {{estimate()}} method can be used to determine whether there is enough space left to - download another Metriod Prime level: + store content for an application:


-navigator.storage.estimate().then(info => {
-  if(info.quota - info.usage > metroidPrimeLevel.size)
-    return fetch(metroidPrimeLevel.url)
-  throw new Error("no space")
-}).then( /* … */ )
+ function retrieveNextChunk(nextChunkInfo) {
+   return navigator.storage.estimate().then(info => {
+     if(info.quota - info.usage > nextChunkInfo.size)
+       return fetch(nextChunkInfo.url)
+     else throw new Error("insufficient space to store next chunk")
+   }).then( /* … */ )
+ }
 
@@ -95,16 +91,17 @@ navigator.storage.estimate().then(info => {

Terminology

-This specification uses terminology from the DOM and HTML Standards. [[DOM]] [[HTML]] +This specification uses terminology from the DOM, HTML, IDL, and URL Standards. [[DOM]] [[HTML]] +[[WEBIDL]] [[URL]] A schemeless origin group is a group of one of the following:

This definition will move to a more suitable location eventually. diff --git a/storage.html b/storage.html index d1bf51d..640488b 100644 --- a/storage.html +++ b/storage.html @@ -71,7 +71,7 @@

Storage

-

Living Standard — Last Updated

+

Living Standard — Last Updated

@@ -143,42 +143,43 @@

A simple way to make storage persistent is through invoking the persist() method. It simultaneously requests the end user for permission and changes the storage to be persistent once granted:

-
navigator.storage.persist().then(persisted => {
-  if(persisted) {
+
navigator.storage.persist().then(persisted => {
+  if(persisted) {
     /* … */
   }
-})
+})
 

To not show user-agent-driven dialogs to the end user unannounced slightly more involved code can be written:

-
Promise.all([
-  navigator.storage.persisted(),
-  navigator.permissions.query({name: "persistent-storage"})
-]).then((persisted, permission) => {
-  if(!persisted && permission == "granted") {
-    navigator.storage.persist().then( /* … */ )
-  } else if(!persistent && permission == "default") {
-    showPersistentStorageExplanation()
+
Promise.all([
+  navigator.storage.persisted(),
+  navigator.permissions.query({name: "persistent-storage"})
+]).then((persisted, permission) => {
+  if(!persisted && permission == "granted") {
+    navigator.storage.persist().then( /* … */ )
+  } else if(!persistent && permission == "default") {
+    showPersistentStorageExplanation()
   }
-})
+})
 

The estimate() method can be used to determine whether there is enough space left to - download another Metriod Prime level:

-
navigator.storage.estimate().then(info => {
-  if(info.quota - info.usage > metroidPrimeLevel.size)
-    return fetch(metroidPrimeLevel.url)
-  throw new Error("no space")
-}).then( /* … */ )
+ store content for an application: 

+
function retrieveNextChunk(nextChunkInfo) {
+  return navigator.storage.estimate().then(info => {
+    if(info.quota - info.usage > nextChunkInfo.size)
+      return fetch(nextChunkInfo.url)
+    else throw new Error("insufficient space to store next chunk")
+  }).then( /* … */ )
+}
 

2. Terminology

-

This specification uses terminology from the DOM and HTML Standards. [DOM] [HTML]

+

This specification uses terminology from the DOM, HTML, IDL, and URL Standards. [DOM] [HTML] [WEBIDL] [URL]

A schemeless origin group is a group of one of the following:

This definition will move to a more suitable location eventually.

3. Infrastructure

@@ -241,9 +242,9 @@

non-persistent boxes within site storage, then the user agent should alert the user and offer a way to clear persistent boxes.

7. API

-
[SecureContext,
- NoInterfaceObject,
- Exposed=(Window,Worker)]
+
[SecureContext,
+ NoInterfaceObject,
+ Exposed=(Window,Worker)]
 interface NavigatorStorage {
   readonly attribute StorageManager storage;
 };
@@ -252,11 +253,11 @@ 

7.

Each environment settings object has an associated StorageManager object. [HTML]

The storage attribute’s getter must return context object’s relevant settings object’s StorageManager object.

-
[SecureContext,
- Exposed=(Window,Worker)]
+
[SecureContext,
+ Exposed=(Window,Worker)]
 interface StorageManager {
   Promise<boolean> persisted();
-  [Exposed=Window] Promise<boolean> persist();
+  [Exposed=Window] Promise<boolean> persist();
 
   Promise<StorageEstimate> estimate();
 };
@@ -416,6 +417,8 @@ 

  • Navigator
  • WorkerNavigator +
  • environment settings object +
  • host
  • in parallel
  • opaque origin
  • queue a task @@ -423,10 +426,17 @@

    tuple origin
  • - [WHATWG-URL] defines the following terms: + [URL] defines the following terms: +
  • + [WEBIDL] defines the following terms: +

    References

    Normative References

    @@ -437,24 +447,26 @@

    N
    Ian Hickson. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/
    [RFC2119]
    S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119 -
    [WHATWG-URL] +
    [URL]
    Anne van Kesteren. URL Standard. Living Standard. URL: https://url.spec.whatwg.org/ +
    [WEBIDL] +
    Cameron McCormack; Boris Zbarsky. WebIDL Level 1. 15 September 2016. PR. URL: https://heycam.github.io/webidl/

    IDL Index

    -
    [SecureContext,
    - NoInterfaceObject,
    - Exposed=(Window,Worker)]
    +
    [SecureContext,
    + NoInterfaceObject,
    + Exposed=(Window,Worker)]
     interface NavigatorStorage {
       readonly attribute StorageManager storage;
     };
     Navigator implements NavigatorStorage;
     WorkerNavigator implements NavigatorStorage;
     
    -[SecureContext,
    - Exposed=(Window,Worker)]
    +[SecureContext,
    + Exposed=(Window,Worker)]
     interface StorageManager {
       Promise<boolean> persisted();
    -  [Exposed=Window] Promise<boolean> persist();
    +  [Exposed=Window] Promise<boolean> persist();
     
       Promise<StorageEstimate> estimate();
     };