Skip to content

Commit 34b3d84

Browse files
schenney-chromiummoz-wptsync-bot
authored andcommitted
Bug 1951309 [wpt PR 51041] - Update Canvas lang tests, a=testonly
Automatic update from web-platform-tests Update canvas language tests Remove the tentative naming for whatwg/html#10873. And make all the tests verify two languages, because browsers differ in which language they consider the default. -- wpt-commits: 20365259dffd3f467b695c4ed0d03006fe50ce23 wpt-pr: 51041
1 parent 1a67a60 commit 34b3d84

File tree

41 files changed

+569
-312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+569
-312
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
11
<!doctype HTML>
22
<meta charset="utf-8">
3-
<title>HTML5 Canvas Test Reference: The lang attribute.</title>
3+
<title>HTML5 Canvas Test Reference: The lang attribute.</title>
44
<link rel="author" href="mailto:[email protected]"/>
5+
<style>
6+
#canvas-zh {
7+
position: absolute;
8+
top: 10px;
9+
left: 10px;
10+
}
11+
#canvas-ja {
12+
position: absolute;
13+
top: 120px;
14+
left: 10px;
15+
}
16+
</style>
517
<script>
6-
function generateReference() {
7-
var canvas = document.getElementById('canvas1');
18+
function drawText(language) {
19+
var canvas = document.getElementById('canvas-' + language);
820
var ctx = canvas.getContext('2d');
921

10-
// The default for lang is inherit, so no need to set any text styles.
1122
ctx.font = '25px serif';
1223
ctx.fillText('今骨直', 5, 50);
1324
}
25+
function generateReference() {
26+
drawText('zh');
27+
drawText('ja');
28+
}
1429
</script>
1530
<body onload="generateReference()">
16-
<canvas lang="zh-CN" id="canvas1" width="300" height="150">
31+
<canvas lang="zh-CN" id="canvas-zh" width="300" height="100">
32+
Browser does not support HTML5 Canvas.
33+
</canvas>
34+
<canvas lang="ja" id="canvas-ja" width="300" height="100">
1735
Browser does not support HTML5 Canvas.
1836
</canvas>
1937
</body>

testing/web-platform/tests/html/canvas/element/manual/text/canvas.2d.lang.dynamic.html

-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@
3636
Browser does not support HTML5 Canvas.
3737
</canvas>
3838
</body>
39-

testing/web-platform/tests/html/canvas/element/manual/text/canvas.2d.lang.empty-ref.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
var canvas = document.getElementById('canvas1');
88
var ctx = canvas.getContext('2d');
99

10-
// The default for lang is inherit, so no need to set any text styles.
10+
// With no lang defined anywhere, this reference will use the unknown
11+
// language, whatever that might produce on the platform.
1112
ctx.font = '25px serif';
1213
ctx.fillText('今骨直', 5, 50);
1314
}

testing/web-platform/tests/html/canvas/element/manual/text/canvas.2d.lang.empty.canvas.tentative.html testing/web-platform/tests/html/canvas/element/manual/text/canvas.2d.lang.empty.canvas.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!doctype HTML>
2-
<html lang="zh-CN">
2+
<html>
33
<meta charset="utf-8">
44
<title>HTML5 Canvas Test: The empty string lang attribute uses the unknown language</title>
55
<link rel="match" href="canvas.2d.lang.empty-ref.html" />
@@ -11,15 +11,16 @@
1111
var canvas = document.getElementById('canvas1');
1212
var ctx = canvas.getContext('2d');
1313

14+
// An empty lang string should produce the same result as no language
15+
// attribute at all, on the canvas element or document element.
1416
ctx.font = '25px serif';
1517
ctx.lang = '';
1618
ctx.fillText('今骨直', 5, 50);
1719
}
1820
</script>
1921
<body onload="runTest()">
20-
<canvas lang="zh-CN" id="canvas1" width="300" height="150">
22+
<canvas id="canvas1" width="300" height="150">
2123
Browser does not support HTML5 Canvas.
2224
</canvas>
2325
</body>
2426
</html>
25-

