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

Unified Diff: LayoutTests/fast/canvas/script-tests/gradient-addColorStop-with-invalid-offset.js

Issue 268443003: Make CanvasGradient.addColorStop throw TypeError for non-finite offsets (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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: LayoutTests/fast/canvas/script-tests/gradient-addColorStop-with-invalid-offset.js
diff --git a/LayoutTests/fast/canvas/script-tests/gradient-addColorStop-with-invalid-offset.js b/LayoutTests/fast/canvas/script-tests/gradient-addColorStop-with-invalid-offset.js
new file mode 100644
index 0000000000000000000000000000000000000000..493ad9aaccc092e189d4b7c6f8692fcc03727897
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/gradient-addColorStop-with-invalid-offset.js
@@ -0,0 +1,10 @@
+description('This test checks invalid offsets on gradients.');
+
+var gradient = document.createElement('canvas').getContext('2d').createLinearGradient(0, 0, 150, 0);
+
+// Check that invalid offset values throw.
+shouldThrow("gradient.addColorStop(-1, '#000')");
+shouldThrow("gradient.addColorStop(2, '#000')");
+shouldThrow("gradient.addColorStop(Infinity, '#000')");
+shouldThrow("gradient.addColorStop(-Infinity, '#000')");
+shouldThrow("gradient.addColorStop(NaN, '#000')");

Powered by Google App Engine
This is Rietveld 408576698