diff --git a/test/test_browser.py b/test/test_browser.py index 10271bbfe7f0e..fc756d15e6b72 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -9,6 +9,7 @@ import re import shlex import shutil +import struct import subprocess import time import zlib @@ -70,8 +71,9 @@ from tools import ports, shared from tools.feature_matrix import Feature +from tools.link import binary_encode from tools.shared import EMCC, FILE_PACKAGER, PIPE -from tools.utils import WINDOWS, delete_dir +from tools.utils import WINDOWS, delete_dir, write_binary, write_file def make_test_chunked_synchronous_xhr_server(support_byte_ranges, data, port): @@ -5582,6 +5584,30 @@ def end_headers(self): server.stop() server.join() + # Tests encoding of all byte pairs for binary encoding in SINGLE_FILE mode. + @parameterized({ + '': ('',), + 'strict': ('"use strict";',), + }) + def test_binary_encode(self, extra): + # Encode values 0 .. 65535 into test data + test_data = bytearray(struct.pack('<' + 'H' * 65536, *range(65536))) + write_binary('data.tmp', test_data) + binary_encoded = binary_encode('data.tmp') + + write_file('test.html', '''
+''') + + self.run_browser('test.html', '/report_result?exit:0') + class emrun(RunnerCore): def test_emrun_info(self): diff --git a/test/test_other.py b/test/test_other.py index 9f5a0a03ee756..0aed9edbcb986 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -15198,12 +15198,17 @@ def test_linkable_relocatable(self): self.do_run_in_out_file_test('hello_world.c', cflags=['-Wno-deprecated', '-sLINKABLE', '-sRELOCATABLE']) # Tests encoding of all byte pairs for binary encoding in SINGLE_FILE mode. - def test_binary_encode(self): + @parameterized({ + '': ('',), + 'strict': ('"use strict";',), + }) + def test_binary_encode(self, extra): # Encode values 0 .. 65535 into test data test_data = bytearray(struct.pack('<' + 'H' * 65536, *range(65536))) write_binary('data.tmp', test_data) binary_encoded = binary_encode('data.tmp') - test_js = '''var u16 = new Uint16Array(binaryDecode(src).buffer); + test_js = extra + ''' +var u16 = new Uint16Array(binaryDecode(src).buffer); for(var i = 0; i < 65536; ++i) if (u16[i] != i) throw i; console.log('OK');'''