Skip to content

🐛 修复 Edge Dev 下脚本注入静默失效 - #1725

Open
mikemikimike wants to merge 1 commit into
scriptscat:mainfrom
mikemikimike:fix/issue-1724-c2
Open

🐛 修复 Edge Dev 下脚本注入静默失效#1725
mikemikimike wants to merge 1 commit into
scriptscat:mainfrom
mikemikimike:fix/issue-1724-c2

Conversation

@mikemikimike

Copy link
Copy Markdown

Checklist / 检查清单

  • Fixes mentioned issues / 修复已提及的问题
  • Code reviewed by human / 代码通过人工检查
  • Changes tested / 已完成测试

Background

On Edge Dev 154, user scripts can silently stop working because the registration guard only checks scriptcat-inject. When scriptcat-scripting is missing, the guard returns early and the broadcaster is not recreated. The isolated-world environment reader can also throw when chrome.extension is unavailable.

Changes

  • Check the registered scriptcat-scripting content script together with scriptcat-inject before skipping registration.
  • Re-run the registration path when either registration is missing.
  • Read chrome.extension.inIncognitoContext defensively and default to false when the API is unavailable.
  • Add regression tests for recovery, idempotent registration, and the missing chrome.extension API.

Implementation considerations

The existing registration flow remains responsible for unregistering and recreating missing registrations. The additional content-script query is only used by the already-registered fast path, so valid registrations continue to avoid duplicate work.

Known limitations

The full CI test command completed with 4421 passed and 38 failures across 15 files. The failures are existing environment-, timing-, and Windows-path-sensitive failures; the changed test files passed. GitHub Actions for fork pull requests may require maintainer approval before jobs run.

Review focus

  • Verify the scriptcat-scripting registration check matches the broadcaster registration lifecycle.
  • Verify the optional chrome.extension access is compatible with all supported extension contexts.
  • Confirm the recovery path remains idempotent when both registrations exist.

References

Issue 1724 reports the Edge Dev 154 regression and identifies both affected code paths.

Related

Refs #1724

Validation

  • node pnpm.cjs exec vitest run src/app/service/extension/extension_env.test.ts src/app/service/service_worker/runtime.test.ts — 58 passed.
  • node pnpm.cjs run typecheck — passed.
  • node pnpm.cjs run lint — passed.
  • node pnpm.cjs run build — passed with existing asset-size and dynamic-require warnings.
  • node pnpm.cjs run test:ci — 4421 passed, 38 existing environment/timing/path failures.

Screenshots / 截图

@cyfung1031 cyfung1031 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CodFrm looks good to me. please follow up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants