Skip to content
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

[WIP] Add Firefox support #216

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions ext-src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,18 @@ export default class Browser extends EventEmitter {
if (this.config.chromeExecutable) {
chromePath = this.config.chromeExecutable;
}

let extensionSettings = vscode.workspace.getConfiguration('browser-preview');
let ignoreHTTPSErrors = extensionSettings.get<boolean>('ignoreHttpsErrors');
let shouldUseFirefox = extensionSettings.get<boolean>('firefoxMode');
// Detect remote debugging port
this.remoteDebugPort = await getPort({ port: 9222, host: '127.0.0.1' });
chromeArgs.push(`--remote-debugging-port=${this.remoteDebugPort}`);
if (shouldUseFirefox) {
chromeArgs.push(`--remote-debugging-port=${this.remoteDebugPort}`);
chromeArgs.push('-wait-for-browser');
} else {
var arg = `--remote-debugging-port=${this.remoteDebugPort}`;
}
chromeArgs.push(arg);

if (!chromePath) {
this.telemetry.sendEvent('error', {
Expand All @@ -49,13 +57,21 @@ export default class Browser extends EventEmitter {
chromeArgs.push('--no-sandbox');
}

let extensionSettings = vscode.workspace.getConfiguration('browser-preview');
let ignoreHTTPSErrors = extensionSettings.get<boolean>('ignoreHttpsErrors');
this.browser = await puppeteer.launch({
executablePath: chromePath,
args: chromeArgs,
ignoreHTTPSErrors
});
if (shouldUseFirefox) {
this.browser = await puppeteer.launch({
executablePath: chromePath,
args: chromeArgs,
product: 'firefox',
headless: false,
ignoreHTTPSErrors
});
} else {
this.browser = await puppeteer.launch({
executablePath: chromePath,
args: chromeArgs,
ignoreHTTPSErrors
});
}
}

public async newPage(): Promise<BrowserPage> {
Expand Down
Loading