gecko/content/canvas/test/test_text.space.replace.html
2008-06-10 16:16:59 -07:00

31 lines
1.2 KiB
HTML

<!DOCTYPE HTML>
<title>Canvas test: text.space.replace</title>
<script src="/MochiKit/MochiKit.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
<body>
<canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
var _deferred = false;
SimpleTest.waitForExplicitFinish();
MochiKit.DOM.addLoadEvent(function () {
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
var swid = ctx.measureText(' ').width;
ctx.font = "10px sans-serif";
isnot(swid, 0.0, "measureText reutuns zero for a non-empty string");
is(swid, ctx.measureText('\x09').width, "measureText does not replace whitespace char with a space");
is(swid, ctx.measureText('\x0A').width, "measureText does not replace whitespace char with a space");
is(swid, ctx.measureText('\x0B').width, "measureText does not replace whitespace char with a space");
is(swid, ctx.measureText('\x0C').width, "measureText does not replace whitespace char with a space");
is(swid, ctx.measureText('\x0D').width, "measureText does not replace whitespace char with a space");
if (!_deferred) SimpleTest.finish();
});
</script>