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

Unified Diff: test/webkit/fast/js/string-anchor.js

Issue 21070002: Migrate more tests from blink repository. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 | « test/webkit/fast/js/kde/var_decl_init-expected.txt ('k') | test/webkit/fast/js/string-anchor-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/webkit/fast/js/string-anchor.js
diff --git a/test/webkit/cached-call-uninitialized-arguments.js b/test/webkit/fast/js/string-anchor.js
similarity index 57%
copy from test/webkit/cached-call-uninitialized-arguments.js
copy to test/webkit/fast/js/string-anchor.js
index de3f098800776a4d3ea0493b4db7876824f0d1e4..f213b89156daa2a2810b94de3183d0ed3fc10896 100644
--- a/test/webkit/cached-call-uninitialized-arguments.js
+++ b/test/webkit/fast/js/string-anchor.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.anchor(name).'
);
-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("'_'.anchor('b')", '"<a name=\\"b\\">_</a>"');
+
+// Does not escape special characters in `this` value.
+shouldBe("'<'.anchor('b')", '"<a name=\\"b\\"><</a>"');
- function shouldBeUndefined(_a) {
- var exception;
- var _av;
- try {
- _av = eval(_a);
- } catch (e) {
- exception = e;
- }
+// first argument gets ToString()ed.
+shouldBe("'_'.anchor(0x2A)", '"<a name=\\"42\\">_</a>"');
- 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("'_'.anchor('\"')", '"<a name=\\"&quot;\\">_</a>"');
+shouldBe("'_'.anchor('\" href=\"http://www.evil.com')", '"<a name=\\"&quot; href=&quot;http://www.evil.com\\">_</a>"');
- shouldBeUndefined("arg4");
- shouldBeUndefined("arg5");
- shouldBeUndefined("arg6");
- }
+// Generic use on Number object.
+shouldBe("String.prototype.anchor.call(0x2A, 0x2A)", '"<a name=\\"42\\">42</a>"');
- arr.forEach(callback);
-}
+// Generic use on non-coercible object `undefined`.
+shouldThrow("String.prototype.anchor.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.anchor.call(null)", '"TypeError: Type error"');
-var arr = [1];
-callAfterRecursingForDepth(20, doForEach, arr);
+// Check anchor.length.
+shouldBe("String.prototype.anchor.length", "1");
« no previous file with comments | « test/webkit/fast/js/kde/var_decl_init-expected.txt ('k') | test/webkit/fast/js/string-anchor-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698