Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | function test() { |
michael@0 | 2 | // test for existence of values |
michael@0 | 3 | var hasItem = Application.storage.has("fuel-test-missing"); |
michael@0 | 4 | is(hasItem, false, "Check 'Application.storage.has' for nonexistent item"); |
michael@0 | 5 | Application.storage.set("fuel-test", "dummy"); |
michael@0 | 6 | hasItem = Application.storage.has("fuel-test"); |
michael@0 | 7 | is(hasItem, true, "Check 'Application.storage.has' for existing item"); |
michael@0 | 8 | |
michael@0 | 9 | // test getting nonexistent and existing values |
michael@0 | 10 | var itemValue = Application.storage.get("fuel-test-missing", "default"); |
michael@0 | 11 | is(itemValue, "default", "Check 'Application.storage.get' for nonexistent item"); |
michael@0 | 12 | itemValue = Application.storage.get("fuel-test", "default"); |
michael@0 | 13 | is(itemValue, "dummy", "Check 'Application.storage.get' for existing item"); |
michael@0 | 14 | |
michael@0 | 15 | // test for overwriting an existing value |
michael@0 | 16 | Application.storage.set("fuel-test", "smarty"); |
michael@0 | 17 | itemValue = Application.storage.get("fuel-test", "default"); |
michael@0 | 18 | is(itemValue, "smarty", "Check 'Application.storage.get' for overwritten item"); |
michael@0 | 19 | |
michael@0 | 20 | // check for change event when setting a value |
michael@0 | 21 | waitForExplicitFinish(); |
michael@0 | 22 | Application.storage.events.addListener("change", onStorageChange); |
michael@0 | 23 | Application.storage.set("fuel-test", "change event"); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | function onStorageChange(evt) { |
michael@0 | 27 | is(evt.data, "fuel-test", "Check 'Application.storage.set' fired a change event"); |
michael@0 | 28 | Application.storage.events.removeListener("change", onStorageChange); |
michael@0 | 29 | finish(); |
michael@0 | 30 | } |