Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/offscreen/text/2d.text.drawing.style.fontStretch.settings.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<meta charset="UTF-8">
<title>OffscreenCanvas test: 2d.text.drawing.style.fontStretch.settings</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<h1>2d.text.drawing.style.fontStretch.settings</h1>
<p class="desc">Testing value setting of fontStretch in Canvas</p>
<script>
var t = async_test("Testing value setting of fontStretch in Canvas");
var t_pass = t.done.bind(t);
var t_fail = t.step_func(function(reason) {
throw reason;
});
t.step(function() {
var canvas = new OffscreenCanvas(100, 50);
var ctx = canvas.getContext('2d');
// Setting fontStretch with lower cases
ctx.fontStretch = "ultra-condensed";
_assertSame(ctx.fontStretch, "ultra-condensed", "ctx.fontStretch", "\"ultra-condensed\"");
ctx.fontStretch = "extra-condensed";
_assertSame(ctx.fontStretch, "extra-condensed", "ctx.fontStretch", "\"extra-condensed\"");
ctx.fontStretch = "condensed";
_assertSame(ctx.fontStretch, "condensed", "ctx.fontStretch", "\"condensed\"");
ctx.fontStretch = "semi-condensed";
_assertSame(ctx.fontStretch, "semi-condensed", "ctx.fontStretch", "\"semi-condensed\"");
ctx.fontStretch = "normal";
_assertSame(ctx.fontStretch, "normal", "ctx.fontStretch", "\"normal\"");
ctx.fontStretch = "semi-expanded";
_assertSame(ctx.fontStretch, "semi-expanded", "ctx.fontStretch", "\"semi-expanded\"");
ctx.fontStretch = "expanded";
_assertSame(ctx.fontStretch, "expanded", "ctx.fontStretch", "\"expanded\"");
ctx.fontStretch = "extra-expanded";
_assertSame(ctx.fontStretch, "extra-expanded", "ctx.fontStretch", "\"extra-expanded\"");
ctx.fontStretch = "ultra-expanded";
_assertSame(ctx.fontStretch, "ultra-expanded", "ctx.fontStretch", "\"ultra-expanded\"");
// Setting fontStretch with lower cases and upper cases word,
// these values should be ignored.
ctx.fontStretch = "ulTra-condensed";
_assertSame(ctx.fontStretch, "ultra-expanded", "ctx.fontStretch", "\"ultra-expanded\"");
ctx.fontStretch = "Extra-condensed";
_assertSame(ctx.fontStretch, "ultra-expanded", "ctx.fontStretch", "\"ultra-expanded\"");
ctx.fontStretch = "cOndensed";
_assertSame(ctx.fontStretch, "ultra-expanded", "ctx.fontStretch", "\"ultra-expanded\"");
ctx.fontStretch = "Semi-Condensed";
_assertSame(ctx.fontStretch, "ultra-expanded", "ctx.fontStretch", "\"ultra-expanded\"");
ctx.fontStretch = "normaL";
_assertSame(ctx.fontStretch, "ultra-expanded", "ctx.fontStretch", "\"ultra-expanded\"");
ctx.fontStretch = "semi-Expanded";
_assertSame(ctx.fontStretch, "ultra-expanded", "ctx.fontStretch", "\"ultra-expanded\"");
ctx.fontStretch = "Expanded";
_assertSame(ctx.fontStretch, "ultra-expanded", "ctx.fontStretch", "\"ultra-expanded\"");
ctx.fontStretch = "eXtra-expanded";
_assertSame(ctx.fontStretch, "ultra-expanded", "ctx.fontStretch", "\"ultra-expanded\"");
ctx.fontStretch = "abcd";
_assertSame(ctx.fontStretch, "ultra-expanded", "ctx.fontStretch", "\"ultra-expanded\"");
t.done();
});
</script>