testing/web-platform/tests/html/canvas/element/manual/text/canvas.2d.lang.tentative.html testing/web-platform/tests/html/canvas/element/manual/text/canvas.2d.lang.html

+23-5
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,38 @@
66
<link rel="author" href="mailto:[email protected]"/>
77
<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#text-styles"/>
88
<meta name="assert" content="When the canvas context has a lang attribute, override the document." />
9+
<style>
10+
#canvas-zh-CN {
11+
position: absolute;
12+
top: 10px;
13+
left: 10px;
14+
}
15+
#canvas-ja {
16+
position: absolute;
17+
top: 120px;
18+
left: 10px;
19+
}
20+
</style>
921
<script type="text/javascript">
10-
function runTest() {
11-
var canvas = document.getElementById('canvas1');
22+
function drawText(language) {
23+
var canvas = document.getElementById('canvas-' + language);
1224
var ctx = canvas.getContext('2d');
1325

1426
ctx.font = '25px serif';
15-
ctx.lang = 'zh-CN';
27+
ctx.lang = language;
1628
ctx.fillText('今骨直', 5, 50);
1729
}
30+
function runTest() {
31+
drawText('zh-CN');
32+
drawText('ja');
33+
}
1834
</script>
1935
<body onload="runTest()">
20-
<canvas id="canvas1" width="300" height="150">
36+
<canvas id="canvas-zh-CN" width="300" height="100">
37+
Browser does not support HTML5 Canvas.
38+
</canvas>
39+
<canvas id="canvas-ja" width="300" height="100">
2140
Browser does not support HTML5 Canvas.
2241
</canvas>
2342
</body>
2443
</html>
25-

testing/web-platform/tests/html/canvas/element/manual/text/canvas.2d.lang.inherit.canvas.tentative.html

-24
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!doctype HTML>
2+
<html lang="en-US">
3+
<meta charset="utf-8">
4+
<title>HTML5 Canvas Test: The lang attribute inherits from a disconnected canvas element</title>
5+
<link rel="match" href="canvas.2d.lang-ref.html"/>
6+
<link rel="author" href="mailto:[email protected]"/>
7+
<link rel="help"
8+
href="https://html.spec.whatwg.org/multipage/canvas.html#text-styles"/>
9+
<meta name="assert" content="Verify that a disconnected canvas uses the canvas lang."/>
10+
<style>
11+
#canvas-zh-CN {
12+
position: absolute;
13+
top: 10px;
14+
left: 10px;
15+
}
16+
#canvas-ja {
17+
position: absolute;
18+
top: 120px;
19+
left: 10px;
20+
}
21+
</style>
22+
<body>
23+
<script type="text/javascript">
24+
function drawText(language) {
25+
var canvas = document.createElement('canvas');
26+
canvas.setAttribute('width', '300');
27+
canvas.setAttribute('height', '100');
28+
canvas.setAttribute('id', 'canvas-' + language);
29+
canvas.setAttribute('lang', language);
30+
var ctx = canvas.getContext('2d');
31+
32+
// The default for direction is inherit
33+
ctx.font = '25px serif';
34+
ctx.fillText('今骨直', 5, 50);
35+
36+
document.body.appendChild(canvas);
37+
}
38+
39+
drawText('zh-CN');
40+
drawText('ja');
41+
</script>
42+
</body>
43+
</html>

testing/web-platform/tests/html/canvas/element/manual/text/canvas.2d.lang.inherit.disconnected.canvas.tentative.html

