Bug 1728999 - Add simple WPT testcases for the CanvasRenderingContext2D.direction property. r=lsalzman

And remove failure annotations for a couple of existing tests that we now pass.

Depends on D142701

Differential Revision: https://phabricator.services.mozilla.com/D142702
This commit is contained in:
Jonathan Kew
2022-04-05 12:44:43 +00:00
parent 9601e50875
commit 65bf84b87a
7 changed files with 147 additions and 10 deletions

View File

@@ -1,4 +0,0 @@
[2d.text.measure.boundingBox.direction.html]
[Measurement should follow text direction]
expected: FAIL

View File

@@ -27,9 +27,6 @@ prefs: [dom.security.featurePolicy.experimental.enabled:true, dom.security.featu
[AudioTrackList interface object name]
expected: FAIL
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "direction" with the proper type]
expected: FAIL
[VideoTrack interface: attribute kind]
expected: FAIL
@@ -78,9 +75,6 @@ prefs: [dom.security.featurePolicy.experimental.enabled:true, dom.security.featu
[SVGSVGElement interface: attribute onoffline]
expected: FAIL
[CanvasRenderingContext2D interface: attribute direction]
expected: FAIL
[VideoTrack interface: existence and properties of interface prototype object]
expected: FAIL

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Canvas Test: the 'direction' property</title>
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#text-styles">
<link rel="match" href="reference/direction-rtl-ref.html">
<meta name="assert" content="text rendering respects the direction property">
<style>
canvas {
margin: 10px;
border: 1px solid gray;
}
</style>
<canvas id="c" width="300" height="300" dir="rtl"></canvas>
<script>
let ctx = c.getContext("2d");
ctx.direction = "inherit";
ctx.font = "16px sans-serif";
ctx.textAlign = "left";
ctx.fillText("Hello World!", 150, 50);
ctx.textAlign = "right";
ctx.fillText("Hello World!", 150, 100);
ctx.textAlign = "start";
ctx.fillText("Hello World!", 150, 150);
ctx.textAlign = "end";
ctx.fillText("Hello World!", 150, 200);
ctx.textAlign = "center";
ctx.fillText("Hello World!", 150, 250);
</script>

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Canvas Test: the 'direction' property</title>
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#text-styles">
<link rel="match" href="reference/direction-default-ref.html">
<meta name="assert" content="text rendering respects the direction property">
<style>
canvas {
margin: 10px;
border: 1px solid gray;
}
</style>
<canvas id="c" width="300" height="300" dir="rtl"></canvas>
<script>
let ctx = c.getContext("2d");
ctx.direction = "ltr";
ctx.font = "16px sans-serif";
ctx.textAlign = "left";
ctx.fillText("Hello World!", 150, 50);
ctx.textAlign = "right";
ctx.fillText("Hello World!", 150, 100);
ctx.textAlign = "start";
ctx.fillText("Hello World!", 150, 150);
ctx.textAlign = "end";
ctx.fillText("Hello World!", 150, 200);
ctx.textAlign = "center";
ctx.fillText("Hello World!", 150, 250);
</script>

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Canvas Test: the 'direction' property</title>
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#text-styles">
<link rel="match" href="reference/direction-rtl-ref.html">
<meta name="assert" content="text rendering respects the direction property">
<style>
canvas {
margin: 10px;
border: 1px solid gray;
}
</style>
<canvas id="c" width="300" height="300"></canvas>
<script>
let ctx = c.getContext("2d");
ctx.direction = "rtl";
ctx.font = "16px sans-serif";
ctx.textAlign = "left";
ctx.fillText("Hello World!", 150, 50);
ctx.textAlign = "right";
ctx.fillText("Hello World!", 150, 100);
ctx.textAlign = "start";
ctx.fillText("Hello World!", 150, 150);
ctx.textAlign = "end";
ctx.fillText("Hello World!", 150, 200);
ctx.textAlign = "center";
ctx.fillText("Hello World!", 150, 250);
</script>

View File

@@ -0,0 +1,27 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Canvas Reference: the 'direction' property</title>
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com">
<style>
canvas {
margin: 10px;
border: 1px solid gray;
}
</style>
<canvas id="c" width="300" height="300"></canvas>
<script>
let ctx = c.getContext("2d");
ctx.font = "16px sans-serif";
ctx.textAlign = "left";
ctx.fillText("Hello World!", 150, 50);
ctx.textAlign = "right";
ctx.fillText("Hello World!", 150, 100);
ctx.textAlign = "start";
ctx.fillText("Hello World!", 150, 150);
ctx.textAlign = "end";
ctx.fillText("Hello World!", 150, 200);
ctx.textAlign = "center";
ctx.fillText("Hello World!", 150, 250);
</script>

View File

@@ -0,0 +1,27 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Canvas Reference: the 'direction' property</title>
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com">
<style>
canvas {
margin: 10px;
border: 1px solid gray;
}
</style>
<canvas id="c" width="300" height="300"></canvas>
<script>
let ctx = c.getContext("2d");
ctx.font = "16px sans-serif";
ctx.textAlign = "left";
ctx.fillText("!Hello World", 150, 50);
ctx.textAlign = "right";
ctx.fillText("!Hello World", 150, 100);
ctx.textAlign = "right";
ctx.fillText("!Hello World", 150, 150);
ctx.textAlign = "left";
ctx.fillText("!Hello World", 150, 200);
ctx.textAlign = "center";
ctx.fillText("!Hello World", 150, 250);
</script>