From 87079a3d766264ddae0c80e1b7791389b83411d4 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Mon, 11 Mar 2013 22:31:15 -0700 Subject: [PATCH] Bug 821630 - Fix retrieving blobs with get() in Settings API. r=gwagner --- dom/settings/SettingsManager.js | 17 +-- dom/settings/tests/Makefile.in | 1 + dom/settings/tests/test_settings_blobs.html | 128 ++++++++++++++++++++ 3 files changed, 135 insertions(+), 11 deletions(-) create mode 100644 dom/settings/tests/test_settings_blobs.html diff --git a/dom/settings/SettingsManager.js b/dom/settings/SettingsManager.js index 1edc16a7d19a..709ee406022f 100644 --- a/dom/settings/SettingsManager.js +++ b/dom/settings/SettingsManager.js @@ -88,10 +88,7 @@ SettingsLock.prototype = { if (DEBUG) debug("store1: " + JSON.stringify(obj)); setReq = store.put(obj); } else { - //Workaround for cloning issues - let defaultVal = JSON.parse(JSON.stringify(defaultValue)); - let userVal = JSON.parse(JSON.stringify(userValue)); - let obj = {settingName: key, defaultValue: defaultVal, userValue: userVal}; + let obj = {settingName: key, defaultValue: defaultValue, userValue: userValue}; if (DEBUG) debug("store2: " + JSON.stringify(obj)); setReq = store.put(obj); } @@ -114,7 +111,7 @@ SettingsLock.prototype = { Services.DOMRequest.fireError(request, setReq.error.name) } }; - } + }; checkKeyRequest.onerror = function(event) { if (!request.error) { Services.DOMRequest.fireError(request, checkKeyRequest.error.name) @@ -127,8 +124,8 @@ SettingsLock.prototype = { : store.mozGetAll(info.name); getReq.onsuccess = function(event) { - if (DEBUG) debug("Request for '" + info.name + "' successful. " + - "Record count: " + event.target.result.length); + if (DEBUG) debug("Request for '" + info.name + "' successful. " + + "Record count: " + event.target.result.length); if (event.target.result.length == 0) { if (DEBUG) debug("MOZSETTINGS-GET-WARNING: " + info.name + " is not in the database.\n"); @@ -214,8 +211,7 @@ SettingsLock.prototype = { if (this._settingsManager.hasWritePrivileges) { let req = Services.DOMRequest.createRequest(this._settingsManager._window); if (DEBUG) debug("send: " + JSON.stringify(aSettings)); - let settings = JSON.parse(JSON.stringify(aSettings)); - this._requests.enqueue({request: req, intent: "set", settings: settings}); + this._requests.enqueue({request: req, intent: "set", settings: aSettings}); this.createTransactionAndProcess(); return req; } else { @@ -312,7 +308,6 @@ SettingsManager.prototype = { switch (aMessage.name) { case "Settings:Change:Return:OK": - if (DEBUG) debug("Settings:Change:Return:OK"); if (this._onsettingchange || this._callbacks) { if (DEBUG) debug('data:' + msg.key + ':' + msg.value + '\n'); @@ -334,7 +329,7 @@ SettingsManager.prototype = { if (DEBUG) debug("no observers stored!"); } break; - default: + default: if (DEBUG) debug("Wrong message: " + aMessage.name); } }, diff --git a/dom/settings/tests/Makefile.in b/dom/settings/tests/Makefile.in index 032ffa43763b..739799ae5699 100644 --- a/dom/settings/tests/Makefile.in +++ b/dom/settings/tests/Makefile.in @@ -16,6 +16,7 @@ MOCHITEST_FILES = \ test_settings_basics.html \ test_settings_events.html \ test_settings_onsettingchange.html \ + test_settings_blobs.html \ $(NULL) _CHROMEMOCHITEST_FILES = \ diff --git a/dom/settings/tests/test_settings_blobs.html b/dom/settings/tests/test_settings_blobs.html new file mode 100644 index 000000000000..9a29a4500e9c --- /dev/null +++ b/dom/settings/tests/test_settings_blobs.html @@ -0,0 +1,128 @@ + + + + + Test for Bug 821630 Settings API + + + + + + +Mozilla Bug 821630 +

+ +
+
+
+ +