| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <body> | 3 <body> |
| 4 <script src="/js-test-resources/js-test.js"></script> | 4 <script src="/js-test-resources/js-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 description("The image bitmap factories should throw exceptions on cross
-origin access."); | 6 description("The image bitmap factories should throw exceptions on cross-origin
access."); |
| 7 | 7 |
| 8 window.jsTestIsAsync = true; | 8 window.jsTestIsAsync = true; |
| 9 var reason; |
| 9 | 10 |
| 10 var img = document.createElement('img'); | 11 function shouldBeRejected(promise, message) { |
| 11 var vid = document.createElement('video'); | 12 return promise.then(function() { |
| 13 testFailed('Resolved unexpectedly: ' + message); |
| 14 }, function(e) { |
| 15 reason = e; |
| 16 testPassed('Rejected as expected: ' + message); |
| 17 shouldBeTrue('reason instanceof Error'); |
| 18 debug(e); |
| 19 }); |
| 20 } |
| 12 | 21 |
| 13 document.body.appendChild(img); | 22 Promise.resolve().then(function() { |
| 14 img.src = 'http://localhost:8080/security/resources/abe.png'; | 23 return new Promise(function(resolve, reject) { |
| 15 img.addEventListener('load', function () { | 24 var image = document.createElement('img'); |
| 16 shouldThrow('createImageBitmap(img, 0, 0, 10, 10)', '"SecurityError:
Failed to execute \'createImageBitmap\' on \'Window\': Cross-origin access to t
he source image is denied."'); | 25 image.addEventListener('load', resolve.bind(undefined, image)); |
| 17 | 26 image.src = 'http://localhost:8080/security/resources/abe.png'; |
| 18 vid.src = 'http://localhost:8080/media/resources/load-video.php?name
=test.ogv&type=video/ogv'; | 27 document.body.appendChild(image); |
| 19 vid.addEventListener('playing', function () { | 28 }).then(function(image) { |
| 20 shouldThrow('createImageBitmap(vid, 0, 0, 10, 10)', '"SecurityEr
ror: Failed to execute \'createImageBitmap\' on \'Window\': Cross-origin access
to the source video is denied."'); | 29 return shouldBeRejected(createImageBitmap(image, 0, 0, 10, 10), 'image')
; |
| 21 finishJSTest(); | 30 }); |
| 22 }); | 31 }).then(function() { |
| 23 document.body.appendChild(vid); | 32 return new Promise(function(resolve, reject) { |
| 24 vid.play(); | 33 var video = document.createElement('video'); |
| 25 }); | 34 video.src = 'http://localhost:8080/media/resources/load-video.php?name=t
est.ogv&type=video/ogv'; |
| 26 </script> | 35 video.addEventListener('playing', resolve.bind(undefined, video)); |
| 36 document.body.appendChild(video); |
| 37 video.play(); |
| 38 }).then(function(video) { |
| 39 return shouldBeRejected(createImageBitmap(video, 0, 0, 10, 10), 'video')
; |
| 40 }); |
| 41 }).catch(function(e) { |
| 42 testFailed('Unexpected rejection: ' + e); |
| 43 }).then(finishJSTest, finishJSTest); |
| 44 </script> |
| 27 </body> | 45 </body> |
| 28 </html> | 46 </html> |
| OLD | NEW |