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

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

Issue 1078663002: Deflake the whitespace-length-invalid test (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: split test in two Created 5 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <!doctype html>
2 <title>Whitespace in attribute values tests</title>
3 <script src=../../resources/testharness.js></script>
4 <script src=../../resources/testharnessreport.js></script>
5 <svg id="testcontainer">
6 </svg>
7 <div id=log></div>
8 <script>
9 var svg = document.querySelector("svg");
10
11 // test length values
12 var EPSILON = Math.pow(2, -24); // float epsilon
13 var whitespace = [ "", " ", " ", "\r\n\t ", "\f" ];
14 var validunits = [ "", "em", "ex", "px", "in", "cm", "mm", "pt", "pc", "%" ];
15
16 // This test was split out from whitespace-length.html because the trybots were too slow.
17
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>",
57 svg,
58 "x",
59 0, // expected default value
60 whitespace,
61 [], // valid
62 [ Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINIT Y, "fnord", "E", "e", "e+", "E-", "-", "+", "-.", ".-", ".", "+.", ".E0", "e1" ] , // invalid
63 validunits,
64 [], // garbage
65 function(elm, value) { assert_approx_equals(elm.x.baseVal.value InSpecifiedUnits, parseFloat(value), EPSILON); },
66 function(elm, expected) { assert_approx_equals(elm.x.baseVal.va lue, expected, EPSILON); } );
67
68 </script>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/fast/svg/whitespace-length-invalid-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698