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

Unified Diff: third_party/WebKit/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html

Issue 2260763002: Convert LayoutTests/svg/text/* js-tests.js tests to testharness.js based tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Align with review comments Created 4 years, 4 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
Index: third_party/WebKit/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html
diff --git a/third_party/WebKit/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html b/third_party/WebKit/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html
index ea7ac89ad7ae7be421ef0b80303293031860db9f..d0c5f62657ca014685c9c79afea306e43b2c19a0 100644
--- a/third_party/WebKit/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html
+++ b/third_party/WebKit/LayoutTests/svg/text/svgtextcontentelement-methods-parameters.html
@@ -1,108 +1,105 @@
<!DOCTYPE html>
-<html>
-<head>
+<title>SVGTextContentElement methods' parameters are correctly validated</title>
<link rel="help" href="http://www.w3.org/TR/SVG2/text.html#InterfaceSVGTextContentElement">
-<script src="../../resources/js-test.js"></script>
-</head>
-<body>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<script>
-description("Check that SVGTextContentElement methods' parameters are correctly validated");
+test(function() {
+ var svgNS = "http://www.w3.org/2000/svg";
+ var svgRoot = document.createElementNS(svgNS, "svg");
+ document.documentElement.appendChild(svgRoot);
-var svgNS = "http://www.w3.org/2000/svg";
+ var svgText = document.createElementNS(svgNS, "text");
+ svgText.style.fontFamily = "Ahem";
+ svgText.style.fontSize = "20px";
+ svgText.appendChild(document.createTextNode("abcdefg"));
+ svgRoot.appendChild(svgText);
-var svgRoot = document.createElementNS(svgNS, "svg");
-document.documentElement.appendChild(svgRoot);
+ var emptySvgText = document.createElementNS(svgNS, "text");
+ svgRoot.appendChild(emptySvgText);
-var svgText = document.createElementNS(svgNS, "text");
-svgText.style.fontFamily = "Ahem";
-svgText.style.fontSize = "20px";
-svgText.appendChild(document.createTextNode("abcdefg"));
-svgRoot.appendChild(svgText);
-
-var emptySvgText = document.createElementNS(svgNS, "text");
-svgRoot.appendChild(emptySvgText);
-
-var actualTestPoint, expectedTestPoint;
-function shouldBeEqualToSVGPoint(actualPoint, expectedPoint)
-{
+ function assert_equals_to_SVGPoint(actualPoint, expectedPoint)
+ {
actualTestPoint = actualPoint;
expectedTestPoint = expectedPoint;
fs 2016/08/23 08:30:11 These should go too. Use the ones without *Test*.
Shanmuga Pandi 2016/08/23 09:22:08 Done.
- shouldBe("actualTestPoint.x", "expectedTestPoint.x");
- shouldBe("actualTestPoint.y", "expectedTestPoint.y");
-}
+ assert_equals(actualTestPoint.x, expectedTestPoint.x);
+ assert_equals(actualTestPoint.y, expectedTestPoint.y);
+ }
-var actualTestRect, expectedTestRect;
-function shouldBeEqualToSVGRect(actualRect, expectedRect)
-{
+ function assert_equals_to_SVGRect(actualRect, expectedRect)
+ {
actualTestRect = actualRect;
expectedTestRect = expectedRect;
fs 2016/08/23 08:30:11 Ditto.
Shanmuga Pandi 2016/08/23 09:22:08 Done.
- shouldBe("actualTestRect.x", "expectedTestRect.x");
- shouldBe("actualTestRect.y", "expectedTestRect.y");
- shouldBe("actualTestRect.width", "expectedTestRect.width");
- shouldBe("actualTestRect.height", "expectedTestRect.height");
-}
+ assert_equals(actualTestRect.x, expectedTestRect.x);
+ assert_equals(actualTestRect.y, expectedTestRect.y);
+ assert_equals(actualTestRect.width, expectedTestRect.width);
+ assert_equals(actualTestRect.height, expectedTestRect.height);
+ }
+
+ // Arguments should be mandatory.
+ assert_throws(new TypeError(), function() { svgText.getSubStringLength(); });
+ assert_throws(new TypeError(), function() { svgText.getSubStringLength(2); });
+ assert_throws(new TypeError(), function() { svgText.getStartPositionOfChar(); });
+ assert_throws(new TypeError(), function() { svgText.getEndPositionOfChar(); });
+ assert_throws(new TypeError(), function() { svgText.getExtentOfChar(); });
+ assert_throws(new TypeError(), function() { svgText.getRotationOfChar(); });
+ assert_throws(new TypeError(), function() { svgText.getCharNumAtPosition(); });
+ assert_throws(new TypeError(), function() { svgText.getCharNumAtPosition('aString'); });
+ assert_throws(new TypeError(), function() { svgText.getCharNumAtPosition(svgText); });
+ assert_throws(new TypeError(), function() { svgText.selectSubString(); });
+ assert_throws(new TypeError(), function() { svgText.selectSubString(2); });
+
+ // Should throw an IndexSizeError if charnum is greater than or equal to the number of characters at this node.
+ assert_throws("IndexSizeError", function() { svgText.getSubStringLength(999, 2); });
+ assert_throws("IndexSizeError", function() { svgText.getStartPositionOfChar(999); });
+ assert_throws("IndexSizeError", function() { svgText.getEndPositionOfChar(999); });
+ assert_throws("IndexSizeError", function() { svgText.getExtentOfChar(999); });
+ assert_throws("IndexSizeError", function() { svgText.getRotationOfChar(999); });
+ assert_throws("IndexSizeError", function() { svgText.selectSubString(999, 2); });
-// Arguments should be mandatory.
-shouldThrow("svgText.getSubStringLength()", '"TypeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': 2 arguments required, but only 0 present."');
-shouldThrow("svgText.getSubStringLength(2)", '"TypeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': 2 arguments required, but only 1 present."');
-shouldThrow("svgText.getStartPositionOfChar()", '"TypeError: Failed to execute \'getStartPositionOfChar\' on \'SVGTextContentElement\': 1 argument required, but only 0 present."');
-shouldThrow("svgText.getEndPositionOfChar()", '"TypeError: Failed to execute \'getEndPositionOfChar\' on \'SVGTextContentElement\': 1 argument required, but only 0 present."');
-shouldThrow("svgText.getExtentOfChar()", '"TypeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': 1 argument required, but only 0 present."');
-shouldThrow("svgText.getRotationOfChar()", '"TypeError: Failed to execute \'getRotationOfChar\' on \'SVGTextContentElement\': 1 argument required, but only 0 present."');
-shouldThrow("svgText.getCharNumAtPosition()", '"TypeError: Failed to execute \'getCharNumAtPosition\' on \'SVGTextContentElement\': 1 argument required, but only 0 present."');
-shouldThrow("svgText.getCharNumAtPosition('aString')", '"TypeError: Failed to execute \'getCharNumAtPosition\' on \'SVGTextContentElement\': parameter 1 is not of type \'SVGPoint\'."');
-shouldThrow("svgText.getCharNumAtPosition(svgText)", '"TypeError: Failed to execute \'getCharNumAtPosition\' on \'SVGTextContentElement\': parameter 1 is not of type \'SVGPoint\'."');
-shouldThrow("svgText.selectSubString()", '"TypeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': 2 arguments required, but only 0 present."');
-shouldThrow("svgText.selectSubString(2)", '"TypeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': 2 arguments required, but only 1 present."');
+ // Test the equality part of the restriction.
+ assert_throws("IndexSizeError", function() { svgText.getSubStringLength(7, 2); });
+ assert_throws("IndexSizeError", function() { svgText.getStartPositionOfChar(7); });
+ assert_throws("IndexSizeError", function() { svgText.getEndPositionOfChar(7); });
+ assert_throws("IndexSizeError", function() { svgText.getExtentOfChar(7); });
+ assert_throws("IndexSizeError", function() { svgText.getRotationOfChar(7); });
+ assert_throws("IndexSizeError", function() { svgText.selectSubString(7, 2); });
-// Should throw an IndexSizeError if charnum is greater than or equal to the number of characters at this node.
-shouldThrow("svgText.getSubStringLength(999, 2)", '"IndexSizeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."');
-shouldThrow("svgText.getStartPositionOfChar(999)", '"IndexSizeError: Failed to execute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."');
-shouldThrow("svgText.getEndPositionOfChar(999)", '"IndexSizeError: Failed to execute \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."');
-shouldThrow("svgText.getExtentOfChar(999)", '"IndexSizeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."');
-shouldThrow("svgText.getRotationOfChar(999)", '"IndexSizeError: Failed to execute \'getRotationOfChar\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."');
-shouldThrow("svgText.selectSubString(999, 2)", '"IndexSizeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (999) is greater than the maximum bound (7)."');
-// Test the equality part of the restriction.
-shouldThrow("svgText.getSubStringLength(7, 2)", '"IndexSizeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."');
-shouldThrow("svgText.getStartPositionOfChar(7)", '"IndexSizeError: Failed to execute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."');
-shouldThrow("svgText.getEndPositionOfChar(7)", '"IndexSizeError: Failed to execute \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."');
-shouldThrow("svgText.getExtentOfChar(7)", '"IndexSizeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."');
-shouldThrow("svgText.getRotationOfChar(7)", '"IndexSizeError: Failed to execute \'getRotationOfChar\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."');
-shouldThrow("svgText.selectSubString(7, 2)", '"IndexSizeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (7) is greater than or equal to the maximum bound (7)."');
-// Test the equality part of the restriction for the <number of chars> == 0 case.
-shouldThrow("emptySvgText.getSubStringLength(0, 2)", '"IndexSizeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."');
-shouldThrow("emptySvgText.getStartPositionOfChar(0)", '"IndexSizeError: Failed to execute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."');
-shouldThrow("emptySvgText.getEndPositionOfChar(0)", '"IndexSizeError: Failed to execute \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."');
-shouldThrow("emptySvgText.getExtentOfChar(0)", '"IndexSizeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."');
-shouldThrow("emptySvgText.getRotationOfChar(0)", '"IndexSizeError: Failed to execute \'getRotationOfChar\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."');
-shouldThrow("emptySvgText.selectSubString(0, 2)", '"IndexSizeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (0) is greater than or equal to the maximum bound (0)."');
+ // Test the equality part of the restriction for the <number of chars> == 0 case.
+ assert_throws("IndexSizeError", function() { emptySvgText.getSubStringLength(0, 2); });
+ assert_throws("IndexSizeError", function() { emptySvgText.getStartPositionOfChar(0); });
+ assert_throws("IndexSizeError", function() { emptySvgText.getEndPositionOfChar(0); });
+ assert_throws("IndexSizeError", function() { emptySvgText.getExtentOfChar(0); });
+ assert_throws("IndexSizeError", function() { emptySvgText.getRotationOfChar(0); });
+ assert_throws("IndexSizeError", function() { emptySvgText.selectSubString(0, 2); });
-// Should not throw if charnum is negative and wraps to a valid positive index (-4294967294 wraps to 2).
-shouldBe("svgText.getSubStringLength(-4294967294, 2)", "svgText.getSubStringLength(2, 2)");
-shouldBeEqualToSVGPoint("svgText.getStartPositionOfChar(-4294967294)", "svgText.getStartPositionOfChar(2)");
-shouldBeEqualToSVGPoint("svgText.getEndPositionOfChar(-4294967294)", "svgText.getEndPositionOfChar(2)");
-shouldBeEqualToSVGRect("svgText.getExtentOfChar(-4294967294)", "svgText.getExtentOfChar(2)");
-shouldBe("svgText.getRotationOfChar(-4294967294)", "svgText.getRotationOfChar(2)");
-shouldNotThrow("svgText.selectSubString(-4294967294, 2)");
+ // Should not throw if charnum is negative and wraps to a valid positive index (-4294967294 wraps to 2).
+ assert_equals(svgText.getSubStringLength(-4294967294, 2), svgText.getSubStringLength(2, 2));
+ assert_equals_to_SVGPoint(svgText.getStartPositionOfChar(-4294967294), svgText.getStartPositionOfChar(2));
+ assert_equals_to_SVGPoint(svgText.getEndPositionOfChar(-4294967294), svgText.getEndPositionOfChar(2));
+ assert_equals_to_SVGRect(svgText.getExtentOfChar(-4294967294), svgText.getExtentOfChar(2));
+ assert_equals(svgText.getRotationOfChar(-4294967294), svgText.getRotationOfChar(2));
+ svgText.selectSubString(-4294967294, 2);
-// Should throw an IndexSizeError if charnum is negative and wraps to an invalid positive index.
-shouldThrow("svgText.getSubStringLength(-1, 2)", '"IndexSizeError: Failed to execute \'getSubStringLength\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."');
-shouldThrow("svgText.getStartPositionOfChar(-1)", '"IndexSizeError: Failed to execute \'getStartPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."');
-shouldThrow("svgText.getEndPositionOfChar(-1)", '"IndexSizeError: Failed to execute \'getEndPositionOfChar\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."');
-shouldThrow("svgText.getExtentOfChar(-1)", '"IndexSizeError: Failed to execute \'getExtentOfChar\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."');
-shouldThrow("svgText.getRotationOfChar(-1)", '"IndexSizeError: Failed to execute \'getRotationOfChar\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."');
-shouldThrow("svgText.selectSubString(-1, 2)", '"IndexSizeError: Failed to execute \'selectSubString\' on \'SVGTextContentElement\': The charnum provided (4294967295) is greater than the maximum bound (7)."');
+ // Should throw an IndexSizeError if charnum is negative and wraps to an invalid positive index.
+ assert_throws("IndexSizeError", function() { svgText.getSubStringLength(-1, 2); });
+ assert_throws("IndexSizeError", function() { svgText.getStartPositionOfChar(-1); });
+ assert_throws("IndexSizeError", function() { svgText.getEndPositionOfChar(-1); });
+ assert_throws("IndexSizeError", function() { svgText.getExtentOfChar(-1); });
+ assert_throws("IndexSizeError", function() { svgText.getRotationOfChar(-1); });
+ assert_throws("IndexSizeError", function() { svgText.selectSubString(-1, 2); });
-// We should not throw if nchars is negative or too large.
-// If nchars specifies more characters than are available, then the substring will consist of all characters
-// starting with charnum until the end of the list of characters.
-shouldBe("svgText.getSubStringLength(2, 999)", "svgText.getSubStringLength(2, 5)");
-shouldBe("svgText.getSubStringLength(2, -1)", "svgText.getSubStringLength(2, 5)");
-shouldBe("svgText.getSubStringLength(2, 2)", "svgText.getSubStringLength(2, -4294967294)");
-shouldNotThrow("svgText.selectSubString(2, 999)");
-shouldNotThrow("svgText.selectSubString(2, -1)");
-shouldNotThrow("svgText.selectSubString(2, -4294967294)");
+ // We should not throw if nchars is negative or too large.
+ // If nchars specifies more characters than are available, then the substring will consist of all characters
+ // starting with charnum until the end of the list of characters.
+ assert_equals(svgText.getSubStringLength(2, 999), svgText.getSubStringLength(2, 5));
+ assert_equals(svgText.getSubStringLength(2, -1), svgText.getSubStringLength(2, 5));
+ assert_equals(svgText.getSubStringLength(2, 2), svgText.getSubStringLength(2, -4294967294));
+ svgText.selectSubString(2, 999);
+ svgText.selectSubString(2, -1);
+ svgText.selectSubString(2, -4294967294);
+ // cleanup
+ document.documentElement.removeChild(svgRoot);
fs 2016/08/23 08:30:11 Just leave the elements in the tree.
Shanmuga Pandi 2016/08/23 08:57:33 When I leave the element within tree, even with "h
+});
</script>
-</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698