-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use the tool in online environments where context needs to be specified? #24
Comments
Currently backbone running into iframes isn't supported. The extension still needs a way to detect the contexts of the page and to let you choose the one to use, plus changing the panel so to interact with the right context. I've looked up at this time ago, since can be useful also for using it with Ripple, etc. but seemed to require quite a lot of work. If you can help, I'm on this ;) |
What would you need for help with this? |
A simple solution could be to detect the page iframes in the panel activation page (that with the link "Restart the application in debug mode") and let the user choose the context to use, e.g. with a select. An instance of the backbone agent is injected in every frame (via inspectedWindow.reload, unfortunately doesn't seem to exist a way to choose a specific frame), hence, we need a way for each instance to detect in which frame it is running (probably by getting its url, could be that this must be done in the content script) in order to send that information to the panel. The panel will then execute functions only in the choosen iframe (see inspectedWindow.eval "frameURL" and inspectedPageClient.js#L26) and ignore messages from other instances. |
Do you have any branches you've already been working on this in? |
No branches unfortunately, I just did some problem analysis. Anyway, the ember inspector is doing something similar, the codebase is huge, but you can take a look at:
I get that this can be quite confusing without knowing the codebase, I will try to look at that myself as soon as possible. |
Haha, guess I won't be of any help, I didn't have time last night to dig into it. Thanks for getting it done so quickly! |
Changes pushed, took a bit of time since I had to rethink various aspects of the communication model to integrate this new "multi frame" scenario in the seamless way possible. No iframe selection dialogs or anything else to set on startup, no additional actions are required. However, to the best of my knowledge, it seems that Chrome allows you to execute code in the context of a frame only by specifying its url, which is not necessarily unique!
As an additional note, there is (very) limited support for Ripple since it dynamically completely change the page content after the page has loaded, moving all the content into an iframe with the same src of the page! |
Hmm. I wonder if the injected script could find the frames. Then search each for backbone. Extreme? Maybe... |
@jasonLaster yeh you could, right now that's pretty much what the debugger does, except it runs multiple injected script instances, one per frame. You could also run one single instance on the top frame and search the frames here manually, but note that there are the same origin security policies that could prevent you from accessing the frame contents, this applies even to the associated content scripts. |
Hmm. Interesting. Maybe something here: emberjs/ember-inspector#29 |
I looked a bit at their code, not too deeply, but it seems that they get the iframes on the page + monitor new added frames and inject the ember_debug (their corresponding agent) on them as soon as they are detected. This is in a way what we are doing right now, except we use the chrome.devtools.inspectedWindow.reload function that does this automatically, since we need to run the agent since from the beginning, while they probably don't have this requirement. Problem is in the communication from panel to agent, since we are using https://developer.chrome.com/extensions/devtools_inspectedWindow#method-eval but this allows only to specify the frameurl, not the frameid. A solution is to use a messaging-only interaction, where the panel sends a message with a request, e.g. send me the view 12 info, and the agent sends back a message with the requested data. The ember inspector seems to do something like this, which probably is also more general since they also support other browsers: each ember_debug instance creates an unique id based on the url, the date, the application itself, etc. This unique id is then used in the communication, the panel sends a message with the unique id, every agent (ember_debug) receives it and skips the message if the id is not the same; you could also send a null id and the message seems to be interpreted like a broadcast. This is a doable solution, but for sure could make the communication a bit trickier, since you have to keep track of what response is associated to what request, don't know if there is some simple method to track responses. References:
|
http://stackoverflow.com/questions/24788968/use-backbone-debugger-in-online-js-environment
Trying to get the functionality to validate tested collaborative code on JSFiddle or Plnkr or the like...
The text was updated successfully, but these errors were encountered: