wxt
wxt copied to clipboard
feat: add onBeforeMount callback to createIframeUi options
Overview
This PR introduces an onBeforeMount callback to the createIframeUi function. The main motivation is that the allow attribute must be set before the iframe is injected into the DOM, otherwise browser will not include permission policies specified in it.
Manual Testing
- Go to the
wxt-demoproject. - Add the following code to
entrypoints/iframe-src/index.html
navigator.mediaDevices.getUserMedia({
audio: true,
video: true,
});
- Add the
onMountcallback to setallowattribute toiframe.content.ts:
onMount: (wrapper, iframe) => {
iframe.setAttribute('allow', 'camera;microphone');
}
- Go to google.com and try to refresh the page. You will get inconsistent permission prompts (Actually, they will work only when iframe is hot reloaded or on "reload iframe" click in browser context menu).
- Change
onMounttoonBeforeMountand it will prompt you every time you refresh the page.
Deploy Preview for creative-fairy-df92c4 ready!
| Name | Link |
|---|---|
| Latest commit | 8e892824fe5ce7dd5b1acaa4f1d97e87b147f414 |
| Latest deploy log | https://app.netlify.com/projects/creative-fairy-df92c4/deploys/68c954166f546e0008715168 |
| Deploy Preview | https://deploy-preview-1899--creative-fairy-df92c4.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify project configuration.
@aklinker1 Pls can you review it, since we're having with media permissions