tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

2d.state.saverestore.strokeStyle.html (2281B)


      1 <!DOCTYPE html>
      2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
      3 <meta charset="UTF-8">
      4 <title>Canvas test: 2d.state.saverestore.strokeStyle</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/html/canvas/resources/canvas-tests.js"></script>
      8 <link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
      9 
     10 <h1>2d.state.saverestore.strokeStyle</h1>
     11 
     12 <script>
     13 
     14 test(t => {
     15  const canvas = document.createElement('canvas');
     16  canvas.width = 300;
     17  canvas.height = 150;
     18  const ctx = canvas.getContext('2d');
     19 
     20  const old = ctx.strokeStyle;
     21  ctx.save();
     22  ctx.strokeStyle = "#ff0000";
     23  ctx.restore();
     24  _assertSame(ctx.strokeStyle, old, "ctx.strokeStyle", "old");
     25 }, "save()/restore() restores strokeStyle, for a canvas of size (300, 150).");
     26 
     27 test(t => {
     28  const canvas = document.createElement('canvas');
     29  canvas.width = 300;
     30  canvas.height = 150;
     31  const ctx = canvas.getContext('2d');
     32 
     33  ctx.strokeStyle = "#ff0000";
     34  const old = ctx.strokeStyle;
     35  // We're not interested in failures caused by get(set(x)) != x (e.g.
     36  // from rounding), so compare against `old` instead of "#ff0000".
     37  ctx.save();
     38  _assertSame(ctx.strokeStyle, old, "ctx.strokeStyle", "old");
     39  ctx.restore();
     40 }, "save() does not modify strokeStyle, for a canvas of size (300, 150).");
     41 
     42 test(t => {
     43  const canvas = document.createElement('canvas');
     44  canvas.width = 0;
     45  canvas.height = 0;
     46  const ctx = canvas.getContext('2d');
     47 
     48  const old = ctx.strokeStyle;
     49  ctx.save();
     50  ctx.strokeStyle = "#ff0000";
     51  ctx.restore();
     52  _assertSame(ctx.strokeStyle, old, "ctx.strokeStyle", "old");
     53 }, "save()/restore() restores strokeStyle, for a canvas of size (0, 0).");
     54 
     55 test(t => {
     56  const canvas = document.createElement('canvas');
     57  canvas.width = 0;
     58  canvas.height = 0;
     59  const ctx = canvas.getContext('2d');
     60 
     61  ctx.strokeStyle = "#ff0000";
     62  const old = ctx.strokeStyle;
     63  // We're not interested in failures caused by get(set(x)) != x (e.g.
     64  // from rounding), so compare against `old` instead of "#ff0000".
     65  ctx.save();
     66  _assertSame(ctx.strokeStyle, old, "ctx.strokeStyle", "old");
     67  ctx.restore();
     68 }, "save() does not modify strokeStyle, for a canvas of size (0, 0).");
     69 
     70 </script>