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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-convertToBlob-noIdleTask.html

Issue 2613733002: Enforce OffscreenCanvas.convertToBlob to terminate after idling for too long (Closed)
Patch Set: test Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-convertToBlob-noIdleTask.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-convertToBlob-noIdleTask.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-convertToBlob-noIdleTask.html
new file mode 100644
index 0000000000000000000000000000000000000000..53d3afeadec6841c370f646194117c2bc3c498a7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-convertToBlob-noIdleTask.html
@@ -0,0 +1,46 @@
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script type = 'text/javascript'>
+// In WebKit Layout Tests, flag "--enable-threaded-compositing", which is
Justin Novosad 2017/01/06 15:49:21 nit: WebKit -> blink
+// essential for idle task running, is not turned on by default. This makes
+// it convenient to test the case when CanvasAsyncBlobCreator is idling for
+// too long and switching to forcing encoding in a normal task.
+// Passing this test means that the enforcing mechanism in
+// CanvasAsyncBlobCreator for OffscreenCanvas case is working as expected.
+var w = 4;
+var h = 4;
+
+var newImg = new Image();
+function imageLoaded() {
+ var canvas2 = document.createElement("canvas");
+ canvas2.width = w;
+ canvas2.height = h;
+ var ctx2 = canvas2.getContext("2d");
+ ctx2.drawImage(newImg, 0, 0, w, h);
+
+ var imageData = ctx2.getImageData(0, 0, w, h).data;
+ assert_equals(imageData[0], 255);
+ assert_equals(imageData[1], 1);
+ assert_equals(imageData[2], 2);
+ assert_equals(imageData[3], 255);
+ testImageFromOffscreen.done();
+}
+
+var testImageFromOffscreen = async_test(
+ "Check if the image loaded from blob returned by " +
+ "OffscreenCanvas.convertToBlob() have expected image data values.");
+
+testImageFromOffscreen.step(function() {
+ newImg.onload = testImageFromOffscreen.step_func(imageLoaded);
+
+ var offscreenCanvas = new OffscreenCanvas(w, h);
+ var ctx = offscreenCanvas.getContext("2d");
+ ctx.fillStyle = "#FF0102";
+ ctx.fillRect(0, 0, w, h);
+
+ offscreenCanvas.convertToBlob().then(function(blob) {
+ newImg.src = URL.createObjectURL(blob);
+ });
+});
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698