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

page.frames() does not list chrome-extension:// frames on non-extension pages #2506

Closed
tomholub opened this issue May 6, 2018 · 1 comment

Comments

@tomholub
Copy link

tomholub commented May 6, 2018

  • Puppeteer version: puppeteer@1.3.0-next.1525301631811
  • Platform / OS version: Ubuntu 17.10
  • Node.js version: v9.4.0

What steps will reproduce the problem?

  1. have a chrome-extension://.. iframe inside a parent google.com (or any standard domain) page
  2. try to access the iframe through page.frames()
  3. notice all extension frames missing

Test bundle: debug.zip

const puppeteer = require('puppeteer');

(async() => {
  let browser = await puppeteer.launch({
    args: ['--disable-extensions-except=add_iframe', '--load-extension=add_iframe'],
    headless: false,
    slowMo: 50,
  });

  let page = await browser.newPage();
  await page.goto('https://google.com/404');

  await page.waitForSelector('iframe', {timeout: 5000, visible: true});
  let iframeHandle = await page.$('iframe');
  let iframeSrc = await (await iframeHandle.getProperty('src')).jsonValue();

  let frames = await page.frames();
  let urls = frames.map(frame => frame.url()); // ignores extension frames!

  console.log(`parsed iframe src: ${iframeSrc}`);
  console.log(`page.frames() url: ${JSON.stringify(urls)}`);
  console.log(urls.indexOf(iframeSrc) === -1 ? 'FAIL' : 'PASS');
})();
// manifest.json

{
  "manifest_version": 2,
  "name": "Add iframe to google 404 page",
  "description": "...",
  "version": "0.0.1",
  "permissions": ["https://google.com/404"],
  "content_scripts": [{"matches": ["https://google.com/404"], "js": ["add_iframe.js"]}],
  "web_accessible_resources": ["iframe.htm"],
  "minimum_chrome_version": "55"
}
<!-- add_iframe/iframe.htm -->

<html>
  <head>
  </head>
  <body>
    <b>I was added by an extension</b>
  </body>
</html>
// add_iframe/add_iframe.js

window.onload = function() {
  var iframe = document.createElement('iframe');
  iframe.src = chrome.runtime.getURL("iframe.htm");
  document.body.appendChild(iframe);
};

What is the expected result?

page.frames()
returns: <Array> An array of all frames attached to the page.

What happens instead?

parsed iframe src: chrome-extension://cbibhaihljjmbbcephldnjjgnbjifgph/iframe.htm
page.frames() url: ["https://google.com/404"]
FAIL

image

Scenarios

  • https://domain.com inside https://other-domain.com works
  • chrome-extension://... inside chrome-extension://... works
  • chrome-extension://... inside https://domain.com does not work
@aslushnikov
Copy link
Contributor

That's due to site isolation, dupe of #2548.

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

2 participants