tor-browser

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

2d.fillStyle.CSSRGB.html (1669B)


      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>OffscreenCanvas test: 2d.fillStyle.CSSRGB</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 
      9 <h1>2d.fillStyle.CSSRGB</h1>
     10 <p class="desc">CSSRGB works as color input</p>
     11 
     12 
     13 <script>
     14 var t = async_test("CSSRGB works as color input");
     15 var t_pass = t.done.bind(t);
     16 var t_fail = t.step_func(function(reason) {
     17    throw reason;
     18 });
     19 t.step(function() {
     20 
     21  var canvas = new OffscreenCanvas(100, 50);
     22  var ctx = canvas.getContext('2d');
     23 
     24  ctx.fillStyle = new CSSRGB(1, 0, 1);
     25  _assertSame(ctx.fillStyle, '#ff00ff', "ctx.fillStyle", "'#ff00ff'");
     26  ctx.fillRect(0, 0, 100, 50);
     27  _assertPixel(canvas, 50,25, 255,0,255,255);
     28 
     29  const color = new CSSRGB(0, CSS.percent(50), 0);
     30  ctx.fillStyle = color;
     31  _assertSame(ctx.fillStyle, '#008000', "ctx.fillStyle", "'#008000'");
     32  ctx.fillRect(0, 0, 100, 50);
     33  _assertPixel(canvas, 50,25, 0,128,0,255);
     34  color.g = 0;
     35  ctx.fillStyle = color;
     36  _assertSame(ctx.fillStyle, '#000000', "ctx.fillStyle", "'#000000'");
     37  ctx.fillRect(0, 0, 100, 50);
     38  _assertPixel(canvas, 50,25, 0,0,0,255);
     39 
     40  color.alpha = 0;
     41  ctx.fillStyle = color;
     42  _assertSame(ctx.fillStyle, 'rgba(0, 0, 0, 0)', "ctx.fillStyle", "'rgba(0, 0, 0, 0)'");
     43  ctx.reset();
     44  color.alpha = 0.5;
     45  ctx.fillStyle = color;
     46  ctx.fillRect(0, 0, 100, 50);
     47  _assertPixel(canvas, 50,25, 0,0,0,128);
     48 
     49  color.alpha = 1;
     50  color.g = 1;
     51  ctx.fillStyle = color;
     52  ctx.fillRect(0, 0, 100, 50);
     53  t.done();
     54 
     55 });
     56 </script>