[Data urls] [MV2] chrome.tabs.executeScript throws an error about permitions denial in MV2 extension

77 views
Skip to first unread message

Alexander Luria

unread,
Feb 21, 2023, 11:14:44 AM2/21/23
to Chromium Extensions
I am using chrome.tabs.executeScript function, which is trying to invoke an action on a tab that was opened with dataUrl. 
I get an error in the from executeScript function
Unchecked runtime.lastError: Cannot access contents of url "data:text/html;base64,<base64string>.". Extension manifest must request permission to access this host.

My permission include
"permissions": [
"tabs",
"debugger",
"webNavigation",
"cookies",
"<all_urls>",
"data:/*",
"activeTab",
"matchAboutBlank",
"http://*/*",
"https://*/*",
"background",
"desktopCapture",
"chrome://favicon/",
"pageCapture",
"storage",
"notifications",
"downloads",
"downloads.shelf"
]

what do I need to change for it to work? I cannot set the extension to MV3.
Is this a bug? 

wOxxOm

unread,
Feb 21, 2023, 1:59:10 PM2/21/23
to Chromium Extensions, Alexander Luria
AFAICT It was never supported. Limited support is available in MV3 for data: iframes not tabs and only when using a content script declared in manifest.json with match_origin_as_fallback, according to https://crbug.com/55084#c90 and #c94. In other words there's no solution for data: tabs, but if you want to read the tab's DOM you can probably just get the tab's URL and use DOMParser inside an offscreen document (optionally with btoa if the URL is base64-encoded).

Alexander Luria

unread,
Feb 22, 2023, 4:43:20 AM2/22/23
to Chromium Extensions, wOxxOm, Alexander Luria
Thank you very much. I suspected that. 
Reading the DOM is not helpful since I need to inject stuff into the running page.
Reply all
Reply to author
Forward
0 new messages