Module org.htmlunit
Package org.htmlunit

Class StorageHolder

java.lang.Object
org.htmlunit.StorageHolder
All Implemented Interfaces:
Serializable

public class StorageHolder extends Object implements Serializable
Holder for different types of storages.

Experimental API: May be changed in next release!

Author:
Ahmed Ashour, Ronald Brill, Marc Guillemot, Vidya m
See Also:
  • Constructor Details

    • StorageHolder

      public StorageHolder()
  • Method Details

    • getStore

      public Map<String,String> getStore(StorageHolder.Type storageType, Page page)
      Gets the store of the give type for the page. The local storage is shared by all pages of the same origin; the session storage is shared by all pages of the same origin inside the same top level window. Pages without an origin of their own (e.g. about:blank iframes) are using the origin of their creator.
      Parameters:
      storageType - the type
      page - the page
      Returns:
      the store
    • getLocalStorage

      public Map<String,String> getLocalStorage(URL url)
      Gets the local storage (map).
      Parameters:
      url - the page origin
      Returns:
      the store
    • getSessionStorage

      public Map<String,String> getSessionStorage(WebWindow webWindow)
      Gets the session storage (map) of the window for the origin of the page currently loaded into the window.

      If the window has no page with an origin yet (no page or about:blank), a store not bound to an origin is returned; this store is used as session storage for the origin of the first page loaded into this window that accesses the session storage. This allows to pre-populate the session storage before loading the page; getSessionStorage(WebWindow, URL) is the preferred way to do this.

      Parameters:
      webWindow - the window
      Returns:
      the store
    • getSessionStorage

      public Map<String,String> getSessionStorage(WebWindow webWindow, URL url)
      Gets the session storage (map) of the window for the given origin. The session storage is shared by all windows (including frames) of the same top level window.
      Parameters:
      webWindow - the window
      url - the origin
      Returns:
      the store
    • copySessionStorage

      public void copySessionStorage(WebWindow opener, WebWindow newWindow)
      Copies the session storage of the opener's origin into the session storage of a newly opened top level window (e.g. by window.open()). Nothing is copied if the target window already has session storage for this origin.
      Parameters:
      opener - the window that opened the new one
      newWindow - the new window