Commit aa034381 authored by Michael Droettboom's avatar Michael Droettboom

Proxy compatibility for Chrome

parent 670473f2
......@@ -142,6 +142,12 @@ EM_JS(int, pyproxy_init, (), {
isPyProxy: function(jsobj) {
return jsobj['$$'] !== undefined && jsobj['$$']['type'] === 'PyProxy';
},
addExtraKeys: function(result) {
result.push('toString');
result.push('prototype');
result.push('arguments');
result.push('caller');
},
isExtensible: function() { return true },
has: function (jsobj, jskey) {
ptrobj = this.getPtr(jsobj);
......@@ -197,8 +203,7 @@ EM_JS(int, pyproxy_init, (), {
var idresult = __pyproxy_ownKeys(ptrobj);
var jsresult = Module.hiwire_get_value(idresult);
Module.hiwire_decref(idresult);
jsresult.push('toString');
jsresult.push('prototype');
this.addExtraKeys(jsresult);
return jsresult;
},
enumerate: function (jsobj) {
......@@ -206,8 +211,7 @@ EM_JS(int, pyproxy_init, (), {
var idresult = __pyproxy_enumerate(ptrobj);
var jsresult = Module.hiwire_get_value(idresult);
Module.hiwire_decref(idresult);
jsresult.push('toString');
jsresult.push('prototype');
this.addExtraKeys(jsresult);
return jsresult;
},
apply: function (jsobj, jsthis, jsargs) {
......
......@@ -125,7 +125,7 @@ def test_pyproxy(selenium):
'__lt__', '__module__', '__ne__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__',
'__str__', '__subclasshook__', '__weakref__', 'bar', 'baz',
'get_value', 'toString', 'prototype'])
'get_value', 'toString', 'prototype', 'arguments', 'caller'])
assert selenium.run("hasattr(f, 'baz')")
selenium.run_js("delete pyodide.pyimport('f').baz")
assert not selenium.run("hasattr(f, 'baz')")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment