OLD | NEW |
(Empty) | |
| 1 function assert_allowed_image_in_document(test, doc, url) { |
| 2 doc.addEventListener('securitypolicyviolation', test.step_func(e => { |
| 3 if (e.blockedURI == url) |
| 4 assert_unreached("No violation expected for " + url); |
| 5 })); |
| 6 |
| 7 var i = doc.createElement('img'); |
| 8 i.onerror = test.unreached_func("onerror fired for " + url); |
| 9 i.onload = test.step_func_done(); |
| 10 i.src = url; |
| 11 } |
| 12 |
| 13 |
| 14 function assert_blocked_image_in_document(test, doc, url) { |
| 15 var cspEvent = false; |
| 16 var errorEvent = false; |
| 17 doc.addEventListener('securitypolicyviolation', test.step_func(e => { |
| 18 if (e.blockedURI != url) |
| 19 return; |
| 20 |
| 21 cspEvent = true; |
| 22 if (errorEvent) |
| 23 test.done(); |
| 24 })); |
| 25 |
| 26 var i = doc.createElement('img'); |
| 27 i.onload = test.unreached_func("onload fired for " + url); |
| 28 i.onerror = test.step_func(e => { |
| 29 errorEvent = true; |
| 30 if (cspEvent) |
| 31 test.done(); |
| 32 }); |
| 33 i.src = url; |
| 34 } |
OLD | NEW |