New issue
Advanced search Search tips

Issue 599167 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Closed: Mar 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Content script isn't running in iframe within another extension's page

Reported by cool...@gmail.com, Mar 30 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0

Steps to reproduce the problem:
Suppose that 2 extensions are installed in Google Chrome.

-------------

1st extension runs content.js on w3.org:

manifest.json:

"content_scripts": [{
    "matches": [ "https://www.w3.org/*" ],
    "all_frames": true,
    "js": [ "content.js" ]
}]

content.js:

alert('content');

-------------

2nd extension has page.html, which loads w3.org into iframe:

manifest.json:

"web_accessible_resources": ["page.html"]

page.html:

<!DOCTYPE html>
<iframe src="https://www.w3.org/"></iframe>

-------------

Now enter in address bar chrome-extension://2nd-extension-id/page.html. You will see w3.com, but content.js was not running (no alert() window). I do not see errors in console.

What is the expected behavior?
content.js must be running in iframe (alert() window must be shown).

What went wrong?
Content script isn't running in iframe within another extension's page.

WebStore page: 

Did this work before? N/A 

Chrome version: 49.0.2623.110 m (64-bit)  Channel: stable
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version: Shockwave Flash 21.0 r0
 
Cc: creis@chromium.org
Owner: rdevlin....@chromium.org
Status: WontFix (was: Unconfirmed)
We deliberately don't do this for security reasons.  Only the owning extension is allowed to run scripts on its pages or subframes.  Though this could change with OOPI, since the risk is largely mitigated then.

Comment 3 by creis@chromium.org, Mar 30 2016

Components: Internals>Sandbox>SiteIsolation
Right-- there's a chance you could relax the restriction once the web iframes run in a different process than the extension (via --isolate-extensions).  See https://www.chromium.org/developers/design-documents/oop-iframes.

Comment 4 by cool...@gmail.com, Mar 30 2016

I hope this bug will be fixed after release of the OOPI.

Comment 5 by nasko@chromium.org, Mar 30 2016

This doesn't need full out-of-process iframes support. It can be supported once we ship --isolate-extensions enabled by default.

Comment 6 by creis@chromium.org, Mar 30 2016

Nasko: I'm not sure the distinction you're making, since we do need out-of-process iframes for this (at least enough to ship --isolate-extensions, as we've both mentioned).  Agreed that we don't need full Site Isolation.

Comment 7 by nasko@chromium.org, Mar 30 2016

Indeed I failed to communicate properly. I meant that we need Isolate Extensions support, not full Site Isolation.

Comment 8 by rob@robwu.nl, Mar 31 2016

Side note, neither alert nor console.log seems to have any apparent effect when --isolate-extensions is enabled.

Here is a test case that inserts a marker in the page. You can use it to see whether the content script did really.

1. Download and exta-and-b.zip (this contains two extensions, in directories "exta" and "extb").
2. Start Chrome with both extensions enabled and OOPIF for extensions (I also tried --site-per-process):
   chromium --load-extension=exta,extb --isolate-extensions
3. Click on the extension button of extension B to open a page with example.com in a frame.
4. Look at the frame and check whether you see "Extension A ran" and/or "Extension B ran" in the frame, and whether there are console messages and/or dialogs.

Actual (in Chrome 51.0.2696.0):
- Only "Extension B ran" is shown.
- There are no messages in the console.
- There are no alert dialogs.

Expected:
- I should see "Extension B ran" in the page.
- I should see "Extension B ran" in the console.
- I should get an alert dialog showing "b".
- And maybe also the above, but then for extension A (that is this bug).

Site isolation folks: Were you aware of these bugs (i.e. console messages not appearing and dialogs not showing up)? If not, please create new tickets and reference this test case.
exta-and-b.zip
2.2 KB Download
@8 Sanity check - you looked at the console for the subframe, right, not just the top frame?

Re A not running, right now we have a specific check that the top-level frame isn't an extension page (separate from process checks), so this is expected behavior.  When we launch Isolate Extensions, we can re-evaluate this decision, but (unlike the blessed vs unblessed context) this won't just automagically work.

Comment 10 by rob@robwu.nl, Mar 31 2016

#9 Confirmed that the message does show up in the frame's console (I expected it to be aggregated with the main frame's console, just like the non-OOPIF case).

The alert dialog doesn't appear though.
Yes, alerts are a known problem and tracked in  issue 453893 .

Sign in to add a comment