tor-browser

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

2d-getcontext-options.html (1233B)


      1 <!DOCTYPE html>
      2 <title>Options conversion for getContext("2d")</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script>
      6 test(() => {
      7  const expected = [
      8    "alpha",
      9    "colorSpace",
     10    "colorSpace toString",
     11    "desynchronized",
     12    "willReadFrequently",
     13  ];
     14  var actual = [];
     15  const options = {
     16    get alpha() {
     17      actual.push("alpha");
     18      return true;
     19    },
     20    get willReadFrequently() {
     21      actual.push("willReadFrequently");
     22      return false;
     23    },
     24    get desynchronized() {
     25      actual.push("desynchronized");
     26      return false;
     27    },
     28    get colorSpace() {
     29      actual.push("colorSpace");
     30      return {
     31        toString() {
     32          actual.push("colorSpace toString");
     33          return "srgb";
     34        }
     35      };
     36    },
     37  };
     38 
     39  const canvas = document.createElement("canvas");
     40  const context = canvas.getContext('2d', options);
     41  assert_not_equals(context, null, "context");
     42  assert_array_equals(actual, expected, "order of operations (creation)");
     43  actual = [];
     44  assert_equals(canvas.getContext('2d', options), context, "cached context");
     45  assert_array_equals(actual, expected, "order of operations (caching)");
     46 });
     47 </script>