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

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: using promise chain in 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.");
Justin Novosad 2016/01/04 20:45:51 No need for "FAIL:" because testFailed already add
xidachen 2016/01/05 16:06:44 Acknowledged.
32 } catch (e) {
33 testPassed("PASS: ImageBitmap is tainted. Threw error: " + e);
Justin Novosad 2016/01/04 20:45:51 No need for "PASS:". Notice the lines starting in
xidachen 2016/01/05 16:06:44 Acknowledged.
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
42 image.addEventListener('load', function() {
43 document.body.appendChild(image);
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() {
Justin Novosad 2016/01/04 20:45:51 inconsistent line wrapping ("then" vs. ".then")
xidachen 2016/01/05 16:06:44 Acknowledged.
57 document.body.appendChild(video);
58 video.play();
59 video.addEventListener('playing', function() {
60 shouldBeAcceptedAndTainted(createImageBitmap(video, 0, 0, 10, 10), 'video' ).then(finishJSTest, finishJSTest);
Justin Novosad 2016/01/04 20:45:51 The rejection handlers should print a failure mess
xidachen 2016/01/05 16:06:44 Acknowledged.
30 }); 61 });
31 }).then(function() { 62 }, function() {
Justin Novosad 2016/01/04 20:45:51 "function() { myFunction(); }" => "myFunction"
xidachen 2016/01/05 16:06:44 Acknowledged.
32 return new Promise(function(resolve, reject) { 63 finishJSTest();
33 var video = document.createElement('video'); 64 });
34 video.src = 'http://localhost:8080/media/resources/load-video.php?name=t est.ogv&amp;type=video/ogv'; 65 });
35 video.addEventListener('playing', resolve.bind(undefined, video)); 66 }, function() {
36 document.body.appendChild(video); 67 finishJSTest();
37 video.play(); 68 });
38 }).then(function(video) { 69 }, function() {
39 return shouldBeRejected(createImageBitmap(video, 0, 0, 10, 10), 'video') ; 70 finishJSTest();
40 }); 71 });
41 }).catch(function(e) { 72 });
42 testFailed('Unexpected rejection: ' + e);
43 }).then(finishJSTest, finishJSTest);
44 </script> 73 </script>
45 </body> 74 </body>
46 </html> 75 </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