Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / security / cross-origin-createImageBitmap.html
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.");
7
8 window.jsTestIsAsync = true;
9 var reason;
10
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     });
20 }
21
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>