Changeset 205515 in webkit
- Timestamp:
- Sep 6, 2016 3:59:29 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r205514 r205515 1 2016-09-06 Chris Dumez <cdumez@apple.com> 2 3 Align srcset attribute parsing with the HTML specification 4 https://bugs.webkit.org/show_bug.cgi?id=161636 5 6 Reviewed by Darin Adler. 7 8 Re-sync fast/hidpi/image-srcset-invalid-descriptor.html with Blink. 9 10 * fast/hidpi/image-srcset-invalid-descriptor-expected.txt: 11 * fast/hidpi/image-srcset-invalid-descriptor.html: 12 1 13 2016-09-06 Ryan Haddad <ryanhaddad@apple.com> 2 14 -
trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor-expected.txt
r177772 r205515 1 PASS document.getElementById("invalid_with_x").clientWidth is 100 2 PASS document.getElementById("invalid_without_x").clientWidth is 100 3 PASS document.getElementById("future_descriptor").clientWidth is 100 4 PASS document.getElementById("future_descriptor_without_x").clientWidth is 100 5 PASS document.getElementById("x_with_w_ignored").clientWidth is 200 6 PASS document.getElementById("x_with_h_ignored").clientWidth is 200 1 PASS document.getElementById("foo").clientWidth==200 is true 2 PASS document.getElementById("foo2").clientWidth==200 is true 3 PASS document.getElementById("foo3").clientWidth==200 is true 4 PASS document.getElementById("foo4").clientWidth==200 is true 5 PASS document.getElementById("foo5").clientWidth==200 is true 6 PASS document.getElementById("foo6").clientWidth==200 is true 7 PASS document.getElementById("foo7").clientWidth==200 is true 8 PASS document.getElementById("foo8").clientWidth==200 is true 9 PASS document.getElementById("foo9").clientWidth==200 is true 10 PASS document.getElementById("foo10").clientWidth==200 is true 7 11 PASS successfullyParsed is true 8 12 9 13 TEST COMPLETE 10 This test passes if the image below is a 100px blue square when the deviceScaleFactor is 1. 11 It tests that even though the 1x resource contains many invalid descriptors, only the invalid descriptors are ignored (according to the spec). 14 This test passes if the image below is a 200px green square when the deviceScaleFactor is 1. 15 It tests that the 1x resource is ignored since it contains invalid descriptors. 16 The 2x resource has an intrinsic width of 200px, since it's a 400px wide image at 2x DPR. 12 17 -
trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor.html
r178721 r205515 1 <html> 2 <head> 1 <!DOCTYPE html> 3 2 <script> 4 3 window.targetScaleFactor = 1; 5 4 </script> 6 <script src=" ../../resources/srcset-helper.js"></script>5 <script src="resources/srcset-helper.js"></script> 7 6 <script src="../../resources/js-test.js"></script> 8 7 <script> 9 function runTest() { 10 shouldBe('document.getElementById("invalid_with_x").clientWidth', '100'); 11 shouldBe('document.getElementById("invalid_without_x").clientWidth', '100'); 12 shouldBe('document.getElementById("future_descriptor").clientWidth', '100'); 13 shouldBe('document.getElementById("future_descriptor_without_x").clientWidth', '100'); 14 shouldBe('document.getElementById("x_with_w_ignored").clientWidth', '200'); 15 shouldBe('document.getElementById("x_with_h_ignored").clientWidth', '200'); 16 } 8 addEventListener("load", function() { 9 shouldBeTrue('document.getElementById("foo").clientWidth==200'); 10 shouldBeTrue('document.getElementById("foo2").clientWidth==200'); 11 shouldBeTrue('document.getElementById("foo3").clientWidth==200'); 12 shouldBeTrue('document.getElementById("foo4").clientWidth==200'); 13 shouldBeTrue('document.getElementById("foo5").clientWidth==200'); 14 shouldBeTrue('document.getElementById("foo6").clientWidth==200'); 15 shouldBeTrue('document.getElementById("foo7").clientWidth==200'); 16 shouldBeTrue('document.getElementById("foo8").clientWidth==200'); 17 shouldBeTrue('document.getElementById("foo9").clientWidth==200'); 18 shouldBeTrue('document.getElementById("foo10").clientWidth==200'); 19 }, false); 17 20 </script> 18 </head> 19 20 <body id="body"> 21 <div>This test passes if the image below is a 100px blue square when the deviceScaleFactor is 1.</div> 22 <div> It tests that even though the 1x resource contains many invalid descriptors, 23 only the invalid descriptors are ignored (according to the spec).</div> 24 <img id="invalid_with_x" src="" srcset="resources/blue-100-px-square.png 43q 1x dfs 3dd, resources/green-400-px-square.png 2x"> 25 <img id="invalid_without_x" src="" srcset="resources/blue-100-px-square.png 300q, resources/green-400-px-square.png 2x"> 26 <img id="future_descriptor" srcset=",resources/blue-100-px-square.png 1x future-descriptor(3x, 4h, whatever), resources/green-400-px-square.png 2x"> 27 <img id="future_descriptor_without_x" srcset=",resources/blue-100-px-square.png future-descriptor(3x, 4h, whatever), resources/green-400-px-square.png 2x"> 28 <img id="x_with_w_ignored" srcset=",resources/blue-100-px-square.png 1x 100w, resources/green-400-px-square.png 2x"> 29 <img id="x_with_h_ignored" srcset=",resources/blue-100-px-square.png 1x 100h, resources/green-400-px-square.png 2x"> 30 </body> 31 </html> 21 <div>This test passes if the image below is a 200px green square when the deviceScaleFactor is 1.</div> 22 <div>It tests that the 1x resource is ignored since it contains invalid descriptors.</div> 23 <div>The 2x resource has an intrinsic width of 200px, since it's a 400px wide image at 2x DPR.</div> 24 <img id="foo" src="" srcset="resources/blue-100-px-square.png 43q 1x dfs 3dd, resources/green-400-px-square.png 2x"> 25 <img id="foo2" src="" srcset="resources/blue-100-px-square.png 300q, resources/green-400-px-square.png 2x"> 26 <img id="foo3" src="" srcset="resources/blue-100-px-square.png 100w 100w, resources/green-400-px-square.png 2x"> 27 <img id="foo4" src="" srcset="resources/blue-100-px-square.png 100h 100h, resources/green-400-px-square.png 2x"> 28 <img id="foo5" src="" srcset="resources/blue-100-px-square.png 100x 100h, resources/green-400-px-square.png 2x"> 29 <img id="foo6" src="" srcset="resources/blue-100-px-square.png 100x 100w, resources/green-400-px-square.png 2x"> 30 <img id="foo7" src="" srcset="resources/blue-100-px-square.png -100w, resources/green-400-px-square.png 2x"> 31 <img id="foo8" src="" srcset="resources/blue-100-px-square.png -100h, resources/green-400-px-square.png 2x"> 32 <img id="foo9" src="" srcset="resources/blue-100-px-square.png -1x, resources/green-400-px-square.png 2x"> 33 <img id="foo10" src="" srcset="resources/blue-100-px-square.png 100h, resources/green-400-px-square.png 2x"> -
trunk/LayoutTests/imported/w3c/ChangeLog
r205473 r205515 1 2016-09-06 Chris Dumez <cdumez@apple.com> 2 3 Align srcset attribute parsing with the HTML specification 4 https://bugs.webkit.org/show_bug.cgi?id=161636 5 6 Reviewed by Darin Adler. 7 8 Rebaseline a couple of W3C tests now that more checks are passing. 9 10 * web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt: 11 * web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt: 12 1 13 2016-09-06 Youenn Fablet <youenn@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt
r204090 r205515 5 5 FAIL <img srcset="/images/green-256x256.png 2x" data-expect="128"> assert_equals: naturalWidth expected 128 but got 256 6 6 FAIL <img srcset="/images/green-256x256.png 10000x" data-expect="0"> assert_equals: naturalWidth expected 0 but got 256 7 FAIL <img srcset="/images/green-256x256.png 9e99999999999999999999999x" data-expect="0"> assert_equals: naturalWidth expected 0 but got 256 7 PASS <img srcset="/images/green-256x256.png 9e99999999999999999999999x" data-expect="0"> 8 8 PASS <img srcset="/images/green-256x256.png 256w" sizes="256px" data-expect="256"> 9 9 FAIL <img srcset="/images/green-256x256.png 512w" sizes="256px" data-expect="128"> assert_equals: naturalWidth expected 128 but got 256 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt
r204090 r205515 27 27 PASS "data:,a 1x " 28 28 PASS "data:,a 1x," 29 FAIL "data:,a ( , data:,b 1x, ), data:,c" assert_equals: expected "data:,c" but got "data:,a" 30 FAIL "data:,a ((( , data:,b 1x, ), data:,c" assert_equals: expected "data:,c" but got "data:,a" 31 FAIL "data:,a [ , data:,b 1x, ], data:,c" assert_equals: expected "data:,b" but got "data:,a" 32 FAIL "data:,a { , data:,b 1x, }, data:,c" assert_equals: expected "data:,b" but got "data:,a" 33 FAIL "data:,a \" , data:,b 1x, \", data:,c" assert_equals: expected "data:,b" but got "data:,a" 34 FAIL "data:,a \\,data:;\,b, data:,c" assert_equals: expected "data:;\\,b" but got "data:,a" 29 PASS "data:,a ( , data:,b 1x, ), data:,c" 30 PASS "data:,a ((( , data:,b 1x, ), data:,c" 31 PASS "data:,a [ , data:,b 1x, ], data:,c" 32 PASS "data:,a { , data:,b 1x, }, data:,c" 33 PASS "data:,a \" , data:,b 1x, \", data:,c" 34 PASS "data:,a \\,data:;\,b, data:,c" 35 35 PASS "data:,a, data:,b (" 36 36 PASS "data:,a, data:,b ( " … … 38 38 PASS "data:,a, data:,b (x" 39 39 PASS "data:,a, data:,b ()" 40 FAIL "data:,a (, data:,b" assert_equals: expected "" but got "data:,a" 41 FAIL "data:,a /*, data:,b, data:,c */" assert_equals: expected "data:,b" but got "data:,a" 42 FAIL "data:,a //, data:,b" assert_equals: expected "data:,b" but got "data:,a" 43 FAIL "data:,a foo" assert_equals: expected "" but got "data:,a" 44 FAIL "data:,a foo foo" assert_equals: expected "" but got "data:,a" 45 FAIL "data:,a foo 1x" assert_equals: expected "" but got "data:,a" 46 FAIL "data:,a foo 1x foo" assert_equals: expected "" but got "data:,a" 47 FAIL "data:,a foo 1w" assert_equals: expected "" but got "data:,a" 48 FAIL "data:,a foo 1w foo" assert_equals: expected "" but got "data:,a" 40 PASS "data:,a (, data:,b" 41 PASS "data:,a /*, data:,b, data:,c */" 42 PASS "data:,a //, data:,b" 43 PASS "data:,a foo" 44 PASS "data:,a foo foo" 45 PASS "data:,a foo 1x" 46 PASS "data:,a foo 1x foo" 47 PASS "data:,a foo 1w" 48 PASS "data:,a foo 1w foo" 49 49 PASS "data:,a 1x 1x" 50 50 PASS "data:,a 1w 1w" … … 58 58 PASS "data:,a 1x 1w 1h" 59 59 PASS "data:,a 1w" 60 FAIL "data:,a 1h" assert_equals: expected "" but got "data:,a" 61 FAIL "data:,a 1h foo" assert_equals: expected "" but got "data:,a" 62 FAIL "data:,a foo 1h" assert_equals: expected "" but got "data:,a" 60 PASS "data:,a 1h" 61 PASS "data:,a 1h foo" 62 PASS "data:,a foo 1h" 63 63 PASS "data:,a 0w" 64 64 PASS "data:,a -1w" 65 65 PASS "data:,a 1w -1w" 66 FAIL "data:,a 1.0w" assert_equals: expected "" but got "data:,a" 66 PASS "data:,a 1.0w" 67 67 PASS "data:,a 1w 1.0w" 68 FAIL "data:,a 1e0w" assert_equals: expected "" but got "data:,a" 68 PASS "data:,a 1e0w" 69 69 PASS "data:,a 1w 1e0w" 70 FAIL "data:,a 1www" assert_equals: expected "" but got "data:,a" 70 PASS "data:,a 1www" 71 71 PASS "data:,a 1w 1www" 72 FAIL "data:,a +1w" assert_equals: expected "" but got "data:,a" 72 PASS "data:,a +1w" 73 73 PASS "data:,a 1w +1w" 74 FAIL "data:,a 1W" assert_equals: expected "" but got "data:,a" 75 FAIL "data:,a 1w 1W" assert_equals: expected "" but got "data:,a" 74 PASS "data:,a 1W" 75 PASS "data:,a 1w 1W" 76 76 PASS "data:,a Infinityw" 77 77 PASS "data:,a 1w Infinityw" … … 80 80 PASS "data:,a 0x1w" 81 81 PASS "data:,a 0X1w" 82 FAIL "data:,a 1\x01w" (trailing U+0001) assert_equals: expected "" but got "data:,a" 83 FAIL "data:,a 1 w" (trailing U+00A0) assert_equals: expected "" but got "data:,a" 84 FAIL "data:,a 1 w" (trailing U+1680) assert_equals: expected "" but got "data:,a" 85 FAIL "data:,a 1 w" (trailing U+2000) assert_equals: expected "" but got "data:,a" 86 FAIL "data:,a 1 w" (trailing U+2001) assert_equals: expected "" but got "data:,a" 87 FAIL "data:,a 1 w" (trailing U+2002) assert_equals: expected "" but got "data:,a" 88 FAIL "data:,a 1 w" (trailing U+2003) assert_equals: expected "" but got "data:,a" 89 FAIL "data:,a 1 w" (trailing U+2004) assert_equals: expected "" but got "data:,a" 90 FAIL "data:,a 1 w" (trailing U+2005) assert_equals: expected "" but got "data:,a" 91 FAIL "data:,a 1 w" (trailing U+2006) assert_equals: expected "" but got "data:,a" 92 FAIL "data:,a 1 w" (trailing U+2007) assert_equals: expected "" but got "data:,a" 93 FAIL "data:,a 1 w" (trailing U+2008) assert_equals: expected "" but got "data:,a" 94 FAIL "data:,a 1 w" (trailing U+2009) assert_equals: expected "" but got "data:,a" 95 FAIL "data:,a 1 w" (trailing U+200A) assert_equals: expected "" but got "data:,a" 96 FAIL "data:,a 1w" (trailing U+200C) assert_equals: expected "" but got "data:,a" 97 FAIL "data:,a 1w" (trailing U+200D) assert_equals: expected "" but got "data:,a" 98 FAIL "data:,a 1 w" (trailing U+202F) assert_equals: expected "" but got "data:,a" 99 FAIL "data:,a 1 w" (trailing U+205F) assert_equals: expected "" but got "data:,a" 100 FAIL "data:,a 1 w" (trailing U+3000) assert_equals: expected "" but got "data:,a" 101 FAIL "data:,a 1w" (trailing U+FEFF) assert_equals: expected "" but got "data:,a" 82 PASS "data:,a 1\x01w" (trailing U+0001) 83 PASS "data:,a 1 w" (trailing U+00A0) 84 PASS "data:,a 1 w" (trailing U+1680) 85 PASS "data:,a 1 w" (trailing U+2000) 86 PASS "data:,a 1 w" (trailing U+2001) 87 PASS "data:,a 1 w" (trailing U+2002) 88 PASS "data:,a 1 w" (trailing U+2003) 89 PASS "data:,a 1 w" (trailing U+2004) 90 PASS "data:,a 1 w" (trailing U+2005) 91 PASS "data:,a 1 w" (trailing U+2006) 92 PASS "data:,a 1 w" (trailing U+2007) 93 PASS "data:,a 1 w" (trailing U+2008) 94 PASS "data:,a 1 w" (trailing U+2009) 95 PASS "data:,a 1 w" (trailing U+200A) 96 PASS "data:,a 1w" (trailing U+200C) 97 PASS "data:,a 1w" (trailing U+200D) 98 PASS "data:,a 1 w" (trailing U+202F) 99 PASS "data:,a 1 w" (trailing U+205F) 100 PASS "data:,a 1 w" (trailing U+3000) 101 PASS "data:,a 1w" (trailing U+FEFF) 102 102 PASS "data:,a \x011w" (leading U+0001) 103 103 PASS "data:,a 1w" (leading U+00A0) 104 FAIL "data:,a 1w" (leading U+1680) assert_equals: expected "" but got "data:,a" 105 FAIL "data:,a 1w" (leading U+2000) assert_equals: expected "" but got "data:,a" 106 FAIL "data:,a 1w" (leading U+2001) assert_equals: expected "" but got "data:,a" 107 FAIL "data:,a 1w" (leading U+2002) assert_equals: expected "" but got "data:,a" 108 FAIL "data:,a 1w" (leading U+2003) assert_equals: expected "" but got "data:,a" 109 FAIL "data:,a 1w" (leading U+2004) assert_equals: expected "" but got "data:,a" 110 FAIL "data:,a 1w" (leading U+2005) assert_equals: expected "" but got "data:,a" 111 FAIL "data:,a 1w" (leading U+2006) assert_equals: expected "" but got "data:,a" 112 FAIL "data:,a 1w" (leading U+2007) assert_equals: expected "" but got "data:,a" 113 FAIL "data:,a 1w" (leading U+2008) assert_equals: expected "" but got "data:,a" 114 FAIL "data:,a 1w" (leading U+2009) assert_equals: expected "" but got "data:,a" 115 FAIL "data:,a 1w" (leading U+200A) assert_equals: expected "" but got "data:,a" 104 PASS "data:,a 1w" (leading U+1680) 105 PASS "data:,a 1w" (leading U+2000) 106 PASS "data:,a 1w" (leading U+2001) 107 PASS "data:,a 1w" (leading U+2002) 108 PASS "data:,a 1w" (leading U+2003) 109 PASS "data:,a 1w" (leading U+2004) 110 PASS "data:,a 1w" (leading U+2005) 111 PASS "data:,a 1w" (leading U+2006) 112 PASS "data:,a 1w" (leading U+2007) 113 PASS "data:,a 1w" (leading U+2008) 114 PASS "data:,a 1w" (leading U+2009) 115 PASS "data:,a 1w" (leading U+200A) 116 116 PASS "data:,a 1w" (leading U+200C) 117 117 PASS "data:,a 1w" (leading U+200D) 118 118 PASS "data:,a 1w" (leading U+202F) 119 FAIL "data:,a 1w" (leading U+205F) assert_equals: expected "" but got "data:,a" 120 FAIL "data:,a 1w" (leading U+3000) assert_equals: expected "" but got "data:,a" 119 PASS "data:,a 1w" (leading U+205F) 120 PASS "data:,a 1w" (leading U+3000) 121 121 PASS "data:,a 1w" (leading U+FEFF) 122 122 PASS "data:,a 0x" … … 132 132 PASS "data:,a .x" 133 133 PASS "data:,a -.x" 134 FAIL "data:,a 1.x" assert_equals: expected "" but got "data:,a" 134 PASS "data:,a 1.x" 135 135 PASS "data:,a .5x" 136 136 PASS "data:,a .5e1x" … … 139 139 PASS "data:,a 1.0x" 140 140 PASS "data:,a 1x 1.0x" 141 FAIL "data:,a +1x" assert_equals: expected "" but got "data:,a" 142 FAIL "data:,a 1X" assert_equals: expected "" but got "data:,a" 141 PASS "data:,a +1x" 142 PASS "data:,a 1X" 143 143 PASS "data:,a Infinityx" 144 144 PASS "data:,a NaNx" … … 187 187 PASS "data:,a 1w 0h" 188 188 PASS "data:,a 1w -1h" 189 FAIL "data:,a 1w 1.0h" assert_equals: expected "" but got "data:,a" 190 FAIL "data:,a 1w 1e0h" assert_equals: expected "" but got "data:,a" 191 FAIL "data:,a 1w 1hhh" assert_equals: expected "" but got "data:,a" 192 FAIL "data:,a 1w +1h" assert_equals: expected "" but got "data:,a" 193 FAIL "data:,a 1w 1H" assert_equals: expected "" but got "data:,a" 189 PASS "data:,a 1w 1.0h" 190 PASS "data:,a 1w 1e0h" 191 PASS "data:,a 1w 1hhh" 192 PASS "data:,a 1w +1h" 193 PASS "data:,a 1w 1H" 194 194 PASS "data:,a 1w Infinityh" 195 195 PASS "data:,a 1w NaNh" 196 196 PASS "data:,a 0x1h" 197 197 PASS "data:,a 0X1h" 198 FAIL "data:,a 1w 1\x01h" (trailing U+0001) assert_equals: expected "" but got "data:,a" 199 FAIL "data:,a 1w 1 h" (trailing U+00A0) assert_equals: expected "" but got "data:,a" 200 FAIL "data:,a 1w 1 h" (trailing U+1680) assert_equals: expected "" but got "data:,a" 201 FAIL "data:,a 1w 1 h" (trailing U+2000) assert_equals: expected "" but got "data:,a" 202 FAIL "data:,a 1w 1 h" (trailing U+2001) assert_equals: expected "" but got "data:,a" 203 FAIL "data:,a 1w 1 h" (trailing U+2002) assert_equals: expected "" but got "data:,a" 204 FAIL "data:,a 1w 1 h" (trailing U+2003) assert_equals: expected "" but got "data:,a" 205 FAIL "data:,a 1w 1 h" (trailing U+2004) assert_equals: expected "" but got "data:,a" 206 FAIL "data:,a 1w 1 h" (trailing U+2005) assert_equals: expected "" but got "data:,a" 207 FAIL "data:,a 1w 1 h" (trailing U+2006) assert_equals: expected "" but got "data:,a" 208 FAIL "data:,a 1w 1 h" (trailing U+2007) assert_equals: expected "" but got "data:,a" 209 FAIL "data:,a 1w 1 h" (trailing U+2008) assert_equals: expected "" but got "data:,a" 210 FAIL "data:,a 1w 1 h" (trailing U+2009) assert_equals: expected "" but got "data:,a" 211 FAIL "data:,a 1w 1 h" (trailing U+200A) assert_equals: expected "" but got "data:,a" 212 FAIL "data:,a 1w 1h" (trailing U+200C) assert_equals: expected "" but got "data:,a" 213 FAIL "data:,a 1w 1h" (trailing U+200D) assert_equals: expected "" but got "data:,a" 214 FAIL "data:,a 1w 1 h" (trailing U+202F) assert_equals: expected "" but got "data:,a" 215 FAIL "data:,a 1w 1 h" (trailing U+205F) assert_equals: expected "" but got "data:,a" 216 FAIL "data:,a 1w 1 h" (trailing U+3000) assert_equals: expected "" but got "data:,a" 217 FAIL "data:,a 1w 1h" (trailing U+FEFF) assert_equals: expected "" but got "data:,a" 198 PASS "data:,a 1w 1\x01h" (trailing U+0001) 199 PASS "data:,a 1w 1 h" (trailing U+00A0) 200 PASS "data:,a 1w 1 h" (trailing U+1680) 201 PASS "data:,a 1w 1 h" (trailing U+2000) 202 PASS "data:,a 1w 1 h" (trailing U+2001) 203 PASS "data:,a 1w 1 h" (trailing U+2002) 204 PASS "data:,a 1w 1 h" (trailing U+2003) 205 PASS "data:,a 1w 1 h" (trailing U+2004) 206 PASS "data:,a 1w 1 h" (trailing U+2005) 207 PASS "data:,a 1w 1 h" (trailing U+2006) 208 PASS "data:,a 1w 1 h" (trailing U+2007) 209 PASS "data:,a 1w 1 h" (trailing U+2008) 210 PASS "data:,a 1w 1 h" (trailing U+2009) 211 PASS "data:,a 1w 1 h" (trailing U+200A) 212 PASS "data:,a 1w 1h" (trailing U+200C) 213 PASS "data:,a 1w 1h" (trailing U+200D) 214 PASS "data:,a 1w 1 h" (trailing U+202F) 215 PASS "data:,a 1w 1 h" (trailing U+205F) 216 PASS "data:,a 1w 1 h" (trailing U+3000) 217 PASS "data:,a 1w 1h" (trailing U+FEFF) 218 218 PASS "data:,a 1w \x011h" (leading U+0001) 219 219 PASS "data:,a 1w 1h" (leading U+00A0) 220 FAIL "data:,a 1w 1h" (leading U+1680) assert_equals: expected "" but got "data:,a" 221 FAIL "data:,a 1w 1h" (leading U+2000) assert_equals: expected "" but got "data:,a" 222 FAIL "data:,a 1w 1h" (leading U+2001) assert_equals: expected "" but got "data:,a" 223 FAIL "data:,a 1w 1h" (leading U+2002) assert_equals: expected "" but got "data:,a" 224 FAIL "data:,a 1w 1h" (leading U+2003) assert_equals: expected "" but got "data:,a" 225 FAIL "data:,a 1w 1h" (leading U+2004) assert_equals: expected "" but got "data:,a" 226 FAIL "data:,a 1w 1h" (leading U+2005) assert_equals: expected "" but got "data:,a" 227 FAIL "data:,a 1w 1h" (leading U+2006) assert_equals: expected "" but got "data:,a" 228 FAIL "data:,a 1w 1h" (leading U+2007) assert_equals: expected "" but got "data:,a" 229 FAIL "data:,a 1w 1h" (leading U+2008) assert_equals: expected "" but got "data:,a" 230 FAIL "data:,a 1w 1h" (leading U+2009) assert_equals: expected "" but got "data:,a" 231 FAIL "data:,a 1w 1h" (leading U+200A) assert_equals: expected "" but got "data:,a" 220 PASS "data:,a 1w 1h" (leading U+1680) 221 PASS "data:,a 1w 1h" (leading U+2000) 222 PASS "data:,a 1w 1h" (leading U+2001) 223 PASS "data:,a 1w 1h" (leading U+2002) 224 PASS "data:,a 1w 1h" (leading U+2003) 225 PASS "data:,a 1w 1h" (leading U+2004) 226 PASS "data:,a 1w 1h" (leading U+2005) 227 PASS "data:,a 1w 1h" (leading U+2006) 228 PASS "data:,a 1w 1h" (leading U+2007) 229 PASS "data:,a 1w 1h" (leading U+2008) 230 PASS "data:,a 1w 1h" (leading U+2009) 231 PASS "data:,a 1w 1h" (leading U+200A) 232 232 PASS "data:,a 1w 1h" (leading U+200C) 233 233 PASS "data:,a 1w 1h" (leading U+200D) 234 234 PASS "data:,a 1w 1h" (leading U+202F) 235 FAIL "data:,a 1w 1h" (leading U+205F) assert_equals: expected "" but got "data:,a" 236 FAIL "data:,a 1w 1h" (leading U+3000) assert_equals: expected "" but got "data:,a" 235 PASS "data:,a 1w 1h" (leading U+205F) 236 PASS "data:,a 1w 1h" (leading U+3000) 237 237 PASS "data:,a 1w 1h" (leading U+FEFF) 238 238 -
trunk/Source/WebCore/ChangeLog
r205512 r205515 1 2016-09-06 Chris Dumez <cdumez@apple.com> 2 3 Align srcset attribute parsing with the HTML specification 4 https://bugs.webkit.org/show_bug.cgi?id=161636 5 6 Reviewed by Darin Adler. 7 8 Align srcset attribute parsing with the HTML specification: 9 - https://html.spec.whatwg.org/#parse-a-srcset-attribute 10 11 The new behavior is also consistent with Firefox and Chrome 12 as all 3 browsers now pass 100% of the checks at: 13 - http://w3c-test.org/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html 14 15 No new tests, rebaselined existing tests. 16 17 * html/parser/HTMLParserIdioms.cpp: 18 (WebCore::parseValidHTMLNonNegativeIntegerInternal): 19 (WebCore::parseValidHTMLNonNegativeInteger): 20 (WebCore::parseValidHTMLFloatingPointNumberInternal): 21 (WebCore::parseValidHTMLFloatingPointNumber): 22 * html/parser/HTMLParserIdioms.h: 23 Add convenience for parsing *valid* HTML non-negative integers and 24 *valid* floating point number values. 25 26 * html/parser/HTMLSrcsetParser.cpp: 27 (WebCore::parseDescriptors): 28 - Use parseValidHTMLFloatingPointNumber() to parse density so that the value 29 is parsed as a valid HTML floating point number value, as per the spec. 30 - Use parseValidHTMLNonNegativeInteger() to parse width and height so that 31 the value is parsed as a valid HTML non-negative integer value, as per the 32 spec. 33 - Return false if descriptor does not have a h, w and x at the end as per: 34 https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 13: Anything else) 35 - Return false if height is set but not width, as per: 36 https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 14) 37 38 (WebCore::parseImageCandidatesFromSrcsetAttribute): 39 - Skip whitespace if URL does not end with a comma instead of assuming there is 40 a single space character, as per: 41 https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 8. Otherwise 1.) 42 1 43 2016-09-06 Fujii Hironori <Hironori.Fujii@sony.com> 2 44 -
trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp
r205400 r205515 217 217 } 218 218 219 template <typename CharacterType> 220 static Optional<int> parseValidHTMLNonNegativeIntegerInternal(const CharacterType* position, const CharacterType* end) 221 { 222 // A string is a valid non-negative integer if it consists of one or more ASCII digits. 223 for (auto* c = position; c < end; ++c) { 224 if (!isASCIIDigit(*c)) 225 return Nullopt; 226 } 227 228 Optional<int> signedValue = parseHTMLIntegerInternal(position, end); 229 if (!signedValue || signedValue.value() < 0) 230 return Nullopt; 231 232 return signedValue; 233 } 234 235 // https://html.spec.whatwg.org/#valid-non-negative-integer 236 Optional<int> parseValidHTMLNonNegativeInteger(StringView input) 237 { 238 if (input.isEmpty()) 239 return Nullopt; 240 241 if (LIKELY(input.is8Bit())) { 242 auto* start = input.characters8(); 243 return parseValidHTMLNonNegativeIntegerInternal(start, start + input.length()); 244 } 245 246 auto* start = input.characters16(); 247 return parseValidHTMLNonNegativeIntegerInternal(start, start + input.length()); 248 } 249 250 template <typename CharacterType> 251 static Optional<double> parseValidHTMLFloatingPointNumberInternal(const CharacterType* position, size_t length) 252 { 253 ASSERT(length > 0); 254 255 // parseDouble() allows the string to start with a '+' or to end with a '.' but those 256 // are not valid floating point numbers as per HTML. 257 if (*position == '+' || *(position + length - 1) == '.') 258 return Nullopt; 259 260 size_t parsedLength = 0; 261 double number = parseDouble(position, length, parsedLength); 262 return parsedLength == length && std::isfinite(number) ? number : Optional<double>(); 263 } 264 265 // https://html.spec.whatwg.org/#valid-floating-point-number 266 Optional<double> parseValidHTMLFloatingPointNumber(StringView input) 267 { 268 if (input.isEmpty()) 269 return Nullopt; 270 271 if (LIKELY(input.is8Bit())) { 272 auto* start = input.characters8(); 273 return parseValidHTMLFloatingPointNumberInternal(start, input.length()); 274 } 275 276 auto* start = input.characters16(); 277 return parseValidHTMLFloatingPointNumberInternal(start, input.length()); 278 } 279 219 280 static inline bool isHTMLSpaceOrDelimiter(UChar character) 220 281 { -
trunk/Source/WebCore/html/parser/HTMLParserIdioms.h
r205400 r205515 67 67 // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-non-negative-integers 68 68 WEBCORE_EXPORT Optional<int> parseHTMLNonNegativeInteger(const String&); 69 70 // https://html.spec.whatwg.org/#valid-non-negative-integer 71 Optional<int> parseValidHTMLNonNegativeInteger(StringView); 72 73 // https://html.spec.whatwg.org/#valid-floating-point-number 74 Optional<double> parseValidHTMLFloatingPointNumber(StringView); 69 75 70 76 // https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-floating-point-number-values -
trunk/Source/WebCore/html/parser/HTMLSrcsetParser.cpp
r184040 r205515 132 132 UChar descriptorChar = descriptor[descriptorCharPosition]; 133 133 descriptor = descriptor.substring(0, descriptorCharPosition); 134 bool isValid = false;135 134 if (descriptorChar == 'x') { 136 135 if (result.hasDensity() || result.hasHeight() || result.hasWidth()) 137 136 return false; 138 float density = descriptor.toFloat(isValid);139 if (! isValid || density< 0)140 return false; 141 result.setDensity(density );137 Optional<double> density = parseValidHTMLFloatingPointNumber(descriptor); 138 if (!density || density.value() < 0) 139 return false; 140 result.setDensity(density.value()); 142 141 } else if (descriptorChar == 'w') { 143 142 if (result.hasDensity() || result.hasWidth()) 144 143 return false; 145 int resourceWidth = descriptor.toInt(isValid);146 if (! isValid || resourceWidth<= 0)147 return false; 148 result.setResourceWidth(resourceWidth );144 Optional<int> resourceWidth = parseValidHTMLNonNegativeInteger(descriptor); 145 if (!resourceWidth || resourceWidth.value() <= 0) 146 return false; 147 result.setResourceWidth(resourceWidth.value()); 149 148 } else if (descriptorChar == 'h') { 150 149 // This is here only for future compat purposes. … … 152 151 if (result.hasDensity() || result.hasHeight()) 153 152 return false; 154 int resourceHeight = descriptor.toInt(isValid); 155 if (!isValid || resourceHeight <= 0) 156 return false; 157 result.setResourceHeight(resourceHeight); 158 } 159 } 160 return true; 153 Optional<int> resourceHeight = parseValidHTMLNonNegativeInteger(descriptor); 154 if (!resourceHeight || resourceHeight.value() <= 0) 155 return false; 156 result.setResourceHeight(resourceHeight.value()); 157 } else 158 return false; 159 } 160 return !result.hasHeight() || result.hasWidth(); 161 161 } 162 162 … … 194 194 continue; 195 195 } else { 196 // Advancing position here (contrary to spec) to avoid an useless extra state machine step. 197 // Filed a spec bug: https://github.com/ResponsiveImagesCG/picture-element/issues/189 198 ++position; 196 skipWhile<CharType, isHTMLSpace<CharType>>(position, attributeEnd); 199 197 Vector<StringView> descriptorTokens; 200 198 tokenizeDescriptors(position, attributeEnd, descriptorTokens);
Note: See TracChangeset
for help on using the changeset viewer.