chrome.scripting.executeScript accessing src doc iframes with sandbox attribute

7 views
Skip to first unread message

Michael Dougall

unread,
7:04 AM (1 hour ago) 7:04 AM
to Chromium Extensions
Howdy!

I'm having problems executing a script inside a sandboxes iframe that uses srcdoc. 

chrome.scripting.executeScript(
{
target: { tabId: tab.id, allFrames: true },
func: () => {
console.log('code executing');
return Promise.resolve();
},
},
async (results) => {
results.forEach(() => {
console.log('got back!');
});
}
);

This works:

```
<iframe srcDoc="<h1>Hello world!</h1>" style={{ position: 'fixed', zIndex: 9999 }} sandbox=""></iframe>
```

This doesn't work:

```
<iframe srcDoc="<h1>Hello world!</h1>" style={{ position: 'fixed', zIndex: 9999 }} sandbox="allow-scripts"></iframe>
```

Is there something needed on my end (or the iframe end) to make this work? Assume removing sandbox is non-negotiable.

Cheers,
Mike
Reply all
Reply to author
Forward
0 new messages