45 lines
1.4 KiB
HTML
45 lines
1.4 KiB
HTML
<!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=\\""\\">_</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=\\""\\">_</a>"');
|
|
shouldBe("'_'.link('\" target=\"_blank')", '"<a href=\\"" target="_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>
|