File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -135,7 +135,19 @@ Object.keys(descs).forEach((key) => {
135135export function proxyContext ( global : any , context : any ) {
136136 const special = Object . assign ( writables ) ;
137137 // 后台脚本要不要考虑不能使用eval?
138- const thisContext : { [ key : string ] : any } = { eval : global . eval } ;
138+ const thisContext : { [ key : string ] : any } = {
139+ eval : global . eval ,
140+ } ;
141+ // keyword是与createContext时同步的,避免访问到context的内部变量
142+ const contextKeyword : { [ key : string ] : any } = {
143+ message : 1 ,
144+ valueChangeListener : 1 ,
145+ connect : 1 ,
146+ runFlag : 1 ,
147+ valueUpdate : 1 ,
148+ sendMessage : 1 ,
149+ scriptRes : 1 ,
150+ } ;
139151 // @ts -ignore
140152 const proxy = new Proxy ( context , {
141153 defineProperty ( _ , name , desc ) {
@@ -167,6 +179,9 @@ export function proxyContext(global: any, context: any) {
167179 return thisContext [ name ] ;
168180 }
169181 if ( context [ name ] ) {
182+ if ( contextKeyword [ name ] ) {
183+ return undefined ;
184+ }
170185 return context [ name ] ;
171186 }
172187 if ( special [ name ] !== undefined ) {
@@ -210,9 +225,9 @@ export function proxyContext(global: any, context: any) {
210225 return true ;
211226 }
212227 if ( context [ name ] ) {
213- return true ;
214- }
215- if ( thisContext [ name ] ) {
228+ if ( contextKeyword [ name ] ) {
229+ return false ;
230+ }
216231 return true ;
217232 }
218233 if ( special [ name ] !== undefined ) {
You can’t perform that action at this time.
0 commit comments