Open Bug 1030657 Opened 11 years ago Updated 3 years ago

Browser mochitests use SpecialPowers.wrap() for no reason

Categories

(Testing :: Mochitest, defect)

defect

Tracking

(Not tracked)

People

(Reporter: past, Unassigned)

Details

In bug 985427 I discovered that sending a keyboard event to a particular element in a browser mochitest would end up going through SpecialPowers.wrap(), which Bobby says is redundant, not to mention fatal for the test. You can see the error if you revert the patch in that bug. Changing the order in EventUtils.js _getDOMWindowUtils() didn't help, as SpecialPowers was always present. Hopefully someone more familiar with this code can figure out the right fix.
I know jmaher went crazy with some of these things a while ago because so much code is shared between browser-chrome/mochitest-chrome/mochitest-plain.
when we originally rolled this out we thought everything was going to use strict e10s and wanted to make a simple compatibility layer between user and chrome space. So we designed this where we had a core hook and then harness specific bits that could implement things differently (i.e. direct calls) or reduced set of hooks to simplify the code. Since we haven't used this, all changes (i.e. wrap()) since it was written ended up potentially breaking the original design. That isn't a problem until we end up here. A lot of code is shared between the harnesses (simpletest.js) which calls specialpowers. As you can imagine this makes it difficult. so getDOMWindowUtils is critical, maybe we could determine if we are in browser-chrome and use a different version of it?
(In reply to Joel Maher (:jmaher) from comment #2) > so getDOMWindowUtils is critical, maybe we could determine if we are in > browser-chrome and use a different version of it? Yes. Functionality in the harness itself should avoid depending on SpecialPowers.wrap (depending on other SpecialPowers-y functionality is fine). If that isn't possible for some reason, the code should at least check first whether it's already in chrome, and use the chrome-y version before the SpecialPowers.wrap-y version.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.