⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276498 in webkit


Ignore:
Timestamp:
Apr 23, 2021, 8:16:30 AM (5 years ago)
Author:
cathiechen
Message:

Import the update to "mapping attribute width and height to aspect ratio" tests from WPT
https://bugs.webkit.org/show_bug.cgi?id=224911

Reviewed by Rob Buis.

Import the update to "mapping attribute width and height to aspect ratio" tests from WPT commit 0ae0bb7cab. Split up the test cases, to make sure
each image has its own test case and won't affect testing other images.

  • web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/canvas-aspect-ratio-expected.txt:
  • web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt:
  • web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio.html:
  • web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/picture-aspect-ratio-expected.txt:
  • web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/picture-aspect-ratio.html:
  • web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/resources/aspect-ratio.js:

(test_computed_style_aspect_ratio):

  • web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/video-aspect-ratio-expected.txt:
Location:
trunk/LayoutTests/imported/w3c
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r276488 r276498  
     12021-04-23  Cathie Chen  <cathiechen@igalia.com>
     2
     3        Import the update to "mapping attribute width and height to aspect ratio" tests from WPT
     4        https://bugs.webkit.org/show_bug.cgi?id=224911
     5
     6        Reviewed by Rob Buis.
     7
     8        Import the update to "mapping attribute width and height to aspect ratio" tests from WPT commit 0ae0bb7cab. Split up the test cases, to make sure
     9        each image has its own test case and won't affect testing other images.
     10
     11        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/canvas-aspect-ratio-expected.txt:
     12        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt:
     13        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio.html:
     14        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/picture-aspect-ratio-expected.txt:
     15        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/picture-aspect-ratio.html:
     16        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/resources/aspect-ratio.js:
     17        (test_computed_style_aspect_ratio):
     18        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/video-aspect-ratio-expected.txt:
     19
    1202021-04-22  Tyler Wilcock  <twilco.o@protonmail.com>
    221
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/canvas-aspect-ratio-expected.txt

    r276296 r276498  
    33PASS Canvas width and height attributes are used as the surface size with contain:size
    44PASS Canvas width and height attributes are used as the surface size
    5 FAIL canvas with {"width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
    6 PASS canvas with {"width":"0","height":"1"}
    7 PASS canvas with {"width":"1","height":"0"}
    8 PASS canvas with {"width":"0","height":"0"}
    9 FAIL canvas with {"width":"0.5","height":"1.5"} assert_in_array: value "auto" not in array ["auto 0 / 1", "auto 0.5 / 1.5"]
    10 PASS canvas with {"width":"10%","height":"20"}
    11 PASS canvas with {"width":null,"height":null}
    12 PASS canvas with {"width":"10","height":null}
    13 PASS canvas with {"width":null,"height":"20"}
    14 PASS canvas with {"width":"xx","height":"20"}
     5FAIL Computed style test: canvas with {"width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
     6PASS Computed style test: canvas with {"width":"0","height":"1"}
     7PASS Computed style test: canvas with {"width":"1","height":"0"}
     8PASS Computed style test: canvas with {"width":"0","height":"0"}
     9FAIL Computed style test: canvas with {"width":"0.5","height":"1.5"} assert_in_array: value "auto" not in array ["auto 0 / 1", "auto 0.5 / 1.5"]
     10PASS Computed style test: canvas with {"width":"10%","height":"20"}
     11PASS Computed style test: canvas with {"width":null,"height":null}
     12PASS Computed style test: canvas with {"width":"10","height":null}
     13PASS Computed style test: canvas with {"width":null,"height":"20"}
     14PASS Computed style test: canvas with {"width":"xx","height":"20"}
    1515
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-expected.txt

    r276296 r276498  
    11
    22
    3 FAIL Image width and height attributes are used to infer aspect-ratio assert_approx_equals: aspect-ratio should override intrinsic size of images that don't have any src. expected 0.8 +/- 0.001 but got Infinity
    4 FAIL img with {"width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
    5 FAIL input with {"type":"image","width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
    6 PASS input with {"type":"submit","width":"10","height":"20"}
    7 FAIL img with {"width":"0","height":"1"} assert_equals: expected "auto 0 / 1" but got "auto"
    8 FAIL input with {"type":"image","width":"0","height":"1"} assert_equals: expected "auto 0 / 1" but got "auto"
    9 PASS input with {"type":"submit","width":"0","height":"1"}
    10 FAIL img with {"width":"1","height":"0"} assert_equals: expected "auto 1 / 0" but got "auto"
    11 FAIL input with {"type":"image","width":"1","height":"0"} assert_equals: expected "auto 1 / 0" but got "auto"
    12 PASS input with {"type":"submit","width":"1","height":"0"}
    13 FAIL img with {"width":"0","height":"0"} assert_equals: expected "auto 0 / 0" but got "auto"
    14 FAIL input with {"type":"image","width":"0","height":"0"} assert_equals: expected "auto 0 / 0" but got "auto"
    15 PASS input with {"type":"submit","width":"0","height":"0"}
    16 FAIL img with {"width":"0.5","height":"1.5"} assert_equals: expected "auto 0.5 / 1.5" but got "auto"
    17 FAIL input with {"type":"image","width":"0.5","height":"1.5"} assert_equals: expected "auto 0.5 / 1.5" but got "auto"
    18 PASS input with {"type":"submit","width":"0.5","height":"1.5"}
    19 PASS img with {"width":null,"height":null}
    20 PASS input with {"type":"image","width":null,"height":null}
    21 PASS input with {"type":"submit","width":null,"height":null}
    22 PASS img with {"width":"10","height":null}
    23 PASS input with {"type":"image","width":"10","height":null}
    24 PASS input with {"type":"submit","width":"10","height":null}
    25 PASS img with {"width":null,"height":"20"}
    26 PASS input with {"type":"image","width":null,"height":"20"}
    27 PASS input with {"type":"submit","width":null,"height":"20"}
    28 PASS img with {"width":"xx","height":"20"}
    29 PASS input with {"type":"image","width":"xx","height":"20"}
    30 PASS input with {"type":"submit","width":"xx","height":"20"}
    31 PASS img with {"width":"10%","height":"20"}
    32 PASS input with {"type":"image","width":"10%","height":"20"}
    33 PASS input with {"type":"submit","width":"10%","height":"20"}
     3PASS Image width and height attributes are used to infer aspect-ratio
     4PASS Create, append and test immediately: <img> with attributes width=250, height=100
     5PASS Create, append and test immediately: <img> with attributes width=0.8, height=0.2
     6PASS Create, append and test immediately: <img> with attributes width=50% height=25%
     7FAIL Computed style test: img with {"width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
     8FAIL Computed style test: input with {"type":"image","width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
     9PASS Computed style test: input with {"type":"submit","width":"10","height":"20"}
     10FAIL Computed style test: img with {"width":"0","height":"1"} assert_equals: expected "auto 0 / 1" but got "auto"
     11FAIL Computed style test: input with {"type":"image","width":"0","height":"1"} assert_equals: expected "auto 0 / 1" but got "auto"
     12PASS Computed style test: input with {"type":"submit","width":"0","height":"1"}
     13FAIL Computed style test: img with {"width":"1","height":"0"} assert_equals: expected "auto 1 / 0" but got "auto"
     14FAIL Computed style test: input with {"type":"image","width":"1","height":"0"} assert_equals: expected "auto 1 / 0" but got "auto"
     15PASS Computed style test: input with {"type":"submit","width":"1","height":"0"}
     16FAIL Computed style test: img with {"width":"0","height":"0"} assert_equals: expected "auto 0 / 0" but got "auto"
     17FAIL Computed style test: input with {"type":"image","width":"0","height":"0"} assert_equals: expected "auto 0 / 0" but got "auto"
     18PASS Computed style test: input with {"type":"submit","width":"0","height":"0"}
     19FAIL Computed style test: img with {"width":"0.5","height":"1.5"} assert_equals: expected "auto 0.5 / 1.5" but got "auto"
     20FAIL Computed style test: input with {"type":"image","width":"0.5","height":"1.5"} assert_equals: expected "auto 0.5 / 1.5" but got "auto"
     21PASS Computed style test: input with {"type":"submit","width":"0.5","height":"1.5"}
     22PASS Computed style test: img with {"width":null,"height":null}
     23PASS Computed style test: input with {"type":"image","width":null,"height":null}
     24PASS Computed style test: input with {"type":"submit","width":null,"height":null}
     25PASS Computed style test: img with {"width":"10","height":null}
     26PASS Computed style test: input with {"type":"image","width":"10","height":null}
     27PASS Computed style test: input with {"type":"submit","width":"10","height":null}
     28PASS Computed style test: img with {"width":null,"height":"20"}
     29PASS Computed style test: input with {"type":"image","width":null,"height":"20"}
     30PASS Computed style test: input with {"type":"submit","width":null,"height":"20"}
     31PASS Computed style test: img with {"width":"xx","height":"20"}
     32PASS Computed style test: input with {"type":"image","width":"xx","height":"20"}
     33PASS Computed style test: input with {"type":"submit","width":"xx","height":"20"}
     34PASS Computed style test: img with {"width":"10%","height":"20"}
     35PASS Computed style test: input with {"type":"image","width":"10%","height":"20"}
     36PASS Computed style test: input with {"type":"submit","width":"10%","height":"20"}
     37PASS Loaded images test: <img> without width height attributes
     38PASS Loaded images test: <img> with width and height attributes, but conflicting to the original aspect ratio
     39FAIL Loaded images test: <img> with width, height and empty src attributes assert_approx_equals: aspect-ratio should override intrinsic size of images that don't have any src. expected 0.8 +/- 0.001 but got Infinity
     40FAIL Loaded images test: Error image with width and height attributes assert_approx_equals: aspect-ratio should affect the size of error images. expected 0.8 +/- 0.001 but got 1
     41PASS Loaded images test: Error image with width, height and alt attributes
     42FAIL Loaded images test: <img> with width and height attributes, but not equal to the original aspect ratio assert_approx_equals: The original aspect ratio of blue.png expected 1.2547169811320755 +/- 0.001 but got 1.25
    3443
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio.html

    r276296 r276498  
    1818<img src="error.png" alt="Alt text" width=100 height=500>
    1919<script>
    20 let t = async_test("Image width and height attributes are used to infer aspect-ratio");
     20let guard = async_test("Image width and height attributes are used to infer aspect-ratio");
    2121function assert_ratio(img, expected, description) {
    2222  let epsilon = 0.001;
     
    3535// This is not racy because the spec requires the user agent to queue a task:
    3636// https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data
    37 t.step(function() {
     37test(function() {
     38  // This img will be tested again after loaded. In order to locate it correctly, body should append it first.
    3839  var img = new Image();
    3940  img.width = 250;
     
    4243  document.body.appendChild(img);
    4344  assert_ratio(img, 2.5);
     45}, "Create, append and test immediately: <img> with attributes width=250, height=100");
    4446
     47test(function () {
    4548  img = new Image();
    4649  img.setAttribute("width", "0.8");
     
    4952  document.body.appendChild(img);
    5053  assert_ratio(img, 4);
     54}, "Create, append and test immediately: <img> with attributes width=0.8, height=0.2");
    5155
     56test(function () {
    5257  img = new Image();
    5358  img.setAttribute("width", "50%");
     
    5762  // Percentages should be  ignored.
    5863  assert_equals(getComputedStyle(img).height, "0px");
    59 });
    60 
    61 onload = t.step_func_done(function() {
    62   let images = document.querySelectorAll("img");
    63   assert_ratio(images[0], 2.0, "2.0 is the original aspect ratio of green.png");
    64   assert_ratio(images[1], 2.0, "Loaded image's aspect ratio, at least by default, overrides width / height ratio.");
    65   assert_ratio(images[2], 100/125, "aspect-ratio should override intrinsic size of images that don't have any src.");
    66   assert_ratio(images[3], 100/125, "aspect-ratio should affect the size of error images.");
    67   assert_not_equals(images[5].offsetHeight, 500, "Images with alt text should be inline and ignore the aspect ratio");
    68   assert_ratio(images[6], 133/106, "The original aspect ratio of blue.png");
    69 });
     64}, "Create, append and test immediately: <img> with attributes width=50% height=25%");
    7065
    7166test_computed_style("10", "20", "auto 10 / 20");
     
    8580test_computed_style("10%", "20", "auto");
    8681
     82onload = function() {
     83  let images = document.querySelectorAll("img");
     84  // Tests for images finished loading.
     85  test(function() {
     86    assert_ratio(images[0], 2.0, "2.0 is the original aspect ratio of green.png");
     87  }, "Loaded images test: <img> without width height attributes");
     88
     89  test(function() {
     90    assert_ratio(images[1], 2.0, "Loaded image's aspect ratio, at least by default, overrides width / height ratio.");
     91  }, "Loaded images test: <img> with width and height attributes, but conflicting to the original aspect ratio");
     92
     93  test(function () {
     94    assert_ratio(images[2], 100 / 125, "aspect-ratio should override intrinsic size of images that don't have any src.");
     95  }, "Loaded images test: <img> with width, height and empty src attributes");
     96
     97  test(function () {
     98    assert_ratio(images[3], 100 / 125, "aspect-ratio should affect the size of error images.");
     99  }, "Loaded images test: Error image with width and height attributes");
     100
     101  test(function () {
     102    assert_not_equals(images[5].offsetHeight, 500, "Images with alt text should be inline and ignore the aspect ratio");
     103  }, "Loaded images test: Error image with width, height and alt attributes");
     104
     105  test(function () {
     106    assert_ratio(images[6], 133 / 106, "The original aspect ratio of blue.png");
     107  }, "Loaded images test: <img> with width and height attributes, but not equal to the original aspect ratio");
     108
     109  guard.done();
     110};
    87111</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/picture-aspect-ratio-expected.txt

    r276296 r276498  
    33
    44
    5 FAIL source width and height attributes are used to infer aspect-ratio in <picture> assert_equals: expected "auto 100 / 100" but got "auto"
     5PASS source width and height attributes are used to infer aspect-ratio in <picture>
    66FAIL Computed style for width/height/aspect-ratio assert_approx_equals: expected 1 +/- 0.001 but got Infinity
    77FAIL Source width/height should take precedence over img attributes. assert_approx_equals: expected 2 +/- 0.001 but got 5
     
    99FAIL If the <source> has only one of width/height, we don't get an aspect ratio, even if the <img> has both. assert_equals: expected "100px" but got "200px"
    1010FAIL If we don't have width/height on the source, we fall back to width/height on the <img>. assert_equals: expected "auto 200 / 100" but got "auto"
    11 FAIL If we only have one width/height attribute, we should get that attribute mapped but no aspect ratio, even if <img> has attributes. assert_equals: expected "100px" but got "200px"
     11FAIL If we only have one width attribute, we should get width mapped but no aspect ratio, even if <img> has attributes. assert_equals: expected "100px" but got "200px"
     12FAIL If we only have height attribute, we should get height mapped but no aspect ratio, even if <img> has attributes. assert_equals: expected "auto" but got "200px"
    1213FAIL Dynamically changing width/height should change computed style assert_equals: expected "auto 100 / 100" but got "auto"
    1314FAIL Changing which <source> matches should change computed style assert_equals: expected "auto 100 / 100" but got "auto"
    1415FAIL Percentages on source should be ignored for aspect-ratio but used for width/height. assert_equals: expected 100 but got 0
    1516FAIL Trailing garbage should be ignored but not make the attribute invalid assert_equals: expected 100 but got 0
     17PASS Loaded picture test: Both <source> and <img> are without width and height attributes
     18FAIL Loaded picture test: <source> with width and height attributes, <img> without width and height attributes assert_equals: expected "auto 100 / 100" but got "auto"
     19FAIL Loaded picture test: Both <source> and <img> are with width and height attributes assert_equals: expected "auto 100 / 100" but got "auto"
    1620
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/picture-aspect-ratio.html

    r276296 r276498  
    4444
    4545<script>
    46 let t = async_test("source width and height attributes are used to infer aspect-ratio in <picture>");
     46let guard = async_test("source width and height attributes are used to infer aspect-ratio in <picture>");
    4747function assert_ratio(img, expected, description) {
    4848  let epsilon = 0.001;
     
    139139  assert_equals(getComputedStyle(img).width, "100px");
    140140  assert_equals(getComputedStyle(img).height, "auto");
    141 
     141}, "If we only have one width attribute, we should get width mapped but no aspect ratio, even if <img> has attributes.");
     142
     143test(function() {
    142144  img = createPicture(undefined, 100);
    143145  img.parentNode.style.display = "none";
     
    148150  assert_equals(getComputedStyle(img).width, "auto");
    149151  assert_equals(getComputedStyle(img).height, "100px");
    150 }, "If we only have one width/height attribute, we should get that attribute mapped but no aspect ratio, even if <img> has attributes.");
     152}, "If we only have height attribute, we should get height mapped but no aspect ratio, even if <img> has attributes.");
    151153
    152154test(function() {
     
    204206}, "Trailing garbage should be ignored but not make the attribute invalid");
    205207
    206 onload = t.step_func_done(function() {
     208onload = function() {
    207209  let images = document.querySelectorAll("img");
    208   var img = images[0];
    209   assert_ratio(img, 2.0, "2.0 is the original aspect ratio of green-100x50.png");
    210   assert_cs(img, "auto");
    211   img.style.display = "none";
    212   img.setAttribute("nowidth", "true");
    213   assert_equals(getComputedStyle(img).width, "auto");
    214   assert_equals(getComputedStyle(img).height, "auto");
    215   img = images[1];
    216   assert_ratio(img, 2.0, "Loaded image's aspect ratio, at least by default, overrides width / height ratio.");
    217   assert_cs(img, "auto 100 / 100");
    218   img.style.display = "none";
    219   img.setAttribute("nowidth", "true");
    220   assert_equals(getComputedStyle(img).width, "100px");
    221   assert_equals(getComputedStyle(img).height, "100px");
    222   img = images[2];
    223   assert_ratio(img, 2.0, "Loaded image's aspect ratio, at least by default, overrides width / height ratio (2).");
    224   assert_cs(img, "auto 100 / 100");
    225   img.style.display = "none";
    226   img.setAttribute("nowidth", "true");
    227   assert_equals(getComputedStyle(img).width, "100px");
    228   assert_equals(getComputedStyle(img).height, "100px");
    229 });
     210  test(function() {
     211    var img = images[0];
     212    assert_ratio(img, 2.0, "2.0 is the original aspect ratio of green-100x50.png");
     213    assert_cs(img, "auto");
     214    img.style.display = "none";
     215    img.setAttribute("nowidth", "true");
     216    assert_equals(getComputedStyle(img).width, "auto");
     217    assert_equals(getComputedStyle(img).height, "auto");
     218  }, "Loaded picture test: Both <source> and <img> are without width and height attributes");
     219
     220  test(function () {
     221    img = images[1];
     222    assert_ratio(img, 2.0, "Loaded image's aspect ratio, at least by default, overrides width / height ratio.");
     223    assert_cs(img, "auto 100 / 100");
     224    img.style.display = "none";
     225    img.setAttribute("nowidth", "true");
     226    assert_equals(getComputedStyle(img).width, "100px");
     227    assert_equals(getComputedStyle(img).height, "100px");
     228  }, "Loaded picture test: <source> with width and height attributes, <img> without width and height attributes");
     229
     230  test(function () {
     231    img = images[2];
     232    assert_ratio(img, 2.0, "Loaded image's aspect ratio, at least by default, overrides width / height ratio (2).");
     233    assert_cs(img, "auto 100 / 100");
     234    img.style.display = "none";
     235    img.setAttribute("nowidth", "true");
     236    assert_equals(getComputedStyle(img).width, "100px");
     237    assert_equals(getComputedStyle(img).height, "100px");
     238  }, "Loaded picture test: Both <source> and <img> are with width and height attributes");
     239
     240  guard.done();
     241};
    230242</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/resources/aspect-ratio.js

    r276296 r276498  
    1515    }
    1616    elem.remove();
    17   }, `${tag} with ${JSON.stringify(attributes)}`);
     17  }, `Computed style test: ${tag} with ${JSON.stringify(attributes)}`);
    1818}
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/video-aspect-ratio-expected.txt

    r276296 r276498  
    22
    33FAIL Video width and height attributes are not used to infer aspect-ratio assert_approx_equals: expected 2.5 +/- 0.001 but got 2
    4 FAIL video with {"width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
    5 FAIL video with {"width":"0.5","height":"1.5"} assert_equals: expected "auto 0.5 / 1.5" but got "auto"
    6 PASS video with {"width":"0","height":"1"}
    7 PASS video with {"width":"1","height":"0"}
    8 PASS video with {"width":"0","height":"0"}
    9 PASS video with {"width":null,"height":null}
    10 PASS video with {"width":"10","height":null}
    11 PASS video with {"width":null,"height":"20"}
    12 PASS video with {"width":"xx","height":"20"}
    13 PASS video with {"width":"10%","height":"20"}
     4FAIL Computed style test: video with {"width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
     5FAIL Computed style test: video with {"width":"0.5","height":"1.5"} assert_equals: expected "auto 0.5 / 1.5" but got "auto"
     6PASS Computed style test: video with {"width":"0","height":"1"}
     7PASS Computed style test: video with {"width":"1","height":"0"}
     8PASS Computed style test: video with {"width":"0","height":"0"}
     9PASS Computed style test: video with {"width":null,"height":null}
     10PASS Computed style test: video with {"width":"10","height":null}
     11PASS Computed style test: video with {"width":null,"height":"20"}
     12PASS Computed style test: video with {"width":"xx","height":"20"}
     13PASS Computed style test: video with {"width":"10%","height":"20"}
    1414
Note: See TracChangeset for help on using the changeset viewer.