Skip to content

Commit 7c44cb4

Browse files
committed
[test] Simplify post_manual_reftest. NFC
Rather than embedding `reftest.js` directly in the html, simply include it via script src attribute.
1 parent 81fe157 commit 7c44cb4

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

test/test_browser.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -862,28 +862,25 @@ def test_sdl_canvas(self):
862862
self.btest_exit('test_sdl_canvas.c', args=['-sLEGACY_GL_EMULATION', '-O2', '-sSAFE_HEAP', '-lSDL', '-lGL'])
863863

864864
def post_manual_reftest(self):
865-
assert os.path.exists('reftest.js')
866865
html = read_file('test.html')
867866
html = html.replace('</body>', '''
867+
<script src="reftest.js"/>
868868
<script>
869-
function assert(x, y) { if (!x) throw 'assertion failed ' + y }
870-
%s
871-
872869
var windowClose = window.close;
873870
window.close = () => {
874871
// wait for rafs to arrive and the screen to update before reftesting
875-
setTimeout(function() {
872+
setTimeout(() => {
876873
doReftest();
877874
setTimeout(windowClose, 5000);
878875
}, 1000);
879876
};
880877
</script>
881-
</body>''' % read_file('reftest.js'))
878+
</body>''')
882879
create_file('test.html', html)
883880

884881
def test_sdl_canvas_proxy(self):
885882
create_file('data.txt', 'datum')
886-
self.btest('test_sdl_canvas_proxy.c', reference='browser/test_sdl_canvas_proxy.png', args=['--proxy-to-worker', '--preload-file', 'data.txt', '-lSDL', '-lGL'], manual_reference=True, post_build=self.post_manual_reftest)
883+
self.btest('test_sdl_canvas_proxy.c', reference='browser/test_sdl_canvas_proxy.png', args=['--proxy-to-worker', '--preload-file', 'data.txt', '-lSDL', '-lGL'])
887884

888885
@requires_graphics_hardware
889886
def test_glgears_proxy_jstarget(self):
@@ -2115,7 +2112,7 @@ def test_cubegeom_pre3(self):
21152112
def test_cubegeom(self, args):
21162113
# proxy only in the simple, normal case (we can't trace GL calls when
21172114
# proxied)
2118-
self.btest('third_party/cubegeom/cubegeom.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '-g', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'] + args, also_proxied=not args)
2115+
self.btest('third_party/cubegeom/cubegeom.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '-g', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'] + args)
21192116

21202117
@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
21212118
@requires_graphics_hardware
@@ -3393,10 +3390,10 @@ def test_sdl2_canvas_write(self):
33933390
def test_sdl2_gl_frames_swap(self):
33943391
def post_build():
33953392
self.post_manual_reftest()
3396-
html = read_file('test.html')
3397-
html2 = html.replace('''Module['postRun'] = doReftest;''', '') # we don't want the very first frame
3398-
assert html != html2
3399-
create_file('test.html', html2)
3393+
reftest = read_file('reftest.js')
3394+
reftest2 = reftest.replace("Module['postRun'] = doReftest;", '') # we don't want the very first frame
3395+
assert reftest != reftest2
3396+
create_file('reftest.js', reftest2)
34003397
self.btest('test_sdl2_gl_frames_swap.c', reference='browser/test_sdl2_gl_frames_swap.png', args=['--proxy-to-worker', '-sGL_TESTING', '-sUSE_SDL=2'], manual_reference=True, post_build=post_build)
34013398

34023399
@no_wasm64('SDL2 + wasm64')

0 commit comments

Comments
 (0)