chrome.contextMenus.onClicked.addListener(): `Cannot access contents of the page` on Google Doc
Reported by
vitaly.z...@gmail.com,
Apr 24 2018
|
||||||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Steps to reproduce the problem:
Create test extension:
manifest.json:
{
"manifest_version": 2,
"name": "test",
"permissions": ["activeTab", "contextMenus"],
"background": {
"scripts": ["eventPage.js"],
"persistent": false
},
"version": "0"
}
eventPage.js:
chrome.contextMenus.create({
'title': 'Click',
'id': 'root',
'contexts': ['all']
})
chrome.contextMenus.onClicked.addListener(_ => {
chrome.tabs.executeScript({
'code': 'console.log("Message from event page")'
});
});
Open some random Google Doc, for example https://docs.google.com/document/d/1lA3fL5ScQut_4aDd0SBzxTJSKAlMsDobLsijLnh_zms/edit?usp=sharing
Open Devtools -> Console.
Context menu on page: 'Click'.
What is the expected behavior?
Message in JS console: 'Message from event page'.
What went wrong?
Error in JS Console of the event page:
`Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of the page. Extension manifest must request permission to access the respective host.`
Did this work before? N/A
Does this work in other browsers? Yes
Chrome version: 65.0.3325.181 Channel: n/a
OS Version: OS X 10.13.4
Flash Version:
The same code works as expected in Firefox.
,
Apr 26 2018
Thanks for filing the issue! @Reporter: As it would be out of scope for creating an extension from our end, Could you please share a sample test extension which helps us to triage the issue in a better way from TE end.
,
Apr 26 2018
The code from first post.
,
Apr 26 2018
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
May 3 2018
,
May 22 2018
Unable to reproduce the issue on reported version 65.0.3325.181 and on latest stable 66.0.3359.181 using Mac 10.13.3 with steps mentioned below. 1. Installed attached extension 2. Opened doc specified and opened devtools console 3. Selected "Click" option from context menu and observed "Message from event page" message. Attaching screenshot for reference. @Reporter: Please check the screenshot and let us know if we miss anything. Also please upgrade chrome to latest stable and check this issue. You can download latest build from https://www.chromium.org/getting-involved/dev-channel.
,
Jul 9
This is WontFix from our side. Extensions have to expressly request permissions to access pages they want to interact with.
,
Jul 10
After click to the button or context menu item we can interact with the current page without permissions. |
||||||
►
Sign in to add a comment |
||||||
Comment 1 by krajshree@chromium.org
, Apr 25 2018