browser_ApplicationStorage.js
Go to the documentation of this file.
1 function test() {
2  // test for existence of values
3  var hasItem = Application.storage.has("fuel-test-missing");
4  is(hasItem, false, "Check 'Application.storage.has' for non-existing item");
5  Application.storage.set("fuel-test", "dummy");
6  hasItem = Application.storage.has("fuel-test");
7  is(hasItem, true, "Check 'Application.storage.has' for existing item");
8 
9  // test getting non-existing and existing values
10  var itemValue = Application.storage.get("fuel-test-missing", "default");
11  is(itemValue, "default", "Check 'Application.storage.get' for non-existing item");
12  itemValue = Application.storage.get("fuel-test", "default");
13  is(itemValue, "dummy", "Check 'Application.storage.get' for existing item");
14 
15  // test for overwriting an existing value
16  Application.storage.set("fuel-test", "smarty");
17  itemValue = Application.storage.get("fuel-test", "default");
18  is(itemValue, "smarty", "Check 'Application.storage.get' for overwritten item");
19 
20  // check for change event when setting a value
22  Application.storage.events.addListener("change", onStorageChange);
23  Application.storage.set("fuel-test", "change event");
24 }
25 
26 function onStorageChange(evt) {
27  is(evt.data, "fuel-test", "Check 'Application.storage.set' fired a change event");
28  Application.storage.events.removeListener("change", onStorageChange);
29  finish();
30 }
var Application
Definition: sbAboutDRM.js:37
function test()
waitForExplicitFinish()
function onStorageChange(evt)