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

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: more on layout test 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
31 testFailed("FAIL: ImageBitmap is not tainted.");
32 } catch (e) {
33 testPassed("PASS: ImageBitmap is tainted. Threw error: " + e);
34 }
35 }
36
37 var image = document.createElement('img');
38 image.src = 'http://localhost:8080/security/resources/abe.png';
39 var video = document.createElement('video');
40 video.src = 'http://localhost:8080/media/resources/load-video.php?name=test.ogv& amp;type=video/ogv';
41 var p1, p2, p3, p4;
42
43 image.addEventListener('load', function() {
44 document.body.appendChild(image);
45 p1 = shouldBeAcceptedAndTainted(createImageBitmap(image, 0, 0, 10, 10), 'ima ge');
46 var canvas = document.createElement("canvas");
47 canvas.width = 10;
48 canvas.height = 10;
49 var context = canvas.getContext("2d");
50 context.drawImage(image, 0, 0, 10, 10);
Justin Novosad 2015/12/30 20:42:18 Add a comment that this is to taint the canvas
xidachen 2015/12/31 03:37:01 Done.
51 p2 = shouldBeAcceptedAndTainted(createImageBitmap(canvas, 0, 0, 10, 10), 'ca nvas');
52 createImageBitmap(image).then(imageBitmap => {
53 p3 = shouldBeAcceptedAndTainted(createImageBitmap(imageBitmap, 0, 0, 10, 10), 'imageBitmap');
30 }); 54 });
31 }).then(function() { 55 Promise.all([p1, p2, p3]).then(function() {
Justin Novosad 2015/12/30 20:42:18 Although this is clean and concise, it makes execu
xidachen 2015/12/31 03:37:01 Done.
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=t est.ogv&amp;type=video/ogv';
35 video.addEventListener('playing', resolve.bind(undefined, video));
36 document.body.appendChild(video); 56 document.body.appendChild(video);
37 video.play(); 57 video.play();
38 }).then(function(video) { 58 video.addEventListener('playing', function() {
39 return shouldBeRejected(createImageBitmap(video, 0, 0, 10, 10), 'video') ; 59 p4 = shouldBeAcceptedAndTainted(createImageBitmap(video, 0, 0, 10, 1 0), 'video');
60 p4.then(finishJSTest, finishJSTest);
61 });
62 }, function() {
63 finishJSTest();
40 }); 64 });
41 }).catch(function(e) { 65 });
42 testFailed('Unexpected rejection: ' + e);
43 }).then(finishJSTest, finishJSTest);
44 </script> 66 </script>
45 </body> 67 </body>
46 </html> 68 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/cross-origin-createImageBitmap-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698