B2G/gecko/browser/components/sessionstore/src/SessionStorage.jsm
/**
   * Reads an entry in the session storage data contained in a tab's history.
   * @param aURI
   *        That history entry uri
   * @param aDocShell
   *        A tab's docshell (containing the sessionStorage)
   */
Reads an entry in the session storage data contained in a tab's history.
@param aURI
That history entry uri
@param aDocShell
A tab's docshell (containing the sessionStorage)
Reads an entry in the session storage data contained in a tab ' s history . @param aURI That history entry uri @param aDocShell A tab ' s docshell ( containing the sessionStorage )
function DomStorage_readEntry(aPrincipal, aDocShell) {
    let hostData = {};
    let storage;
    try {
      storage = aDocShell.getSessionStorageForPrincipal(aPrincipal, "", false);
    } catch (e) {
    }
    if (storage && storage.length) {
       for (let i = 0; i < storage.length; i++) {
        try {
          let key = storage.key(i);
          hostData[key] = storage.getItem(key);
        } catch (e) {
        }
      }
    }
    return hostData;
  }
function DomStorage_readEntry ( aPrincipal , aDocShell ) { let hostData = { } ; let storage ; try { storage = aDocShell . getSessionStorageForPrincipal ( aPrincipal , "" , false ) ; } catch ( e ) { } if ( storage && storage . length ) { for ( let i = 0 ; i < storage . length ; i ++ ) { try { let key = storage . key ( i ) ; hostData [ key ] = storage . getItem ( key ) ; } catch ( e ) { } } } return hostData ; }
Reads an entry in the session storage data contained in a tab's history.
Reads an entry in the session storage data contained in a tab ' s history .
// Using getSessionStorageForPrincipal instead of // getSessionStorageForURI just to be able to pass aCreate = false, // that avoids creation of the sessionStorage object for the page // earlier than the page really requires it. It was causing problems // while accessing a storage when a page later changed its domain. // sessionStorage might throw if it's turned off, see bug 458954 // This currently throws for secured items (cf. bug 442048).