Closed Bug 79473 Opened 23 years ago Closed 23 years ago

setCharPref or setBoolPref does not work properly.

Categories

(Core Graveyard :: Embedding: APIs, defect)

x86
Windows NT
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED WORKSFORME

People

(Reporter: dsirnapalli, Assigned: alecf)

Details

I used the following piece of code.

var nsIPrefBranchObj = nsIPrefServiceObj.getDefaultBranch(null);
alert(nsIPrefBranchObj.getCharPref("browser.startup.homepage"));
nsIPrefBranchObj.setCharPref("browser.startup.homepage", "http://www.goto.com");
nsIPrefServiceObj.savePrefFile(null);
alert(nsIPrefBranchObj.getCharPref("browser.startup.homepage"));

The second alert shows the right value.It shows "http://www.goto.com", but when 
i open prefs.js, it still contains the old value.That means it's picking up the 
value from memory.When i close mozilla browser pref.js still contains the old 
value. When i run the above code again the first alert picks up the homepage 
from all.js("chrome://navigator-region/locale/region.properties") even though 
pref.js contains "www.mozilla.org".
I think if you do
var nsIPrefBranchObj = nsIPrefServiceObj.getBranch(null);

This code will do what you expect it to...

yes, they work, or the browser wouldn't save preferences!
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → WORKSFORME
when i use..
var nsIPrefBranchObj = nsIPrefServiceObj.getBranch(null);
it works.
Status: RESOLVED → VERIFIED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.