Closed Bug 481044 Opened 15 years ago Closed 9 years ago

FUEL fuelIPreferenceBranch.reset doesn't work

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: jorgev, Unassigned)

Details

Attachments

(1 file)

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.
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.
OS: Mac OS X → All
Hardware: x86 → All
Version: 3.5 Branch → Trunk
Here's a quick patch to clear up the issue with Preference.reset throwing an exception back up to the user.
That patch looks fine, but it isn't really related to this bug (reset() throwing on PreferenceBranch objects).
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?
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.