ui: focus scan name input and start scanning on Enter
'Profile from card' and 'New snapshot' now focus the name field when the dialog opens, and Enter in that field starts the scan (profilerScanNameKeydown, ignored while the Scan button is disabled). Tests for the key handler and the input wiring; SW cache v98 -> v99.
This commit is contained in:
@@ -21,7 +21,7 @@ function extractFunc(src, name, asyncFn) {
|
||||
return (asyncFn ? 'async ' : '') + src.slice(m.index, i + 1);
|
||||
}
|
||||
|
||||
const FNS = ['profilerNormHex', 'profilerNormHexStrict', 'profilerMatch', 'profilerMatchMin', 'profilerMaskPrefix4', 'profilerFileFields', 'profilerContentKindForFileType', 'profilerEmptyRecordContent', 'profilerValidateProfile', 'profilerCustomNameForPath', 'profilerUpdateRulePath', 'profilerResultAspects', 'profilerAspectSummary', 'profilerNumRanges', 'esc', 'escHtml', 'profilerRawDataCheck', 'profilerRenderReport', 'parseBerLen', 'parseTlvList', 'fcpInt', 'fcpParseTlvs', 'fcpFileDescriptor', 'fcpLifeCycle', 'fcpSfi', 'fcpDo', 'fcpDecode', 'fcpDiffHtml', 'profilerFciPreviewItems', 'profilerUpdateFciPreview', 'profilerUpdateRule', 'profilerFciInput', 'profilerScanToggleAll', 'profilerScanIgnoreAllState', 'swapNibbles', 'decIccid', 'profilerSnapshotIccid', 'profilerValidateSnapshot', 'profilerListSwitch', 'profilerScanRefreshOptions', 'profilerLiveSource', 'profilerSnapshotSource', 'profilerVisibleResults', 'profilerMaskFidForFile', 'profilerRulesFromSnapshot', 'profilerExtraFileResults'];
|
||||
const FNS = ['profilerNormHex', 'profilerNormHexStrict', 'profilerMatch', 'profilerMatchMin', 'profilerMaskPrefix4', 'profilerFileFields', 'profilerContentKindForFileType', 'profilerEmptyRecordContent', 'profilerValidateProfile', 'profilerCustomNameForPath', 'profilerUpdateRulePath', 'profilerResultAspects', 'profilerAspectSummary', 'profilerNumRanges', 'esc', 'escHtml', 'profilerRawDataCheck', 'profilerRenderReport', 'parseBerLen', 'parseTlvList', 'fcpInt', 'fcpParseTlvs', 'fcpFileDescriptor', 'fcpLifeCycle', 'fcpSfi', 'fcpDo', 'fcpDecode', 'fcpDiffHtml', 'profilerFciPreviewItems', 'profilerUpdateFciPreview', 'profilerUpdateRule', 'profilerFciInput', 'profilerScanToggleAll', 'profilerScanIgnoreAllState', 'swapNibbles', 'decIccid', 'profilerSnapshotIccid', 'profilerValidateSnapshot', 'profilerListSwitch', 'profilerScanRefreshOptions', 'profilerLiveSource', 'profilerSnapshotSource', 'profilerVisibleResults', 'profilerMaskFidForFile', 'profilerRulesFromSnapshot', 'profilerExtraFileResults', 'profilerScanNameKeydown'];
|
||||
let code = '';
|
||||
for (const f of FNS) code += extractFunc(html, f) + '\n';
|
||||
code += extractFunc(html, 'profilerBuildFileRule', true) + '\n';
|
||||
@@ -1112,3 +1112,21 @@ test('profilerExtraFileResults reports files missing from the master', () => {
|
||||
assert.strictEqual(extras[0].status, 'fail');
|
||||
assert.deepStrictEqual(extras[0].checks, [{ label: 'extra file', expected: 'absent', actual: 'present', ok: false }]);
|
||||
});
|
||||
|
||||
test('profilerScanNameKeydown starts the scan on Enter only', () => {
|
||||
const btn = { disabled: false };
|
||||
global.document = { getElementById: () => btn };
|
||||
let started = 0;
|
||||
global.profilerScanStart = () => { started++; };
|
||||
let prevented = 0;
|
||||
profilerScanNameKeydown({ key: 'Enter', preventDefault: () => prevented++ });
|
||||
profilerScanNameKeydown({ key: 'a', preventDefault: () => prevented++ });
|
||||
assert.strictEqual(started, 1);
|
||||
assert.strictEqual(prevented, 1);
|
||||
btn.disabled = true;
|
||||
profilerScanNameKeydown({ key: 'Enter', preventDefault: () => prevented++ });
|
||||
assert.strictEqual(started, 1);
|
||||
assert.strictEqual(prevented, 1);
|
||||
delete global.document;
|
||||
delete global.profilerScanStart;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user