Skip to content
Open
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
22 changes: 18 additions & 4 deletions js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,25 @@ export const TOKEN_ICON_CONFIG = {
export const getAllNetworks = () => Object.values(networkConfig);

export const isDebugEnabled = (component) => {
// Check if debug mode is forced via localStorage
const localDebug = localStorage.getItem('debug');
let localDebug;
try {
localDebug = localStorage.getItem('debug');
} catch {
return DEBUG_CONFIG[component];
}
if (localDebug) {
const debugSettings = JSON.parse(localDebug);
return debugSettings[component] ?? DEBUG_CONFIG[component];
try {
const debugSettings = JSON.parse(localDebug);
if (debugSettings && typeof debugSettings === 'object') {
return debugSettings[component] ?? DEBUG_CONFIG[component];
}
} catch {
try {
localStorage.removeItem('debug');
} catch {
// Ignore storage cleanup failures and fall back to defaults.
}
}
}
return DEBUG_CONFIG[component];
};
Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/wallet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,16 @@ test('keeps app disconnect wired when a wallet appears after read-only startup',
await expect(page.locator('.liberdus-wallet-connect__button')).toBeVisible();
await expect.poll(() => page.evaluate(() => window.walletManager?.getAccount?.())).toBeNull();
});

test('ignores invalid debug settings stored in localStorage', async ({ page }) => {
await installWalletBeforeLoad(page);
await page.addInitScript(() => {
window.localStorage.setItem('debug', '{invalid-json');
});

await page.goto('/');

await waitForWalletUi(page);
await expect(page.locator('.liberdus-wallet-connect__button')).toBeVisible();
await expect.poll(() => page.evaluate(() => window.localStorage.getItem('debug'))).toBeNull();
});