dom/tests/mochitest/bugs/test_bug375457.html
author reed@reedloden.com
Tue, 18 Mar 2008 12:55:12 -0700
changeset 13260 420ae36c33ecda69046374fbddf06f3c0fc1d8c6
child 28048 8f7b73d88f6bbedec99c6c8ef48b243ab922d05c
permissions -rw-r--r--
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!])]

<!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>