tor-browser

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

db_smilCSSFromBy.js (7526B)


      1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
      2 /* vim: set ts=2 sw=2 sts=2 et: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 /* testcase data for simple "from-by" animations of CSS properties */
      8 
      9 // NOTE: This js file requires db_smilCSSPropertyList.js
     10 
     11 // Lists of testcases for re-use across multiple properties of the same type
     12 var _fromByTestLists = {
     13  color: [
     14    new AnimTestcaseFromBy("rgb(10, 20, 30)", "currentColor", {
     15      midComp: "rgb(35, 45, 55)",
     16      toComp: "rgb(60, 70, 80)",
     17    }),
     18    new AnimTestcaseFromBy("currentColor", "rgb(30, 20, 10)", {
     19      fromComp: "rgb(50, 50, 50)",
     20      midComp: "rgb(65, 60, 55)",
     21      toComp: "rgb(80, 70, 60)",
     22    }),
     23    new AnimTestcaseFromBy(
     24      "rgba(10, 20, 30, 0.2)",
     25      "rgba(50, 50, 50, 1)",
     26      // (rgb(10, 20, 30) * 0.2 * 0.5 + rgb(52, 54, 56) * 1.0 * 0.5) * (1 / 0.6)
     27      {
     28        midComp: "rgba(45, 48, 52, 0.6)",
     29        // (rgb(10, 20, 30) * 0.2 + rgb(50, 50, 50) * 1) / 1.0
     30        toComp: "rgb(52, 54, 56)",
     31      }
     32    ),
     33 
     34    // The "from" and "by" values in the test case below overflow the maxium
     35    // color-channel values when added together.
     36    // (e.g. for red [ignoring alpha for now], 100 + 240 = 340 which is > 255)
     37    //
     38    // The SVG Animation spec says we should clamp color values "as late as
     39    // possible" i.e. allow the channel overflow and clamp at paint-time.
     40    //
     41    // That gives us:
     42    //
     43    //   to-value = (rgb(100, 100, 100) * 0.6 + rgb(240, 240, 240) * 1.0)) * 1
     44    //            = rgb(300, 300, 300)
     45    //   midComp  = (rgb(100, 100, 100) * 0.6 * 0.5 + rgb(300, 300, 300) * 1.0 * 0.5) * (1 / 0.8)
     46    //            = rgb(225, 225, 225)
     47    //
     48    //
     49    new AnimTestcaseFromBy(
     50      "rgba(100, 100, 100, 0.6)",
     51      "rgba(240, 240, 240, 1)",
     52      { midComp: "rgba(225, 225, 225, 0.8)", toComp: "rgb(255, 255, 255)" }
     53    ),
     54  ],
     55  lengthNoUnits: [
     56    new AnimTestcaseFromBy("0", "50", {
     57      fromComp: "0px", // 0 acts like 0px
     58      midComp: "25px",
     59      toComp: "50px",
     60    }),
     61    new AnimTestcaseFromBy("30", "10", {
     62      fromComp: "30px",
     63      midComp: "35px",
     64      toComp: "40px",
     65    }),
     66  ],
     67  lengthPx: [
     68    new AnimTestcaseFromBy("0px", "8px", {
     69      fromComp: "0px",
     70      midComp: "4px",
     71      toComp: "8px",
     72    }),
     73    new AnimTestcaseFromBy("1px", "10px", {
     74      fromComp: "1px",
     75      midComp: "6px",
     76      toComp: "11px",
     77    }),
     78  ],
     79  opacity: [
     80    new AnimTestcaseFromBy("1", "-1", { midComp: "0.5", toComp: "0" }),
     81    new AnimTestcaseFromBy("0.4", "-0.6", { midComp: "0.1", toComp: "0" }),
     82    new AnimTestcaseFromBy(
     83      "0.8",
     84      "-1.4",
     85      { midComp: "0.1", toComp: "0" },
     86      "opacities with abs val >1 get clamped too early"
     87    ),
     88    new AnimTestcaseFromBy(
     89      "1.2",
     90      "-0.6",
     91      { midComp: "0.9", toComp: "0.6" },
     92      "opacities with abs val >1 get clamped too early"
     93    ),
     94  ],
     95  paint: [
     96    // The "none" keyword & URI values aren't addiditve, so the animations in
     97    // these testcases are expected to have no effect.
     98    new AnimTestcaseFromBy("none", "none", { noEffect: 1 }),
     99    new AnimTestcaseFromBy("url(#gradA)", "url(#gradB)", { noEffect: 1 }),
    100    new AnimTestcaseFromBy("url(#gradA)", "url(#gradB) red", { noEffect: 1 }),
    101    new AnimTestcaseFromBy("url(#gradA)", "none", { noEffect: 1 }),
    102    new AnimTestcaseFromBy("red", "url(#gradA)", { noEffect: 1 }),
    103  ],
    104  URIsAndNone: [
    105    // No need to specify { noEffect: 1 }, since plain URI-valued properties
    106    // aren't additive
    107    new AnimTestcaseFromBy("url(#idA)", "url(#idB)"),
    108    new AnimTestcaseFromBy("none", "url(#idB)"),
    109    new AnimTestcaseFromBy("url(#idB)", "inherit"),
    110  ],
    111 };
    112 
    113 // List of attribute/testcase-list bundles to be tested
    114 var gFromByBundles = [
    115  new TestcaseBundle(gPropList.clip, [
    116    new AnimTestcaseFromBy(
    117      "rect(1px, 2px, 3px, 4px)",
    118      "rect(10px, 20px, 30px, 40px)",
    119      {
    120        midComp: "rect(6px, 12px, 18px, 24px)",
    121        toComp: "rect(11px, 22px, 33px, 44px)",
    122      }
    123    ),
    124    // Adding "auto" (either as a standalone value or a subcomponent value)
    125    // should cause animation to fail.
    126    new AnimTestcaseFromBy("auto", "auto", { noEffect: 1 }),
    127    new AnimTestcaseFromBy("auto", "rect(auto, auto, auto, auto)", {
    128      noEffect: 1,
    129    }),
    130    new AnimTestcaseFromBy(
    131      "rect(auto, auto, auto, auto)",
    132      "rect(auto, auto, auto, auto)",
    133      { noEffect: 1 }
    134    ),
    135    new AnimTestcaseFromBy("rect(1px, 2px, 3px, 4px)", "auto", { noEffect: 1 }),
    136    new AnimTestcaseFromBy("auto", "rect(1px, 2px, 3px, 4px)", { noEffect: 1 }),
    137    new AnimTestcaseFromBy(
    138      "rect(1px, 2px, 3px, auto)",
    139      "rect(10px, 20px, 30px, 40px)",
    140      { noEffect: 1 }
    141    ),
    142    new AnimTestcaseFromBy(
    143      "rect(1px, auto, 3px, 4px)",
    144      "rect(10px, auto, 30px, 40px)",
    145      { noEffect: 1 }
    146    ),
    147    new AnimTestcaseFromBy(
    148      "rect(1px, 2px, 3px, 4px)",
    149      "rect(10px, auto, 30px, 40px)",
    150      { noEffect: 1 }
    151    ),
    152  ]),
    153  // Check that 'by' animations for 'cursor' has no effect
    154  new TestcaseBundle(gPropList.cursor, [
    155    new AnimTestcaseFromBy("crosshair", "move"),
    156  ]),
    157  new TestcaseBundle(
    158    gPropList.fill,
    159    [].concat(_fromByTestLists.color, _fromByTestLists.paint)
    160  ),
    161  // Check that 'by' animations involving URIs have no effect
    162  new TestcaseBundle(gPropList.filter, _fromByTestLists.URIsAndNone),
    163  new TestcaseBundle(gPropList.font, [
    164    new AnimTestcaseFromBy(
    165      "10px serif",
    166      "normal normal 400 100px / 10px monospace"
    167    ),
    168  ]),
    169  new TestcaseBundle(
    170    gPropList.font_size,
    171    [].concat(_fromByTestLists.lengthNoUnits, _fromByTestLists.lengthPx)
    172  ),
    173  new TestcaseBundle(gPropList.font_size_adjust, [
    174    // These testcases implicitly have no effect, because font-size-adjust is
    175    // non-additive (and is declared as such in db_smilCSSPropertyList.js)
    176    new AnimTestcaseFromBy("0.5", "0.1"),
    177    new AnimTestcaseFromBy("none", "0.1"),
    178    new AnimTestcaseFromBy("0.1", "none"),
    179  ]),
    180  // Bug 1457353: Change from nsColor to StyleComplexColor causes addition
    181  // with currentcolor to break. Bug 1465307 for work to re-enable.
    182  new TestcaseBundle(gPropList.lighting_color, _fromByTestLists.color),
    183  new TestcaseBundle(gPropList.marker, _fromByTestLists.URIsAndNone),
    184  new TestcaseBundle(gPropList.marker_end, _fromByTestLists.URIsAndNone),
    185  new TestcaseBundle(gPropList.marker_mid, _fromByTestLists.URIsAndNone),
    186  new TestcaseBundle(gPropList.marker_start, _fromByTestLists.URIsAndNone),
    187  new TestcaseBundle(gPropList.overflow, [
    188    new AnimTestcaseFromBy("inherit", "auto"),
    189    new AnimTestcaseFromBy("scroll", "hidden"),
    190  ]),
    191  new TestcaseBundle(gPropList.opacity, _fromByTestLists.opacity),
    192  new TestcaseBundle(gPropList.stroke_miterlimit, [
    193    new AnimTestcaseFromBy("1", "1", { midComp: "1.5", toComp: "2" }),
    194    new AnimTestcaseFromBy("20.1", "-10", { midComp: "15.1", toComp: "10.1" }),
    195  ]),
    196  new TestcaseBundle(gPropList.stroke_dasharray, [
    197    // These testcases implicitly have no effect, because stroke-dasharray is
    198    // non-additive (and is declared as such in db_smilCSSPropertyList.js)
    199    new AnimTestcaseFromBy("none", "5"),
    200    new AnimTestcaseFromBy("10", "5"),
    201    new AnimTestcaseFromBy("1", "2, 3"),
    202  ]),
    203  new TestcaseBundle(
    204    gPropList.stroke_width,
    205    [].concat(_fromByTestLists.lengthNoUnits, _fromByTestLists.lengthPx)
    206  ),
    207 ];