Skip to content

Conversation

bohuslavsemenov
Copy link

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

  1. Go to the wxt-demo project.
  2. Add the following code to entrypoints/iframe-src/index.html
navigator.mediaDevices.getUserMedia({
  audio: true,
  video: true,
});
  1. Add the onMount callback to set allow attribute to iframe.content.ts:
onMount: (wrapper, iframe) => {
  iframe.setAttribute('allow', 'camera;microphone');
}
  1. 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).
  2. Change onMount to onBeforeMount and it will prompt you every time you refresh the page.

Copy link

netlify bot commented Sep 16, 2025

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 8e89282
🔍 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...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant