Commit 5c7f83df authored by cwzwarich@webkit.org's avatar cwzwarich@webkit.org

2009-03-10 Cameron Zwarich <cwzwarich@uwaterloo.ca>

        Reviewed by Geoff Garen.

        Bug 24291: REGRESSION (r38635): Single line JavaScript comment prevents HTML button click handler execution
        <https://bugs.webkit.org/show_bug.cgi?id=24291>
        <rdar://problem/6663472>

        Add an extra newline to the end of the body of the program text constructed
        by the Function constructor for parsing. This allows single line comments to
        be handled correctly by the parser.

        JavaScriptCore:

        * runtime/FunctionConstructor.cpp:
        (JSC::constructFunction):

        LayoutTests:

        * fast/events/onload-single-line-comment-expected.txt: Added.
        * fast/events/onload-single-line-comment.html: Added.
        * fast/js/function-constructor-single-line-comment-expected.txt: Added.
        * fast/js/function-constructor-single-line-comment.html: Added.
        * fast/js/resources/function-constructor-single-line-comment.js: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@41565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 730bcc54
2009-03-10 Cameron Zwarich <cwzwarich@uwaterloo.ca>
Reviewed by Geoff Garen.
Bug 24291: REGRESSION (r38635): Single line JavaScript comment prevents HTML button click handler execution
<https://bugs.webkit.org/show_bug.cgi?id=24291>
<rdar://problem/6663472>
Add an extra newline to the end of the body of the program text constructed
by the Function constructor for parsing. This allows single line comments to
be handled correctly by the parser.
* runtime/FunctionConstructor.cpp:
(JSC::constructFunction):
2009-03-09 Oliver Hunt <oliver@apple.com>
Reviewed by Gavin Barraclough.
......@@ -97,12 +97,12 @@ JSObject* constructFunction(ExecState* exec, const ArgList& args, const Identifi
if (args.isEmpty())
program = "(function(){})";
else if (args.size() == 1)
program = "(function(){" + args.at(exec, 0).toString(exec) + "})";
program = "(function(){" + args.at(exec, 0).toString(exec) + "\n})";
else {
program = "(function(" + args.at(exec, 0).toString(exec);
for (size_t i = 1; i < args.size() - 1; i++)
program += "," + args.at(exec, i).toString(exec);
program += "){" + args.at(exec, args.size() - 1).toString(exec) + "})";
program += "){" + args.at(exec, args.size() - 1).toString(exec) + "\n})";
}
int errLine;
......
2009-03-10 Cameron Zwarich <cwzwarich@uwaterloo.ca>
Reviewed by Geoff Garen.
Tests for bug 24291: REGRESSION (r38635): Single line JavaScript comment prevents HTML button click handler execution
<https://bugs.webkit.org/show_bug.cgi?id=24291>
<rdar://problem/6663472>
* fast/events/onload-single-line-comment-expected.txt: Added.
* fast/events/onload-single-line-comment.html: Added.
* fast/js/function-constructor-single-line-comment-expected.txt: Added.
* fast/js/function-constructor-single-line-comment.html: Added.
* fast/js/resources/function-constructor-single-line-comment.js: Added.
2009-03-10 Cameron Zwarich <cwzwarich@uwaterloo.ca>
Reviewed by Geoff Garen.
......
This test checks whether single line comments are parsed correctly in event handlers.
PASS
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function loaded()
{
document.getElementById("result").innerHTML = "PASS";
if (window.layoutTestController)
layoutTestController.notifyDone();
}
if (window.layoutTestController) {
layoutTestController.waitUntilDone();
layoutTestController.dumpAsText()
}
</script>
</head>
<body onload="loaded();//">
<p>This test checks whether single line comments are parsed correctly in event handlers.
<div id="result">FAIL</div>
</body>
</html>
This test checks that the Function constructor works correctly in the presence of single line comments.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS (new Function('return true//'))() is true
PASS (new Function('return true;//'))() is true
PASS (new Function('a', 'return a//'))(true) is true
PASS (new Function('a', 'return a;//'))(true) is true
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="resources/js-test-style.css">
<script src="resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="resources/function-constructor-single-line-comment.js"></script>
<script src="resources/js-test-post.js"></script>
</body>
</html>
description(
"This test checks that the Function constructor works correctly in the presence of single line comments."
);
shouldBeTrue("(new Function('return true//'))()");
shouldBeTrue("(new Function('return true;//'))()");
shouldBeTrue("(new Function('a', 'return a//'))(true)");
shouldBeTrue("(new Function('a', 'return a;//'))(true)");
var successfullyParsed = true;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment