Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/element/manual/text/canvas.2d.direction.inherit.disconnected.canvas.html - WPT Dashboard Interop Dashboard
<!doctype HTML>
<html>
<meta charset="utf-8">
<head>
<title>HTML5 Canvas Test: The direction attribute inherits from a disconnected canvas element</title>
<link rel="match" href="canvas.2d.direction-ref.html"/>
<link rel="author" href="mailto:schenney@chromium.org"/>
<link rel="help"
<meta name="assert" content="Verify that a disconnected canvas with no style uses the canvas direction."/>
<style>
canvas {
position: absolute;
top: 8px;
left: 8px;
}
</style>
</head>
<body>
<canvas id="canvas1" width="300" height="150">
Browser does not support HTML5 Canvas.
</canvas>
<script type="text/javascript">
var canvas = document.createElement("canvas");
canvas.setAttribute("dir", "rtl");
canvas.setAttribute("width", "300");
canvas.setAttribute("height", "150");
var ctx = canvas.getContext("2d");
// The default for direction is inherit
ctx.font = "25px serif";
ctx.fillText("ABC!", 60, 50);
document.body.appendChild(canvas);
</script>
</body>
</html>