Closed
Bug 776424
Opened 12 years ago
Closed 7 years ago
SpecialPowers.getBoolPref() shouldn't throw if trying to get a preference without value
Categories
(Testing :: Mochitest, defect)
Testing
Mochitest
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: mounir, Unassigned)
Details
Attachments
(2 files, 1 obsolete file)
1.16 KB,
patch
|
cmtalbert
:
review+
|
Details | Diff | Splinter Review |
14.10 KB,
patch
|
Details | Diff | Splinter Review |
It should return 'null' instead. That way, callers don't have to put try/catch blocks around getPref calls and using pushPrefEnv will be allowed for preferences without a default value. FWIW, the current code in pushPrevEnv allows to have null as |originalValue|'s value and does what has to be done in popPrefEnv.
Reporter | ||
Comment 1•12 years ago
|
||
Attachment #644818 -
Flags: review?
Reporter | ||
Updated•12 years ago
|
Attachment #644818 -
Flags: review? → review?(ctalbert)
Comment on attachment 644818 [details] [diff] [review] Patch Cool. I agree with this approach. Thanks for the patch.
Attachment #644818 -
Flags: review?(ctalbert) → review+
Reporter | ||
Comment 3•11 years ago
|
||
BTW, this has not landed - yet - because it is breaking quite a few tests.
Summary: SpecialPowers shouldn't throw if trying to get a preference without value → SpecialPowers.getBoolPref() shouldn't throw if trying to get a preference without value
Comment 4•11 years ago
|
||
Is this related to bug 766687?
Reporter | ||
Comment 5•11 years ago
|
||
(In reply to Martijn Wargers [:mw22] (QA - IRC nick: mw22) from comment #4) > Is this related to bug 766687? Maybe.
Comment 6•11 years ago
|
||
I fixed the errors that I saw when going through the Harness_Sanity/ directory. I put this patch on try server to see if other mochitests are failing because of this change: https://tbpl.mozilla.org/?tree=Try&rev=6d528d7fde7f
Comment 7•11 years ago
|
||
Ok, content/media/test/test_can_play_type_mpeg.html was also depending on this behavior, so I fixed that in this patch.
Attachment #797545 -
Attachment is obsolete: true
Comment 8•11 years ago
|
||
I'm seeing time outs in the dom/ipc/tests/test_process_error.xul mochitest-chrome on the try server with this patch. That test was added in bug 581335. Iiuc, privateNoteIntentionalCrash() is not implemented, so apparently this code in process_error_contentscript.js is supposed to cause a crash: var zero = new ctypes.intptr_t(8); var badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t)); var crash = badptr.contents; It seems like with this patch, the crash isn't triggered anymore. I have no idea why that happens with this patch, it seems unrelated to that code. Is the above code a reliable way to hit the crash?
Comment 9•11 years ago
|
||
That seems unrelated, but that code ought to reliably crash. It's simply dereferencing a near-NULL pointer using ctypes.
Comment 10•11 years ago
|
||
Ok, pushed the latest patch to try again, to see if it still happens: https://tbpl.mozilla.org/?tree=Try&rev=4a6d06c933a3
Comment 11•11 years ago
|
||
That one still shows the failures, I just repulled my tree, perhaps I just had a bad tree: https://tbpl.mozilla.org/?tree=Try&rev=ed08ffd4c58d
Comment 12•11 years ago
|
||
Ok, I think it might be happening because of: http://mxr.mozilla.org/mozilla-central/source/content/xul/document/test/test_bug757137.xul#26 With this patch, the dom.ipc.tabs.disabled pref would have changed after the test file finishes. There are quite some tests that seems to rely on this behavior: http://mxr.mozilla.org/mozilla-central/search?string=specialpowers.getboolpref&find=&findi=&filter=^[^\0]*%24&hitlimit=&tree=mozilla-central http://mxr.mozilla.org/mozilla-central/search?string=specialpowers.getintpref http://mxr.mozilla.org/mozilla-central/search?string=specialpowers.getcharpref They need all to be changed. In that case, they would need to be changed to the SpecialPowers.pushPrefEnv method.
Updated•11 years ago
|
Assignee: mounir → martijn.martijn
Comment 13•11 years ago
|
||
I'm concerned about this approach. You're introducing an API difference between SpecialPowers.get*Pref and Preferences.get*Pref which I don't think many people will expect. We can't change the prefservice API for backward-compat reasons, and so I don't think we should make this change either. The test changes that would be required are a symptom that this is probably not a good idea.
Comment 14•11 years ago
|
||
Ok, WONTFIX then?
Updated•11 years ago
|
Assignee: martijn.martijn → nobody
Comment 15•8 years ago
|
||
Please mark WONTFIX if you still stand by your comment 13.
Flags: needinfo?(benjamin)
Updated•7 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Flags: needinfo?(benjamin)
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•