Files
node/test/parallel/test-inspector-dom-storage.js
Avocado 37305e1128 inspector: report an error when DOM storage is unavailable
getDOMStorageItems() falls back to reading the live Storage object when
its cached map is empty. When getWebStorage() cannot produce one, the
fallback was skipped and the command still answered with Success and an
empty entries array, so a frontend could not tell an empty store from a
store that cannot be read.

getWebStorage() returns nothing whenever globalThis.localStorage is
missing or is not an object, which is the case for any process started
without --localstorage-file.

Return a ServerError in that case, matching how the other failure paths
in the same command report problems.

Reading the storage key in that same configuration aborted the process:
localstorage_file is an empty string, and std::filesystem::absolute()
throws on it under libstdc++ while returning the current directory
under libc++. Node builds without exceptions, so the throw terminated
the process. Use the error_code overloads of absolute() and
weakly_canonical() and report the failure through DispatchResponse.

Fixes: https://github.com/nodejs/node/issues/65895
Signed-off-by: Avocado <ujubongbong@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65973
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-09-18 05:37:29 +00:00

23 lines
724 B
JavaScript

'use strict';
const common = require('../common');
common.skipIfSQLiteMissing();
common.skipIfInspectorDisabled();
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
spawnSyncAndExitWithoutError(process.execPath, [
'--inspect=0',
'--experimental-storage-inspection',
'--localstorage-file=./localstorage.db',
fixtures.path('test-inspector-dom-storage.mjs'),
], { cwd: tmpdir.path });
spawnSyncAndExitWithoutError(process.execPath, [
'--inspect=0',
'--experimental-storage-inspection',
fixtures.path('test-inspector-dom-storage-unavailable.mjs'),
], { cwd: tmpdir.path });