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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-args.html

Issue 2500493002: Prevent bad casting in ImageBitmap when calling ArrayBuffer::createOrNull (Closed)
Patch Set: change all size_t to unsigned Created 4 years, 1 month 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/fast/canvas/canvas-createImageBitmap-invalid-args-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 PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 description("Ensure correct behavior of createImageBitmap for invalid inputs."); 8 description("Ensure correct behavior of createImageBitmap for invalid inputs.");
9 window.jsTestIsAsync = true; 9 window.jsTestIsAsync = true;
10 10
11 var reason; 11 var reason;
12 12
13 function shouldBeRejected(promise, message) { 13 function shouldBeRejected(promise, message, isReasonError) {
14 return promise.then(function() { 14 return promise.then(function() {
15 testFailed('Resolved unexpectedly: ' + message); 15 testFailed('Resolved unexpectedly: ' + message);
16 }, function(e) { 16 }, function(e) {
17 reason = e; 17 reason = e;
18 testPassed('Rejected as expected: ' + message); 18 testPassed('Rejected as expected: ' + message);
19 shouldBeTrue('reason instanceof Error'); 19 if (isReasonError)
20 shouldBeTrue('reason instanceof Error');
20 debug(e); 21 debug(e);
21 }); 22 });
22 } 23 }
23 24
24 function checkInvalidRange(source, message) { 25 function checkInvalidRange(source, message) {
25 return Promise.resolve().then(function() { 26 return Promise.resolve().then(function() {
26 return shouldBeRejected(createImageBitmap(source, 0, 0, 10, 0), message + ' / invalid range'); 27 return shouldBeRejected(createImageBitmap(source, 0, 0, 10, 0), message + ' / invalid range', true);
27 }).then(function() { 28 }).then(function() {
28 return shouldBeRejected(createImageBitmap(source, 0, 0, 0, 10), message + ' / invalid range'); 29 return shouldBeRejected(createImageBitmap(source, 0, 0, 0, 10), message + ' / invalid range', true);
29 }); 30 });
30 } 31 }
31 32
32 function createCanvas() { 33 function createCanvas() {
33 return new Promise(function(resolve, reject) { 34 return new Promise(function(resolve, reject) {
34 var canvas = document.createElement('canvas'); 35 var canvas = document.createElement('canvas');
35 canvas.setAttribute('width', '200'); 36 canvas.setAttribute('width', '200');
36 canvas.setAttribute('height', '200'); 37 canvas.setAttribute('height', '200');
37 resolve(canvas); 38 resolve(canvas);
38 }); 39 });
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 xhr.responseType = 'blob'; 76 xhr.responseType = 'blob';
76 xhr.onload = function() { 77 xhr.onload = function() {
77 resolve(xhr.response); 78 resolve(xhr.response);
78 }; 79 };
79 xhr.onerror = reject; 80 xhr.onerror = reject;
80 xhr.send(); 81 xhr.send();
81 }); 82 });
82 } 83 }
83 84
84 Promise.resolve().then(function() { 85 Promise.resolve().then(function() {
85 return shouldBeRejected(createImageBitmap(undefined), 'undefined'); 86 return shouldBeRejected(createImageBitmap(undefined), 'undefined', true);
86 }).then(function() { 87 }).then(function() {
87 return shouldBeRejected(createImageBitmap(null), 'null'); 88 return shouldBeRejected(createImageBitmap(null), 'null', true);
88 }).then(function() { 89 }).then(function() {
89 return shouldBeRejected(createImageBitmap(new Image), 'empty image'); 90 return shouldBeRejected(createImageBitmap(new Image), 'empty image', true);
90 }).then(function() { 91 }).then(function() {
91 return shouldBeRejected(createImageBitmap(document.createElement('video')), 'empty video'); 92 return shouldBeRejected(createImageBitmap(document.createElement('video')), 'empty video', true);
92 }).then(function() { 93 }).then(function() {
93 return createImage().then(function(image) { 94 return createImage().then(function(image) {
94 return checkInvalidRange(image, 'image'); 95 return checkInvalidRange(image, 'image');
95 }); 96 });
96 }).then(function() { 97 }).then(function() {
97 return createVideo().then(function(video) { 98 return createVideo().then(function(video) {
98 return checkInvalidRange(video, 'video'); 99 return checkInvalidRange(video, 'video');
99 }); 100 });
100 }).then(function() { 101 }).then(function() {
101 return createCanvas().then(function(canvas) { 102 return createCanvas().then(function(canvas) {
102 return checkInvalidRange(canvas, 'canvas'); 103 return checkInvalidRange(canvas, 'canvas');
103 }); 104 });
104 }).then(function() { 105 }).then(function() {
105 return createCanvas().then(function(canvas) { 106 return createCanvas().then(function(canvas) {
106 var imagedata = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height); 107 var imagedata = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height);
107 return checkInvalidRange(imagedata, 'canvas imagedata') 108 return checkInvalidRange(imagedata, 'canvas imagedata')
108 }); 109 });
109 }).then(function() { 110 }).then(function() {
110 return createImage().then(function(image) { 111 return createImage().then(function(image) {
111 return createImageBitmap(image); 112 return createImageBitmap(image);
112 }).then(function(bitmap) { 113 }).then(function(bitmap) {
113 return checkInvalidRange(bitmap, 'image bitmap'); 114 return checkInvalidRange(bitmap, 'image bitmap');
114 }); 115 });
115 }).then(function() { 116 }).then(function() {
116 return createBlob('resources/pattern.png').then(function(blob) { 117 return createBlob('resources/pattern.png').then(function(blob) {
117 return checkInvalidRange(blob, 'blob'); 118 return checkInvalidRange(blob, 'blob');
118 }); 119 });
119 }).then(function() { 120 }).then(function() {
120 return createBlob('resources/shadow-offset.js').then(function(blob) { 121 return createBlob('resources/shadow-offset.js').then(function(blob) {
121 return shouldBeRejected(createImageBitmap(blob), 'invalid blob'); 122 return shouldBeRejected(createImageBitmap(blob), 'invalid blob', true);
122 }); 123 });
123 }).then(function() { 124 }).then(function() {
124 return createInvalidCanvas().then(function(invalidCanvas) { 125 return createInvalidCanvas().then(function(invalidCanvas) {
125 return shouldBeRejected(createImageBitmap(invalidCanvas), 'invalid canva s'); 126 return shouldBeRejected(createImageBitmap(invalidCanvas), 'invalid canva s', false);
126 }); 127 });
128 }).then(function() {
129 var imageData = new ImageData(10, 10);
130 return shouldBeRejected(createImageBitmap(imageData, 0, 0, 0x10004, 0x10004, {premultiplyAlpha:"none"}), 'cropRect too big', false);
127 }).catch(function(e) { 131 }).catch(function(e) {
128 testFailed('Unexpected rejection: ' + e); 132 testFailed('Unexpected rejection: ' + e);
129 }).then(finishJSTest, finishJSTest); 133 }).then(finishJSTest, finishJSTest);
130 134
131 </script> 135 </script>
132 </body> 136 </body>
133 </html> 137 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-args-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698