scripting: prevent some functions to be marked as undefined
This commit is contained in:
parent
0ec4c9e2fb
commit
da3eecfdd4
4 changed files with 12 additions and 13 deletions
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
## 1.19.3
|
||||
|
||||
- bug fixes
|
||||
- scripting: prevent some functions to be marked as undefined
|
||||
|
||||
- misc
|
||||
- change noFocus client option behavior: the defalt client window now doesn't take the focus at all, even when a text input is clicked.
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ var UiModal = require('./ui-modal'),
|
|||
raw = require('nanohtml/raw'),
|
||||
{icon} = require('../ui/utils'),
|
||||
ace = require('brace'),
|
||||
ScriptVm = require('../widgets/scripts/script-vm'),
|
||||
scriptGlobals = ScriptVm.globals,
|
||||
scriptGlobals = require('../widgets/scripts/script-vm').globals,
|
||||
editors = {}, editorModes = {
|
||||
javascript: require('brace/mode/javascript'),
|
||||
css: require('brace/mode/css'),
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ var widgetManager = require('../../managers/widgets'),
|
|||
{deepCopy} = require('../../utils'),
|
||||
{urlParser} = require('../utils'),
|
||||
Vm = require('../vm'),
|
||||
toolbar,
|
||||
scriptGlobals = {empty:true}
|
||||
toolbar
|
||||
|
||||
|
||||
class ScriptVm extends Vm {
|
||||
|
|
@ -532,22 +531,21 @@ class ScriptVm extends Vm {
|
|||
|
||||
this.sandbox.contentWindow.Image = Image
|
||||
|
||||
this.globals = {}
|
||||
|
||||
for (var imports of ['set', 'get', 'getProp', 'getIndex', 'updateProp', 'send', 'httpGet', 'stateGet', 'stateSet', 'storage',
|
||||
'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'setFocus', 'unfocus' , 'setFocusable', 'setScroll', 'getScroll', 'toolbar',
|
||||
'openUrl', 'getVar', 'setVar', 'runAs', 'Image', 'updateCanvas']) {
|
||||
this.sanitize(this.sandbox.contentWindow[imports])
|
||||
this.globals[imports] = true
|
||||
}
|
||||
|
||||
if (scriptGlobals.empty){
|
||||
delete scriptGlobals.empty
|
||||
for (var k in this.sandbox.contentWindow) {
|
||||
if (window[k] === undefined) scriptGlobals[k] = true
|
||||
}
|
||||
ScriptVm.globals = scriptGlobals
|
||||
for (var k in this.sandbox.contentWindow) {
|
||||
if (window[k] === undefined) this.globals[k] = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ScriptVm
|
||||
module.exports = new ScriptVm()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
var ScriptVm = require('./script-vm'),
|
||||
scriptVm = new ScriptVm(),
|
||||
var scriptVm = require('./script-vm'),
|
||||
noop = ()=>{}
|
||||
|
||||
class Script {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue