Last Comment Bug 481044 - FUEL fuelIPreferenceBranch.reset doesn't work
: FUEL fuelIPreferenceBranch.reset doesn't work
Status: RESOLVED INVALID
:
Product: Firefox
Classification: Client Software
Component: General (show other bugs)
: Trunk
: All All
: -- normal with 1 vote (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-03-02 14:49 PST by Jorge Villalobos [:jorgev]
Modified: 2015-03-02 07:28 PST (History)
5 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
wraps the clearUserPref in a try / catch (802 bytes, patch)
2010-02-04 14:58 PST, Bryan Clark (DevTools PM) [@clarkbw]
no flags Details | Diff | Splinter Review

Description Jorge Villalobos [:jorgev] 2009-03-02 14:49:50 PST
Happens to me on Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b2) Gecko/20081201 Firefox/3.1b2. When I try to call this function, I get:

Error: uncaught exception: [Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIPrefBranch.resetBranch]"  nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)"  location: "JS frame :: file:///Applications/Internet/Firefox%203.1.app/Contents/MacOS/components/fuelApplication.js :: prefs_reset :: line 1010"  data: no]

Looking at the documentation, this looks about right, the component doesn't implement the reset call. But, considering that FUEL should fix these issues exactly, I would expect it to work around this limitation and reset the branch in some other way.
Comment 1 Bryan Clark (DevTools PM) [@clarkbw] 2010-02-03 14:25:31 PST
Just some notes about this as the problem still exists.  Changing the flags as well since this is all platforms and broken on Trunk.

= PreferenceBranch =
The function resetBranch was never implemented and so raises an error
http://mxr.mozilla.org/mozilla-central/source/modules/libpref/src/nsPrefBranch.cpp#503

STEELs PreferenceBranch.reset function calls resetBranch and that's the error you get in comment 0
http://mxr.mozilla.org/mozilla-central/source/toolkit/components/exthelper/extApplication.js#278

= Preference =
You can however do a direct call to a pref
Application.prefs.get("extensions.googlecalendartab@momo.url").reset()

Because that uses the clearUserPref function
http://mxr.mozilla.org/mozilla-central/source/modules/libpref/src/nsPrefBranch.cpp#438

The gotcha is that if the pref doesn't exist or hasn't been modified (is default) means that clearUserPref will raise an error.

If this reset() function simply wrapped the clearUserPref call in a try / catch block extensions could call reset without having to worry about it.
Comment 2 Bryan Clark (DevTools PM) [@clarkbw] 2010-02-04 14:58:21 PST
Created attachment 425318 [details] [diff] [review]
wraps the clearUserPref in a try / catch

Here's a quick patch to clear up the issue with Preference.reset throwing an exception back up to the user.
Comment 3 :Gavin Sharp [email: gavin@gavinsharp.com] 2010-02-08 07:10:25 PST
That patch looks fine, but it isn't really related to this bug (reset() throwing on PreferenceBranch objects).
Comment 4 beamgeraet 2010-11-30 14:21:42 PST
From my point of view the following could fix the issue:
(javascript code as I am not so used to cpp)
function reset() {
  preferences = this.all;
  for (i=0; i<preferences.length; i++) {
    try {
      preferences[i].reset();
    } catch () {}
  }
}

What do you think?

Note You need to log in before you can comment on or make changes to this bug.