Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Inject content script into sandboxed iframe.

58 views
Skip to first unread message

Ahmed Rafi Ullah

unread,
Jan 8, 2025, 5:26:37 PMJan 8
to Chromium Extensions
Question is the title about, can i inject a content script into a sandboxed iframe. From the docs there is no mention that its not possible, i tried to follow the docs and get this error

blocked script execution in 'about:blank' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.

The iframe is sandboxed like so 

<iframe id="canvas-iframe" sandbox="allow-same-origin"></iframe>

its url is about blank


It there a way to make it work ?

Ahmed Rafi Ullah

unread,
Jan 8, 2025, 5:36:14 PMJan 8
to Chromium Extensions, Oliver Dunk, Patrick Kettner

The code im using is this and its mv3

const res = await chrome.scripting.registerContentScripts([
{
id: scriptId,
world: 'MAIN',
runAt: 'document_start',
persistAcrossSessions: true,
js: jsFileNames,
matches,
allFrames: true,
excludeMatches: exclusions,
matchOriginAsFallback: true,
},
])

Ahmed Rafi Ullah

unread,
Jan 8, 2025, 5:43:30 PMJan 8
to Chromium Extensions, Ahmed Rafi Ullah, Oliver Dunk, Patrick Kettner
I looked at this and this seems to be an issue in mv2, may its still present in mv3 with dynamically registered content scripts ?

woxxom

unread,
Jan 9, 2025, 3:28:28 AMJan 9
to Chromium Extensions, Ahmed Rafi Ullah, Oliver Dunk, Patrick Kettner
There was a bug with sandbox injection that was recently fixed in Chrome 130, https://crbug.com/355256366. If you still encounter it, make a new bug report with a demo extension.
Reply all
Reply to author
Forward
0 new messages