@@ -441,9 +441,8 @@ def make_main_two_files(path1, path2, nonexistingpath):
441
441
# With FS.preloadFile
442
442
443
443
create_file ('pre.js' , '''
444
- Module.preRun = function() {
445
- FS.createPreloadedFile('/', 'someotherfile.txt', 'somefile.txt', true, false); // we need --use-preload-plugins for this.
446
- };
444
+ // we need --use-preload-plugins for this.
445
+ Module.preRun = () => FS.createPreloadedFile('/', 'someotherfile.txt', 'somefile.txt', true, false);
447
446
''' )
448
447
make_main ('someotherfile.txt' )
449
448
self .btest_exit ('main.cpp' , args = ['--pre-js' , 'pre.js' , '--use-preload-plugins' ])
@@ -714,7 +713,7 @@ def setup(assetLocalization):
714
713
<center><canvas id='canvas' width='256' height='256'></canvas></center>
715
714
<hr><div id='output'></div><hr>
716
715
<script type='text/javascript'>
717
- window.onerror = function (error) {
716
+ window.onerror = (error) => {
718
717
window.disableErrorReporting = true;
719
718
window.onerror = null;
720
719
var result = error.indexOf("test.data") >= 0 ? 1 : 0;
@@ -868,7 +867,7 @@ def post_manual_reftest(self):
868
867
%s
869
868
870
869
var windowClose = window.close;
871
- window.close = function() {
870
+ window.close = () => {
872
871
// wait for rafs to arrive and the screen to update before reftesting
873
872
setTimeout(function() {
874
873
doReftest();
@@ -936,8 +935,7 @@ def test_sdl_key(self, delay):
936
935
937
936
def test_sdl_key_proxy (self ):
938
937
create_file ('pre.js' , '''
939
- var Module = {};
940
- Module.postRun = function() {
938
+ Module.postRun = () => {
941
939
function doOne() {
942
940
Module._one();
943
941
setTimeout(doOne, 1000/60);
@@ -1026,7 +1024,7 @@ def post():
1026
1024
1027
1025
def test_sdl_text (self ):
1028
1026
create_file ('pre.js' , '''
1029
- Module.postRun = function() {
1027
+ Module.postRun = () => {
1030
1028
function doOne() {
1031
1029
Module._one();
1032
1030
setTimeout(doOne, 1000/60);
@@ -1173,10 +1171,8 @@ def test_sdl_joystick_1(self):
1173
1171
create_file ('pre.js' , '''
1174
1172
var gamepads = [];
1175
1173
// Spoof this function.
1176
- navigator['getGamepads'] = function() {
1177
- return gamepads;
1178
- };
1179
- window['addNewGamepad'] = function(id, numAxes, numButtons) {
1174
+ navigator['getGamepads'] = () => gamepads;
1175
+ window['addNewGamepad'] = (id, numAxes, numButtons) => {
1180
1176
var index = gamepads.length;
1181
1177
gamepads.push({
1182
1178
axes: new Array(numAxes),
@@ -1188,13 +1184,13 @@ def test_sdl_joystick_1(self):
1188
1184
for (i = 0; i < numAxes; i++) gamepads[index].axes[i] = 0;
1189
1185
for (i = 0; i < numButtons; i++) gamepads[index].buttons[i] = 0;
1190
1186
};
1191
- window['simulateGamepadButtonDown'] = function (index, button) {
1187
+ window['simulateGamepadButtonDown'] = (index, button) => {
1192
1188
gamepads[index].buttons[button] = 1;
1193
1189
};
1194
- window['simulateGamepadButtonUp'] = function (index, button) {
1190
+ window['simulateGamepadButtonUp'] = (index, button) => {
1195
1191
gamepads[index].buttons[button] = 0;
1196
1192
};
1197
- window['simulateAxisMotion'] = function (index, axis, value) {
1193
+ window['simulateAxisMotion'] = (index, axis, value) => {
1198
1194
gamepads[index].axes[axis] = value;
1199
1195
};
1200
1196
''' )
@@ -1207,10 +1203,8 @@ def test_sdl_joystick_2(self):
1207
1203
create_file ('pre.js' , '''
1208
1204
var gamepads = [];
1209
1205
// Spoof this function.
1210
- navigator['getGamepads'] = function() {
1211
- return gamepads;
1212
- };
1213
- window['addNewGamepad'] = function(id, numAxes, numButtons) {
1206
+ navigator['getGamepads'] = () => gamepads;
1207
+ window['addNewGamepad'] = (id, numAxes, numButtons) => {
1214
1208
var index = gamepads.length;
1215
1209
gamepads.push({
1216
1210
axes: new Array(numAxes),
@@ -1224,15 +1218,15 @@ def test_sdl_joystick_2(self):
1224
1218
for (i = 0; i < numButtons; i++) gamepads[index].buttons[i] = { pressed: false, value: 0 };
1225
1219
};
1226
1220
// FF mutates the original objects.
1227
- window['simulateGamepadButtonDown'] = function (index, button) {
1221
+ window['simulateGamepadButtonDown'] = (index, button) => {
1228
1222
gamepads[index].buttons[button].pressed = true;
1229
1223
gamepads[index].buttons[button].value = 1;
1230
1224
};
1231
- window['simulateGamepadButtonUp'] = function (index, button) {
1225
+ window['simulateGamepadButtonUp'] = (index, button) => {
1232
1226
gamepads[index].buttons[button].pressed = false;
1233
1227
gamepads[index].buttons[button].value = 0;
1234
1228
};
1235
- window['simulateAxisMotion'] = function (index, axis, value) {
1229
+ window['simulateAxisMotion'] = (index, axis, value) => {
1236
1230
gamepads[index].axes[axis] = value;
1237
1231
};
1238
1232
''' )
@@ -1246,10 +1240,8 @@ def test_glfw_joystick(self):
1246
1240
create_file ('pre.js' , '''
1247
1241
var gamepads = [];
1248
1242
// Spoof this function.
1249
- navigator['getGamepads'] = function() {
1250
- return gamepads;
1251
- };
1252
- window['addNewGamepad'] = function(id, numAxes, numButtons) {
1243
+ navigator['getGamepads'] = () => gamepads;
1244
+ window['addNewGamepad'] = (id, numAxes, numButtons) => {
1253
1245
var index = gamepads.length;
1254
1246
var gamepad = {
1255
1247
axes: new Array(numAxes),
@@ -1269,15 +1261,15 @@ def test_glfw_joystick(self):
1269
1261
window.dispatchEvent(event);
1270
1262
};
1271
1263
// FF mutates the original objects.
1272
- window['simulateGamepadButtonDown'] = function (index, button) {
1264
+ window['simulateGamepadButtonDown'] = (index, button) => {
1273
1265
gamepads[index].buttons[button].pressed = true;
1274
1266
gamepads[index].buttons[button].value = 1;
1275
1267
};
1276
- window['simulateGamepadButtonUp'] = function (index, button) {
1268
+ window['simulateGamepadButtonUp'] = (index, button) => {
1277
1269
gamepads[index].buttons[button].pressed = false;
1278
1270
gamepads[index].buttons[button].value = 0;
1279
1271
};
1280
- window['simulateAxisMotion'] = function (index, axis, value) {
1272
+ window['simulateAxisMotion'] = (index, axis, value) => {
1281
1273
gamepads[index].axes[axis] = value;
1282
1274
};
1283
1275
''' )
@@ -1394,7 +1386,7 @@ def test_fs_idbfs_fsync(self):
1394
1386
# sync from persisted state into memory before main()
1395
1387
self .set_setting ('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE' , '$ccall' )
1396
1388
create_file ('pre.js' , '''
1397
- Module.preRun = function() {
1389
+ Module.preRun = () => {
1398
1390
addRunDependency('syncfs');
1399
1391
1400
1392
FS.mkdir('/working1');
@@ -1420,8 +1412,7 @@ def test_fs_workerfs_read(self):
1420
1412
secret = 'a' * 10
1421
1413
secret2 = 'b' * 10
1422
1414
create_file ('pre.js' , '''
1423
- var Module = {};
1424
- Module.preRun = function() {
1415
+ Module.preRun = () => {
1425
1416
var blob = new Blob(['%s']);
1426
1417
var file = new File(['%s'], 'file.txt');
1427
1418
FS.mkdir('/work');
@@ -1658,7 +1649,7 @@ def test_worker(self):
1658
1649
Worker Test
1659
1650
<script>
1660
1651
var worker = new Worker('worker.js');
1661
- worker.onmessage = function (event) {
1652
+ worker.onmessage = (event) => {
1662
1653
var xhr = new XMLHttpRequest();
1663
1654
xhr.open('GET', 'http://localhost:%s/report_result?' + event.data);
1664
1655
xhr.send();
@@ -1704,7 +1695,7 @@ def test_chunked_synchronous_xhr(self):
1704
1695
<script>
1705
1696
var worker = new Worker(""" + json .dumps (worker_filename ) + r""");
1706
1697
var buffer = [];
1707
- worker.onmessage = function (event) {
1698
+ worker.onmessage = (event) => {
1708
1699
if (event.data.channel === "stdout") {
1709
1700
var xhr = new XMLHttpRequest();
1710
1701
xhr.open('GET', 'http://localhost:%s/report_result?' + event.data.line);
@@ -1731,14 +1722,13 @@ def test_chunked_synchronous_xhr(self):
1731
1722
""" % self .port )
1732
1723
1733
1724
create_file ('worker_prejs.js' , r"""
1734
- if (typeof(Module) === "undefined") Module = {};
1735
- Module["arguments"] = ["/bigfile"];
1736
- Module["preInit"] = function() {
1737
- FS.createLazyFile('/', "bigfile", "http://localhost:11111/bogus_file_path", true, false);
1725
+ Module.arguments = ["/bigfile"];
1726
+ Module.preInit = () => {
1727
+ FS.createLazyFile('/', "bigfile", "http://localhost:11111/bogus_file_path", true, false);
1738
1728
};
1739
1729
var doTrace = true;
1740
- Module[" print"] = function (s) { self.postMessage({channel: "stdout", line: s}); } ;
1741
- Module[" printErr"] = function (s) { self.postMessage({channel: "stderr", char: s, trace: ((doTrace && s === 10) ? new Error().stack : null)}); doTrace = false; };
1730
+ Module. print = (s) => self.postMessage({channel: "stdout", line: s});
1731
+ Module. printErr = (s) => { self.postMessage({channel: "stderr", char: s, trace: ((doTrace && s === 10) ? new Error().stack : null)}); doTrace = false; };
1742
1732
""" )
1743
1733
self .compile_btest ([test_file ('checksummer.c' ), '-g' , '-sSMALL_XHR_CHUNKS' , '-o' , worker_filename ,
1744
1734
'--pre-js' , 'worker_prejs.js' ])
@@ -2371,7 +2361,7 @@ def test_runtimelink(self):
2371
2361
def test_pre_run_deps (self ):
2372
2362
# Adding a dependency in preRun will delay run
2373
2363
create_file ('pre.js' , '''
2374
- Module.preRun = function() {
2364
+ Module.preRun = () => {
2375
2365
addRunDependency();
2376
2366
out('preRun called, added a dependency...');
2377
2367
setTimeout(function() {
@@ -2390,10 +2380,8 @@ def test_mem_init(self):
2390
2380
function myJSCallback() { // called from main()
2391
2381
Module._note(1);
2392
2382
}
2393
- Module.preRun = function() {
2394
- addOnPreMain(function() {
2395
- Module._note(2);
2396
- });
2383
+ Module.preRun = () => {
2384
+ addOnPreMain(() => Module._note(2));
2397
2385
};
2398
2386
''' )
2399
2387
create_file ('post.js' , '''
@@ -2417,7 +2405,7 @@ def test(what, status):
2417
2405
xhr.responseType = 'arraybuffer';
2418
2406
xhr.send(null);
2419
2407
2420
- console.warn = function (x) {
2408
+ console.warn = (x) => {
2421
2409
if (x.indexOf('a problem seems to have happened with Module.memoryInitializerRequest') >= 0) {
2422
2410
maybeReportResultToServer('got_error');
2423
2411
}
@@ -2504,9 +2492,7 @@ def test_runtime_misuse(self, mode):
2504
2492
''' % self .port
2505
2493
2506
2494
create_file ('pre_runtime.js' , r'''
2507
- Module.onRuntimeInitialized = function(){
2508
- myJSCallback();
2509
- };
2495
+ Module.onRuntimeInitialized = () => myJSCallback();
2510
2496
''' )
2511
2497
2512
2498
for filename , extra_args , second_code in [
@@ -2876,7 +2862,7 @@ def test_locate_file(self, args):
2876
2862
}
2877
2863
''' )
2878
2864
create_file ('data.txt' , 'load me right before...' )
2879
- create_file ('pre.js' , 'Module.locateFile = function (x) { return "sub/" + x } ;' )
2865
+ create_file ('pre.js' , 'Module.locateFile = (x) => "sub/" + x;' )
2880
2866
self .run_process ([FILE_PACKAGER , 'test.data' , '--preload' , 'data.txt' ], stdout = open ('data.js' , 'w' ))
2881
2867
# put pre.js first, then the file packager data, so locateFile is there for the file loading code
2882
2868
self .compile_btest (['src.cpp' , '-O2' , '-g' , '--pre-js' , 'pre.js' , '--pre-js' , 'data.js' , '-o' , 'page.html' , '-sFORCE_FILESYSTEM' , '-sWASM=' + str (wasm )] + args , reporting = Reporting .JS_ONLY )
@@ -2988,7 +2974,7 @@ def test_sdl2_image_formats(self):
2988
2974
2989
2975
def test_sdl2_key (self ):
2990
2976
create_file ('pre.js' , '''
2991
- Module.postRun = function() {
2977
+ Module.postRun = () => {
2992
2978
function doOne() {
2993
2979
Module._one();
2994
2980
setTimeout(doOne, 1000/60);
@@ -3017,7 +3003,7 @@ def test_sdl2_key(self):
3017
3003
3018
3004
def test_sdl2_text (self ):
3019
3005
create_file ('pre.js' , '''
3020
- Module.postRun = function() {
3006
+ Module.postRun = () => {
3021
3007
function doOne() {
3022
3008
Module._one();
3023
3009
setTimeout(doOne, 1000/60);
@@ -3609,7 +3595,7 @@ def test_dynamic_link(self):
3609
3595
temp[1] = 'x';
3610
3596
EM_ASM({
3611
3597
Module.realPrint = out;
3612
- out = function (x) {
3598
+ out = (x) => {
3613
3599
if (!Module.printed) Module.printed = x;
3614
3600
Module.realPrint(x);
3615
3601
};
@@ -3677,7 +3663,7 @@ def do_run(src, expected_output, emcc_args):
3677
3663
# setup by the shell).
3678
3664
create_file ('post.js' , r'''
3679
3665
Module.realPrint = out;
3680
- out = function (x) {
3666
+ out = (x) => {
3681
3667
if (!Module.printed) Module.printed = "";
3682
3668
Module.printed += x + '\n'; // out is passed str without last \n
3683
3669
Module.realPrint(x);
@@ -4379,7 +4365,7 @@ def test_binaryen_async(self):
4379
4365
};
4380
4366
}
4381
4367
// show stderr for the viewer's fun
4382
- err = function (x) {
4368
+ err = (x) => {
4383
4369
out('<<< ' + x + ' >>>');
4384
4370
console.log(x);
4385
4371
};
0 commit comments