Closed
Bug 674255
Opened 13 years ago
Closed 13 years ago
add API to SpecialPowers that allows a callback from an NSObserverService observation
Categories
(Testing :: Mochitest, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla10
People
(Reporter: imelven, Assigned: imelven)
References
Details
(Keywords: dev-doc-needed, Whiteboard: [inbound])
Attachments
(1 file, 6 obsolete files)
2.77 KB,
patch
|
imelven
:
review+
|
Details | Diff | Splinter Review |
the Mochitests for CSP use nsObserverService to determine when CSP has blocked something from being loaded. this requires the use of enablePrivilege('UniversalXPConnect') which we want to move away from. instead we use the SpecialPowers object. this means for these tests SpecialPowers needs an API that lets you set a callback when a particular event is observed. i discussed this briefly with sicking and we agreed on an API along the lines of SpecialPowers.addObserver(<thing to observe>, <callback function in mochitest>) a SpecialPowers.removeObserver() is required also, as each test must clean up its observers before exiting (to avoid leaks during test suite runs)
Comment 1•13 years ago
|
||
I cover this in bug 668283.
Assignee | ||
Comment 2•13 years ago
|
||
(In reply to comment #1) > I cover this in bug 668283. awesome, i'll make this a duplicate of that bug and mark the other CSP bugs dependent on bug 668283. Thanks !
Assignee | ||
Updated•13 years ago
|
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Updated•13 years ago
|
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Assignee | ||
Comment 4•13 years ago
|
||
this is a piece of jdm's work in bug 668283 broken out so i can try to land CSP bugs that depend on this
Assignee | ||
Updated•13 years ago
|
Attachment #557985 -
Flags: review?(ted.mielczarek)
Assignee | ||
Comment 5•13 years ago
|
||
Ted, please route to another reviewer if you're not the right person, i guessed based on hg log :)
Assignee | ||
Comment 6•13 years ago
|
||
updated for bitrot
Attachment #557985 -
Attachment is obsolete: true
Attachment #557985 -
Flags: review?(ted.mielczarek)
Attachment #559349 -
Flags: review?(ted.mielczarek)
Comment 7•13 years ago
|
||
Comment on attachment 559349 [details] [diff] [review] port the needed piece of SpecialPowers.js from jdm's patch for 668283 Review of attachment 559349 [details] [diff] [review]: ----------------------------------------------------------------- ::: testing/mochitest/specialpowers/content/specialpowers.js @@ +423,5 @@ > + can_QI: function(obj) { > + return obj.QueryInterface !== undefined; > + }, > + > + do_QueryInterfaceAndGet: function(obj, iface, props) { I know you just ported this from jdm's patch, but this API is really confusing to me. I had to go look up the example usage in his other patch to figure out what exactly it did. I don't have a problem with exposing do_QueryInterface, but we need to figure out a saner way to expose "get some set of properties off of this object" than the API here.
Attachment #559349 -
Flags: review?(ted.mielczarek) → review-
Updated•13 years ago
|
Assignee: nobody → imelven
Comment 8•13 years ago
|
||
The API for getPrivilegedProps that I came up with in one of my other many patches is probably a better choice here in conjunction with do_QueryInterface. The result would look like |getPrivilegedProps(do_QueryInterface(obj, Ci.nsIFoo), "thing.stuff.foo")|.
Comment 9•13 years ago
|
||
Yeah, I like that.
Assignee | ||
Comment 10•13 years ago
|
||
switched to getPrivilegedProps after review and discussion, thanks !
Attachment #559349 -
Attachment is obsolete: true
Attachment #562930 -
Flags: review?(ted.mielczarek)
Assignee | ||
Comment 11•13 years ago
|
||
i tested out the failure case in the CSP bug depending on this and found i messed up getPrivilegedProps in the previous patch, this one works as desired.
Attachment #562930 -
Attachment is obsolete: true
Attachment #562930 -
Flags: review?(ted.mielczarek)
Attachment #563491 -
Flags: review?(ted.mielczarek)
Comment 12•13 years ago
|
||
Comment on attachment 563491 [details] [diff] [review] patch v4 Review of attachment 563491 [details] [diff] [review]: ----------------------------------------------------------------- ::: testing/mochitest/specialpowers/content/specialpowers.js @@ +417,5 @@ > + removeObserver: function(obs, notification) { > + var obsvc = Cc['@mozilla.org/observer-service;1'] > + .getService(Ci.nsIObserverService); > + obsvc.removeObserver(obs, notification); > + }, These look good, I'm just wondering if we'll need a more e10s version of this in the future: something that lets you add/remove observers in the parent process, with forwarding of the notifications. @@ +431,5 @@ > + getPrivilegedProps: function(obj, props) { > + let i; > + > + for (i = 0; i < props.length; i++) > + obj = obj[props[i]]; This isn't the same API that jdm talked about in comment 8. Did he just misremember what he had proposed? I really think I'd prefer passing "foo.bar" instead of ["foo", "bar"]. It's only a split away, shouldn't be that hard. @@ +439,5 @@ > + return new String(obj); > + default: > + return obj; > + } > + } Could you add a simple test for some of these APIs to the SpecialPowers sanity tests? http://mxr.mozilla.org/mozilla-central/source/testing/mochitest/tests/test_SpecialPowersExtension.html?force=1 It's probably a pain to test add/removeObserver, but at least the other ones would be nice.
Comment 13•13 years ago
|
||
I never actually wrote a version that used "a.b.c", but as mentioned, splitting is easy.
Updated•13 years ago
|
Keywords: dev-doc-needed
Comment 14•13 years ago
|
||
Comment on attachment 563491 [details] [diff] [review] patch v4 Review of attachment 563491 [details] [diff] [review]: ----------------------------------------------------------------- r=me if you change the getPrivilegedProps API to take a string like "foo.bar" instead of a list.
Attachment #563491 -
Flags: review?(ted.mielczarek) → review+
Assignee | ||
Comment 15•13 years ago
|
||
have the split change ready to go, will throw together some tests for the non-observer things and send for feedback.
Assignee | ||
Comment 16•13 years ago
|
||
changed to "foo.bar" syntax for getPrivilegedProps, added some tests for the non-observer stuff added to SpecialPowers. Ted, can you take a quick look at the tests and see if they make sense please ? :) If all looks good, this should be ready to land (i maybe should try pushing them to Try as well too ? )
Attachment #563491 -
Attachment is obsolete: true
Attachment #563891 -
Flags: feedback?(ted.mielczarek)
Comment 17•13 years ago
|
||
(In reply to Ian Melven :imelven from comment #16) > Created attachment 563891 [details] [diff] [review] [diff] [details] [review] > patch v5 > > changed to "foo.bar" syntax for getPrivilegedProps, added some tests for the > non-observer stuff added to SpecialPowers. Ted, can you take a quick look at > the tests and see if they make sense please ? :) If all looks good, this > should be ready to land (i maybe should try pushing them to Try as well too > ? ) Hi Ian, thanks for working on these patches. We've noticed failures in try that we haven't seen locally with special powers APIs, so it would be good to run these changes through try while you wait for review, and see how things go. thanks again!
Assignee | ||
Comment 18•13 years ago
|
||
unbitrotted for a try push, ted, do these tests make sense ?
Attachment #563891 -
Attachment is obsolete: true
Attachment #563891 -
Flags: feedback?(ted.mielczarek)
Attachment #564406 -
Flags: feedback?(ted.mielczarek)
Assignee | ||
Comment 19•13 years ago
|
||
https://tbpl.mozilla.org/?usebuildbot=1&tree=Try&rev=a1354ace2df7 lots of orange, a couple red and a purple i could use some help figuring out if any of this is expected or caused by my changes (i'm assuming the infrastructure exception isn't ? )
Comment 20•13 years ago
|
||
None of the oranges look like your patch caused them.
Assignee | ||
Comment 21•13 years ago
|
||
discussed with jdm on IRC and learned a lot of very useful tips about working with tbpl and try ! if these tests seem ok, this should be ready to land, I think.
Comment 22•13 years ago
|
||
Comment on attachment 564406 [details] [diff] [review] patch v6 Review of attachment 564406 [details] [diff] [review]: ----------------------------------------------------------------- Looks good, thanks! Please document these new methods on MDN once you land: https://developer.mozilla.org/en/SpecialPowers
Attachment #564406 -
Flags: feedback?(ted.mielczarek) → feedback+
Assignee | ||
Comment 23•13 years ago
|
||
unbitrot including move of special powers API's to specialpowersAPI.js, ready to land
Attachment #564406 -
Attachment is obsolete: true
Assignee | ||
Updated•13 years ago
|
Attachment #566933 -
Attachment is patch: true
Assignee | ||
Comment 24•13 years ago
|
||
should be ready to land, marking checkin-needed
Keywords: checkin-needed
Assignee | ||
Updated•13 years ago
|
Flags: in-testsuite+
Assignee | ||
Comment 25•13 years ago
|
||
Comment on attachment 566933 [details] [diff] [review] patch v7 carrying over r+ from ted as the patch is the same apart from the file the new apis are in - let me know if this isn't kosher please !
Attachment #566933 -
Flags: review+
Comment 26•13 years ago
|
||
Pushed to mozilla-inbound: http://hg.mozilla.org/integration/mozilla-inbound/rev/5f9ff53ccaab
Whiteboard: [inbound]
Updated•13 years ago
|
Keywords: checkin-needed
Comment 27•13 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/5f9ff53ccaab
Status: REOPENED → RESOLVED
Closed: 13 years ago → 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
You need to log in
before you can comment on or make changes to this bug.
Description
•