script-vm: fix setTimeout/setInterval override
This commit is contained in:
parent
f4af775a98
commit
1aa3fbfef5
1 changed files with 13 additions and 13 deletions
|
|
@ -53,6 +53,19 @@ class Vm {
|
|||
|
||||
// global context
|
||||
this.globals = {}
|
||||
this.globals.console = {
|
||||
...console,
|
||||
log: (...msg)=>{
|
||||
msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m) : m)
|
||||
this.getWidget().log(msg.join(' '))
|
||||
}
|
||||
}
|
||||
|
||||
this.globals.setTimeout =
|
||||
this.globals.setInterval = ()=>{
|
||||
throw 'setTimeout and setInterval can\'t be used in the JS sandbox'
|
||||
}
|
||||
|
||||
this.registerGlobals()
|
||||
|
||||
// detach sandbox
|
||||
|
|
@ -75,19 +88,6 @@ class Vm {
|
|||
|
||||
registerGlobals() {
|
||||
|
||||
this.globals.console = {
|
||||
...console,
|
||||
log: (...msg)=>{
|
||||
msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m) : m)
|
||||
this.getWidget().log(msg.join(' '))
|
||||
}
|
||||
}
|
||||
|
||||
this.globals.setTimeout =
|
||||
this.globals.setInterval = ()=>{
|
||||
throw 'setTimeout and setInterval can\'t be used in the JS sandbox'
|
||||
}
|
||||
|
||||
this.globals.globals = globals
|
||||
|
||||
for (var k in this.globals) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue