-
Notifications
You must be signed in to change notification settings - Fork 54
/
2d.state.saverestore.lineWidth.html
41 lines (34 loc) · 1.2 KB
/
2d.state.saverestore.lineWidth.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>OffscreenCanvas test: 2d.state.saverestore.lineWidth</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/2dcontext/resources/canvas-tests.js"></script>
<h1>2d.state.saverestore.lineWidth</h1>
<p class="desc">save()/restore() works for lineWidth</p>
<script>
var t = async_test("save()/restore() works for lineWidth");
var t_pass = t.done.bind(t);
var t_fail = t.step_func(function(reason) {
throw reason;
});
t.step(function() {
var offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');
// Test that restore() undoes any modifications
var old = ctx.lineWidth;
ctx.save();
ctx.lineWidth = 0.5;
ctx.restore();
_assertSame(ctx.lineWidth, old, "ctx.lineWidth", "old");
// Also test that save() doesn't modify the values
ctx.lineWidth = 0.5;
old = ctx.lineWidth;
// we're not interested in failures caused by get(set(x)) != x (e.g.
// from rounding), so compare against 'old' instead of against 0.5
ctx.save();
_assertSame(ctx.lineWidth, old, "ctx.lineWidth", "old");
ctx.restore();
t.done();
});
</script>