Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / security / cross-origin-createImageBitmap.html
blobb5b56246330c1651dda1cd7b99ac56b1721b2f14
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="/js-test-resources/js-test.js"></script>
5 <script>
6 description("The image bitmap factories should throw exceptions on cross-origin access.");
8 window.jsTestIsAsync = true;
9 var reason;
11 function shouldBeRejected(promise, message) {
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 });
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');
30 });
31 }).then(function() {
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&amp;type=video/ogv';
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>
45 </body>
46 </html>