From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- js/src/jit-test/tests/basic/html-extensions.js | 87 ++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 js/src/jit-test/tests/basic/html-extensions.js (limited to 'js/src/jit-test/tests/basic/html-extensions.js') diff --git a/js/src/jit-test/tests/basic/html-extensions.js b/js/src/jit-test/tests/basic/html-extensions.js new file mode 100644 index 0000000000..5cf52aefd1 --- /dev/null +++ b/js/src/jit-test/tests/basic/html-extensions.js @@ -0,0 +1,87 @@ +var noParamFuns = ["".bold, "".italics, "".fixed, "".strike, "".small, "".big, + "".blink, "".sup, "".sub]; +var noParamTags = ["b", "i", "tt", "strike", "small", "big", + "blink", "sup", "sub"]; + +function testNoParam(s) { + for (var i=0; i" + String(s) + ""); + } +} +testNoParam("Foo"); +testNoParam('aaa"bbb\'c<>123'); +testNoParam(123); + +// toString should be called, not valueOf +testNoParam({toString: () => 1, valueOf: () => { throw "fail"; } }); + +assertEq("".anchor.length, 1); +assertEq("".link.length, 1); +assertEq("".fontsize.length, 1); +assertEq("".fontcolor.length, 1); + +// Ensure @@replace on String.prototype isn't called. +String.prototype[Symbol.replace] = function() { + throw "Shouldn't call @@replace"; +}; + +// " in the attribute value is escaped (") +assertEq("bla\"<>'".anchor("foo'<>\"\"123\"/\\"), + """123"/\\\">bla\"<>'"); +assertEq("bla\"<>'".link("foo'<>\"\"123\"/\\"), + """123"/\\\">bla\"<>'"); +assertEq("bla\"<>'".fontsize("foo'<>\"\"123\"/\\"), + """123"/\\\">bla\"<>'"); +assertEq("bla\"<>'".fontcolor("foo'<>\"\"123\"/\\"), + """123"/\\\">bla\"<>'"); + +assertEq("".anchor('"'), ''); +assertEq("".link('"'), ''); +assertEq("".fontcolor('"'), ''); +assertEq("".fontsize('"'), ''); + +assertEq("".anchor('"1'), ''); +assertEq("".link('"1'), ''); +assertEq("".fontcolor('"1'), ''); +assertEq("".fontsize('"1'), ''); + +assertEq("".anchor('"""a"'), ''); +assertEq("".link('"""a"'), ''); +assertEq("".fontcolor('"""a"'), ''); +assertEq("".fontsize('"""a"'), ''); + +assertEq("".anchor(""), ''); +assertEq("".link(""), ''); +assertEq("".fontcolor(""), ''); +assertEq("".fontsize(""), ''); + +assertEq("foo".anchor(), "foo"); +assertEq("foo".link(), "foo"); +assertEq("foo".fontcolor(), "foo"); +assertEq("foo".fontsize(), "foo"); + +assertEq("foo".anchor(3.14), 'foo'); +assertEq("foo".link(3.14), 'foo'); +assertEq("foo".fontcolor(3.14), 'foo'); +assertEq("foo".fontsize(3.14), 'foo'); + +assertEq("foo".anchor({}), 'foo'); +assertEq("foo".link(Math), 'foo'); +assertEq("foo".fontcolor([1,2]), 'foo'); +assertEq("foo".fontsize({}), 'foo'); + +// toString should be called, not valueOf, and toString must be called on |this| +// before it's called on the argument. Also makes sure toString is called only +// once. +var count = 0; +var o1 = {toString: () => { return count += 1; }, valueOf: () => { throw "fail"; } }; +var o2 = {toString: () => { return count += 5; }, valueOf: () => { throw "fail"; } }; +assertEq("".anchor.call(o1, o2), '1'); +assertEq("".link.call(o1, o2), '7'); +assertEq("".fontcolor.call(o1, o2), '13'); +assertEq("".fontsize.call(o1, o2), '19'); +assertEq(count, 24); -- cgit v1.2.3