修正 shouldFnBind 兼容 Proxy Function#985
Merged
Merged
Conversation
Member
|
我这里启用了 AdGuard 就会出现这个问题(扩展拿不到最原始的fetch),关闭这个问题就消失了(拿到了最原始的fetch),这个问题也好奇怪(TM也是如此) 之前也有因为 AdGuard 产生的问题: #773 (comment)
|
Collaborator
Author
你用这个PR的跑跑看 |
Collaborator
Author
|
先改一下单元测试 |
Collaborator
Author
|
修改完了 |
Contributor
There was a problem hiding this comment.
Pull Request Overview
此 PR 修复了沙盒环境中无法正确识别被 Proxy 包装的原生函数的问题。当浏览器扩展(如广告拦截器)使用 Proxy 封装原生函数时,shouldFnBind 函数无法正确识别这些函数,导致 Illegal invocation 错误。
主要变更:
- 重构了原生函数检测逻辑,支持识别 Proxy 包装的原生函数
- 完善测试覆盖,包括单元测试和集成测试
- 修正注释中的拼写错误
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/app/service/content/create_context.ts | 重构 getNativeCodeSegs 函数返回前缀和后缀,修改 shouldFnBind 以支持检测 Proxy 包装的原生函数 |
| src/app/service/content/create_context.test.ts | 新增单元测试验证 shouldFnBind 对 Proxy 函数的处理 |
| src/app/service/content/exec_script.test.ts | 更新集成测试,添加 Proxy Function 测试用例,修正注释拼写 |
| tests/vitest.setup.ts | 添加 setTimeoutForTest2 作为 Proxy 包装函数的测试桩 |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.






概述 Descriptions
我似乎又遇到了一个沙盒问题,使用 Bilibili-Evolved 安装插件,下载视频,会出现下面这个错误,看起来是fetch没有.bind
https://www.bilibili.com/video/BV1zuxbzFEJd/
一个最小化可复现脚本:
变更内容 Changes
截图 Screenshots