Index: test/webkit/fast/js/string-fontcolor.js |
diff --git a/test/webkit/cached-call-uninitialized-arguments.js b/test/webkit/fast/js/string-fontcolor.js |
similarity index 56% |
copy from test/webkit/cached-call-uninitialized-arguments.js |
copy to test/webkit/fast/js/string-fontcolor.js |
index de3f098800776a4d3ea0493b4db7876824f0d1e4..67f4ef2e07826f59779f19bb47a51f1d33b1ac2d 100644 |
--- a/test/webkit/cached-call-uninitialized-arguments.js |
+++ b/test/webkit/fast/js/string-fontcolor.js |
@@ -22,45 +22,32 @@ |
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
description( |
-"This test checks that uninitialized parameters for cached call functions correctly defaults to undefined." |
- |
+'This is a test case for String.prototype.fontcolor(color).' |
); |
-function doForEach(arr) { |
- function callback(element, index, array, arg4, arg5, arg6) { |
+// This test is based on http://mathias.html5.org/tests/javascript/string/. |
+ |
+// Simple case. |
+shouldBe("'_'.fontcolor('b')", '"<font color=\\"b\\">_</font>"'); |
+ |
+// Does not escape special characters in `this` value. |
+shouldBe("'<'.fontcolor('b')", '"<font color=\\"b\\"><</font>"'); |
- function shouldBeUndefined(_a) { |
- var exception; |
- var _av; |
- try { |
- _av = eval(_a); |
- } catch (e) { |
- exception = e; |
- } |
+// First argument gets ToString()ed. |
+shouldBe("'_'.fontcolor(0x2A)", '"<font color=\\"42\\">_</font>"'); |
- if (exception) |
- testFailed(_a + " should be undefined. Threw exception " + exception); |
- else if (typeof _av == "undefined") |
- testPassed(_a + " is undefined."); |
- else |
- testFailed(_a + " should be undefined. Was " + _av); |
- } |
+// Check that the quotation mark is correctly escaped. |
+shouldBe("'_'.fontcolor('\"')", '"<font color=\\""\\">_</font>"'); |
+shouldBe("'_'.fontcolor('\" size=\"2px')", '"<font color=\\"" size="2px\\">_</font>"'); |
- shouldBeUndefined("arg4"); |
- shouldBeUndefined("arg5"); |
- shouldBeUndefined("arg6"); |
- } |
+// Generic use on Number object. |
+shouldBe("String.prototype.fontcolor.call(0x2A, 0x2A)", '"<font color=\\"42\\">42</font>"'); |
- arr.forEach(callback); |
-} |
+// Generic use on non-coercible object `undefined`. |
+shouldThrow("String.prototype.fontcolor.call(undefined)", '"TypeError: Type error"'); |
-function callAfterRecursingForDepth(depth, func, arr) { |
- if (depth > 0) { |
- callAfterRecursingForDepth(depth - 1, func, arr); |
- } else { |
- func(arr); |
- } |
-} |
+// Generic use on non-coercible object `null`. |
+shouldThrow("String.prototype.fontcolor.call(null)", '"TypeError: Type error"'); |
-var arr = [1]; |
-callAfterRecursingForDepth(20, doForEach, arr); |
+// Check fontcolor.length. |
+shouldBe("String.prototype.fontcolor.length", "1"); |