-33
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!doctype HTML>
2+
<html lang="zh-CN">
3+
<meta charset="utf-8">
4+
<title>HTML5 Canvas Test: The lang attribute inherits the document lang when disconnected</title>
5+
<link rel="match" href="canvas.2d.lang-ref.html"/>
6+
<link rel="author" href="mailto:[email protected]"/>
7+
<link rel="help"
8+
href="https://html.spec.whatwg.org/multipage/canvas.html#text-styles"/>
9+
<meta name="assert" content="Verify that a disconnected canvas with no lang attribute uses the document lang."/>
10+
<style>
11+
#canvas-zh-CN {
12+
position: absolute;
13+
top: 10px;
14+
left: 10px;
15+
}
16+
#canvas-ja {
17+
position: absolute;
18+
top: 120px;
19+
left: 10px;
20+
}
21+
</style>
22+
<body>
23+
<script type="text/javascript">
24+
function drawText(language) {
25+
var canvas = document.createElement('canvas');
26+
canvas.setAttribute('width', '300');
27+
canvas.setAttribute('height', '100');
28+
canvas.setAttribute('id', 'canvas-' + language);
29+
var ctx = canvas.getContext('2d');
30+
31+
// The default for direction is inherit
32+
ctx.font = '25px serif';
33+
ctx.fillText('今骨直', 5, 50);
34+
35+
document.body.appendChild(canvas);
36+
}
37+
38+
drawText('zh-CN');
39+
document.documentElement.setAttribute('lang', 'ja');
40+
drawText('ja');
41+
</script>
42+
</body>
43+
</html>

testing/web-platform/tests/html/canvas/element/manual/text/canvas.2d.lang.inherit.document.disconnected.canvas.tentative.html

-32
This file was deleted.

testing/web-platform/tests/html/canvas/element/manual/text/canvas.2d.lang.inherit.document.tentative.html

-24
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!doctype HTML>
2+
<html lang="ja">
3+
<meta charset="utf-8">
4+
<title>HTML5 Canvas Test: The lang attribute inherits from the canvas rather than the document</title>
5+
<link rel="match" href="canvas.2d.lang-ref.html" />
6+
<link rel="author" href="mailto:[email protected]"/>
7+
<link rel="help" href="https://html.spec.whatwg.org/multipage/canvas.html#text-styles"/>
8+
<meta name="assert" content="When the canvas element has a lang attribute, override the document." />
9+
<style>
10+
#canvas-zh {
11+
position: absolute;
12+
top: 10px;
13+
left: 10px;
14+
}
15+
#canvas-ja {
16+
position: absolute;
17+
top: 120px;
18+
left: 10px;
19+
}
20+
</style>
21+
<script>
22+
function generateReference() {
23+
// The 'canvas-zh' element has a lang attribute, use it.
24+
var canvasZH = document.getElementById('canvas-zh');
25+
var ctxZH = canvasZH.getContext('2d');
26+
27+
ctxZH.font = '25px serif';
28+
ctxZH.fillText('今骨直', 5, 50);
29+
30+
// The 'canvas-ja' element has no lang attribute, use the document lang.
31+
var canvasJA = document.getElementById('canvas-ja');
32+
var ctxJA = canvasJA.getContext('2d');
33+
34+
ctxJA.font = '25px serif';
35+
ctxJA.fillText('今骨直', 5, 50);
36+
}
37+
</script>
38+
<body onload="generateReference()">
39+
<canvas lang="zh-CN" id="canvas-zh" width="300" height="100">
40+
Browser does not support HTML5 Canvas.
41+
</canvas>
42+
<canvas id="canvas-ja" width="300" height="100">
43+
Browser does not support HTML5 Canvas.
44+
</canvas>
45+
</body>
46+
</html>

testing/web-platform/tests/html/canvas/element/text/2d.text.direction.default.tentative.html testing/web-platform/tests/html/canvas/element/text/2d.text.direction.default.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<!DOCTYPE html>
22
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
33
<meta charset="UTF-8">
4-
<title>Canvas test: 2d.text.direction.default.tentative</title>
4+
<title>Canvas test: 2d.text.direction.default</title>
55
<script src="/resources/testharness.js"></script>
66
<script src="/resources/testharnessreport.js"></script>
77
<script src="/html/canvas/resources/canvas-tests.js"></script>
88
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
99
<body class="show_output">
1010

11-
<h1>2d.text.direction.default.tentative</h1>
11+
<h1>2d.text.direction.default</h1>
1212
<p class="desc"></p>
1313

1414

0 commit comments

Comments
 (0)