Skip to content
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

iframe fail #5

Open
albell opened this issue Aug 7, 2012 · 2 comments
Open

iframe fail #5

albell opened this issue Aug 7, 2012 · 2 comments

Comments

@albell
Copy link

albell commented Aug 7, 2012

Thanks for this. Very clever and useful. This is something the various Dev Tools Inspectors should really implement natively. Congrats on beating them to it!

One issue: In chrome 21, the plugin doesn't work on text inside an iframe. No bubble pops up at all. Try inspecting the results pane here:

http://jsfiddle.net/Wsmfv/

Any fix greatly appreciated.

@chengyin
Copy link
Owner

Sorry for the late reply.

I will have to look into it. I intentionally avoid iframe because I can't simply use the same scope between the main window and the iframe ones. It will show another WF instance in the iframe, which is not good.

@glajchs
Copy link

glajchs commented Mar 27, 2013

I also ran into this problem when trying to debug some font usages in my iframe. My iframe is inserted via the chrome extension I'm building (it's basically a toolbar at the top of the page to help users instrument their website with our product). You could use the same method I'm using to talk to the iframe, which is you send messages to your background page for your extension via chrome's extension messaging API, and then the background page sends a message to all frames in the current page like so:
chrome.tabs.sendMessage(
tabId,
{ allFrames: true, dataToSend: {} );
Make sure to set tabId to the sender.tab.id from the request that you sent to the background page.

In your manifest, specify that the content scripts should run in all frames like so:
"content_scripts" : [
{
// other stuff here...
"all_frames" : true
}
Then in your content scripts you can listen for chrome extension events via:
chrome.extension.onMessage.addListener(
function(request, sender, sendResponse) {
}
);
In this way you can send data to/from your iframes, do calculations within the actual iframe's scope to determine fonts via the content scripts, and send the result of your calculations back to the top-level page.

You will of course have to conditionalize the logic within your content scripts to do different stuff based upon whether they are running in the toplevel or in an iframe, so there is a bit of work involved there.

But it may be worth the feature. I know I'd love to see it :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants