(DO NOT MERGE) Issue #433: Dirty comm channel between main add-on and webextension#1008
(DO NOT MERGE) Issue #433: Dirty comm channel between main add-on and webextension#1008lmorchard wants to merge 1 commit into
Conversation
8848ef4 to
8556899
Compare
|
/cc @chuckharmston @meandavejustice @groovecoder - all you folks probably have an interest in this. This is probably a terrible idea, because I came up with it while sleep-deprived and flying back from London. But, what this does is implement a message-passing channel between webextensions and our main bootstrap add-on. The mechanism is a new page at The webextension sends a Here's the nasty hacky part: In the middle, the I wanted to use LocalStorage in the Future expansion of this idea, if it can be polished up, can also include the messaging required for sending variant testing configuration around (for #477). |
|
Oh, and also this commit has the webextension and main add-on both hard-coded to load |
|
Oh yeah, and this results in real normal Telemetry pings, as opposed to the server-side solution in #952 |
|
What if we use IndexedDB (via localForage)? Less hacky? |
Tried both the localStorage & IndexedDB drivers in localForage. Same error: |
| subject: EXPERIMENT_ID, | ||
| data: data | ||
| } | ||
| }, '*'); |
There was a problem hiding this comment.
In the "real world" implementation, I assume we would tell devs to only post the message to targetOrigin of testpilot.firefox.com ?
There was a problem hiding this comment.
Yeah, but until/unless I figure out a way to configure this for dev/stage/prod environment it's * for now
|
I'm still trying to get my local testpilot install to work, but then I'll be eager to try this out with my extension. I agree the cookie thing is a bit hacky, but it does seem to be the best we can do for now? Do you have a bug # or issue # for the security error thrown by localStorage and IndexedDB? |
|
Would you want to do this instead of #952 ? Or in addition to it? |
Instead of. This would give us normal full Telemetry pings for all experiment types. |
No, I have no idea yet whether it's a bug or working as intended. Still researching that / hoping someone else knows what's up. |
|
FWIW I've added both methods of boilerplate/example code into my extension: https://github.com/groovecoder/blok/compare/disable-and-ask-why-4?expand=1#diff-d8c11c63dfd474a75f05fbbdba0889f8R27 If I can get testpilot running locally I'll try them both out. |
|
FWIW, I also just tried setting the 😕 The hell? I feel like I've strayed into a minefield of corner cases here. |
| {'user_id': request.user.email if not request.user.is_anonymous() else ''}) | ||
|
|
||
|
|
||
| @xframe_options_exempt |
There was a problem hiding this comment.
Any chance we could use parent-src CSP around this to protect it from click-jacking? (IIRC ALLOW-FROM doesn't allow multiple origin values?)
|
Wow, so this actually works in my web extension. 🎉 Except I couldn't put the
Still, I:
I see Oh, and here's a fun video reward for making such an amazingly-creative solution: |
There's no sandbox for Telemetry as far as I know. The 127.0.0.1 server is intended to be an instance of vdjeric/gzipServer, but it could be any HTTP server to see the POST requests. There's an about:config setting to turn on telemetry console messages when requests go out, too, but I can't remember what it is :/ |
Hmm, is that not a spot where |
|
Probably could use that too. Not sure if it gets me anything over postMessage right now. But my add-on is growing large enough that some actual architecture and design is in order. I'll keep |
|
Not seeing any other feedback or ideas on this... @chuckharmston? @meandavejustice? Might just see what I can do to clean up the last loose ends and merge this Monday if I don't get any more eyes on it before end of day. Mainly:
Just going to go with the cookie hack until/unless a better working solution reveals itself. |
8556899 to
d3f7306
Compare
|
Not sure if it's any better, but ... For another add-on we've coded it such that it uses whichever site was last visited in the browser. I.e., when the browser goes to testpilot.firefox.com, a content script configures the add-on to use testpilot.firefox.com, when the user goes to testpilot.dev:8000, the content script configures the add-on to use testpilot.dev:8000. But that just shifts the issue - still hard to know which site you're using when doing development. Hmm ... It also means each web extension experiment would have to implement a similar mechanism, so that's double-bad. |
|
So yeah - 👍 to hard-code testpilot.firefox.com into the add-ons and the extension experiments by default. And make devs go in and change the code to use other environments. |
…nsion
- New /postmessage-proxy page served by Django
- Main add-on loads /postmessage-proxy into a background page worker in
an iframe
- Example webextension loads /postmessage-proxy into a background page
worker in an iframe
- proxy.js on /postmessage-proxy listens for postMessage events:
- queueTelemetryPing to enqueue a telemetry ping to be sent by the
main add-on
- fetchTelemetryPings to fetch all queued telemetry pings from the
main add-on and submit them all
- GIANT HACK: proxy.js maintains the queue as a JSON-serialized array in
a cookie, because that's the only shared persistent data for the
iframe I could get working. (LocalStorage fails with a security error)
- add vendor gulpfile task to copy over vendor scripts
- add vendor/js.cookie.js as a lazy way to manage cookies
d3f7306 to
88a05a7
Compare
an iframe
worker in an iframe
main add-on
main add-on and submit them all
a cookie, because that's the only shared persistent data for the
iframe I could get working. (LocalStorage fails with a security error)
Made a quick drawing of the messaging flow:
