diff --git a/CLOBBER b/CLOBBER index 321838d35b0..860990bc94f 100644 --- a/CLOBBER +++ b/CLOBBER @@ -22,4 +22,4 @@ # changes to stick? As of bug 928195, this shouldn't be necessary! Please # don't change CLOBBER for WebIDL changes any more. -Bug 1165422 - Updated the Android SDK versions +Bug 1012403 - Update SettingsService tests (requires clobber due to package manifest change) diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index e2eb0b8118c..e40b7e04b7f 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -535,6 +535,8 @@ @RESPATH@/components/messageWakeupService.manifest @RESPATH@/components/SettingsManager.js @RESPATH@/components/SettingsManager.manifest +@BINPATH@/components/SettingsService.js +@BINPATH@/components/SettingsService.manifest @RESPATH@/components/Webapps.js @RESPATH@/components/Webapps.manifest @RESPATH@/components/AppsService.js diff --git a/dom/settings/moz.build b/dom/settings/moz.build index 10a6055ba12..325e8fca678 100644 --- a/dom/settings/moz.build +++ b/dom/settings/moz.build @@ -9,7 +9,7 @@ EXTRA_COMPONENTS += [ 'SettingsManager.manifest', ] -if CONFIG['MOZ_B2G']: +if CONFIG['MOZ_B2G'] or CONFIG['ENABLE_TESTS']: EXTRA_COMPONENTS += [ 'SettingsService.js', 'SettingsService.manifest', diff --git a/dom/settings/tests/mochitest.ini b/dom/settings/tests/mochitest.ini index 6d1ab67f309..87e3c3be926 100644 --- a/dom/settings/tests/mochitest.ini +++ b/dom/settings/tests/mochitest.ini @@ -1,5 +1,4 @@ [DEFAULT] -skip-if = (toolkit == 'gonk' && debug) #debug-only failure, bug 932878 support-files = file_loadserver.js file_bug1110872.js diff --git a/dom/settings/tests/test_settings_service.js b/dom/settings/tests/test_settings_service.js index 42f340acad1..33e026c137e 100644 --- a/dom/settings/tests/test_settings_service.js +++ b/dom/settings/tests/test_settings_service.js @@ -18,99 +18,104 @@ XPCOMUtils.defineLazyServiceGetter(this, "SettingsService", "nsISettingsService"); let tests = [ - /* Callback tests */ - function() { - let callbackCount = 10; + /* Callback tests */ + function() { + let callbackCount = 10; - let callback = { - handle: function(name, result) { - switch (callbackCount) { - case 10: - case 9: - is(result, true, "result is true"); - break; - case 8: - case 7: - is(result, false, "result is false"); - break; - case 6: - case 5: - is(result, 9, "result is 9"); - break; - case 4: - case 3: - is(result, 9.4, "result is 9.4"); - break; - case 2: - is(result, false, "result is false"); - break; - case 1: - is(result, null, "result is null"); - break; - default: - ok(false, "Unexpected call: " + callbackCount); - } + let callback = { + handle: function(name, result) { + switch (callbackCount) { + case 10: + case 9: + is(result, true, "result is true"); + break; + case 8: + case 7: + is(result, false, "result is false"); + break; + case 6: + case 5: + is(result, 9, "result is 9"); + break; + case 4: + case 3: + is(result, 9.4, "result is 9.4"); + break; + case 2: + is(result, false, "result is false"); + break; + case 1: + is(result, null, "result is null"); + break; + default: + ok(false, "Unexpected call: " + callbackCount); + } - --callbackCount; - if (callbackCount === 0) { - next(); - } + --callbackCount; + if (callbackCount === 0) { + next(); + } + }, + + handleError: function(name) { + ok(false, "error: " + name); + } + }; + + let lock = SettingsService.createLock(); + let lock1 = SettingsService.createLock(); + + lock.set("asdf", true, callback, null); + lock1.get("asdf", callback); + lock.get("asdf", callback); + lock.set("asdf", false, callback, null); + lock.get("asdf", callback); + lock.set("int", 9, callback, null); + lock.get("int", callback); + lock.set("doub", 9.4, callback, null); + lock.get("doub", callback); + lock1.get("asdfxxx", callback); }, - handleError: function(name) { - ok(false, "error: " + name); + /* Observer tests */ + function() { + const MOZSETTINGS_CHANGED = "mozsettings-changed"; + const TEST_OBSERVER_KEY = "test.observer.key"; + const TEST_OBSERVER_VALUE = true; + const TEST_OBSERVER_MESSAGE = "test.observer.message"; + + var obs = { + observe: function (subject, topic, data) { + + if (topic !== MOZSETTINGS_CHANGED) { + ok(false, "Event is not mozsettings-changed."); + return; + } + // Data is now stored in subject + if ("wrappedJSObject" in subject) { + ok(true, "JS object wrapped into subject"); + subject = subject.wrappedJSObject; + } + function checkProp(name, type, value) { + ok(name in subject, "subject." + name + " is present"); + is(typeof subject[name], type, "subject." + name + " is " + type); + is(subject[name], value, "subject." + name + " is " + value); + } + + checkProp("key", "string", TEST_OBSERVER_KEY); + checkProp("value", "boolean", TEST_OBSERVER_VALUE); + checkProp("isInternalChange", "boolean", true); + + Services.obs.removeObserver(this, MOZSETTINGS_CHANGED); + next(); + } + }; + + Services.obs.addObserver(obs, MOZSETTINGS_CHANGED, false); + + let lock = SettingsService.createLock(); + lock.set(TEST_OBSERVER_KEY, TEST_OBSERVER_VALUE, null); } - }; - - let lock = SettingsService.createLock(); - let lock1 = SettingsService.createLock(); - - lock.set("asdf", true, callback, null); - lock1.get("asdf", callback); - lock.get("asdf", callback); - lock.set("asdf", false, callback, null); - lock.get("asdf", callback); - lock.set("int", 9, callback, null); - lock.get("int", callback); - lock.set("doub", 9.4, callback, null); - lock.get("doub", callback); - lock1.get("asdfxxx", callback); - }, - - /* Observer tests */ - function() { - const MOZSETTINGS_CHANGED = "mozsettings-changed"; - const TEST_OBSERVER_KEY = "test.observer.key"; - const TEST_OBSERVER_VALUE = true; - const TEST_OBSERVER_MESSAGE = "test.observer.message"; - - function observer(subject, topic, data) { - - if (topic !== MOZSETTINGS_CHANGED) { - ok(false, "Event is not mozsettings-changed."); - return; - } - - data = JSON.parse(data); - function checkProp(name, type, value) { - ok(name in data, "data." + name + " is present"); - is(typeof data[name], type, "data." + name + " is " + type); - is(data[name], value, "data." + name + " is " + value); - } - - checkProp("key", "string", TEST_OBSERVER_KEY); - checkProp("value", "boolean", TEST_OBSERVER_VALUE); - checkProp("isInternalChange", "boolean", true); - - Services.obs.removeObserver(this, MOZSETTINGS_CHANGED); - next(); - } - - Services.obs.addObserver(observer, MOZSETTINGS_CHANGED, false); - - let lock = SettingsService.createLock(); - lock.set(TEST_OBSERVER_KEY, TEST_OBSERVER_VALUE, null); - } ]; function next() {