OLD | NEW |
1 function create_window_in_test(t, srcdoc) { | 1 function create_window_in_test(t, srcdoc) { |
2 let p = new Promise((resolve) => { | 2 let p = new Promise((resolve) => { |
3 let f = document.createElement('iframe'); | 3 let f = document.createElement('iframe'); |
4 f.srcdoc = srcdoc ? srcdoc : ''; | 4 f.srcdoc = srcdoc ? srcdoc : ''; |
5 f.onload = (event) => { | 5 f.onload = (event) => { |
6 let w = f.contentWindow; | 6 let w = f.contentWindow; |
7 t.add_cleanup(() => f.parentNode && f.remove()); | 7 t.add_cleanup(() => f.parentNode && f.remove()); |
8 resolve(w); | 8 resolve(w); |
9 }; | 9 }; |
10 document.body.appendChild(f); | 10 document.body.appendChild(f); |
(...skipping 30 matching lines...) Expand all Loading... |
41 assert_equals(actual[i][0], expected[i][0], callback + ' callback should be
invoked'); | 41 assert_equals(actual[i][0], expected[i][0], callback + ' callback should be
invoked'); |
42 assert_equals(actual[i][1], expected[i][1], callback + ' should be invoked o
n the element ' + expected[i][1]); | 42 assert_equals(actual[i][1], expected[i][1], callback + ' should be invoked o
n the element ' + expected[i][1]); |
43 assert_array_equals(actual[i][2], expected[i][2], callback + ' should be inv
oked with the arguments ' + expected[i][2]); | 43 assert_array_equals(actual[i][2], expected[i][2], callback + ' should be inv
oked with the arguments ' + expected[i][2]); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 function assert_is_upgraded(element, className, description) { | 47 function assert_is_upgraded(element, className, description) { |
48 assert_true(element.matches(':defined'), description); | 48 assert_true(element.matches(':defined'), description); |
49 assert_equals(Object.getPrototypeOf(element), className.prototype, description
); | 49 assert_equals(Object.getPrototypeOf(element), className.prototype, description
); |
50 } | 50 } |
| 51 |
| 52 // Asserts that func synchronously invokes the error event handler in w |
| 53 // with the expected error. |
| 54 function assert_reports(w, expected_error, func, description) { |
| 55 let old_onerror = w.onerror; |
| 56 let errors = []; |
| 57 w.onerror = (event, source, line_number, column_number, error) => { |
| 58 errors.push(error); |
| 59 return true; // the error is handled |
| 60 }; |
| 61 try { |
| 62 func(); |
| 63 } catch (e) { |
| 64 assert_unreached(`should report, not throw, an exception: ${e}`); |
| 65 } finally { |
| 66 w.onerror = old_onerror; |
| 67 } |
| 68 assert_equals(1, errors.length); |
| 69 // assert_throws has an error expectation matcher that can only be |
| 70 // accessed by throwing the error |
| 71 assert_throws(expected_error, () => { throw errors[0]; }); |
| 72 } |
OLD | NEW |