Skip to content

Commit

Permalink
Add support of default_panel and default_icon for sidebar_action
Browse files Browse the repository at this point in the history
  • Loading branch information
ariasuni committed Apr 13, 2020
1 parent f0a81e5 commit a0767ca
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Assets resolved by this plugin:
- `browser_action.default_icon`
- `page_action.default_popup`
- `page_action.default_icon`
- `sidebar_action.default_panel`
- `sidebar_action.default_icon`
- `icons`
- `web_accessible_resources`
- `chrome_url_overrides.bookmarks`
Expand Down
21 changes: 21 additions & 0 deletions src/ManifestAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ManifestAsset extends Asset {
web_accessible_resources: this.processWebAccessibleResources,
browser_action: this.processBrowserAction,
page_action: this.processPageAction,
sidebar_action: this.processSidebarAction,
icons: this.processIcons,
options_ui: this.processOptionsUi,
options_page: this.processOptionsPage,
Expand Down Expand Up @@ -235,6 +236,26 @@ class ManifestAsset extends Asset {
}
}

processSidebarAction() {
const action = this.ast.sidebar_action
if (!action) {
return
}

if (action.default_panel) {
action.default_panel = this.processSingleDependency(
action.default_panel
)
}
const defaultIcon = action.default_icon
if (defaultIcon) {
action.default_icon =
typeof defaultIcon === 'string'
? this.processSingleDependency(defaultIcon)
: this.processAllIcons(defaultIcon)
}
}

processOptionsPage() {
// Chrome
const optionsPage = this.ast.options_page
Expand Down
4 changes: 4 additions & 0 deletions test/integration/web-extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
"options_ui": {
"page": "options.html"
},
"sidebar_action": {
"default_icon": "favicon.ico",
"default_panel": "sidebar.html"
},
"web_accessible_resources": [
"inject.js"
]
Expand Down
11 changes: 11 additions & 0 deletions test/integration/web-extension/sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>

<head>
<script src="sidebar/index.js"></script>
</head>

<body>
</body>

</html>
5 changes: 5 additions & 0 deletions test/integration/web-extension/sidebar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main()

function main() {
console.log('Hello, world!')
}
3 changes: 2 additions & 1 deletion test/web-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ describe('WebExtension', () => {
{ name: 'favicon.ico' },
{ name: 'inject.js' },
{ name: 'options.html' },
{ name: 'popup.html' }
{ name: 'popup.html' },
{ name: 'sidebar.html' }
]
})

Expand Down

0 comments on commit a0767ca

Please sign in to comment.