Skip to content

Commit

Permalink
[test] Simplify post_manual_reftest. NFC
Browse files Browse the repository at this point in the history
Rather than embedding `reftest.js` directly in the html, simply include
it via script src attribute.
  • Loading branch information
sbc100 committed Feb 2, 2024
1 parent 01be75a commit fdf17f2
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,25 +865,23 @@ def post_manual_reftest(self):
assert os.path.exists('reftest.js')
html = read_file('test.html')
html = html.replace('</body>', '''
<script src="reftest.js"/>
<script>
function assert(x, y) { if (!x) throw 'assertion failed ' + y }
%s
var windowClose = window.close;
window.close = () => {
// wait for rafs to arrive and the screen to update before reftesting
setTimeout(function() {
setTimeout(() => {
doReftest();
setTimeout(windowClose, 5000);
}, 1000);
};
</script>
</body>''' % read_file('reftest.js'))
</body>''')
create_file('test.html', html)

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

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

@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
@requires_graphics_hardware
Expand Down Expand Up @@ -3393,10 +3391,10 @@ def test_sdl2_canvas_write(self):
def test_sdl2_gl_frames_swap(self):
def post_build():
self.post_manual_reftest()
html = read_file('test.html')
html2 = html.replace('''Module['postRun'] = doReftest;''', '') # we don't want the very first frame
assert html != html2
create_file('test.html', html2)
reftest = read_file('reftest.js')
reftest2 = reftest.replace("Module['postRun'] = doReftest;", '') # we don't want the very first frame
assert reftest != reftest2
create_file('reftest.js', reftest2)
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)

@no_wasm64('SDL2 + wasm64')
Expand Down

0 comments on commit fdf17f2

Please sign in to comment.