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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-size-tooBig.html

Issue 2249853008: Reject createImageBitmap promise when the cropRect or resize is too big (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update tests Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-size-tooBig.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-size-tooBig.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-size-tooBig.html
new file mode 100644
index 0000000000000000000000000000000000000000..e29cc56301e460a33b8f9ab0b446764896e781be
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-size-tooBig.html
@@ -0,0 +1,103 @@
+<!DOCTYPE HTML>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+function testImageBitmap(source)
+{
+ return createImageBitmap(source, 0, 0, 0x8000, 0x8000, {imageOrientation: "flipY", premultiplyAlpha: "none"}).then(function() {
+ assert_true(false, "Promise should be rejected if the cropRect is too big.");
+ }, function() {
+ return createImageBitmap(source, 5, 5, 10, 10, {resizeWidth: 0x8000, resizeHeight: 0x8000}).then(function() {
+ assert_true(false, "Promise should be rejected if the resizeWidth or resizeHeight is too big.");
+ }, function() {
+ });
+ });
+}
+
+function initializeTestCanvas()
+{
+ var testCanvas = document.createElement("canvas");
+ testCanvas.width = 20;
+ testCanvas.height = 20;
+ var testCtx = testCanvas.getContext("2d");
+ testCtx.fillStyle = "rgb(255, 0, 0)";
+ testCtx.fillRect(0, 0, 10, 10);
+ testCtx.fillStyle = "rgb(0, 255, 0)";
+ testCtx.fillRect(10, 0, 10, 10);
+ testCtx.fillStyle = "rgb(0, 0, 255)";
+ testCtx.fillRect(0, 10, 10, 10);
+ testCtx.fillStyle = "rgb(0, 0, 0)";
+ testCtx.fillRect(10, 10, 10, 10);
+ return testCanvas;
+}
+
+function getBlobWithXhr(url)
+{
+ return new Promise((resolve, reject) => {
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", url);
+ xhr.responseType = 'blob';
+ xhr.send();
+ xhr.onload = function() {
+ resolve(xhr.response);
+ };
+ });
+}
+
+function loadImage(url)
+{
+ return new Promise((resolve, reject) => {
+ var image = new Image();
+ image.onload = function() {
+ resolve(image);
+ }
+ image.src = url;
+ });
+}
+
+function loadVideo(url)
+{
+ return new Promise((resolve, reject) => {
+ var video = document.createElement("video");
+ video.oncanplaythrough = function() {
+ resolve(video);
+ };
+ video.src = url;
+ });
+}
+
+// Blob
+promise_test(function() {
+ return getBlobWithXhr('resources/pattern.png').then(testImageBitmap);
+}, 'createImageBitmap from a Blob with a big cropRect.');
+
+// HTMLCanvasElement
+promise_test(function() {
+ var testCanvas = initializeTestCanvas();
+ return testImageBitmap(testCanvas);
+}, 'createImageBitmap from a HTMLCanvasElement with a big cropRect.');
+
+// HTMLImageElement
+promise_test(function() {
+ return loadImage('resources/pattern.png').then(testImageBitmap);
+}, 'createImageBitmap from a HTMLImageElement with a big cropRect.');
+
+// ImageBitmap
+promise_test(function() {
+ var testCanvas = initializeTestCanvas();
+ return createImageBitmap(testCanvas).then(testImageBitmap);
+}, 'createImageBitmap from an ImageBitmap with a big cropRect.');
+
+// ImageData
+promise_test(function() {
+ var canvas = initializeTestCanvas();
+ var ctx = canvas.getContext("2d");
+ var data = ctx.getImageData(0, 0, 20, 20);
+ return testImageBitmap(data);
+}, 'createImageBitmap from an ImageData with a big cropRect.');
+
+// HTMLVideoElement
+promise_test(function() {
+ return loadVideo('../../compositing/resources/video.ogv').then(testImageBitmap);
+}, 'createImageBitmap from a HTMLVideoElement with resize option.');
+</script>

Powered by Google App Engine
This is Rietveld 408576698