Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap.html

Issue 1532473002: Add a origin clean flag in ImageBitmap class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compilation error Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 not throw exceptions on cross-ori gin access.");
7 7
8 window.jsTestIsAsync = true; 8 window.jsTestIsAsync = true;
9 var reason; 9 var reason;
10 10
11 function shouldBeRejected(promise, message) { 11 function shouldBeAcceptedAndTainted(promise, message) {
12 return promise.then(function() { 12 return promise.then(function(imageBitmap) {
13 testFailed('Resolved unexpectedly: ' + message); 13 testPassed('Resolved as expected: ' + message);
14 shouldBeTainted(imageBitmap);
14 }, function(e) { 15 }, function(e) {
15 reason = e; 16 reason = e;
16 testPassed('Rejected as expected: ' + message); 17 testFailed('Rejected unexpectedly: ' + message);
17 shouldBeTrue('reason instanceof Error'); 18 shouldBeTrue('reason instanceof Error');
18 debug(e); 19 debug(e);
19 }); 20 });
20 } 21 }
21 22
22 Promise.resolve().then(function() { 23 function shouldBeTainted(imageBitmap) {
23 return new Promise(function(resolve, reject) { 24 var canvas = document.createElement("canvas");
24 var image = document.createElement('img'); 25 canvas.width = 10;
25 image.addEventListener('load', resolve.bind(undefined, image)); 26 canvas.height = 10;
26 image.src = 'http://localhost:8080/security/resources/abe.png'; 27 var context = canvas.getContext("2d");
27 document.body.appendChild(image); 28 context.drawImage(imageBitmap, 0, 0, 10, 10);
28 }).then(function(image) { 29 try {
29 return shouldBeRejected(createImageBitmap(image, 0, 0, 10, 10), 'image') ; 30 var imageData = context.getImageData(0, 0, 10, 10);
30 }); 31 testFailed("ImageBitmap is not tainted.");
31 }).then(function() { 32 } catch (e) {
32 return new Promise(function(resolve, reject) { 33 testPassed("ImageBitmap is tainted. Threw error: " + e);
33 var video = document.createElement('video'); 34 }
34 video.src = 'http://localhost:8080/media/resources/load-video.php?name=t est.ogv&amp;type=video/ogv'; 35 }
35 video.addEventListener('playing', resolve.bind(undefined, video)); 36
36 document.body.appendChild(video); 37 var image = document.createElement('img');
37 video.play(); 38 image.src = 'http://localhost:8080/security/resources/abe.png';
38 }).then(function(video) { 39 var video = document.createElement('video');
39 return shouldBeRejected(createImageBitmap(video, 0, 0, 10, 10), 'video') ; 40 video.src = 'http://localhost:8080/media/resources/load-video.php?name=test.ogv& amp;type=video/ogv';
40 }); 41
41 }).catch(function(e) { 42 image.addEventListener('load', function() {
42 testFailed('Unexpected rejection: ' + e); 43 document.body.appendChild(image);
43 }).then(finishJSTest, finishJSTest); 44 shouldBeAcceptedAndTainted(createImageBitmap(image, 0, 0, 10, 10), 'image')
45 .then(function() {
46 var canvas = document.createElement("canvas");
47 canvas.width = 10;
48 canvas.height = 10;
49 var context = canvas.getContext("2d");
50 // taint the canvas
51 context.drawImage(image, 0, 0, 10, 10);
52 shouldBeAcceptedAndTainted(createImageBitmap(canvas, 0, 0, 10, 10), 'canvas' )
53 .then(function() {
54 createImageBitmap(image).then(imageBitmap => {
55 shouldBeAcceptedAndTainted(createImageBitmap(imageBitmap, 0, 0, 10, 10), 'im ageBitmap')
56 .then(function() {
57 document.body.appendChild(video);
58 video.play();
59 video.addEventListener('playing', function() {
60 shouldBeAcceptedAndTainted(createImageBitmap(video, 0, 0, 10, 10), 'video' )
61 .then(finishJSTest, ()=> {
62 testFailed("Unexpected failure");
63 finishJSTest();
64 });
65 });
66 }, ()=> {
67 testFailed("Unexpected failure");
68 finishJSTest();
69 });
70 });
71 }, ()=> {
72 testFailed("Unexpected failure");
73 finishJSTest();
74 });
75 }, ()=> {
76 testFailed("Unexpected failure");
77 finishJSTest();
78 });
79 });
44 </script> 80 </script>
45 </body> 81 </body>
46 </html> 82 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698