Bugfix for document.doctype (#85)

This commit is contained in:
DarkCat09 2023-06-30 10:26:04 +04:00
parent 5132b5ea3a
commit cfee59d119
2 changed files with 14 additions and 7 deletions

View file

@ -135,12 +135,15 @@ class Js2PyInterpreter(Interpreter):
super().__init__()
ctx = js2py.EvalJs({'atob': atob})
ctx.execute('window.document = { };')
ctx.execute('window.Map = function(_i){ };')
ctx.execute('window.setTimeout = function(_f,_t){ };')
ctx.execute('window.setInterval = function(_f,_t){ };')
ctx.execute('document.getElementById = function(_a) { };')
ctx.execute('window.encodeURIComponent = function(_s){ };')
ctx.execute('''
window.Map = function(_i){ };
window.setTimeout = function(_f,_t){ };
window.setInterval = function(_f,_t){ };
window.encodeURIComponent = function(_s){ };
window.document = { };
document.doctype = { };
document.getElementById = function(_s){ };
''')
self.ctx = ctx

View file

@ -14,9 +14,13 @@ const vm = new VM({
atob: atob,
setTimeout: (_a, _b) => {},
setInterval: (_a, _b) => {},
document: {
getElementById: (_i) => {},
doctype: {},
},
},
})
vm.run('var window = global; var document = {}')
vm.run('var window = global')
const listener = (req, res) => {