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

launch Microsoft Edge with specified args #623

Merged
merged 4 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@
"description": "Launch Microsoft Edge in headless mode. (requires relaunching Visual Studio Code)",
"default": false
},
"vscode-edge-devtools.enableCors": {
"type": "boolean",
"description": "Launch Microsoft Edge with cors enabled. (requires relaunching Visual Studio Code)",
"default": false
},
"vscode-edge-devtools.timeout": {
"type": "number",
"description": "The number of milliseconds that the Microsoft Edge Tools will keep trying to attach the browser before timing out",
Expand Down
14 changes: 14 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,16 @@ export async function launchBrowser(browserPath: string, port: number, targetUrl
];

const headless: boolean = isHeadlessEnabled();
const corsEnabled: boolean = isCorsEnabled();

if (userDataDir) {
args.unshift(`--user-data-dir=${userDataDir}`);
}

if (corsEnabled) {
args.unshift('--disable-web-security');
hkal marked this conversation as resolved.
Show resolved Hide resolved
}

const browserInstance = await puppeteer.launch({executablePath: browserPath, args, headless});
return browserInstance;
}
Expand Down Expand Up @@ -611,6 +616,15 @@ export function isHeadlessEnabled(): boolean {
return headless;
}

/**
* Verifies if the cors checkbox in extension settings is enabled.
*/
export function isCorsEnabled(): boolean {
const settings = vscode.workspace.getConfiguration(SETTINGS_STORE_NAME);
const enableCors: boolean = settings.get('enableCors') || false;
return enableCors;
}

/**
* Replaces the workspaceFolder placeholder in a specified path, returns the
* given path with file disk path.
Expand Down