Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / security / cross-origin-createImageBitmap.html
index ca29d33..b5b5624 100644 (file)
@@ -1,26 +1,46 @@
 <!DOCTYPE html>
 <html>
 <body>
-    <script src="/js-test-resources/js-test-pre.js"></script>
-    <script>
-        description("The image bitmap factories should throw exceptions on cross-origin access.");
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+description("The image bitmap factories should throw exceptions on cross-origin access.");
 
-        window.jsTestIsAsync = true;
+window.jsTestIsAsync = true;
+var reason;
 
-        var img = document.createElement('img');
-        document.body.appendChild(img);
-        img.src = 'http://localhost:8080/security/resources/abe.png';
-        
-        shouldThrow('createImageBitmap(img, 0, 0, 10, 10)', '"SecurityError: Failed to execute \'createImageBitmap\' on \'ImageBitmapFactories\': cross-origin access to the source image is denied."');
+function shouldBeRejected(promise, message) {
+    return promise.then(function() {
+        testFailed('Resolved unexpectedly: ' + message);
+    }, function(e) {
+        reason = e;
+        testPassed('Rejected as expected: ' + message);
+        shouldBeTrue('reason instanceof Error');
+        debug(e);
+    });
+}
 
-        var vid = document.createElement('video');
-        vid.src = 'http://localhost:8080/media/resources/load-video.php?name=test.ogv&amp;type=video/ogv';
-        vid.addEventListener('playing', function () {
-            shouldThrow('createImageBitmap(vid, 0, 0, 10, 10)', '"SecurityError: Failed to execute \'createImageBitmap\' on \'ImageBitmapFactories\': cross-origin access to the source video is denied."');
-            finishJSTest();
-        });
-        document.body.appendChild(vid);
-        vid.play();
-    </script>
+Promise.resolve().then(function() {
+    return new Promise(function(resolve, reject) {
+        var image = document.createElement('img');
+        image.addEventListener('load', resolve.bind(undefined, image));
+        image.src = 'http://localhost:8080/security/resources/abe.png';
+        document.body.appendChild(image);
+    }).then(function(image) {
+        return shouldBeRejected(createImageBitmap(image, 0, 0, 10, 10), 'image');
+    });
+}).then(function() {
+    return new Promise(function(resolve, reject) {
+        var video = document.createElement('video');
+        video.src = 'http://localhost:8080/media/resources/load-video.php?name=test.ogv&amp;type=video/ogv';
+        video.addEventListener('playing', resolve.bind(undefined, video));
+        document.body.appendChild(video);
+        video.play();
+    }).then(function(video) {
+        return shouldBeRejected(createImageBitmap(video, 0, 0, 10, 10), 'video');
+    });
+}).catch(function(e) {
+    testFailed('Unexpected rejection: ' + e);
+}).then(finishJSTest, finishJSTest);
+</script>
 </body>
 </html>