Skip to content

Commit 2b41554

Browse files
committed
Make browser test suite pass on Safari
1 parent 30b2eeb commit 2b41554

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

test/common.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,12 @@ def end_headers(self):
22422242
self.send_header('Cross-Origin-Opener-Policy', 'same-origin')
22432243
self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')
22442244
self.send_header('Cross-Origin-Resource-Policy', 'cross-origin')
2245-
self.send_header('Cache-Control', 'no-cache, no-store, must-revalidate')
2245+
2246+
self.send_header('Cache-Control', 'no-cache, no-store, must-revalidate, private, max-age=0')
2247+
self.send_header('Expires', '0')
2248+
self.send_header('Pragma', 'no-cache')
2249+
self.send_header('Vary', '*') # Safari insists on caching if this header is not present in addition to the above
2250+
22462251
return SimpleHTTPRequestHandler.end_headers(self)
22472252

22482253
def do_POST(self): # noqa: DC04
@@ -2329,9 +2334,13 @@ def do_GET(self):
23292334
raise Exception('browser harness error, excessive response to server - test must be fixed! "%s"' % self.path)
23302335
self.send_response(200)
23312336
self.send_header('Content-type', 'text/plain')
2332-
self.send_header('Cache-Control', 'no-cache, must-revalidate')
2337+
2338+
self.send_header('Cache-Control', 'no-cache, no-store, must-revalidate, private, max-age=0')
2339+
self.send_header('Expires', '0')
2340+
self.send_header('Pragma', 'no-cache')
2341+
self.send_header('Vary', '*') # Safari insists on caching if this header is not present in addition to the above
2342+
23332343
self.send_header('Connection', 'close')
2334-
self.send_header('Expires', '-1')
23352344
self.end_headers()
23362345
self.wfile.write(b'OK')
23372346

