File: image-set-computed.sub.html

package info (click to toggle)
firefox-esr 140.3.1esr-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,539,016 kB
  • sloc: cpp: 7,380,478; javascript: 6,388,099; ansic: 3,710,142; python: 1,393,715; xml: 628,165; asm: 426,918; java: 184,025; sh: 65,742; makefile: 19,302; objc: 13,059; perl: 12,912; yacc: 4,583; cs: 3,846; pascal: 3,352; lex: 1,720; ruby: 1,226; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (73 lines) | stat: -rw-r--r-- 4,743 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<title>Image set computed value</title>
<link rel="help" href="https://drafts.csswg.org/css-images-4/#serialization">
<link rel="help" href="https://www.w3.org/TR/cssom-1/#serializing-css-values">
<link rel="help" href="https://www.w3.org/TR/css-values-4/#canonical-unit">
<link rel="help" href="https://www.w3.org/TR/css-values-4/#resolution">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<body>
<div id="target"></div>
<script>
function test_computed_value_variants(property, specified, computed) {
  if (!computed) computed = specified;
  test_computed_value(property, specified, computed);
  test_computed_value(property, "-webkit-" + specified, computed);
}

function test_calculated_resolution_units() {
  test_computed_value_variants(
    'background-image',
    "image-set(url('http://{{host}}/example.png') calc(1x * 2))",
    'image-set(url("http://{{host}}/example.png") 2dppx)'
  );

  test_computed_value_variants(
    'background-image',
    "image-set(url('http://{{host}}/example.png') calc(6dppx / 3))",
    'image-set(url("http://{{host}}/example.png") 2dppx)'
  );

  test_computed_value_variants(
    'background-image',
    "image-set(url('http://{{host}}/example.png') calc(100dpi - 4dpi))",
    'image-set(url("http://{{host}}/example.png") 1dppx)'
  );

  test_computed_value_variants(
    'background-image',
    "image-set(url('http://{{host}}/example.png') calc(37dpcm + 0.79532dpcm))",
    [
      'image-set(url("http://{{host}}/example.png") 1dppx)',
      'image-set(url("http://{{host}}/example.png") 1.000001dppx)'
    ]
  );

  test_computed_value_variants(
    'background-image',
    "image-set(url('http://{{host}}/example.png') calc(-1 * 1x))",
    'image-set(url("http://{{host}}/example.png") 0dppx)'
  );
}

// The resolution unit is expected to be converted to the canonical unit 'dppx'
// for computed style.
test_computed_value_variants('background-image', "image-set(url(http://{{host}}/example.png) 1x)", 'image-set(url("http://{{host}}/example.png") 1dppx)');
test_computed_value_variants('background-image', "image-set(url(http://{{host}}/example.png) 1x, 'http://{{host}}/example.png' 2x)", 'image-set(url("http://{{host}}/example.png") 1dppx, url("http://{{host}}/example.png") 2dppx)');
test_computed_value_variants('background-image', 'image-set(url("http://{{host}}/example.png") 1dppx)');
test_computed_value_variants('background-image', "image-set(url(http://{{host}}/example.png) 48dpi)", 'image-set(url("http://{{host}}/example.png") 0.5dppx)');
test_computed_value_variants('background-image', "image-set(url(http://{{host}}/example.png) 2400dpcm, 'http://{{host}}/example.png' 2x)", 'image-set(url("http://{{host}}/example.png") 63.5dppx, url("http://{{host}}/example.png") 2dppx)');
test_computed_value_variants('background-image', "image-set('http://{{host}}/example.jpeg' 240dpi, url(http://{{host}}/example.png) 3.5x)", 'image-set(url("http://{{host}}/example.jpeg") 2.5dppx, url("http://{{host}}/example.png") 3.5dppx)');
test_computed_value_variants('background-image', "image-set(linear-gradient(black, white) 1x)", "image-set(linear-gradient(rgb(0, 0, 0), rgb(255, 255, 255)) 1dppx)");
test_computed_value_variants('background-image', "image-set(url(http://{{host}}/example.png) 1x type('image/png'))", 'image-set(url("http://{{host}}/example.png") 1dppx type("image/png"))');
test_computed_value_variants('background-image', "image-set(url(http://{{host}}/example.png) type('image/png'))", 'image-set(url("http://{{host}}/example.png") 1dppx type("image/png"))');
test_computed_value_variants('background-image', "image-set(url(http://{{host}}/example.png) type('image/png') 1x)", 'image-set(url("http://{{host}}/example.png") 1dppx type("image/png"))');
test_computed_value_variants('content', "image-set(url('http://{{host}}/example.png') 192dpi, linear-gradient(black, white) 1x)", 'image-set(url("http://{{host}}/example.png") 2dppx, linear-gradient(rgb(0, 0, 0), rgb(255, 255, 255)) 1dppx)');

// Unsupported type should still serialize.
test_computed_value_variants('background-image', 'image-set(url("http://{{host}}/example.png") type("image/unsupported"))', 'image-set(url("http://{{host}}/example.png") 1dppx type("image/unsupported"))');
test_computed_value_variants('background-image', 'image-set(url("http://{{host}}/example.png") 2x type("image/unsupported"), url("http://{{host}}/example.png") 1x type("image/unsupported"))', 'image-set(url("http://{{host}}/example.png") 2dppx type("image/unsupported"), url("http://{{host}}/example.png") 1dppx type("image/unsupported"))');

test_calculated_resolution_units();
</script>