Open Bug 791881 Opened 13 years ago Updated 3 years ago

SpecialPowers.setPref and Services.prefs.getPref aren't in sync on child process

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect

Tracking

()

People

(Reporter: gwagner, Unassigned)

Details

Attachments

(1 file)

We see some races using following code in a child process (mochitest on otoro): SpecialPowers.setBoolPref("xxx", false); SpecialPowers.getBoolPref("xxx"); Services.prefs.getBoolPref("xxx"); According to bent, SpecialPowers uses a sync approach and Services an async approach.
Attached patch patchSplinter Review
Assignee: nobody → anygregor
(In reply to Gregor Wagner [:gwagner] from comment #0) > According to bent, SpecialPowers uses a sync approach and Services an async > approach. Not quite... SpecialPowers sends sync messages to the parent, but then the message that the parent sends to the child to update the child's pref set is an async message. Due to the way IPDL messages work that async message won't be seen until after the child has returned to the event loop.
Isn't this why pushPrefEnv exists?
Not as far as I can tell. pushPrefEnv() just pushes prefs so that they can be popped off automatically at the end of the test, right? There is some fancy setTimeout() madness there to try to wait for all of the parent process changes to trickle down, so maybe you're right? However, it's really not obvious that setBoolPref() is "wrong" and pushPrefEnv() is "right" here. We should either fix setBoolPref() to do the change synchronously or remove the sync API here entirely.
The origin of pushPrefEnv came from my investigations that revealed this problem. pushPrefEnv takes a callback that executes once the child process receives a notification that the pref is updated, making it the correct thing to use. My patch that made setFooPref spin the event loop until the same thing happened was denied.
Tests aren't allowed to use set*Pref() directly.
(In reply to Chris Jones [:cjones] [:warhammer] from comment #7) > Tests aren't allowed to use set*Pref() directly. Hm I guess I don't understand. How should we use it instead? From MDN: SpecialPowers is a set of APIs available to Mochitest tests. If we can't use SpecialPowers.set*Pref we have to rewrite many tests.
(In reply to Gregor Wagner [:gwagner] from comment #8) > (In reply to Chris Jones [:cjones] [:warhammer] from comment #7) > > Tests aren't allowed to use set*Pref() directly. > > Hm I guess I don't understand. How should we use it instead? pushPrefEnv(). > From MDN: SpecialPowers is a set of APIs available to Mochitest tests. > If we can't use SpecialPowers.set*Pref we have to rewrite many tests. The plan was to remove all those and then remove set*().
I've filed bug 1056851 for conversion to SpecialPowers.pushPrefEnv. I guess this bug could be used for that, but I think it would be better to have a new bug for it. But it would mean this bug can closed. Is it ok to close this bug?
Component: DOM → DOM: Core & HTML

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: anygregor → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: