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

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

Issue 1748163003: Add rendering context and rendering 2D context to OffscreenCanvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make OffscreenCanvasRenderingContext Modules exportable" Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-getContext2D.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-getContext2D.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-getContext2D.html
new file mode 100644
index 0000000000000000000000000000000000000000..be7fad2d54b60a290f746673458268aa8d5a239b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-getContext2D.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<script src="../../resources/js-test.js"></script>
+<script>
+description("Tests basic functionalities of offscreenCanvas.getContext on the main thread");
+
+// Tests onstructor of OffscreenCanvas and length/width change
+var aCanvas = new OffscreenCanvas(40, 60);
+shouldBe("aCanvas.width", "40");
+shouldBe("aCanvas.height", "60");
+
+aCanvas.width = 110;
+aCanvas.height = 90;
+shouldBe("aCanvas.width", "110");
+shouldBe("aCanvas.height", "90");
+
+aCanvas.width = 0; // Zero dimension is allowed
+shouldBe("aCanvas.width", "0");
+
+// Tests object type of getContext('2d')
+var ctx;
+shouldNotThrow("ctx = aCanvas.getContext('2d')");
+shouldBeType("ctx", "OffscreenCanvasRenderingContext2D");
+
+// Calling getContext on a different context type will return null
+var ctx2 = aCanvas.getContext("webgl");
+shouldBeNull("ctx2");
+
+// Calling getContext on the same context type will return the original context type
+var ctx3 = aCanvas.getContext("2d");
+shouldBeNonNull("ctx3");
+shouldBeTrue("ctx3 == ctx");
+
+// TODO: change the below part of the test when webgl is supported.
+// Calling getContext on an unimplemented context type will return null
+var bogusCanvas = new OffscreenCanvas(20, 20);
+var bogusCtx = bogusCanvas.getContext("webgl");
+shouldBeNull("bogusCtx");
+</script>

Powered by Google App Engine
This is Rietveld 408576698