dom/tests/mochitest/localstorage/localStorageCommon.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 function localStorageFlush(cb)
     2 {
     3   var ob = {
     4     observe : function(sub, top, dat)
     5     {
     6       os().removeObserver(ob, "domstorage-test-flushed");
     7       cb();
     8     }
     9   };
    10   os().addObserver(ob, "domstorage-test-flushed", false);
    11   notify("domstorage-test-flush-force");
    12 }
    14 function localStorageReload()
    15 {
    16   notify("domstorage-test-reload");
    17 }
    19 function localStorageFlushAndReload(cb)
    20 {
    21   localStorageFlush(function() {
    22     localStorageReload();
    23     cb();
    24   });
    25 }
    27 function localStorageClearAll()
    28 {
    29   os().notifyObservers(null, "cookie-changed", "cleared");
    30 }
    32 function localStorageClearDomain(domain)
    33 {
    34   os().notifyObservers(null, "browser:purge-domain-data", domain);
    35 }
    37 function os()
    38 {
    39   return SpecialPowers.Services.obs;
    40 }
    42 function notify(top)
    43 {
    44   os().notifyObservers(null, top, null);
    45 }

mercurial