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

Side by Side Diff: LayoutTests/fast/svg/resources/whitespace-helper.js

Issue 302643004: [SVG2] Allow leading and trailing whitespace in svg attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@relax_todouble_wtf
Patch Set: split tests to combat slow xp trybots Created 6 years, 6 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 | LayoutTests/fast/svg/whitespace-angle.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /**
2 * Tests attribute parsing and handling of whitespace in attribute values.
3 *
4 * @param type Name of the type being tested (only for test output)
5 * @param target The element that should be tested
6 * @param attribute The name of the attribute that should be tested
7 * @param expected The fallback/default value that is the expectation for invali d values
8 * @param whitespace An array of strings that are valid whitespace characters
9 * @param valid An array of strings containing valid attribute values
10 * @param invalid An array of strings containing invalid attribute values
11 * @param garbage An array of strings containing values that would make a valid value invalid when concatenated
12 * @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
13 * @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
14 */
15 function testType(type, target, attribute, expected, whitespace, valid, invalid, validunits, garbage, assert_valid_custom, assert_invalid_custom) {
16 whitespace.forEach(function(leading) {
17 whitespace.forEach(function(trailing) {
18 valid.forEach(function(value) {
19 validunits.forEach(function(unit) {
20 var valueStr = leading + value + unit + trailing;
21 var escapedValueStr = valueStr.replace(/(\r)/g, '\\r').repla ce(/(\n)/g, '\\n').replace(/(\t)/g, '\\t').replace(/(\f)/g, '\\f');
22 test(function() {
23 try {
24 target.setAttribute(attribute, valueStr);
25 assert_equals(target.getAttribute(attribute), valueS tr);
26 assert_valid_custom(target, value);
27 }
28 finally {
29 target.removeAttribute(attribute);
30 }
31 }, "Test " + type + " valid value: " + escapedValueStr );
32 });
33 });
34
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 // test whitespace between value and unit
55 validunits.forEach(function(unit) {
56 if (unit == "" || leading == "")
57 return;
58 valid.forEach(function(value) {
59 var valueStr = value + leading + unit;
60 var escapedValueStr = valueStr.replace(/(\r)/g, '\\r').replace(/ (\n)/g, '\\n').replace(/(\t)/g, '\\t').replace(/(\f)/g, '\\f');
61 test(function() {
62 try {
63 target.setAttribute(attribute, valueStr);
64 assert_equals(target.getAttribute(attribute), valueStr);
65 assert_invalid_custom(target, expected);
66 }
67 finally {
68 target.removeAttribute(attribute);
69 }
70 }, "Test " + type + " WS invalid value: " + escapedValueStr);
71 });
72 });
73
74 // test trailing garbage
75 garbage.forEach(function(trailing) {
76 valid.forEach(function(value) {
77 var valueStr = leading + value + trailing;
78 var escapedValueStr = valueStr.replace(/(\r)/g, '\\r').replace(/ (\n)/g, '\\n').replace(/(\t)/g, '\\t').replace(/(\f)/g, '\\f');
79 test(function() {
80 try {
81 target.setAttribute(attribute, valueStr);
82 assert_equals(target.getAttribute(attribute), valueStr);
83 assert_invalid_custom(target, expected);
84 }
85 finally {
86 target.removeAttribute(attribute);
87 }
88 }, "Test " + type + " trailing garbage, value: " + escapedValueS tr);
89 });
90 });
91 });
92 }
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/svg/whitespace-angle.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698