Add query param to check if Blazor WASM app is under debug (#24972)
This commit is contained in:
parent
90408c0191
commit
5297d5fd39
File diff suppressed because one or more lines are too long
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue