dom/tests/mochitest/localstorage/localStorageCommon.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/localstorage/localStorageCommon.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,45 @@
     1.4 +function localStorageFlush(cb)
     1.5 +{
     1.6 +  var ob = {
     1.7 +    observe : function(sub, top, dat)
     1.8 +    {
     1.9 +      os().removeObserver(ob, "domstorage-test-flushed");
    1.10 +      cb();
    1.11 +    }
    1.12 +  };
    1.13 +  os().addObserver(ob, "domstorage-test-flushed", false);
    1.14 +  notify("domstorage-test-flush-force");
    1.15 +}
    1.16 +
    1.17 +function localStorageReload()
    1.18 +{
    1.19 +  notify("domstorage-test-reload");
    1.20 +}
    1.21 +
    1.22 +function localStorageFlushAndReload(cb)
    1.23 +{
    1.24 +  localStorageFlush(function() {
    1.25 +    localStorageReload();
    1.26 +    cb();
    1.27 +  });
    1.28 +}
    1.29 +
    1.30 +function localStorageClearAll()
    1.31 +{
    1.32 +  os().notifyObservers(null, "cookie-changed", "cleared");
    1.33 +}
    1.34 +
    1.35 +function localStorageClearDomain(domain)
    1.36 +{
    1.37 +  os().notifyObservers(null, "browser:purge-domain-data", domain);
    1.38 +}
    1.39 +
    1.40 +function os()
    1.41 +{
    1.42 +  return SpecialPowers.Services.obs;
    1.43 +}
    1.44 +
    1.45 +function notify(top)
    1.46 +{
    1.47 +  os().notifyObservers(null, top, null);
    1.48 +}

mercurial