Skip to content

Commit fdf17f2

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 01be75a commit fdf17f2

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

test/test_browser.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -865,25 +865,23 @@ def post_manual_reftest(self):
865865
assert os.path.exists('reftest.js')
866866
html = read_file('test.html')
867867
html = html.replace('</body>', '''
868+
<script src="reftest.js"/>
868869
<script>
869-
function assert(x, y) { if (!x) throw 'assertion failed ' + y }
870-
%s
871-
872870
var windowClose = window.close;
873871
window.close = () => {
874872
// wait for rafs to arrive and the screen to update before reftesting
875-
setTimeout(function() {
873+
setTimeout(() => {
876874
doReftest();
877875
setTimeout(windowClose, 5000);
878876
}, 1000);
879877
};
880878
</script>
881-
</body>''' % read_file('reftest.js'))
879+
</body>''')
882880
create_file('test.html', html)
883881

884882
def test_sdl_canvas_proxy(self):
885883
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)
884+
self.btest('test_sdl_canvas_proxy.c', reference='browser/test_sdl_canvas_proxy.png', args=['--proxy-to-worker', '--preload-file', 'data.txt', '-lSDL', '-lGL'])
887885

888886
@requires_graphics_hardware
889887
def test_glgears_proxy_jstarget(self):
@@ -2115,7 +2113,7 @@ def test_cubegeom_pre3(self):
21152113
def test_cubegeom(self, args):
21162114
# proxy only in the simple, normal case (we can't trace GL calls when
21172115
# 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)
2116+
self.btest('third_party/cubegeom/cubegeom.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '-g', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'] + args)
21192117

21202118
@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
21212119
@requires_graphics_hardware
@@ -3393,10 +3391,10 @@ def test_sdl2_canvas_write(self):
33933391
def test_sdl2_gl_frames_swap(self):
33943392
def post_build():
33953393
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)
3394+
reftest = read_file('reftest.js')
3395+
reftest2 = reftest.replace("Module['postRun'] = doReftest;", '') # we don't want the very first frame
3396+
assert reftest != reftest2
3397+
create_file('reftest.js', reftest2)
34003398
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)
34013399

34023400
@no_wasm64('SDL2 + wasm64')

0 commit comments

Comments
 (0)