tor-browser

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

gradient-interpolation-method-valid.html (5059B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <title>CSS Images Module Level 4: parsing gradients with color interpolation methods</title>
      6 <link rel="author" title="Sam Weinig" href="mailto:weinig@apple.com">
      7 <link rel="help" href="https://drafts.csswg.org/css-images-4/#gradients">
      8 <link rel="help" href="https://drafts.csswg.org/css-color-4/#color-interpolation-method">
      9 <meta name="assert" content="gradients supports the addition of color-interpolation-method to the grammar">
     10 <script src="/resources/testharness.js"></script>
     11 <script src="/resources/testharnessreport.js"></script>
     12 <script src="/css/support/parsing-testcommon.js"></script>
     13 </head>
     14 <body>
     15 <script>
     16 
     17 const LINEAR_GRADIENT_SPECIFIERS = [
     18    { input: '30deg' },
     19    { input: 'to right bottom' },
     20 ];
     21 
     22 const RADIAL_GRADIENT_SPECIFIERS = [
     23    { input: '50px' },
     24    { input: 'ellipse 50% 40em', output: '50% 40em' },
     25    { input: 'at right center' },
     26 ];
     27 
     28 const CONIC_GRADIENT_SPECIFIERS = [
     29    { input: 'from 30deg' },
     30    { input: 'at left 10px top 50em' },
     31 ];
     32 
     33 const legacy_stops = "red, blue"
     34 const legacy_stops_with_hint = "red, 50%, blue"
     35 const non_legacy_stops = "color(srgb 1 0 0), blue"
     36 
     37 function test_gradients_no_specified_interpolation_method(gradientFunction, specifiers, stops)
     38 {
     39    for (const specifier of specifiers) {
     40        const input = specifier.input
     41        const output = specifier.output ? specifier.output : specifier.input
     42        test_valid_value(`background-image`, `${gradientFunction}(${input}, ${stops})`, `${gradientFunction}(${output}, ${stops})`)
     43    }
     44 }
     45 
     46 function test_gradients(gradientFunction, colorInterpolationMethod, colorInterpolationMethodResult, specifiers, stops) {
     47    const resultForNoSpecifierCase = (colorInterpolationMethodResult == "") ? "" : `in ${colorInterpolationMethodResult}, `
     48    test_valid_value(`background-image`, `${gradientFunction}(in ${colorInterpolationMethod}, ${stops})`, `${gradientFunction}(${resultForNoSpecifierCase}${stops})`)
     49 
     50    for (const specifier of specifiers) {
     51        const input = specifier.input
     52        const output = specifier.output ? specifier.output : specifier.input
     53        const result = colorInterpolationMethodResult == "" ? ", " : ` in ${colorInterpolationMethodResult}, `
     54        test_valid_value(`background-image`, `${gradientFunction}(${input} in ${colorInterpolationMethod}, ${stops})`, `${gradientFunction}(${output}${result}${stops})`)
     55        test_valid_value(`background-image`, `${gradientFunction}(in ${colorInterpolationMethod} ${input}, ${stops})`, `${gradientFunction}(${output}${result}${stops})`)
     56    }
     57 }
     58 
     59 function test_gradient_with_interpolation_method(gradientFunction, colorInterpolationMethod, colorInterpolationMethodResult, specifiers, stops) {
     60    const colorInterpolationMethodResultForLegacyStops = (colorInterpolationMethodResult == "srgb") ? "" : colorInterpolationMethodResult;
     61    test_gradients(gradientFunction, colorInterpolationMethod, colorInterpolationMethodResultForLegacyStops, specifiers, legacy_stops)
     62    test_gradients(gradientFunction, colorInterpolationMethod, colorInterpolationMethodResultForLegacyStops, specifiers, legacy_stops_with_hint)
     63 
     64    const colorInterpolationMethodResultForNonLegacyStops = (colorInterpolationMethodResult == "oklab") ? "" : colorInterpolationMethodResult;
     65    test_gradients(gradientFunction, colorInterpolationMethod, colorInterpolationMethodResultForNonLegacyStops, specifiers, non_legacy_stops)
     66 }
     67 
     68 function test_each_interpolation_method(gradientFunction, specifiers) {
     69    test_gradients_no_specified_interpolation_method(gradientFunction, specifiers, legacy_stops)
     70    test_gradients_no_specified_interpolation_method(gradientFunction, specifiers, legacy_stops_with_hint)
     71    test_gradients_no_specified_interpolation_method(gradientFunction, specifiers, non_legacy_stops)
     72 
     73    for (const colorSpace of [ "lab", "oklab", "srgb", "srgb-linear", "xyz", "xyz-d50", "xyz-d65" ]) {
     74        const colorInterpolationMethod = colorSpace
     75        const colorInterpolationMethodResult = colorSpace == "xyz" ? "xyz-d65" : colorInterpolationMethod
     76 
     77        test_gradient_with_interpolation_method(gradientFunction, colorInterpolationMethod, colorInterpolationMethodResult, specifiers)
     78    }
     79 
     80    for (const colorSpace of [ "hsl", "hwb", "lch", "oklch" ]) {
     81        for (const hueInterpolationMethod of [ "", " shorter hue", " longer hue", " increasing hue", " decreasing hue" ]) {
     82            const colorInterpolationMethod = `${colorSpace}${hueInterpolationMethod}`
     83            const colorInterpolationMethodResult = hueInterpolationMethod == " shorter hue" ? colorSpace : colorInterpolationMethod
     84 
     85            test_gradient_with_interpolation_method(gradientFunction, colorInterpolationMethod, colorInterpolationMethodResult, specifiers)
     86        }
     87    }
     88 }
     89 
     90 test_each_interpolation_method("linear-gradient", LINEAR_GRADIENT_SPECIFIERS)
     91 test_each_interpolation_method("radial-gradient", RADIAL_GRADIENT_SPECIFIERS)
     92 test_each_interpolation_method("conic-gradient", CONIC_GRADIENT_SPECIFIERS)
     93 
     94 </script>
     95 </body>
     96 </html>