-
Notifications
You must be signed in to change notification settings - Fork 385
fix: Fixed Chrome Not Opening Extensions Pages provided in URL #2321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
a163a3c
2f86d4a
d485a71
8ca4550
7b56d10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,8 +150,28 @@ export class ChromiumExtensionRunner { | |
| }); | ||
| }); | ||
|
|
||
| const chromeFlags = [...DEFAULT_CHROME_FLAGS]; | ||
| let startingUrl; | ||
| var specialStartingUrls = ''; | ||
| if (this.params.startUrl) { | ||
| const startingUrls = Array.isArray(this.params.startUrl) ? | ||
| this.params.startUrl : [this.params.startUrl]; | ||
|
|
||
| // Remove URLs starting with chrome:// from startingUrls and let bg.js open them instead | ||
| for (let i = 0; i < startingUrls.length; i++) { | ||
| if (startingUrls[i].toLowerCase().startsWith('chrome://')) { | ||
| specialStartingUrls += startingUrls[i] + " " | ||
| startingUrls.splice(i, 1) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By removing the element during the iteration, you'll end up skipping URLs. For example: At To fix this, you could iterate over the URLs in reverse order and prepend the URLs to the |
||
| } | ||
| } | ||
|
|
||
| startingUrl = startingUrls.shift(); | ||
|
|
||
| chromeFlags.push(...startingUrls); | ||
| } | ||
|
|
||
| // Create the extension that will manage the addon reloads | ||
| this.reloadManagerExtension = await this.createReloadManagerExtension(); | ||
| this.reloadManagerExtension = await this.createReloadManagerExtension(specialStartingUrls); | ||
|
|
||
| // Start chrome pointing it to a given profile dir | ||
| const extensions = [this.reloadManagerExtension].concat( | ||
|
|
@@ -166,8 +186,6 @@ export class ChromiumExtensionRunner { | |
| log.debug(`(chromiumBinary: ${chromiumBinary})`); | ||
| } | ||
|
|
||
| const chromeFlags = [...DEFAULT_CHROME_FLAGS]; | ||
|
|
||
| chromeFlags.push(`--load-extension=${extensions}`); | ||
|
|
||
| if (this.params.args) { | ||
|
|
@@ -213,13 +231,6 @@ export class ChromiumExtensionRunner { | |
| chromeFlags.push(`--profile-directory=${profileDirName}`); | ||
| } | ||
|
|
||
| let startingUrl; | ||
| if (this.params.startUrl) { | ||
| const startingUrls = Array.isArray(this.params.startUrl) ? | ||
| this.params.startUrl : [this.params.startUrl]; | ||
| startingUrl = startingUrls.shift(); | ||
| chromeFlags.push(...startingUrls); | ||
| } | ||
|
|
||
| this.chromiumInstance = await this.chromiumLaunch({ | ||
| enableExtensions: true, | ||
|
|
@@ -280,7 +291,7 @@ export class ChromiumExtensionRunner { | |
| }); | ||
| } | ||
|
|
||
| async createReloadManagerExtension(): Promise<string> { | ||
| async createReloadManagerExtension(specialStartingUrls: string): Promise<string> { | ||
| const tmpDir = new TempDir(); | ||
| await tmpDir.create(); | ||
| this.registerCleanup(() => tmpDir.remove()); | ||
|
|
@@ -334,6 +345,19 @@ export class ChromiumExtensionRunner { | |
| const ws = new window.WebSocket( | ||
| "ws://${wssInfo.address}:${wssInfo.port}"); | ||
|
|
||
|
|
||
| if (${specialStartingUrls.length} > 0) | ||
| { | ||
| const chromeTabList = "${specialStartingUrls}".trim().split(" ") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Serialize the list of URLs with |
||
| chrome.runtime.onInstalled.addListener(details => { | ||
| if (details.reason === chrome.runtime.OnInstalledReason.INSTALL ) { | ||
| chromeTabList.forEach(url => { | ||
| chrome.tabs.create({ url }); | ||
| }); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespace is off, please fix this. |
||
| }); | ||
| } | ||
|
|
||
| ws.onmessage = async (evt) => { | ||
| const msg = JSON.parse(evt.data); | ||
| if (msg.type === 'webExtReloadAllExtensions') { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URLs should be appended to an array, not to a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. I had a hard time with template literals and arrays that's why I used string with spaces, but JSON.stringify() solves both this problem and potential code injection issue you mentioned nicely!