Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / browser / fuel / test / browser_ApplicationStorage.js
blob9e6526caf4323cfb4b0a9c80bd5ceb0296b129fd
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");
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");
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");
20 // check for change event when setting a value
21 waitForExplicitFinish();
22 Application.storage.events.addListener("change", onStorageChange);
23 Application.storage.set("fuel-test", "change event");
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();