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

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

Issue 211313003: Fix crash when creating an ImageBitmap from an invalid canvas (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: staticity reinstalment Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 TypeError = "TypeError: Failed to execute 'createImageBitmap' on 'Window': N o function was found that matched the signature provided."; 11 var TypeError = "TypeError: Failed to execute 'createImageBitmap' on 'Window': N o function was found that matched the signature provided.";
12 var IndexSizeError = "IndexSizeError: Index or size was negative, or greater tha n the allowed value."; 12 var IndexSizeError = "IndexSizeError: Index or size was negative, or greater tha n the allowed value.";
13 13
14 var image; 14 var image;
15 var testBitmap; // an ImageBitmap that is uncropped. We use this to test createI mageBitmap(testBitmap) 15 var testBitmap; // an ImageBitmap that is uncropped. We use this to test createI mageBitmap(testBitmap)
16 var d; // image.imageData 16 var d; // image.imageData
17 var blob; 17 var blob;
18 var invalidBlob; 18 var invalidBlob;
19 var invalidBlobTestPassed = false;
20 var invalidCanvasTestPassed = false;
19 21
20 // Draw to an auxillary canvas. 22 // Draw to an auxillary canvas.
21 var aCanvas = document.createElement("canvas"); 23 var aCanvas = document.createElement("canvas");
22 aCanvas.setAttribute("width", "200"); 24 aCanvas.setAttribute("width", "200");
23 aCanvas.setAttribute("height", "200"); 25 aCanvas.setAttribute("height", "200");
24 var aCtx = aCanvas.getContext("2d"); 26 var aCtx = aCanvas.getContext("2d");
25 27
28 // Create a terapixel canvas to generate an invalid canvas through allocation fa ilure
29 var invalidCanvas = document.createElement("canvas");
30 invalidCanvas.setAttribute("width", "1000000");
31 invalidCanvas.setAttribute("height", "1000000");
32
26 image = new Image(); 33 image = new Image();
27 image.onload = imageLoaded; 34 image.onload = imageLoaded;
28 35
29 // Before image loads 36 // Before image loads
30 shouldThrow("createImageBitmap(image)"); 37 shouldThrow("createImageBitmap(image)");
31 image.src = aCanvas.toDataURL(); 38 image.src = aCanvas.toDataURL();
32 39
33 video = document.createElement("video"); 40 video = document.createElement("video");
34 video.addEventListener("canplaythrough", videoLoaded, false); 41 video.addEventListener("canplaythrough", videoLoaded, false);
35 42
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 var xhr2 = new XMLHttpRequest(); 84 var xhr2 = new XMLHttpRequest();
78 xhr2.open("GET", 'resources/repaint.js'); 85 xhr2.open("GET", 'resources/repaint.js');
79 xhr2.responseType = 'blob'; 86 xhr2.responseType = 'blob';
80 xhr2.send(); 87 xhr2.send();
81 xhr2.onload = function() { 88 xhr2.onload = function() {
82 invalidBlob = xhr2.response; 89 invalidBlob = xhr2.response;
83 invalidBlobLoaded = true; 90 invalidBlobLoaded = true;
84 loaded(); 91 loaded();
85 } 92 }
86 93
94 var finishIfDoneCallsRemaining = 2;
95 function finishIfDone() {
96 finishIfDoneCallsRemaining--;
97 if (!finishIfDoneCallsRemaining) {
98 // Because promise fulfillment is asynchonous, pass/fail messages
99 // must be handled here to ensure a deterministic message order.
100 if (invalidBlobTestPassed) {
101 testPassed("createImageBitmap(invalidBlob) was rejected.");
102 } else {
103 testFailed("Invalid blob fulfilled.");
104 }
105 if (invalidCanvasTestPassed) {
106 testPassed("createImageBitmap(invalidCanvas) was rejected.");
107 } else {
108 testFailed("Invalid canvas fulfilled.");
109 }
110 finishJSTest();
111 }
112 }
113
87 function loaded() { 114 function loaded() {
88 if (imageLoaded && videoLoaded && imageBitmapLoaded && blobLoaded && invalid BlobLoaded) { 115 if (imageLoaded && videoLoaded && imageBitmapLoaded && blobLoaded && invalid BlobLoaded) {
89 shouldThrow("createImageBitmap(undefined)", "TypeError"); 116 shouldThrow("createImageBitmap(undefined)", "TypeError");
90 117
91 shouldThrow("createImageBitmap(image, 0, 0, 10, 0)"); 118 shouldThrow("createImageBitmap(image, 0, 0, 10, 0)");
92 shouldThrow("createImageBitmap(image, 0, 0, 0, 10)"); 119 shouldThrow("createImageBitmap(image, 0, 0, 0, 10)");
93 120
94 shouldThrow("createImageBitmap(video, 0, 0, 10, 0)"); 121 shouldThrow("createImageBitmap(video, 0, 0, 10, 0)");
95 shouldThrow("createImageBitmap(video, 0, 0, 0, 10)"); 122 shouldThrow("createImageBitmap(video, 0, 0, 0, 10)");
96 123
97 shouldThrow("createImageBitmap(aCanvas, 0, 0, 10, 0)"); 124 shouldThrow("createImageBitmap(aCanvas, 0, 0, 10, 0)");
98 shouldThrow("createImageBitmap(aCanvas, 0, 0, 0, 10)"); 125 shouldThrow("createImageBitmap(aCanvas, 0, 0, 0, 10)");
99 126
100 shouldThrow("createImageBitmap(d, 0, 0, 10, 0)"); 127 shouldThrow("createImageBitmap(d, 0, 0, 10, 0)");
101 shouldThrow("createImageBitmap(d, 0, 0, 0, 10)"); 128 shouldThrow("createImageBitmap(d, 0, 0, 0, 10)");
102 129
103 shouldThrow("createImageBitmap(aCtx, 0, 0, 10, 0)"); 130 shouldThrow("createImageBitmap(aCtx, 0, 0, 10, 0)");
104 shouldThrow("createImageBitmap(aCtx, 0, 0, 0, 10)"); 131 shouldThrow("createImageBitmap(aCtx, 0, 0, 0, 10)");
105 132
106 shouldThrow("createImageBitmap(testBitmap, 0, 0, 10, 0)"); 133 shouldThrow("createImageBitmap(testBitmap, 0, 0, 10, 0)");
107 shouldThrow("createImageBitmap(testBitmap, 0, 0, 0, 10)"); 134 shouldThrow("createImageBitmap(testBitmap, 0, 0, 0, 10)");
108 135
109 shouldThrow("createImageBitmap(blob, 0, 0, 10, 0)"); 136 shouldThrow("createImageBitmap(blob, 0, 0, 10, 0)");
110 shouldThrow("createImageBitmap(blob, 0, 0, 0, 10)"); 137 shouldThrow("createImageBitmap(blob, 0, 0, 0, 10)");
111 138
112 createImageBitmap(invalidBlob).then(function() { 139 createImageBitmap(invalidBlob).then(function() {
113 testFailed("Invalid blob fulfilled."); 140 finishIfDone();
114 finishJSTest();
115 }, function() { 141 }, function() {
116 testPassed("createImageBitmap(invalidBlob) was rejected."); 142 invalidBlobTestPassed = true;
117 finishJSTest(); 143 finishIfDone();
118 }); 144 });
119 } 145
146 createImageBitmap(invalidCanvas).then(function() {
147 finishIfDone();
148 }, function() {
149 invalidCanvasTestPassed = true;
150 finishIfDone();
151 });
152 }
120 } 153 }
121
122 </script> 154 </script>
123 </body> 155 </body>
124 </html> 156 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-args-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698