From d235b82ccfcb158ba7815c197c21634c802af885 Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Tue, 19 May 2026 11:24:27 +0800 Subject: [PATCH] Fix Plus strategy service worker bootstrap --- background.js | 4 ++-- tests/plus-account-access-strategy.test.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/background.js b/background.js index c35af28..367fe93 100644 --- a/background.js +++ b/background.js @@ -75,6 +75,8 @@ importScripts( ); const DEFAULT_ACTIVE_FLOW_ID = 'openai'; +const PLUS_ACCOUNT_ACCESS_STRATEGY_OAUTH = 'oauth'; +const PLUS_ACCOUNT_ACCESS_STRATEGY_SUB2API_CODEX_SESSION = 'sub2api_codex_session'; const NORMAL_STEP_DEFINITIONS = self.MultiPageStepDefinitions?.getSteps?.({ activeFlowId: DEFAULT_ACTIVE_FLOW_ID, plusModeEnabled: false, @@ -654,8 +656,6 @@ const FIVE_SIM_OPERATOR = DEFAULT_FIVE_SIM_OPERATOR; const PLUS_PAYMENT_METHOD_PAYPAL = 'paypal'; const PLUS_PAYMENT_METHOD_GOPAY = 'gopay'; const PLUS_PAYMENT_METHOD_GPC_HELPER = 'gpc-helper'; -const PLUS_ACCOUNT_ACCESS_STRATEGY_OAUTH = 'oauth'; -const PLUS_ACCOUNT_ACCESS_STRATEGY_SUB2API_CODEX_SESSION = 'sub2api_codex_session'; const DEFAULT_PLUS_PAYMENT_METHOD = PLUS_PAYMENT_METHOD_PAYPAL; const DISPLAY_TIMEZONE = 'Asia/Shanghai'; const MICROSOFT_TOKEN_DNR_RULE_ID = 1001; diff --git a/tests/plus-account-access-strategy.test.js b/tests/plus-account-access-strategy.test.js index 13501c7..84fe8d0 100644 --- a/tests/plus-account-access-strategy.test.js +++ b/tests/plus-account-access-strategy.test.js @@ -3,6 +3,7 @@ const assert = require('node:assert/strict'); const fs = require('node:fs'); const sidepanelSource = fs.readFileSync('sidepanel/sidepanel.js', 'utf8'); +const backgroundSource = fs.readFileSync('background.js', 'utf8'); function extractFunction(name) { const markers = [`async function ${name}(`, `function ${name}(`]; @@ -268,3 +269,15 @@ return { }, ]); }); + +test('background declares Plus account access strategy constants before precomputing session-tail step definitions', () => { + const strategyConstantIndex = backgroundSource.indexOf("const PLUS_ACCOUNT_ACCESS_STRATEGY_SUB2API_CODEX_SESSION = 'sub2api_codex_session';"); + const precomputedSessionStepsIndex = backgroundSource.indexOf('const PLUS_PAYPAL_SUB2API_SESSION_STEP_DEFINITIONS ='); + + assert.ok(strategyConstantIndex >= 0, 'expected Plus account access strategy constant declaration'); + assert.ok(precomputedSessionStepsIndex >= 0, 'expected precomputed SUB2API session step definitions'); + assert.ok( + strategyConstantIndex < precomputedSessionStepsIndex, + 'strategy constant must be declared before background precomputes session-tail step definitions' + ); +});