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

chrome.scripting.executeScript allFrames doesn't resolve on CSP-restrictive pages. #715

Open
tomasdev opened this issue May 18, 2022 · 11 comments

Comments

@tomasdev
Copy link

Describe the bug
chrome.scripting.executeScript callback is never called (if using promises, the promise never resolves) when the page in which it's executed contains iframe with certain CSP headers that seem restrictive / safer.

To Reproduce

// background.js
chrome.action.onClicked.addListener((tab) => {
  console.log('click');

  chrome.scripting.executeScript(
  {
    target: {
      tabId: tab.id,
      allFrames: true,
    },
    'func': function() {
      return document.activeElement;
    },
    'args': [],
  },
  (...args) => {console.log('callback', args)});
});

// manifest.json
{
    "name": "Test executeScript",
    "description": "",
    "version": "0.0.1",
    "manifest_version": 3,
    "permissions": [
        "scripting"
    ],
    "background": {
        "service_worker": "bg.js"
    },
    "action": {},
    "minimum_chrome_version": "93.0.0.0",
}

And then click the extension icon on a site like https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input

Expected behavior
The Promise should throw or the callback should be called.

** Notes**
I'm suspicious of Content Security Policy but I did not try using Charles (or similar proxy) to override header by header to know which one is messing up the extension. This may even be a bug using MV2, Chrome Input Tools also doesn't work on the Mozilla site.

@guest271314

This comment was marked as off-topic.

@tomasdev
Copy link
Author

tomasdev commented May 22, 2022 via email

@guest271314

This comment was marked as off-topic.

@guest271314

This comment was marked as off-topic.

@guest271314

This comment was marked as off-topic.

@tomasdev
Copy link
Author

tomasdev commented May 22, 2022 via email

@tomasdev
Copy link
Author

@guest271314 I tested your zip, the "callback" log is never logged. I'm on Chrome version 101.0.4951.64... so I'm guessing it was fixed at some point between 101 and 104. I'll keep this bug open until 104 is stable

@guest271314

This comment was marked as off-topic.

@guest271314

This comment was marked as off-topic.

@tomasdev
Copy link
Author

tomasdev commented May 23, 2022 via email

@guest271314

This comment was marked as off-topic.

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