summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/offscreen/canvas-host/2d.canvas.host.initial.reset.2dstate.html
blob: 36230dab7735685ef0c4714aff07f42a3edd995e (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>OffscreenCanvas test: 2d.canvas.host.initial.reset.2dstate</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>

<h1>2d.canvas.host.initial.reset.2dstate</h1>
<p class="desc">Resetting the canvas state resets 2D state variables</p>


<script>
var t = async_test("Resetting the canvas state resets 2D state variables");
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');

  canvas.width = 100;
  var default_val;

  default_val = ctx.strokeStyle;
  ctx.strokeStyle = "#ff0000";
  canvas.width = 100;
  _assertSame(ctx.strokeStyle, default_val, "ctx.strokeStyle", "default_val");

  default_val = ctx.fillStyle;
  ctx.fillStyle = "#ff0000";
  canvas.width = 100;
  _assertSame(ctx.fillStyle, default_val, "ctx.fillStyle", "default_val");

  default_val = ctx.globalAlpha;
  ctx.globalAlpha = 0.5;
  canvas.width = 100;
  _assertSame(ctx.globalAlpha, default_val, "ctx.globalAlpha", "default_val");

  default_val = ctx.lineWidth;
  ctx.lineWidth = 0.5;
  canvas.width = 100;
  _assertSame(ctx.lineWidth, default_val, "ctx.lineWidth", "default_val");

  default_val = ctx.lineCap;
  ctx.lineCap = "round";
  canvas.width = 100;
  _assertSame(ctx.lineCap, default_val, "ctx.lineCap", "default_val");

  default_val = ctx.lineJoin;
  ctx.lineJoin = "round";
  canvas.width = 100;
  _assertSame(ctx.lineJoin, default_val, "ctx.lineJoin", "default_val");

  default_val = ctx.miterLimit;
  ctx.miterLimit = 0.5;
  canvas.width = 100;
  _assertSame(ctx.miterLimit, default_val, "ctx.miterLimit", "default_val");

  default_val = ctx.shadowOffsetX;
  ctx.shadowOffsetX = 5;
  canvas.width = 100;
  _assertSame(ctx.shadowOffsetX, default_val, "ctx.shadowOffsetX", "default_val");

  default_val = ctx.shadowOffsetY;
  ctx.shadowOffsetY = 5;
  canvas.width = 100;
  _assertSame(ctx.shadowOffsetY, default_val, "ctx.shadowOffsetY", "default_val");

  default_val = ctx.shadowBlur;
  ctx.shadowBlur = 5;
  canvas.width = 100;
  _assertSame(ctx.shadowBlur, default_val, "ctx.shadowBlur", "default_val");

  default_val = ctx.shadowColor;
  ctx.shadowColor = "#ff0000";
  canvas.width = 100;
  _assertSame(ctx.shadowColor, default_val, "ctx.shadowColor", "default_val");

  default_val = ctx.globalCompositeOperation;
  ctx.globalCompositeOperation = "copy";
  canvas.width = 100;
  _assertSame(ctx.globalCompositeOperation, default_val, "ctx.globalCompositeOperation", "default_val");

  t.done();

});
</script>