@@ -2743,14 +2752,6 @@ def run_browser(self, html_file, expected=None, message=None, timeout=None, extr
27432752
print('[browser launch:', html_file, ']')
27442753
assert not (message and expected), 'run_browser expects `expected` or `message`, but not both'
27452754

2746-
# Accurate version cutoff is not known.
2747-
# Needed at least for version Safari Version 17.6 (17618.3.11.11.7, 17618)
2748-
# Also needed for Safari Version 18.5 (20621.2.5.11.8)
2749-
if is_safari() and get_safari_version() < 190000:
2750-
# Old Safari cannot handle running multiple browser pages in the same browser instance
2751-
# So restart the browser between each browser test.
2752-
self.browser_restart()
2753-
27542755
if expected is not None:
27552756
try:
27562757
self.harness_in_queue.put((

test/test_browser.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ def sendheaders(s, extra=None, length=None):
4040
s.send_header("Content-Length", str(length))
4141
s.send_header("Access-Control-Allow-Origin", "http://localhost:%s" % port)
4242
s.send_header('Cross-Origin-Resource-Policy', 'cross-origin')
43-
s.send_header('Cache-Control', 'no-cache, no-store, must-revalidate')
43+
44+
s.send_header('Cache-Control', 'no-cache, no-store, must-revalidate, private, max-age=0')
45+
s.send_header('Expires', '0')
46+
s.send_header('Pragma', 'no-cache')
47+
s.send_header('Vary', '*') # Safari insists on caching if this header is not present in addition to the above
48+
4449
s.send_header("Access-Control-Expose-Headers", "Content-Length, Accept-Ranges")
4550
s.send_header("Content-type", "application/octet-stream")
4651
if support_byte_ranges:
@@ -2799,6 +2804,7 @@ def test_webgl2_pbo(self):
27992804
self.btest_exit('webgl2_pbo.c', cflags=['-sMAX_WEBGL_VERSION=2', '-lGL'])
28002805

28012806
@no_firefox('fails on CI likely due to GPU drivers there')
2807+
@no_safari('TODO: Fails with report_result?5') # Safari 17.6 (17618.3.11.11.7, 17618)
28022808
@requires_graphics_hardware
28032809
def test_webgl2_sokol_mipmap(self):
28042810
self.reftest('third_party/sokol/mipmap-emsc.c', 'third_party/sokol/mipmap-emsc.png',
@@ -2957,6 +2963,7 @@ def test_sdl2_image_jpeg(self):
29572963
@also_with_wasmfs
29582964
@requires_graphics_hardware
29592965
@with_all_sjlj
2966+
@no_safari('Test enables Wasm exceptions, so will not run in Safari 17.6 (17618.3.11.11.7, 17618)') # Safari 17.6 (17618.3.11.11.7, 17618)
29602967
def test_sdl2_image_formats(self):
29612968
shutil.copy(test_file('screenshot.png'), '.')
29622969
shutil.copy(test_file('screenshot.jpg'), '.')
@@ -3358,7 +3365,7 @@ def test_async_returnvalue(self, args):
33583365
create_file('filey.txt', 'sync_tunnel\nsync_tunnel_bool\n')
33593366
self.btest('test_async_returnvalue.c', '0', cflags=['-sASSERTIONS', '-sASYNCIFY', '-sASYNCIFY_IGNORE_INDIRECT', '--js-library', test_file('browser/test_async_returnvalue.js')] + args)
33603367

3361-
@no_safari('TODO: Fails in Safari Version 17.6 (17618.3.11.11.7, 17618)')
3368+
@no_safari('TODO: Never reports a result, so times out') # Safari 17.6 (17618.3.11.11.7, 17618)
33623369
def test_async_bad_list(self):
33633370
self.btest('test_async_bad_list.c', '0', cflags=['-sASYNCIFY', '-sASYNCIFY_ONLY=waka', '--profiling'])
33643371

@@ -3411,6 +3418,7 @@ def test_modularize(self, args, code, opts):
34113418
self.run_browser('a.html', '/report_result?0')
34123419

34133420
@no_firefox('source phase imports not implemented yet in firefox')
3421+
@no_safari('croaks on line "import source wasmModule from \'./out.wasm\';"') # Safari 17.6 (17618.3.11.11.7, 17618)
34143422
def test_source_phase_imports(self):
34153423
self.compile_btest('browser_test_hello_world.c', ['-sEXPORT_ES6', '-sSOURCE_PHASE_IMPORTS', '-Wno-experimental', '-o', 'out.mjs'])
34163424
create_file('a.html', '''
@@ -3797,6 +3805,7 @@ def test_pthread_gcc_64bit_atomic_fetch_and_op(self):
37973805

37983806
# Test the old GCC atomic __sync_op_and_fetch builtin operations.
37993807
@also_with_wasm2js
3808+
@no_safari('TODO: browser.test_pthread_gcc_atomic_op_and_fetch_wasm2js fails with "abort:Assertion failed: nand_and_fetch_data == -1"') # Safari 17.6 (17618.3.11.11.7, 17618)
38003809
def test_pthread_gcc_atomic_op_and_fetch(self):
38013810
self.cflags += ['-Wno-sync-fetch-and-nand-semantics-changed']
38023811
self.btest_exit('pthread/test_pthread_gcc_atomic_op_and_fetch.c', cflags=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8'])
@@ -3894,6 +3903,7 @@ def test_pthread_cleanup(self):
38943903
'': ([],),
38953904
'spinlock': (['-DSPINLOCK_TEST'],),
38963905
})
3906+
@no_safari('TODO: browser.test_pthread_mutex and browser.test_pthread_mutex_spinlock both hang Safari') # Safari 17.6 (17618.3.11.11.7, 17618)
38973907
def test_pthread_mutex(self, args):
38983908
self.btest_exit('pthread/test_pthread_mutex.c', cflags=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8'] + args)
38993909

@@ -4081,6 +4091,7 @@ def test_pthread_safe_stack(self):
40814091
'no_leak': ['test_pthread_lsan_no_leak', []],
40824092
})
40834093
@no_firefox('https://github.com/emscripten-core/emscripten/issues/15978')
4094+
@no_safari('TODO: browser.test_pthread_lsan_leak fails with /report_result?0') # Safari 17.6 (17618.3.11.11.7, 17618)
40844095
def test_pthread_lsan(self, name, args):
40854096
self.btest(Path('pthread', name + '.cpp'), expected='1', cflags=['-fsanitize=leak', '-pthread', '-sPROXY_TO_PTHREAD', '--pre-js', test_file('pthread', name + '.js')] + args)
40864097

@@ -4092,6 +4103,7 @@ def test_pthread_lsan(self, name, args):
40924103
'leak': ['test_pthread_lsan_leak', ['-gsource-map']],
40934104
'no_leak': ['test_pthread_lsan_no_leak', []],
40944105
})
4106+
@no_safari('TODO: browser.test_pthread_asan_leak fails with /report_result?0') # Safari 17.6 (17618.3.11.11.7, 17618)
40954107
def test_pthread_asan(self, name, args):
40964108
self.btest(Path('pthread', name + '.cpp'), expected='1', cflags=['-fsanitize=address', '-pthread', '-sPROXY_TO_PTHREAD', '--pre-js', test_file('pthread', name + '.js')] + args)
40974109

@@ -4123,6 +4135,7 @@ def test_pthread_exit_process(self):
41234135
args += ['--pre-js', test_file('core/pthread/test_pthread_exit_runtime.pre.js')]
41244136
self.btest('core/pthread/test_pthread_exit_runtime.c', expected='onExit status: 42', cflags=args)
41254137

4138+
@no_safari('TODO: Fails with report_result?unexpected: [object ErrorEvent]') # Safari 17.6 (17618.3.11.11.7, 17618)
41264139
def test_pthread_trap(self):
41274140
create_file('pre.js', '''
41284141
if (typeof window === 'object' && window) {
@@ -5370,6 +5383,7 @@ def test_wasmfs_fetch_backend_threaded(self, args):
53705383
'jspi': (['-Wno-experimental', '-sASYNCIFY=2'],),
53715384
'jspi_wasm_bigint': (['-Wno-experimental', '-sASYNCIFY=2', '-sWASM_BIGINT'],),
53725385
})
5386+
@no_safari('TODO: Fails with abort:Assertion failed: err == 0') # Safari 17.6 (17618.3.11.11.7, 17618)
53735387
def test_wasmfs_opfs(self, args):
53745388
if '-sASYNCIFY=2' in args:
53755389
self.require_jspi()
@@ -5379,6 +5393,7 @@ def test_wasmfs_opfs(self, args):
53795393
self.btest_exit(test, cflags=args + ['-DWASMFS_RESUME'])
53805394

53815395
@no_firefox('no OPFS support yet')
5396+
@no_safari('TODO: Fails with exception:Did not get expected EIO when unlinking file') # Safari 17.6 (17618.3.11.11.7, 17618)
53825397
def test_wasmfs_opfs_errors(self):
53835398
test = test_file('wasmfs/wasmfs_opfs_errors.c')
53845399
postjs = test_file('wasmfs/wasmfs_opfs_errors_post.js')
@@ -5453,6 +5468,7 @@ def test_manual_pthread_proxy_hammer(self, args):
54535468
def test_assert_failure(self):
54545469
self.btest('test_assert_failure.c', 'abort:Assertion failed: false && "this is a test"')
54555470

5471+
@no_safari('TODO: Fails with report_result?exception:rejected! / undefined') # Safari 17.6 (17618.3.11.11.7, 17618)
54565472
def test_pthread_unhandledrejection(self):
54575473
# Check that an unhandled promise rejection is propagated to the main thread
54585474
# as an error. This test is failing if it hangs!

0 commit comments

Comments
 (0)