1 const REPORT_URL = '/gold_rpc/report';
2 const pngPrefx = 'data:image/png;base64,'
4 function reportCanvas(canvas, testname) {
5 testname = testname.replaceAll(' ', '_');
6 // toDataURL returns a base64 encoded string with a data prefix. We only
7 // want the PNG data itself, so we strip that off before submitting it.
8 const b64 = canvas.toDataURL('image/png')
9 .substring(pngPrefx.length);
10 return fetch(REPORT_URL, {
14 'Content-Type': 'application/json',
16 body: JSON.stringify({
21 expect(resp.status).toEqual(201); // StatusCreated
22 console.log(`${testname}: ${resp.statusText}`);
26 function reportError(done) {
33 // A wrapper to catch and print a stacktrace to the logs.
34 // Exceptions normally shows up in the browser console,
35 // but not in the logs that appear on the bots AND a thrown
36 // exception will normally cause a test to time out.
37 // This wrapper mitigates both those pain points.
38 function catchException(done, fn) {
43 console.log('Failed with the following error', e);
44 expect(e).toBeFalsy();
48 // We don't call done with finally because
49 // that would make the break the asynchronous nature