Closed Bug 724299 Opened 13 years ago Closed 7 years ago

Inject pre-wrapped Components object into mochitests

Categories

(Testing :: Mochitest, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: jdm, Unassigned)

Details

Attachments

(1 file)

I've been playing around with injecting a wrapped Components object into the content namespace via the SpecialPowers mechanism, and figured I should document my progress. I got injection working fine by making the hacking the Components object to not be readonly and permanent, so I can overwrite it from the SpecialPowers injection with a wrapped version. I then hacked nsScriptSecurityManager::EnableCapability to not actually enable UniversalXPConnect, so I could see what breaks. I then ran toolkit/components/passwordmgr/test_prompt.html to see how bad the bustage would be, and came across the problem that Camilo warned me about: chromeObject instanceOf Ci.nsIInterface throws an exception (invalid instanceof operator({})). I'm digging into http://wiki.ecmascript.org/doku.php?id=harmony:proxies#interaction_with_instanceof right now to figure out if there's some way to solve this. It's interesting to note that we create the wrapper proxies with no explicit prototype - unfortunately, this problem is not magically solved by passing the wrapped object's prototype as the second argument to Proxy.create, as that just yields an unhelpful exception (TypeError: getPropertyDescriptor is not a function).
I lied, that last exception was a product of my own silliness.
Hmm, so the problem I'm seeing with instanceof is that scripted proxies use a singleton proxy handler that apparently just throws an exception for HasInstance.
Bobby says that `grep -Ri enablePrivilege * | cut -f 1 -d ":" | uniq`; do echo -n "$file: " && cat $file | grep -c instanceof; done` reveals 35 tests using enablePrivilege and instanceof, so this is a bit more than an isolated problem, and a bit less than a fundamental stumbling block.
For reference, that list is: http://pastebin.mozilla.org/1475194
I talked with the proxy folks - the instanceof checks cannot work in the current Harmony spec that is implemented, but dherman is quite happy to make a spec change necessary to make them work (or at least possible, I'm a bit fuzzy on the details) in the Direct Proxy spec. There's no concerted effort to work on Direct Proxies at the moment, so we should probably just go ahead and rewrite the tests :\
(In reply to Josh Matthews [:jdm] from comment #5) > so we should probably just go ahead and rewrite the tests :\ Yeah, I think so. Luke and I are starting to think that we may get some nontrivial snappiness/memory wins by killing |Components| stuff for content globals, so I think we should push this forward and avoid blocking on spec changes and far-off rewrites. Did you manage to check if there were other problems than the |instanceof| case?
No, I did no further investigation.
Note: there are patches to fix the instanceof issue over in bug 726053.
We're also going to be removing Components from content scopes shortly, at which point we'll do the injection (which fixes the JSPROP_PERMANENT problem). I've filed bug 750638 about getting the tests passing with injection enabled and all instances of enablePrivilege removed.
Mass closing mochitest bugs that haven't had activity in the past 5 years. Please re-open or file a new bug with modern context if this is still relevant.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: