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

This commit is contained in:
Safia Abdalla 2020-08-18 11:16:02 -07:00 committed by GitHub
parent 90408c0191
commit 5297d5fd39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -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';
})
let hasReferencedPdbs = false;
export function hasDebuggingEnabled() {
return hasReferencedPdbs && currentBrowserIsChrome;
return isDebugging && hasReferencedPdbs && currentBrowserIsChrome;
}
export function attachDebuggerHotkey(resourceLoader: WebAssemblyResourceLoader) {
@ -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();
}