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

65 lines
2.0 KiB
HTML

<!DOCTYPE HTML>
<title>Canvas test: text.textBaseline</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');
is(ctx.textBaseline, 'alphabetic', "default textBaseline is not 'alphabetic'");
ctx.save();
ctx.textBaseline = 'ideographic';
is(ctx.textBaseline, 'ideographic', 'textBaseline getter returns incorrect value');
ctx.save();
ctx.textBaseline = 'top';
is(ctx.textBaseline, 'top', 'textBaseline getter returns incorrect value');
ctx.save();
ctx.textBaseline = 'middle';
is(ctx.textBaseline, 'middle', 'textBaseline getter returns incorrect value');
ctx.save();
ctx.textBaseline = 'bottom';
is(ctx.textBaseline, 'bottom', 'textBaseline getter returns incorrect value');
ctx.save();
ctx.textBaseline = 'hanging';
is(ctx.textBaseline, 'hanging', 'textBaseline getter returns incorrect value');
ctx.save();
ctx.textBaseline = 'alphabetic';
is(ctx.textBaseline, 'alphabetic', 'textBaseline getter returns incorrect value');
ctx.restore();
is(ctx.textBaseline, 'hanging', 'textBaseline not being stored in the context state');
ctx.restore();
is(ctx.textBaseline, 'bottom', 'textBaseline not being stored in the context state');
ctx.restore();
is(ctx.textBaseline, 'middle', 'textBaseline not being stored in the context state');
ctx.restore();
is(ctx.textBaseline, 'top', 'textBaseline not being stored in the context state');
ctx.restore();
is(ctx.textBaseline, 'ideographic', 'textBaseline not being stored in the context state');
ctx.restore();
is(ctx.textBaseline, 'alphabetic', 'textBaseline not being stored in the context state');
if (!_deferred) SimpleTest.finish();
});
</script>