feat: 添加共享 Kiro 超时模块并更新相关文件以使用统一的页面加载超时预算

This commit is contained in:
QLHazyCoder
2026-05-19 00:09:20 +08:00
parent 6c664ca5bc
commit e197d1e726
9 changed files with 195 additions and 29 deletions
@@ -46,3 +46,12 @@ test('parseDesktopCallbackUrl validates state and redirect port', () => {
);
assert.equal(badPort, null);
});
test('kiro desktop authorize runner uses a shared 3-minute page-load timeout budget', () => {
const source = fs.readFileSync('background/kiro/desktop-authorize-runner.js', 'utf8');
assert.match(source, /DEFAULT_KIRO_PAGE_LOAD_TIMEOUT_MS/);
assert.match(source, /createTimeoutBudget/);
assert.match(source, /resolveTimeoutBudget/);
assert.match(source, /timeoutBudget\.getRemainingMs\(1000\)/);
assert.match(source, /onRetryableError: buildDesktopRetryRecovery\(tabId, \{\s*\.\.\.options,\s*timeoutBudget,/);
});
@@ -57,3 +57,12 @@ test('startBuilderIdDeviceLogin registers Builder ID client and returns login bo
assert.equal(result.interval, 7);
assert.equal(result.region, 'us-east-1');
});
test('kiro register runner uses a shared 3-minute page-load timeout budget', () => {
const source = fs.readFileSync('background/kiro/register-runner.js', 'utf8');
assert.match(source, /DEFAULT_KIRO_PAGE_LOAD_TIMEOUT_MS/);
assert.match(source, /createTimeoutBudget/);
assert.match(source, /resolveTimeoutBudget/);
assert.match(source, /timeoutBudget\.getRemainingMs\(1000\)/);
assert.match(source, /onRetryableError: buildKiroRetryRecovery\(tabId, \{\s*\.\.\.options,\s*timeoutBudget,/);
});
+1
View File
@@ -16,6 +16,7 @@ test('background imports workflow step modules including rebuilt Kiro modules',
'background/steps/fetch-login-code.js',
'background/steps/confirm-oauth.js',
'background/steps/platform-verify.js',
'shared/kiro-timeouts.js',
'background/kiro/state.js',
'background/kiro/register-runner.js',
'background/kiro/desktop-client.js',
+13
View File
@@ -15,6 +15,7 @@ test('background imports shared source registry module', () => {
assert.match(source, /shared\/flow-registry\.js/);
assert.match(source, /shared\/settings-schema\.js/);
assert.match(source, /shared\/source-registry\.js/);
assert.match(source, /shared\/kiro-timeouts\.js/);
});
test('manifest loads shared source registry before content utils in static bundles', () => {
@@ -41,6 +42,18 @@ test('manifest no longer ships a static Kiro content bundle', () => {
assert.equal(hasStaticKiroBundle, false);
});
test('background injects shared Kiro timeout module before Kiro content scripts', () => {
const source = fs.readFileSync('background.js', 'utf8');
assert.match(
source,
/const KIRO_REGISTER_INJECT_FILES = \['shared\/source-registry\.js', 'shared\/kiro-timeouts\.js', 'content\/utils\.js', 'content\/kiro\/register-page\.js'\];/
);
assert.match(
source,
/const KIRO_DESKTOP_AUTHORIZE_INJECT_FILES = \['shared\/source-registry\.js', 'shared\/kiro-timeouts\.js', 'content\/utils\.js', 'content\/kiro\/desktop-authorize-page\.js'\];/
);
});
test('shared source registry exposes canonical Kiro sources and drivers', () => {
const registry = loadSourceRegistry();