Bug 375457 - "toDataURL has incorrect type-checking logic" (a simple test that just ensures we throw an exception when calling toDataURL with null and objects) [p=joe@drew.ca (Joe Drew [JOEDREW!])]
authorreed@reedloden.com
Tue, 18 Mar 2008 12:55:12 -0700
changeset 13260 420ae36c33ecda69046374fbddf06f3c0fc1d8c6
parent 13259 b47ccab192bd943bb800e5efd9d3faea5ec7a83b
child 13261 2e0f2e0f573025d1b806698890c6436c9045d590
push idunknown
push userunknown
push dateunknown
bugs375457
milestone1.9b5pre
Bug 375457 - "toDataURL has incorrect type-checking logic" (a simple test that just ensures we throw an exception when calling toDataURL with null and objects) [p=joe@drew.ca (Joe Drew [JOEDREW!])]
dom/tests/mochitest/bugs/Makefile.in
dom/tests/mochitest/bugs/test_bug375457.html
--- a/dom/tests/mochitest/bugs/Makefile.in
+++ b/dom/tests/mochitest/bugs/Makefile.in
@@ -51,16 +51,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug317448.html \
 		test_bug327891.html \
 		test_bug333983.html \
 		test_bug335976.xhtml \
 		test_bug342448.html \
 		test_bug345521.html \
 		test_bug351601.html \
 		test_bug370098.html \
+		test_bug375457.html \
 		test_bug377539.html \
 		test_bug384122.html \
 		test_bug389366.html \
 		test_bug393974.html \
 		test_bug396843.html \
 		test_bug397571.html \
 		test_bug400204.html \
 		test_bug404748.html \
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/bugs/test_bug375457.html
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=375457
+-->
+<head>
+  <title>Test for Bug 375457</title>
+  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=375457">Mozilla Bug 159849</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+    <canvas id="canvas" width="10" height="10"> </canvas>
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); 
+
+var canvas = document.getElementById("canvas");
+
+var dataURL = undefined;
+var exceptionThrown = false;
+
+try {
+    dataURL = canvas.toDataURL("image/png", null);
+} catch(err) {
+    exceptionThrown = true;
+}
+
+ok(exceptionThrown, 
+   "an exception should have been thrown with not-string encoder options");
+
+ok(dataURL === undefined,
+   "should not have been possible to get a data URL with not-string encoder options",
+   "got " + repr(dataURL) + ", expected undefined");
+
+dataURL = undefined;
+exceptionThrown = false;
+
+try {
+    dataURL = canvas.toDataURL("image/png", canvas);
+} catch(err) {
+    exceptionThrown = true;
+}
+
+ok(exceptionThrown, 
+   "an exception should have been thrown with not-string encoder options");
+
+ok(dataURL === undefined,
+   "should not have been possible to get a data URL with not-string encoder options",
+   "got " + repr(dataURL) + ", expected undefined");
+
+</script>
+</pre>
+</body>
+</html>