fix: Allow actions without a popup (#181)
This commit is contained in:
@@ -599,4 +599,29 @@ describe('Manifest Content', () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('should respect the action field in the manifest without a popup', async () => {
|
||||
const project = new TestProject();
|
||||
project.setConfigFileConfig({
|
||||
manifest: {
|
||||
action: {
|
||||
default_title: 'Hello world',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await project.build();
|
||||
|
||||
expect(await project.getOutputManifest()).toMatchInlineSnapshot(`
|
||||
{
|
||||
"action": {
|
||||
"default_title": "Hello world",
|
||||
},
|
||||
"description": "Example description",
|
||||
"manifest_version": 3,
|
||||
"name": "E2E Extension",
|
||||
"version": "0.0.0",
|
||||
}
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -468,17 +468,13 @@ export interface ExcludableEntrypoint {
|
||||
export type UserManifest = Partial<
|
||||
Omit<
|
||||
Manifest.WebExtensionManifest,
|
||||
| 'action'
|
||||
| 'background'
|
||||
| 'browser_action'
|
||||
| 'chrome_url_overrides'
|
||||
| 'devtools_page'
|
||||
| 'manifest_version'
|
||||
| 'options_page'
|
||||
| 'options_ui'
|
||||
| 'sandbox'
|
||||
| 'page_action'
|
||||
| 'popup'
|
||||
| 'sidepanel'
|
||||
| 'sidebar_action'
|
||||
>
|
||||
|
||||
@@ -214,18 +214,23 @@ function addEntrypoints(
|
||||
config.outDir,
|
||||
'.html',
|
||||
);
|
||||
const options: Manifest.ActionManifest = {
|
||||
default_icon: popup.options.defaultIcon,
|
||||
default_title: popup.options.defaultTitle,
|
||||
browser_style: popup.options.browserStyle,
|
||||
};
|
||||
const options: Manifest.ActionManifest = {};
|
||||
if (popup.options.defaultIcon)
|
||||
options.default_icon = popup.options.defaultIcon;
|
||||
if (popup.options.defaultTitle)
|
||||
options.default_title = popup.options.defaultTitle;
|
||||
if (popup.options.browserStyle)
|
||||
options.browser_style = popup.options.browserStyle;
|
||||
if (manifest.manifest_version === 3) {
|
||||
manifest.action = {
|
||||
...(manifest.action ?? {}),
|
||||
...options,
|
||||
default_popup,
|
||||
};
|
||||
} else {
|
||||
manifest[popup.options.mv2Key ?? 'browser_action'] = {
|
||||
const key = popup.options.mv2Key ?? 'browser_action';
|
||||
manifest[key] = {
|
||||
...(manifest[key] ?? {}),
|
||||
...options,
|
||||
default_popup,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user