Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/pthread/call_sync_on_main_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <assert.h>
#include <string.h>

extern void getDomElementInnerHTML(const char *domElement, char *dst, int size);
extern void getDomElementParentInnerHTML(const char *domElement, char *dst, int size);
extern int isThisInWorker(void);
extern int isThisInWorkerOnMainThread(void);
extern int receivesAndReturnsAnInteger(int i);
Expand All @@ -21,13 +21,13 @@ int main()
{
char dst[256];
char name[7] = "resize";
getDomElementInnerHTML(name, dst, sizeof(dst));
getDomElementParentInnerHTML(name, dst, sizeof(dst));
memset(name, 0, sizeof(name)); // Try to uncover if there might be a race condition and above line was not synchronously processed, and we could take name string away.
int inWorker1 = isThisInWorker(); // Build this application with -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD=1 for this to return 1, otherwise returns 0.
int inWorker2 = isThisInWorkerOnMainThread(); // This should always return 0
int returnedInt = receivesAndReturnsAnInteger(4);
printf("text: \"%s\". inWorker1: %d, inWorker2: %d, returnedInt: %d\n", dst, inWorker1, inWorker2, returnedInt);
assert(!strstr(dst, "Resize canvas"));
assert(strstr(dst, "Resize canvas"));
assert(inWorker1 == PROXY_TO_PTHREAD);
assert(inWorker2 == 0);
assert(returnedInt == 42 + 4);
Expand Down
8 changes: 4 additions & 4 deletions tests/pthread/call_sync_on_main_thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ mergeInto(LibraryManager.library, {
// Test accessing a DOM element on the main thread.
// This function returns the inner text of the div by ID "status"
// Because it accesses the DOM, it must be called on the main thread.
getDomElementInnerHTML__proxy: 'sync',
getDomElementInnerHTML__sig: 'viii',
getDomElementInnerHTML: function(domElementId, dst, size) {
getDomElementParentInnerHTML__proxy: 'sync',
getDomElementParentInnerHTML__sig: 'viii',
getDomElementParentInnerHTML: function(domElementId, dst, size) {
var id = UTF8ToString(domElementId);
var text = document.getElementById(id).innerHTML;
var text = document.getElementById(id).parentElement.innerHTML;
stringToUTF8(text, dst, size);
},

Expand Down