Closed
Bug 872983
Opened 11 years ago
Closed 11 years ago
event.settingValue in mozSettings.onsettingchange gives wrong value
Categories
(Firefox OS Graveyard :: General, defect)
Tracking
(blocking-b2g:leo+, firefox22 wontfix, firefox23 wontfix, firefox24 fixed, b2g18 fixed, b2g18-v1.0.0 wontfix, b2g18-v1.0.1 wontfix, b2g-v1.1hd fixed)
People
(Reporter: johnhu, Assigned: gwagner)
References
Details
Attachments
(1 file)
3.19 KB,
patch
|
fabrice
:
review+
|
Details | Diff | Splinter Review |
While putting an array of object to mozSettings, the event.settingValue of onsettingchange event gives wrong value. It just removes all properties of those objects. I did a simple test on this issue with the following code: if (event.settingName === 'test.key') console.log('onsettingchange: ' + JSON.stringify(event.settingValue)); }; var cset = [{'a':'b','c':[{'d':'e'}]}]; console.log('set: ' + JSON.stringify(cset)); navigator.mozSettings.createLock().set({'test.key': cset}); And the console outputs: E/GeckoConsole( 1031): Content JS LOG at app://settings.gaiamobile.org/js/settings.js:115 in settings_init: set: [{"a":"b","c":[{"d":"e"}]}] E/GeckoConsole( 1031): Content JS LOG at app://settings.gaiamobile.org/js/settings.js:112 in anonymous: onsettingchange: [{}] But, if we use mozSettings.createLock().get('test.key'), it gives the correct value, [{"a":"b","c":[{"d":"e"}]}].
Reporter | ||
Comment 1•11 years ago
|
||
Sorry, above code is incomplete. Please use the following code: navigator.mozSettings.onsettingchange = function(event) { if (event.settingName === 'test.key') console.log('onsettingchange: ' + JSON.stringify(event.settingValue)); }; var cset = [{"a":"b","c":[{"d":"e"}]}]; console.log('set: ' + JSON.stringify(cset)); navigator.mozSettings.createLock().set({'test.key': cset});
Assignee | ||
Comment 2•11 years ago
|
||
JSON.stringify often lies to you in such cases. Can you try to access/print the "a"property directly?
Reporter | ||
Comment 3•11 years ago
|
||
Gregor, Sure, here they are: New version of testing code: navigator.mozSettings.onsettingchange = function(event) { if (event.settingName === 'test.key') { console.log('onsettingchange: a property: ' + event.settingValue[0]['a']); console.log('onsettingchange: c property: ' + event.settingValue[0]['c']); } }; var cset = [{'a':'b','c':[{'d':'e'}]}]; console.log('set: ' + JSON.stringify(cset)); navigator.mozSettings.createLock().set({'test.key': cset}); logcat result: E/GeckoConsole( 1226): Content JS LOG at app://settings.gaiamobile.org/js/settings.js:117 in settings_init: set: [{"a":"b","c":[{"d":"e"}]}] E/GeckoConsole( 1226): Content JS LOG at app://settings.gaiamobile.org/js/settings.js:112 in anonymous: onsettingchange: a property: undefined E/GeckoConsole( 1226): Content JS LOG at app://settings.gaiamobile.org/js/settings.js:113 in anonymous: onsettingchange: c property: undefined I had tested this in Inari, Unagi, and Leo with b2g18. They all gave me the same result.
Comment 4•11 years ago
|
||
Does it work if you do .get('test.key')?
Reporter | ||
Comment 5•11 years ago
|
||
Reuben, Yes. It works if I use get('test.key'). I found this bug because we want to make a memory copy of our settings to prevent multiple querying on mozSettings. Most of them works, but this case, an array of object, doesn't. So, we have to change our code to use get('xxxxxxx');
Comment 6•11 years ago
|
||
The improvement John described was made in bug 840322. It looks like the settings cache fails in this case.
Assignee | ||
Comment 7•11 years ago
|
||
Another expose issue... Thanks for finding!
Assignee: nobody → anygregor
Assignee | ||
Comment 8•11 years ago
|
||
John, can you try this patch?
Reporter | ||
Comment 9•11 years ago
|
||
Gregor, Sorry, it doesn't works. It gives another error about this patch. I am not sure if this is my problem on Gecko version. E/GeckoConsole( 641): [JavaScript Error: "this._wrap is not a function" {file: "jar:file:///system/b2g/omni.ja!/components/SettingsManager.js" line: 318}] my gecko version: dd60c168dc409bc44196d86907dcfef84c7367fb
Assignee | ||
Updated•11 years ago
|
blocking-b2g: --- → leo?
Assignee | ||
Comment 10•11 years ago
|
||
(In reply to John Hu [:johnhu] from comment #9) > Gregor, > > Sorry, it doesn't works. It gives another error about this patch. I am not > sure if this is my problem on Gecko version. > > E/GeckoConsole( 641): [JavaScript Error: "this._wrap is not a function" > {file: "jar:file:///system/b2g/omni.ja!/components/SettingsManager.js" line: > 318}] > > my gecko version: dd60c168dc409bc44196d86907dcfef84c7367fb You need the patch from bug 849616 as well. Don't we all love this branching mess.
Reporter | ||
Comment 11•11 years ago
|
||
Gregor, Great, it works now, see: E/GeckoConsole( 640): Content JS LOG at app://settings.gaiamobile.org/js/settings.js:112 in anonymous: onsettingchange: [{"a":"b","c":[{"d":"e"}]}] E/GeckoConsole( 640): Content JS LOG at app://settings.gaiamobile.org/js/settings.js:113 in anonymous: onsettingchange: a property: b E/GeckoConsole( 640): Content JS LOG at app://settings.gaiamobile.org/js/settings.js:114 in anonymous: onsettingchange: c property: [object Object]
Comment 12•11 years ago
|
||
Blocking based on developer impact and the fact that we're close to a fix.
blocking-b2g: leo? → leo+
Updated•11 years ago
|
Attachment #750847 -
Flags: review+
Updated•11 years ago
|
Keywords: checkin-needed
Comment 13•11 years ago
|
||
Note that the patch in bug 849616 needs to be uplifted first.
Comment 14•11 years ago
|
||
https://hg.mozilla.org/projects/birch/rev/603891a7c4b1
Flags: in-testsuite+
Keywords: checkin-needed
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 16•11 years ago
|
||
https://hg.mozilla.org/releases/mozilla-b2g18/rev/dfb4cc22e0e7
status-b2g18:
--- → fixed
status-b2g18-v1.0.0:
--- → wontfix
status-b2g18-v1.0.1:
--- → wontfix
status-b2g-v1.1hd:
--- → affected
status-firefox22:
--- → wontfix
status-firefox23:
--- → wontfix
status-firefox24:
--- → fixed
Updated•11 years ago
|
Flags: in-moztrap-
You need to log in
before you can comment on or make changes to this bug.
Description
•