fix: Support page_action for Firefox MV3#2200
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Nice change, I like it. Could you add a test to cd packages/wxt
pnpm test manifest |
|
I flipped the logic to != firefox and added I was even more unsure how to make this change, but it does pass. Open to suggestions here... |
|
I added another test that tests what happens when you set The changes you've made so far prevent the Can you update the implementation so the new test passes? |
page_action for Firefox MV3
|
@aklinker1 Can you provide a control case for adding a Lets say I add a custom entrypoint, I will call it "page_action": {
"default_popup": "popout.html",
"default_title": "Page Action Title",
"default_icon": {
"16": "images/logo16.png",
"32": "images/logo32.png",
"48": "images/logo48.png",
"96": "images/logo96.png",
"128": "images/logo128.png"
},
"show_matches": ["*://*/*"]
}I have tried adding this to the index.html for the <meta
name="manifest.default_icon"
content='{
"16":"images/logo16.png",
"24":"images/logo24.png",
"32":"images/logo32.png",
"48":"images/logo48.png",
"128":"images/logo128.png"
}'
/>
<meta name="manifest.type" content="page_action" />
<meta name="manifest.show_matches" content="['*://*/*']" />
<meta name="manifest.default_title" content="Page Action Title" />So is this not possible? If it is, how is it currently done? Moving forward, the only place I see to get this done is in entrypoints.forEach((item) => {
if (item.options.type === 'page_action') {
manifest['page_action'] = {
// ...item.options,
default_title: item.options.defaultTitle,
default_icon: item.options.defaultIcon,
show_matches: item.options.showMatches,
hide_matches: item.options.hideMatches,
default_popup: item.name + '.html',
};
}
});While this generates the correct manifest entry from meta tags, it still does not pass the test... |
|
WXT is designed to only support one popup. So you can't name it So right now, you have to name the file If you want more control over custom entrypoints and manifest generation, you need to use hooks or a WXT module. https://wxt.dev/guide/essentials/wxt-modules.html#add-custom-entrypoints |
|
I confirmed that it is possible, and created a full example for how to do it in WXT: https://github.com/wxt-dev/examples/tree/main/examples/dual-firefox-action I would recommend extensions stick to one action to make it easier to maintain your extension so it works on all browsers, but it is possible to do. For this PR, don't worry about this case, instead, we just care about supporting the single popup. I can help implement the rest if you're not sure how to make the change. |
|
Ok, I got ahead of myself there. To confirm, I don't actually need to support meta tags. The original fix I made works for adding page_action: {
default_popup: 'popout.html',
default_icon: icons,
show_matches: ['*://*/*'],
},So were back to just getting your new test to pass. I will revisit this today when I get a chance and let you know if I need more help. |
|
Correct. Your initial change prevented WXT from stripping |
|
Some more context about why I brought up the DetailsOne of WXT's core design choices is around configuring each entrypoint's options in their own files, not somewhere else. Similar to how content script https://wxt.dev/guide/essentials/entrypoints#defining-manifest-options That said, WXT doesn't stop you from defining some things in the |
|
So, it should be noted that While you can set your What this does, is creates an icon on the address bar when ever a show matches or show hide rule passes (can also be done programmatically). The key for the file to load when the icon clicked is called So if you want to support this with meta, we need to be able to set any html file as the That being said, the current fix, allowing me define the For reference, here is an extension that has a page_action and action (popup). The page action is in the address bar and only shows when the show_matches an address in the address bar. In this case they point point to the popup.html, but the idea is to reduce toolbar clutter and only show icons on the sites their needed for site specific addons. |
|
@aklinker1 I am currently confused on how to modify this because I don't quite understand how it is "expected" to work in this framework. It seems that you have a popup, and you can set the popup to be an But the reality is, you can have an So if you want a traditional "action": {
"default_popup": "popup.html",
"default_icon": {
"16": "images/logo16.png",
"24": "images/logo24.png",
"32": "images/logo32.png",
"48": "images/logo48.png",
"128": "images/logo128.png"
}
},And (firefox only) if you want a "page_action": {
"default_popup": "popup.html",
"default_icon": {
"16": "images/logo16.png",
"24": "images/logo24.png",
"32": "images/logo32.png",
"48": "images/logo48.png",
"96": "images/logo96.png",
"128": "images/logo128.png"
},
"show_matches": ["*://*/*"]
},Which is currently achievable with the changes in this PR as outlined above. I am just not sure how to make the newly added test pass. |
|
Replying to your first comment:
This is not true. MV3 combined the A page action is just another type of action. While it is true you can have neither, one, or both, that doesn't change the fact that they behave the exact same way once visible - if an HTML file is hooked up to it, a "popup" is shown. They all even have the same So in WXT you have a single "popup" entrypoint that can be configured to be added to the manifest as an
Everything you just said here is true for
You seem really focused on the case where you have both an As I have shown in the example I shared yesterday, it is possible to accomplish exactly what you just described, today, without the changes in this PR. It is possible to set meta properties on some other HTML entrypoint and treat it as the So I didn't view the issue or this PR as about adding support for including both a action and page action, you can already do that. I viewed this PR as adding support for respecting the Replying to your second comment:
Honestly, I didn't know that you could have both before you opened the original issue. So I designed WXT around only supporting one action. Even after learning it's possible to have two actions, I don't want to support that because in reality, if you want to release an extension to Chrome, you can't use both. So it's easier to design your extension around a single action and a single popup. That being said, forget about adding support for two actions in this PR. That might be your use-case, but that's not how the issue was worded, nor what the PR description describes. If you want to discuss supporting two actions in WXT, create a new feature request issue. But as I've described, I don't plan on adding this feature to the core WXT package. However, I would be open to adding the example's code into an official WXT module (like auto-icons) that adds this functionality to WXT. Let me describe what I'm looking for in this PR: Currently, WXT only supports a single popup HTML entrypoint. You choose to attach this HTML file to an action as the
This PR should modify the logic to support
Is it clear now why I added the test I added? Sorry for the long reply lol, it just felt like we are not on the same page at all, so I'm trying to explain my POV thoroughly. |
This is not how it works in Firefox. I only write cross-browser addons. In this case, The solution in this PR currently does this. I think we move forward with this as is, and not try to support anything else. |

Overview
Fix to allow
page_actionon Firefox MV3.Manual Testing
I have added the
page_actionto thewxt.config.tsand confirmed both chrome and firefox generate the proper manifest.json.Related Issue
page_actionto Firefox MV3 #2194