Content script does not load on certain iframes

6,469 views
Skip to first unread message

Yaya

unread,
Jan 22, 2010, 5:48:50 AM1/22/10
to Chromium-extensions
Hi,

I have an extension that listens to the keypress and keydown events.
The extension's content script is injected to all frames, using the
"all_frames":true directive. The content script is matched to both
HTTP and HTTPS.

On most sites this works well and my content script catches these
events on each frame, but on certain web pages the script is not
loaded to some of the frames.

One good example is Gmail's "Compose mail" page. This page has an
ifrmae that holds the actual mail message (beneath the subject). My
content script catches all key events on the page except for those
accruing inside this specific iframe (when typing the actual mail
message) .

Here is snippet of the iframe:

"<iframe tabIndex="1" class="Am Al editable" id=":9q" src="html/
compose/static_files/blank_quirks.html" frameBorder="0" style="padding-
bottom: 0px; background-color: white; padding-left: 0px; padding-
right: 0px; height: 234px; overflow: visible; padding-top: 0px;"
closure_hashCode_vghdqk="425" X3c="true">"

..and part of manifest:

"content_scripts": [

{
"matches": ["http://*/*", "https://*/*"],
"js": ["scripts/jquery-1.3.2.js", "scripts/test.js"],
"css": [],
"all_frames":true
}
],

This is a simple test I wrote in my content script that logs each
loaded frame:

$(document).ready(function(e) { console.log(window.location.href); });

As suspected....there is no entry for the iframe mentioned above.


I would appreciate some help.

Arne Roomann-Kurrik

unread,
Jan 26, 2010, 8:57:57 PM1/26/10
to Yaya, Chromium-extensions
I'm not sure I've seen this behavior, but I haven't tried to inject a content script into a Gmail compose window, either.  You mentioned that this happens on many pages - could you list some more examples where this doesn't work?  It would help track this issue down.

~Arne



--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


TAMURA, Kent

unread,
Mar 21, 2010, 1:59:53 PM3/21/10
to Arne Roomann-Kurrik, Yaya, Chromium-extensions
I guess such <iframe> elements are dynamically created.
Iframe elements without src attribute are treated as about:blank.  So content scripts can not work with them.

No extensions work with the iframe in this page 
--
TAMURA Kent
Software Engineer, Google



Antony Sargent

unread,
Mar 23, 2010, 2:39:53 AM3/23/10
to TAMURA, Kent, Arne Roomann-Kurrik, Yaya, Chromium-extensions
You can access iframes with src="about:blank" from the enclosing page's script via their reference in the window.frames array and control their content from there.

Daniel Wagner-Hall

unread,
Mar 23, 2010, 8:34:44 AM3/23/10
to Antony Sargent, TAMURA, Kent, Arne Roomann-Kurrik, Yaya, Chromium-extensions
On 23 March 2010 06:39, Antony Sargent <asar...@chromium.org> wrote:
> You can access iframes with src="about:blank" from the enclosing page's
> script via their reference in the window.frames array and control their
> content from there.

Or at least, you'll be able to when
https://code.google.com/p/chromium/issues/detail?id=20773 is fixed

Antony Sargent

unread,
Mar 23, 2010, 2:00:39 PM3/23/10
to Daniel Wagner-Hall, TAMURA, Kent, Arne Roomann-Kurrik, Yaya, Chromium-extensions
As a workaround until that bug is fixed, you can probably use your content script to inject a <script> tag into the page with js that accesses window.frames.
Reply all
Reply to author
Forward
0 new messages