Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: LayoutTests/fast/svg/whitespace-length-invalid.html

Issue 837393003: Attempt to slim the test down for dbg trybots. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <title>Whitespace in attribute values tests</title> 2 <title>Whitespace in attribute values tests</title>
3 <script src=../../resources/testharness.js></script> 3 <script src=../../resources/testharness.js></script>
4 <script src=../../resources/testharnessreport.js></script> 4 <script src=../../resources/testharnessreport.js></script>
5 <script src=resources/whitespace-helper.js></script>
6 <svg id="testcontainer"> 5 <svg id="testcontainer">
7 <defs>
8 <marker/>
9 <stop/>
10 <filter>
11 <feTurbulence></feTurbulence>
12 </filter>
13 </defs>
14 </svg> 6 </svg>
15 <div id=log></div> 7 <div id=log></div>
16 <script> 8 <script>
17 var svg = document.querySelector("svg"); 9 var svg = document.querySelector("svg");
18 10
19 // test length values 11 // test length values
20 var EPSILON = Math.pow(2, -24); // float epsilon 12 var EPSILON = Math.pow(2, -24); // float epsilon
21 var whitespace = [ "", " ", " ", "\r\n\t ", "\f" ]; 13 var whitespace = [ "", " ", " ", "\r\n\t ", "\f" ];
22 var validunits = [ "", "em", "ex", "px", "in", "cm", "mm", "pt", "pc", "%" ]; 14 var validunits = [ "", "em", "ex", "px", "in", "cm", "mm", "pt", "pc", "%" ];
23 15
24 // This test was split out from whitespace-length.html because the trybots were too slow. 16 // This test was split out from whitespace-length.html because the trybots were too slow.
25 17
26 testType("<length>", 18 /**
19 * Tests attribute parsing and handling of whitespace in attribute values.
20 *
21 * @param type Name of the type being tested (only for test output)
22 * @param target The element that should be tested
23 * @param attribute The name of the attribute that should be tested
24 * @param expected The fallback/default value that is the expectation for invali d values
25 * @param whitespace An array of strings that are valid whitespace characters
26 * @param valid An array of strings containing valid attribute values
27 * @param invalid An array of strings containing invalid attribute values
28 * @param garbage An array of strings containing values that would make a valid value invalid when concatenated
29 * @param assert_valid_custom A function for asserting validity of a valid value , arguments passed to this function: the element and the string from valid value s array
30 * @param assert_invalid_custom A function for asserting that an invalid value r esults in the expected default value, arguments passed to this function: the ele ment and the expected value
31 */
32 function testTypeLocal(type, target, attribute, expected, whitespace, valid, inv alid, validunits, garbage, assert_valid_custom, assert_invalid_custom) {
33 whitespace.forEach(function(leading) {
34 whitespace.forEach(function(trailing) {
35 // test invalid values
36 invalid.forEach(function(value) {
37 validunits.forEach(function(unit) {
38 var valueStr = leading + value + unit + trailing;
39 var escapedValueStr = valueStr.replace(/(\r)/g, '\\r').repla ce(/(\n)/g, '\\n').replace(/(\t)/g, '\\t').replace(/(\f)/g, '\\f');
40 test(function() {
41 try {
42 target.setAttribute(attribute, valueStr);
43 assert_equals(target.getAttribute(attribute), valueS tr);
44 assert_invalid_custom(target, expected);
45 }
46 finally {
47 target.removeAttribute(attribute);
48 }
49 }, "Test " + type + " invalid value: " + escapedValueStr);
50 });
51 });
52 });
53 });
54 }
55
56 testTypeLocal("<length>",
27 svg, 57 svg,
28 "x", 58 "x",
29 0, // expected default value 59 0, // expected default value
30 whitespace, 60 whitespace,
31 [], // valid 61 [], // valid
32 [ Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINIT Y, "fnord", "E", "e", "e+", "E-", "-", "+", "-.", ".-", ".", "+.", ".E0", "e1" ] , // invalid 62 [ Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINIT Y, "fnord", "E", "e", "e+", "E-", "-", "+", "-.", ".-", ".", "+.", ".E0", "e1" ] , // invalid
33 validunits, 63 validunits,
34 [], // garbage 64 [], // garbage
35 function(elm, value) { assert_approx_equals(elm.x.baseVal.value InSpecifiedUnits, parseFloat(value), EPSILON); }, 65 function(elm, value) { assert_approx_equals(elm.x.baseVal.value InSpecifiedUnits, parseFloat(value), EPSILON); },
36 function(elm, expected) { assert_approx_equals(elm.x.baseVal.va lue, expected, EPSILON); } ); 66 function(elm, expected) { assert_approx_equals(elm.x.baseVal.va lue, expected, EPSILON); } );
37 67
38 </script> 68 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698