FUEL fuelIPreferenceBranch.reset doesn't work

RESOLVED INVALID

Status

()

Firefox
General
RESOLVED INVALID
9 years ago
2 years ago

People

(Reporter: jorgev, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

9 years ago
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
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.
That patch looks fine, but it isn't really related to this bug (reset() throwing on PreferenceBranch objects).

Comment 4

7 years ago
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
Last Resolved: 2 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.