4 <script src="/js-test-resources/js-test.js"></script>
6 description("The image bitmap factories should throw exceptions on cross-origin access.");
8 window.jsTestIsAsync = true;
11 function shouldBeRejected(promise, message) {
12 return promise.then(function() {
13 testFailed('Resolved unexpectedly: ' + message);
16 testPassed('Rejected as expected: ' + message);
17 shouldBeTrue('reason instanceof Error');
22 Promise.resolve().then(function() {
23 return new Promise(function(resolve, reject) {
24 var image = document.createElement('img');
25 image.addEventListener('load', resolve.bind(undefined, image));
26 image.src = 'http://localhost:8080/security/resources/abe.png';
27 document.body.appendChild(image);
28 }).then(function(image) {
29 return shouldBeRejected(createImageBitmap(image, 0, 0, 10, 10), 'image');
32 return new Promise(function(resolve, reject) {
33 var video = document.createElement('video');
34 video.src = 'http://localhost:8080/media/resources/load-video.php?name=test.ogv&type=video/ogv';
35 video.addEventListener('playing', resolve.bind(undefined, video));
36 document.body.appendChild(video);
38 }).then(function(video) {
39 return shouldBeRejected(createImageBitmap(video, 0, 0, 10, 10), 'video');
41 }).catch(function(e) {
42 testFailed('Unexpected rejection: ' + e);
43 }).then(finishJSTest, finishJSTest);