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

Unified Diff: third_party/WebKit/LayoutTests/svg/parser/resources/whitespace-helper.js

Issue 2454413002: Break svg/parser/whitespace tests apart some more. (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/svg/parser/whitespace-angle-1.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/svg/parser/resources/whitespace-helper.js
diff --git a/third_party/WebKit/LayoutTests/svg/parser/resources/whitespace-helper.js b/third_party/WebKit/LayoutTests/svg/parser/resources/whitespace-helper.js
index 61eaf0bbfeacb51b152fe5255962dfad003ae35e..775a095435460949cc879c71130b0e7f1b1546bb 100644
--- a/third_party/WebKit/LayoutTests/svg/parser/resources/whitespace-helper.js
+++ b/third_party/WebKit/LayoutTests/svg/parser/resources/whitespace-helper.js
@@ -7,12 +7,12 @@
* @param expected The fallback/default value that is the expectation for invalid values
* @param whitespace An array of strings that are valid whitespace characters
* @param valid An array of strings containing valid attribute values
- * @param invalid An array of strings containing invalid attribute values
+ * @param validUnits An array of strings containing valid unit specifiers
* @param garbage An array of strings containing values that would make a valid value invalid when concatenated
* @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 values array
* @param assert_invalid_custom A function for asserting that an invalid value results in the expected default value, arguments passed to this function: the element and the expected value
*/
-function testType(type, target, attribute, expected, whitespace, valid, invalid, validunits, garbage, assert_valid_custom, assert_invalid_custom) {
+function testType(type, target, attribute, expected, whitespace, valid, validunits, garbage, assert_valid_custom, assert_invalid_custom) {
whitespace.forEach(function(leading) {
whitespace.forEach(function(trailing) {
valid.forEach(function(value) {
@@ -31,24 +31,6 @@ function testType(type, target, attribute, expected, whitespace, valid, invalid,
}, "Test " + type + " valid value: " + escapedValueStr );
});
});
-
- // test invalid values
- invalid.forEach(function(value) {
- validunits.forEach(function(unit) {
- var valueStr = leading + value + unit + trailing;
- var escapedValueStr = valueStr.replace(/(\r)/g, '\\r').replace(/(\n)/g, '\\n').replace(/(\t)/g, '\\t').replace(/(\f)/g, '\\f');
- test(function() {
- try {
- target.setAttribute(attribute, valueStr);
- assert_equals(target.getAttribute(attribute), valueStr);
- assert_invalid_custom(target, expected);
- }
- finally {
- target.removeAttribute(attribute);
- }
- }, "Test " + type + " invalid value: " + escapedValueStr);
- });
- });
});
// test whitespace between value and unit
@@ -90,3 +72,41 @@ function testType(type, target, attribute, expected, whitespace, valid, invalid,
});
});
}
+
+/**
+ * Tests attribute parsing and handling of invalid whitespace in attribute values.
+ *
+ * @param type Name of the type being tested (only for test output)
+ * @param target The element that should be tested
+ * @param attribute The name of the attribute that should be tested
+ * @param expected The fallback/default value that is the expectation for invalid values
+ * @param whitespace An array of strings that are valid whitespace characters
+ * @param invalid An array of strings containing invalid attribute values * @param garbage An array of strings containing values that would make a valid value invalid when concatenated
+ * @param validunits An array of strings containing valid unit specifiers
+ * @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 values array
+ * @param assert_invalid_custom A function for asserting that an invalid value results in the expected default value, arguments passed to this function: the element and the expected value
+ */
+function testInvalidType(type, target, attribute, expected, whitespace, invalid, validunits, assert_valid_custom, assert_invalid_custom) {
+ whitespace.forEach(function(leading) {
+ whitespace.forEach(function(trailing) {
+ // test invalid values
+ invalid.forEach(function(value) {
+ validunits.forEach(function(unit) {
+ var valueStr = leading + value + unit + trailing;
+ var escapedValueStr = valueStr.replace(/(\r)/g, '\\r').replace(/(\n)/g, '\\n').replace(/(\t)/g, '\\t').replace(/(\f)/g, '\\f');
+ test(function() {
+ try {
+ target.setAttribute(attribute, valueStr);
+ assert_equals(target.getAttribute(attribute), valueStr);
+ assert_invalid_custom(target, expected);
+ }
+ finally {
+ target.removeAttribute(attribute);
+ }
+ }, "Test " + type + " invalid value: " + escapedValueStr);
+ });
+ });
+ });
+ });
+}
+
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/svg/parser/whitespace-angle-1.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698