Skip to content

Commit

Permalink
Add query param to check if Blazor WASM app is under debug (#24972)
Browse files Browse the repository at this point in the history
  • Loading branch information
captainsafia authored Aug 18, 2020
1 parent 90408c0 commit 5297d5f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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';
})

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

0 comments on commit 5297d5f

Please sign in to comment.