micropython/tests/ports/webassembly
Damien George 95c19e05ff webassembly/objjsproxy: Lookup attributes without testing they exist.
In JavaScript when accessing an attribute such as `obj.attr` a value of
`undefined` is returned if the attribute does not exist.  This is unlike
Python semantics where an `AttributeError` is raised.  Furthermore, in some
cases in JavaScript (eg a Proxy instance) `attr in obj` can return false
yet `obj.attr` is still valid and returns something other than `undefined`.
So the source of truth for whether a JavaScript attribute exists is to just
right away attempt `obj.attr`.

To more closely match these JavaScript semantics when proxying a JavaScript
object through to Python, change the attribute lookup logic on a `JsProxy`
so that it immediately attempts `obj.attr` instead of first testing if the
attribute exists via `attr in obj`.

This allows JavaScript objects which dynamically create attributes to work
correctly on the Python side, with both `obj.attr` and `obj["attr"]`.  Note
that `obj["attr"]` already works in all cases because it immediately does
the subscript access without first testing if the attribute exists.

As a benefit, this new behaviour matches the Pyodide behaviour.

Signed-off-by: Damien George <damien@micropython.org>
2024-06-28 11:40:24 +10:00
..
asyncio_await_resolve_no_arg.mjs webassembly/asyncio: Fix case where a Promise is resolved with no arg. 2024-05-13 11:48:41 +10:00
asyncio_await_resolve_no_arg.mjs.exp webassembly/asyncio: Fix case where a Promise is resolved with no arg. 2024-05-13 11:48:41 +10:00
asyncio_create_task.mjs webassembly: Add JavaScript-based asyncio support. 2024-04-24 16:24:00 +10:00
asyncio_create_task.mjs.exp webassembly: Add JavaScript-based asyncio support. 2024-04-24 16:24:00 +10:00
asyncio_sleep.mjs webassembly: Add JavaScript-based asyncio support. 2024-04-24 16:24:00 +10:00
asyncio_sleep.mjs.exp webassembly: Add JavaScript-based asyncio support. 2024-04-24 16:24:00 +10:00
asyncio_top_level_await.mjs webassembly/asyncio: Schedule run loop when tasks are pushed to queue. 2024-06-20 00:11:54 +10:00
asyncio_top_level_await.mjs.exp webassembly/asyncio: Schedule run loop when tasks are pushed to queue. 2024-06-20 00:11:54 +10:00
await_error_handling.mjs webassembly/proxy_c: Ensure objs thrown into generators are exceptions. 2024-05-13 11:52:17 +10:00
await_error_handling.mjs.exp webassembly/proxy_js: Create a special "undefined" type for Python. 2024-05-16 12:49:10 +10:00
await_js_async_py.mjs webassembly/proxy_c: Ensure return value of async fun is passed to JS. 2024-03-30 13:13:51 +11:00
await_js_async_py.mjs.exp webassembly/proxy_c: Ensure return value of async fun is passed to JS. 2024-03-30 13:13:51 +11:00
basic.js tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
basic.js.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
filesystem.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
filesystem.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
float.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
float.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
fun_call.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
fun_call.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
fun_proxy.mjs webassembly/proxy_js: Allow a Python proxy of a function to be undone. 2024-03-30 13:13:51 +11:00
fun_proxy.mjs.exp webassembly/proxy_js: Allow a Python proxy of a function to be undone. 2024-03-30 13:13:51 +11:00
fun_py_callback_js.mjs webassembly/proxy_js: Promote Python thenable to a Promise. 2024-03-30 13:13:51 +11:00
fun_py_callback_js.mjs.exp webassembly/proxy_js: Promote Python thenable to a Promise. 2024-03-30 13:13:51 +11:00
globals.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
globals.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
heap_expand.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
heap_expand.mjs.exp webassembly/api: Allow specifying the pystack size. 2024-06-20 00:26:08 +10:00
iterator.mjs webassembly/objpyproxy: Implement JS iterator protocol for Py iterables. 2024-05-07 00:20:56 +10:00
iterator.mjs.exp webassembly/objpyproxy: Implement JS iterator protocol for Py iterables. 2024-05-07 00:20:56 +10:00
js_proxy_attribute.mjs webassembly/objjsproxy: Lookup attributes without testing they exist. 2024-06-28 11:40:24 +10:00
js_proxy_attribute.mjs.exp webassembly/objjsproxy: Lookup attributes without testing they exist. 2024-06-28 11:40:24 +10:00
js_proxy_iterator.mjs webassembly/objjsproxy: Implement proxying of JS iterable protocol. 2024-06-18 22:14:34 +10:00
js_proxy_iterator.mjs.exp webassembly/objjsproxy: Implement proxying of JS iterable protocol. 2024-06-18 22:14:34 +10:00
jsffi_create_proxy.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
jsffi_create_proxy.mjs.exp webassembly/proxy_js: Create a special "undefined" type for Python. 2024-05-16 12:49:10 +10:00
jsffi_to_js.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
jsffi_to_js.mjs.exp webassembly/proxy_js: Create a special "undefined" type for Python. 2024-05-16 12:49:10 +10:00
override_new.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
override_new.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
promise_with_resolvers.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
promise_with_resolvers.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_delete.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_delete.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_dict_undefined.mjs webassembly/proxy_c: Return undefined if dict lookup failed on JS side. 2024-05-16 12:49:42 +10:00
py_proxy_dict_undefined.mjs.exp webassembly/proxy_c: Return undefined if dict lookup failed on JS side. 2024-05-16 12:49:42 +10:00
py_proxy_dict.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_dict.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_has.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_has.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_own_keys.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_own_keys.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_set.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_set.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_to_js.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_to_js.mjs.exp webassembly/proxy_js: Revert back to converting Py None to JS null. 2024-05-16 12:44:43 +10:00
register_js_module.js tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
register_js_module.js.exp webassembly/proxy_js: Create a special "undefined" type for Python. 2024-05-16 12:49:10 +10:00
run_python_async2.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
run_python_async2.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
run_python_async_error.mjs webassembly/proxy_c: Reject promises with a PythonError instance. 2024-05-06 14:04:13 +10:00
run_python_async_error.mjs.exp webassembly/proxy_c: Reject promises with a PythonError instance. 2024-05-06 14:04:13 +10:00
run_python_async_no_await.mjs webassembly/api: Resolve thenables returned from runPythonAsync. 2024-05-07 11:33:05 +10:00
run_python_async_no_await.mjs.exp webassembly/api: Resolve thenables returned from runPythonAsync. 2024-05-07 11:33:05 +10:00
run_python_async.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
run_python_async.mjs.exp webassembly/proxy_js: Create a special "undefined" type for Python. 2024-05-16 12:49:10 +10:00
this_behaviour.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
this_behaviour.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
various.js tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
various.js.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00