blob: 7a97fb3a617e17590c640144a117c65ea7590184 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description(
'This is a test case for String.prototype.link(href).'
);
// This test is based on http://mathias.html5.org/tests/javascript/string/.
// Check that the quotation mark is correctly escaped.
shouldBe("'_'.link('\"')", '"<a href=\\"&quot;\\">_</a>"');
// Simple case.
shouldBe("'_'.link('b')", '"<a href=\\"b\\">_</a>"');
// Does not escape special characters in `this` value.
shouldBe("'<'.link('b')", '"<a href=\\"b\\"><</a>"');
// First argument gets ToString()ed.
shouldBe("'_'.link(0x2A)", '"<a href=\\"42\\">_</a>"');
// Check that the quotation mark is correctly escaped.
shouldBe("'_'.link('\"')", '"<a href=\\"&quot;\\">_</a>"');
shouldBe("'_'.link('\" target=\"_blank')", '"<a href=\\"&quot; target=&quot;_blank\\">_</a>"');
// Generic use on Number object.
shouldBe("String.prototype.link.call(0x2A, 0x2A)", '"<a href=\\"42\\">42</a>"');
// Generic use on non-coercible object `undefined`.
shouldThrowErrorName("String.prototype.link.call(undefined)", 'TypeError');
// Generic use on non-coercible object `null`.
shouldThrowErrorName("String.prototype.link.call(null)", 'TypeError');
// Check link.length.
shouldBe("String.prototype.link.length", "1");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>