forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcall_sync_on_main_thread.js
More file actions
29 lines (26 loc) · 1.01 KB
/
call_sync_on_main_thread.js
File metadata and controls
29 lines (26 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
addToLibrary({
// Test accessing a DOM element on the main thread.
// This function returns the inner text of the given element
// Because it accesses the DOM, it must be called on the main thread.
getDomElementContents__proxy: 'sync',
getDomElementContents__sig: 'pp',
getDomElementContents__deps: ['$stringToNewUTF8'],
getDomElementContents: function(domElementSelector) {
var selector = UTF8ToString(domElementSelector);
var text = document.querySelector(selector).innerHTML;
return stringToNewUTF8(text);
},
receivesAndReturnsAnInteger__proxy: 'sync',
receivesAndReturnsAnInteger__sig: 'ii',
receivesAndReturnsAnInteger: function(i) {
return i + 42;
},
isThisInWorker: function() {
return typeof ENVIRONMENT_IS_WORKER !== 'undefined' && ENVIRONMENT_IS_WORKER;
},
isThisInWorkerOnMainThread__proxy: 'sync',
isThisInWorkerOnMainThread__sig: 'i',
isThisInWorkerOnMainThread: function() {
return typeof ENVIRONMENT_IS_WORKER !== 'undefined' && ENVIRONMENT_IS_WORKER;
}
});