diff --git a/deps/iotivity-constrained b/deps/iotivity-constrained index 057b083a7..12f109026 160000 --- a/deps/iotivity-constrained +++ b/deps/iotivity-constrained @@ -1 +1 @@ -Subproject commit 057b083a7afa4cb759e4d8b5bcd79fb62bc8dac3 +Subproject commit 12f109026f23e0a87b7ebeb300dbf50a79e41693 diff --git a/src/zjs_promise.c b/src/zjs_promise.c index ab9728913..43e3c095b 100644 --- a/src/zjs_promise.c +++ b/src/zjs_promise.c @@ -98,12 +98,12 @@ void zjs_make_promise(jerry_value_t obj, zjs_post_promise_func post, new->then_id = zjs_add_callback_once(ZJS_UNDEFINED, obj, - handle, + new, post_promise); new->catch_id = zjs_add_callback_once(ZJS_UNDEFINED, obj, - handle, + new, post_promise); // Add the "promise" object to the object passed as a property, because the diff --git a/src/zjs_test_promise.c b/src/zjs_test_promise.c index 12d212c1f..049159fee 100644 --- a/src/zjs_test_promise.c +++ b/src/zjs_test_promise.c @@ -7,15 +7,35 @@ #include "zjs_promise.h" #include "zjs_util.h" +typedef struct dummy_handle { + uint32_t value; +} dummy_handle_t; + +#define TEST_VAL 42 + +static void post_promise(void* handle) +{ + if (handle) { + dummy_handle_t* h = (dummy_handle_t*)handle; + if (h->value != TEST_VAL) { + ERR_PRINT("Handle was not valid!!!\n"); + } + zjs_free(h); + } +} + static jerry_value_t create_promise(const jerry_value_t function_obj, const jerry_value_t this, const jerry_value_t argv[], const jerry_length_t argc) { + dummy_handle_t* handle = zjs_malloc(sizeof(dummy_handle_t)); + handle->value = TEST_VAL; + jerry_value_t promise = jerry_create_object(); ZJS_PRINT("Testing promise, object = %u\n", promise); - zjs_make_promise(promise, NULL, NULL); + zjs_make_promise(promise, post_promise, handle); return promise; }