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

Add query param to check if Blazor WASM app is under debug #24972

Merged
1 commit merged into from
Aug 18, 2020
Merged
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
2 changes: 1 addition & 1 deletion src/Components/Web.JS/dist/Release/blazor.webassembly.js

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion src/Components/Web.JS/src/Platform/Mono/MonoDebugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ import { WebAssemblyResourceLoader } from '../WebAssemblyResourceLoader';
const currentBrowserIsChrome = (window as any).chrome
&& navigator.userAgent.indexOf('Edge') < 0; // Edge pretends to be Chrome

let isDebugging = true;

window.addEventListener('load', () => {
const params = new URLSearchParams(window.location.search);
isDebugging = params.get('_blazor_debug') === 'true';
captainsafia marked this conversation as resolved.
Show resolved Hide resolved
})

let hasReferencedPdbs = false;

export function hasDebuggingEnabled() {
return hasReferencedPdbs && currentBrowserIsChrome;
return isDebugging && hasReferencedPdbs && currentBrowserIsChrome;
}

export function attachDebuggerHotkey(resourceLoader: WebAssemblyResourceLoader) {
Expand All @@ -26,6 +33,8 @@ export function attachDebuggerHotkey(resourceLoader: WebAssemblyResourceLoader)
console.error('Cannot start debugging, because the application was not compiled with debugging enabled.');
} else if (!currentBrowserIsChrome) {
console.error('Currently, only Microsoft Edge (80+), or Google Chrome, are supported for debugging.');
} else if (!isDebugging) {
console.error(`_blazor_debug query parameter must be set to enable debugging. To enable debugging, go to ${location.href}?_blazor_debug=true.`);
} else {
launchDebugger();
}
Expand Down