Skip to content

Commit

Permalink
[test] Simplify post_manual_reftest. NFC (#21243)
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 5, 2024
1 parent 4b3988d commit 50d2d32
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,20 +865,18 @@ 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):
Expand Down Expand Up @@ -3362,10 +3360,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 50d2d32

Please sign in to comment.