Bug 52079 - Syntax errors should be early errors.
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Jan 2011 20:20:15 +0000 (20:20 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Jan 2011 20:20:15 +0000 (20:20 +0000)
Reviewed by Oliver Hunt.

Source/JavaScriptCore:

From chapter 16 the spec:
    An implementation must report most errors at the time the relevant ECMAScript language construct is
    evaluated. An early error is an error that can be detected and reported prior to the evaluation of
    any construct in the Program containing the error. An implementation must report early errors in a
    Program prior to the first evaluation of that Program. Early errors in eval code are reported at
    the time eval is called but prior to evaluation of any construct within the eval code. All errors
    that are not early errors are runtime errors.

    An implementation must treat any instance of the following kinds of errors as an early error:
        * Any syntax error."

* JavaScriptCore.xcodeproj/project.pbxproj:
    Added new files.
* bytecode/CodeBlock.cpp:
    Removed op_throw_syntax_error.
* bytecode/Opcode.h:
    Removed op_throw_syntax_error.
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::generate):
    If m_expressionTooDeep then throw a runtime error.
(JSC::BytecodeGenerator::BytecodeGenerator):
    Initialize m_expressionTooDeep.
(JSC::BytecodeGenerator::emitThrowExpressionTooDeepException):
    Sets m_expressionTooDeep.
* bytecompiler/BytecodeGenerator.h:
    Added m_expressionTooDeep, removed emitThrowSyntaxError.
* bytecompiler/NodesCodegen.cpp:
(JSC::RegExpNode::emitBytecode):
(JSC::ContinueNode::emitBytecode):
(JSC::BreakNode::emitBytecode):
(JSC::ReturnNode::emitBytecode):
(JSC::LabelNode::emitBytecode):
    Conditions that threw syntax error are now handled during parsing;
    during bytecompilation these are now just ASSERTs.
* interpreter/Interpreter.cpp:
(JSC::Interpreter::privateExecute):
* jit/JIT.cpp:
(JSC::JIT::privateCompileMainPass):
* jit/JIT.h:
* jit/JITOpcodes.cpp:
* jit/JITOpcodes32_64.cpp:
* jit/JITStubs.cpp:
* jit/JITStubs.h:
    Removed op_throw_syntax_error.
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createRegExp):
    Renamed; added syntax check.
* parser/JSParser.cpp:
(JSC::JSParser::breakIsValid):
(JSC::JSParser::hasLabel):
(JSC::JSParser::Scope::Scope):
(JSC::JSParser::Scope::setIsFunction):
(JSC::JSParser::Scope::isFunctionBoundary):
(JSC::JSParser::ScopeRef::hasContainingScope):
(JSC::JSParser::ScopeRef::containingScope):
(JSC::JSParser::AutoPopScopeRef::AutoPopScopeRef):
(JSC::JSParser::AutoPopScopeRef::~AutoPopScopeRef):
(JSC::JSParser::AutoPopScopeRef::setPopped):
(JSC::JSParser::popScopeInternal):
(JSC::JSParser::popScope):
(JSC::jsParse):
(JSC::JSParser::JSParser):
(JSC::JSParser::parseProgram):
(JSC::JSParser::parseBreakStatement):
(JSC::JSParser::parseContinueStatement):
(JSC::JSParser::parseReturnStatement):
(JSC::JSParser::parseTryStatement):
(JSC::JSParser::parseFunctionInfo):
(JSC::JSParser::parseExpressionOrLabelStatement):
(JSC::JSParser::parsePrimaryExpression):
* parser/JSParser.h:
* parser/Nodes.h:
* parser/Parser.cpp:
(JSC::Parser::parse):
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createRegExp):
    Renamed; added syntax check.
* runtime/ExceptionHelpers.cpp:
(JSC::createOutOfMemoryError):
(JSC::throwOutOfMemoryError):
* runtime/ExceptionHelpers.h:
    Broke out createOutOfMemoryError.
* runtime/Executable.cpp:
(JSC::EvalExecutable::compileInternal):
(JSC::ProgramExecutable::compileInternal):
(JSC::FunctionExecutable::compileForCallInternal):
(JSC::FunctionExecutable::compileForConstructInternal):
    Add check for exception after bytecode generation.
* runtime/RegExpConstructor.cpp:
(JSC::constructRegExp):
* runtime/RegExpPrototype.cpp:
(JSC::regExpProtoFuncCompile):
    RegExp error prefixes not included in error string.
* yarr/RegexParser.h:
(JSC::Yarr::Parser::parse):
    Removed regexBegin/regexEnd/regexError.
* yarr/RegexPattern.cpp:
(JSC::Yarr::RegexPatternConstructor::regexBegin):
    Removed regexEnd/regexError.
(JSC::Yarr::compileRegex):
    Add call to regexBegin (no longer called from the parser).
* yarr/YarrSyntaxChecker.cpp: Added.
(JSC::Yarr::SyntaxChecker::assertionBOL):
(JSC::Yarr::SyntaxChecker::assertionEOL):
(JSC::Yarr::SyntaxChecker::assertionWordBoundary):
(JSC::Yarr::SyntaxChecker::atomPatternCharacter):
(JSC::Yarr::SyntaxChecker::atomBuiltInCharacterClass):
(JSC::Yarr::SyntaxChecker::atomCharacterClassBegin):
(JSC::Yarr::SyntaxChecker::atomCharacterClassAtom):
(JSC::Yarr::SyntaxChecker::atomCharacterClassRange):
(JSC::Yarr::SyntaxChecker::atomCharacterClassBuiltIn):
(JSC::Yarr::SyntaxChecker::atomCharacterClassEnd):
(JSC::Yarr::SyntaxChecker::atomParenthesesSubpatternBegin):
(JSC::Yarr::SyntaxChecker::atomParentheticalAssertionBegin):
(JSC::Yarr::SyntaxChecker::atomParenthesesEnd):
(JSC::Yarr::SyntaxChecker::atomBackReference):
(JSC::Yarr::SyntaxChecker::quantifyAtom):
(JSC::Yarr::SyntaxChecker::disjunction):
(JSC::Yarr::checkSyntax):
* yarr/YarrSyntaxChecker.h: Added.
    Check RegExp syntax.

LayoutTests:

Fix syntax errors in layout tests, and update expected results.

* editing/selection/select-crash-001.html:
* editing/selection/select-crash-002.html:
* fast/canvas/webgl/renderbuffer-initialization.html:
* fast/forms/25153.html:
* fast/forms/textfield-drag-into-disabled.html:
* fast/js/exception-codegen-crash-expected.txt:
* fast/js/exception-codegen-crash.html:
* fast/js/kde/parse-expected.txt:
* fast/js/kde/script-tests/parse.js:
* fast/js/large-expressions-expected.txt:
* fast/js/named-function-expression-expected.txt:
* fast/js/parser-syntax-check-expected.txt:
* fast/js/script-tests/large-expressions.js:
* fast/js/script-tests/named-function-expression.js:
* fast/js/script-tests/parser-syntax-check.js:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A11.1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A11_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A12.1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A12_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T4-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A6-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A8_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A8_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T4-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A6-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A8_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A8_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T10-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T4-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T5-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T6-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T7-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T8-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T9-expected.txt:
* http/tests/security/isolatedWorld/events.html:
* http/tests/security/isolatedWorld/userGestureEvents.html:
* svg/custom/resources/use-instanceRoot-event-listeners.js:
* svg/custom/rgbcolor-syntax.svg:
* svg/custom/use-instanceRoot-modifications.svg:
* svg/custom/use-property-changes-through-svg-dom.svg:
* webarchive/adopt-attribute-styled-body-webarchive-expected.webarchive:
* webarchive/resources/adopt-attribute-styled-body-iframe.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75408 268f45cc-cd09-0410-ab3c-d52691b4dbfc

93 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/selection/select-crash-001.html
LayoutTests/editing/selection/select-crash-002.html
LayoutTests/fast/canvas/webgl/renderbuffer-initialization.html
LayoutTests/fast/forms/25153.html
LayoutTests/fast/forms/textfield-drag-into-disabled.html
LayoutTests/fast/js/exception-codegen-crash-expected.txt
LayoutTests/fast/js/exception-codegen-crash.html
LayoutTests/fast/js/kde/parse-expected.txt
LayoutTests/fast/js/kde/script-tests/parse.js
LayoutTests/fast/js/large-expressions-expected.txt
LayoutTests/fast/js/named-function-expression-expected.txt
LayoutTests/fast/js/parser-syntax-check-expected.txt
LayoutTests/fast/js/script-tests/large-expressions.js
LayoutTests/fast/js/script-tests/named-function-expression.js
LayoutTests/fast/js/script-tests/parser-syntax-check.js
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A11.1_T3-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A11_T3-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A12.1_T3-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A12_T3-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T1-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T2-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T3-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T4-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T1-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T2-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T3-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A6-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A8_T1-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A8_T2-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T1-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T2-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T3-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T4-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T1-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T2-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T3-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A6-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A8_T1-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A8_T2-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T1-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T10-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T2-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T3-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T4-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T5-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T6-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T7-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T8-expected.txt
LayoutTests/fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T9-expected.txt
LayoutTests/http/tests/security/isolatedWorld/events.html
LayoutTests/http/tests/security/isolatedWorld/userGestureEvents.html
LayoutTests/svg/custom/resources/use-instanceRoot-event-listeners.js
LayoutTests/svg/custom/rgbcolor-syntax.svg
LayoutTests/svg/custom/use-instanceRoot-modifications.svg
LayoutTests/svg/custom/use-property-changes-through-svg-dom.svg
LayoutTests/webarchive/adopt-attribute-styled-body-webarchive-expected.webarchive
LayoutTests/webarchive/resources/adopt-attribute-styled-body-iframe.html
Source/JavaScriptCore/Android.mk
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.am
Source/JavaScriptCore/JavaScriptCore.gypi
Source/JavaScriptCore/JavaScriptCore.pro
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/bytecode/Opcode.h
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Source/JavaScriptCore/interpreter/Interpreter.cpp
Source/JavaScriptCore/jit/JIT.cpp
Source/JavaScriptCore/jit/JIT.h
Source/JavaScriptCore/jit/JITOpcodes.cpp
Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
Source/JavaScriptCore/jit/JITStubs.cpp
Source/JavaScriptCore/jit/JITStubs.h
Source/JavaScriptCore/parser/ASTBuilder.h
Source/JavaScriptCore/parser/JSParser.cpp
Source/JavaScriptCore/parser/JSParser.h
Source/JavaScriptCore/parser/Nodes.h
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/SyntaxChecker.h
Source/JavaScriptCore/runtime/ExceptionHelpers.cpp
Source/JavaScriptCore/runtime/ExceptionHelpers.h
Source/JavaScriptCore/runtime/Executable.cpp
Source/JavaScriptCore/runtime/RegExpConstructor.cpp
Source/JavaScriptCore/runtime/RegExpPrototype.cpp
Source/JavaScriptCore/yarr/RegexParser.h
Source/JavaScriptCore/yarr/RegexPattern.cpp
Source/JavaScriptCore/yarr/YarrSyntaxChecker.cpp [new file with mode: 0644]
Source/JavaScriptCore/yarr/YarrSyntaxChecker.h [new file with mode: 0644]

index 1caacc6e2bf3a425fb8309f8539f5727b930c910..d52aa34c8e025b4c840cd4e4f3113cb953bee4a7 100644 (file)
@@ -1,3 +1,69 @@
+2011-01-10  Gavin Barraclough  <barraclough@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Bug 52079 - Syntax errors should be early errors.
+
+        Fix syntax errors in layout tests, and update expected results.
+
+        * editing/selection/select-crash-001.html:
+        * editing/selection/select-crash-002.html:
+        * fast/canvas/webgl/renderbuffer-initialization.html:
+        * fast/forms/25153.html:
+        * fast/forms/textfield-drag-into-disabled.html:
+        * fast/js/exception-codegen-crash-expected.txt:
+        * fast/js/exception-codegen-crash.html:
+        * fast/js/kde/parse-expected.txt:
+        * fast/js/kde/script-tests/parse.js:
+        * fast/js/large-expressions-expected.txt:
+        * fast/js/named-function-expression-expected.txt:
+        * fast/js/parser-syntax-check-expected.txt:
+        * fast/js/script-tests/large-expressions.js:
+        * fast/js/script-tests/named-function-expression.js:
+        * fast/js/script-tests/parser-syntax-check.js:
+        * fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A11.1_T3-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A11_T3-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A12.1_T3-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A12_T3-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T1-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T2-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T3-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T4-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T1-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T2-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T3-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A6-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A8_T1-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A8_T2-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T1-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T2-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T3-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T4-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T1-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T2-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T3-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A6-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A8_T1-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A8_T2-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T1-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T10-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T2-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T3-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T4-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T5-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T6-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T7-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T8-expected.txt:
+        * fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T9-expected.txt:
+        * http/tests/security/isolatedWorld/events.html:
+        * http/tests/security/isolatedWorld/userGestureEvents.html:
+        * svg/custom/resources/use-instanceRoot-event-listeners.js:
+        * svg/custom/rgbcolor-syntax.svg:
+        * svg/custom/use-instanceRoot-modifications.svg:
+        * svg/custom/use-property-changes-through-svg-dom.svg:
+        * webarchive/adopt-attribute-styled-body-webarchive-expected.webarchive:
+        * webarchive/resources/adopt-attribute-styled-body-iframe.html:
+
 2011-01-10  Tony Chang  <tony@chromium.org>
 
         Unreviewed, remove duplicate test expectation for gif-loop-count.
index cc9697832ffd48c3ff83e1223304b3de733c8ae8..1601957465344b89e948f0283be8bd012c90d568 100644 (file)
@@ -10,14 +10,14 @@ html,body,h1{font-size:100%;font-style:inherit;font-weight:inherit;margin:0;padd
 <body>
 <h1 id="test">The Longest German Word?</h1>
 <script type="text/javascript" language="javascript">
-    if (!window.layoutTestController)
-        return;
-    layoutTestController.dumpAsText();
-    var element = document.getElementById("test");
-    var selection = window.getSelection();
-    selection.setPosition(element.firstChild, 2);
-    extendSelectionForwardByCharacterCommand();
-    copyCommand();
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        var element = document.getElementById("test");
+        var selection = window.getSelection();
+        selection.setPosition(element.firstChild, 2);
+        extendSelectionForwardByCharacterCommand();
+        copyCommand();
+    }
 </script>
 </body>
 </html>
index 1b4597b303ce5d93705ffefe8a807a242ddad365..c3ae342dbf99580eceb8e8dea94dd2f5f5bf5936 100644 (file)
@@ -10,11 +10,11 @@ html,body,h1{font-size:100%;font-style:inherit;font-weight:inherit;margin:0;padd
 <body>
 <h1>The Longest German Word?</h1>
 <script type="text/javascript" language="javascript">
-    if (!window.layoutTestController)
-        return;
-    layoutTestController.dumpAsText();
-    selectAllCommand();
-    copyCommand();
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        selectAllCommand();
+        copyCommand();
+    }
 </script>
 </body>
 </html>
index 8dd58f62b82eb51ceb74c031887d7b40e432eaeb..d2d317c7b76117a846296bc8be682d90d2c565e2 100644 (file)
@@ -66,24 +66,22 @@ description('Verify renderbuffers are initialized to 0 before being read in WebG
 
 var canvas = document.getElementById("testbed");
 var gl = canvas.getContext("experimental-webgl");
-if (!gl) {
-    testFailed('canvas.getContext() failed');
-    return false;
-}
+if (gl) {
+    runTest(gl, canvas.width, canvas.height);
 
-runTest(gl, canvas.width, canvas.height);
+    // Testing that canvas resizing will clear the buffers with 0 instead of the current clear values.
+    gl.clearColor(1, 0, 0, 1);
+    canvas.width += 1;
+    canvas.height += 1;
+    runTest(gl, canvas.width, canvas.height);
 
-// Testing that canvas resizing will clear the buffers with 0 instead of the current clear values.
-gl.clearColor(1, 0, 0, 1);
-canvas.width += 1;
-canvas.height += 1;
-runTest(gl, canvas.width, canvas.height);
+    // Testing buffer clearing won't change the clear values.
+    var clearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE);
+    shouldBe("clearColor", "[1, 0, 0, 1]");
 
-// Testing buffer clearing won't change the clear values.
-var clearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE);
-shouldBe("clearColor", "[1, 0, 0, 1]");
-
-successfullyParsed = true;
+    successfullyParsed = true;
+} else
+    testFailed('canvas.getContext() failed');
 </script>
 <script src="../../js/resources/js-test-post.js"></script>
 </body>
index 8a612323504390ef9595b8f4c35ca9c0884a7521..a3c471aab906cad347ff0953b61b052d4ba3cac5 100644 (file)
@@ -2,18 +2,18 @@ This tests to make sure that clicking inside a text field places the caret in it
 <input id="textfield" onFocus="window.scrollBy(0, 40)" value="click in me"><br>
 <div style="height: 1500px;">
 <script>
-if (!window.layoutTestController)
-    return;
-window.layoutTestController.dumpAsText();
-textfield = document.getElementById("textfield");
-// Click near the end of the field so that the caret after all of the text inside it.
-x = textfield.offsetParent.offsetLeft + textfield.offsetLeft + textfield.offsetWidth - 5;
-y = textfield.offsetParent.offsetTop + textfield.offsetTop + textfield.offsetHeight / 2;
-eventSender.mouseMoveTo(x, y);
-eventSender.mouseDown();
-eventSender.mouseUp();
-if (textfield.selectionStart == textfield.value.length && textfield.selectionEnd == textfield.value.length)
-    document.body.innerText = "Success"
-else
-    document.body.innerText = "Failure.  Expected selection to be after all of the text in the text field."
+if (window.layoutTestController) {
+    window.layoutTestController.dumpAsText();
+    textfield = document.getElementById("textfield");
+    // Click near the end of the field so that the caret after all of the text inside it.
+    x = textfield.offsetParent.offsetLeft + textfield.offsetLeft + textfield.offsetWidth - 5;
+    y = textfield.offsetParent.offsetTop + textfield.offsetTop + textfield.offsetHeight / 2;
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+    if (textfield.selectionStart == textfield.value.length && textfield.selectionEnd == textfield.value.length)
+        document.body.innerText = "Success"
+    else
+        document.body.innerText = "Failure.  Expected selection to be after all of the text in the text field."
+}
 </script>
index 8240e5219dfcb321be23988a416e32e8813fde69..5e73744e683f9e48771f04e2ec6121fca8acd7bf 100644 (file)
@@ -17,21 +17,20 @@ var fieldY = field.offsetTop + field.offsetHeight / 2;
 
 window.getSelection().setBaseAndExtent(text, 0, text, 1);
 
-if (!window.layoutTestController)
-    return;
+if (window.layoutTestController) {
+    eventSender.mouseMoveTo(textX, textY);
+    eventSender.mouseDown();
+    // leap forward so mouseDown will kick off a drag instead of starting a new selection.
+    eventSender.leapForward(1000);
 
-eventSender.mouseMoveTo(textX, textY);
-eventSender.mouseDown();
-// leap forward so mouseDown will kick off a drag instead of starting a new selection.
-eventSender.leapForward(1000);
+    eventSender.mouseMoveTo(fieldX, fieldY);
+    eventSender.mouseUp();
 
-eventSender.mouseMoveTo(fieldX, fieldY);
-eventSender.mouseUp();
-
-layoutTestController.dumpAsText();
-var resultText = "FAIL"
-if (!field.value)
-    resultText = "PASS -- http://bugs.webkit.org/show_bug.cgi?id=10177";
-document.body.innerText = resultText;
+    layoutTestController.dumpAsText();
+    var resultText = "FAIL"
+    if (!field.value)
+        resultText = "PASS -- http://bugs.webkit.org/show_bug.cgi?id=10177";
+    document.body.innerText = resultText;
+}
 </script>
 </body>
index 90ae4725d5c4199bdfc2a67d180f5d66a9db3b3e..c43bbefdb6d84f2a7ffa74329c4732c1d2d4ab3b 100644 (file)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 1: ReferenceError: Postfix ++ operator applied to value that is not a reference.
 This page tests some conditions that used to cause crashes during codegen.
 
 If you don't crash, you pass.
index e09d19a448f3bb169407442e3afdb3432f505381..71f03e1d8ce7f396dc8ca85570d3b76feb7efb03 100644 (file)
@@ -14,5 +14,8 @@ var scripts = [
     "(1 = 1).x;"
 ];
 
-eval(scripts.join("\n"));
+try {
+    eval(scripts.join("\n"));
+} catch (e) {
+}
 </script>
index 9f365553c12c48956d5bfeb231e65f8f9ac85548..ecfef7332b551242137e15dc2754e16a5093e08a 100644 (file)
@@ -3,6 +3,18 @@ KDE JS Test
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
+PASS function test() { return;}; lab: 1 is 1
+PASS function test() { while(0) break; } lab: 1 is 1
+PASS function test() { while(0) continue; } lab: 1 is 1
+PASS function test() { return lab;} lab: 1 is 1
+PASS function test() { while(0) break lab; } lab: 1 threw exception SyntaxError: Parse error.
+PASS function test() { while(0) continue lab; } lab: 1 threw exception SyntaxError: Parse error.
+PASS function test() { return } lab: 1 is 1
+PASS function test() { while(0) break } lab: 1 is 1
+PASS function test() { while(0) continue } lab: 1 is 1
+PASS function test() { return 0 } lab: 1 is 1
+PASS function test() { while(0) break lab } lab: 1 threw exception SyntaxError: Parse error.
+PASS function test() { while(0) continue lab } lab: 1 threw exception SyntaxError: Parse error.
 PASS var éĀʯΈᢨ = 101; éĀʯΈᢨ; is 101
 PASS var f÷; threw exception SyntaxError: Parse error.
 PASS var \u0061 = 102; a is 102
index ed42dac1e3a9d8479be8ac6d3dd8928c939852da..dd9bf105d060443422d219b65eae17efb0d289b6 100644 (file)
@@ -1,20 +1,19 @@
-function test() { return;}
-function test() { while(0) break; }
-function test() { while(0) continue; }
-
-function test() { return lab;}
-function test() { while(0) break lab; }
-function test() { while(0) continue lab; }
-
-function test() { return }
-function test() { while(0) break }
-function test() { while(0) continue }
-
-function test() { return 0 }
-function test() { while(0) break lab }
-function test() { while(0) continue lab }
-
-lab:
+// Check parsing of nested scopes; a couple of the break/continue to label cases are invalid.
+shouldBe("function test() { return;}; lab: 1", "1");
+shouldBe("function test() { while(0) break; } lab: 1", "1");
+shouldBe("function test() { while(0) continue; } lab: 1", "1");
+
+shouldBe("function test() { return lab;} lab: 1", "1");
+shouldThrow("function test() { while(0) break lab; } lab: 1");
+shouldThrow("function test() { while(0) continue lab; } lab: 1");
+
+shouldBe("function test() { return } lab: 1", "1");
+shouldBe("function test() { while(0) break } lab: 1", "1");
+shouldBe("function test() { while(0) continue } lab: 1", "1");
+
+shouldBe("function test() { return 0 } lab: 1", "1");
+shouldThrow("function test() { while(0) break lab } lab: 1");
+shouldThrow("function test() { while(0) continue lab } lab: 1");
 
 a = 1
 b = 123 // comment
index 743964f0ffbccb87941097c8f6cef1ff020e0327..879e2649ef4c99db56f2efff18c312e2872abc54 100644 (file)
@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS eval(repeatedExpression("letterA", "+", 100)) is repeatedString("a", 100)
 PASS eval(repeatedExpression("letterA", "+", 1000)) is repeatedString("a", 1000)
 PASS eval(repeatedExpression("letterA", "+", 10000)) is repeatedString("a", 10000)
-PASS eval(repeatedExpression("letterA", "+", 100000)) threw exception SyntaxError: Expression too deep.
+PASS eval(repeatedExpression("letterA", "+", 100000)) threw exception Error: Out of memory.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index c487707df7261c2dfd2cad13474cb0c7a4037203..7b8ecb2a8f5f4f6fb5e47e4a5bbd31184cf80c16 100644 (file)
@@ -16,7 +16,7 @@ PASS (function Foo(){ return 1; }); try { Foo(); throw "FuncExpr was stored"; }
 recursion is possible, though
 PASS var ctr = 3; var x = (function Named(a,b){ if(--ctr) return 2 * Named(a,b); else return a + b; }); x(5,6) is 44
 regression test where kjs regarded an anonymous function declaration (which is illegal) as a FunctionExpr
-PASS try { eval("function(){ return 2; };"); return 0; } catch(e) { 1; } is 1
+PASS var hadError = 0; try { eval("function(){ return 2; };"); } catch(e) { hadError = 1; }; hadError; is 1
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 1879bc1b6b49a0f246701cac0d8cdcd99b082700..cf085e47da268cb089d1a4794404b50dcedaaa34 100644 (file)
@@ -265,8 +265,8 @@ PASS Valid:   "do while (0) if (a) {} else y; while(0)"
 PASS Valid:   "function f() { do while (0) if (a) {} else y; while(0) }"
 PASS Valid:   "if (a) while (b) if (c) with(d) {} else e; else f"
 PASS Valid:   "function f() { if (a) while (b) if (c) with(d) {} else e; else f }"
-PASS Valid:   "break ; break your_limits ; continue ; continue living ; debugger"
-PASS Valid:   "function f() { break ; break your_limits ; continue ; continue living ; debugger }"
+PASS Invalid: "break ; break your_limits ; continue ; continue living ; debugger"
+PASS Invalid: "function f() { break ; break your_limits ; continue ; continue living ; debugger }"
 PASS Invalid: "debugger X"
 PASS Invalid: "function f() { debugger X }"
 PASS Invalid: "break 0.2"
@@ -452,8 +452,8 @@ PASS Invalid: "function f() { for (var (a) in b) { } }"
 PASS Valid:   "for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}"
 PASS Valid:   "function f() { for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {} }"
 try statement
-PASS Valid:   "try { break } catch(e) {}"
-PASS Valid:   "function f() { try { break } catch(e) {} }"
+PASS Invalid: "try { break } catch(e) {}"
+PASS Invalid: "function f() { try { break } catch(e) {} }"
 PASS Valid:   "try {} finally { c++ }"
 PASS Valid:   "function f() { try {} finally { c++ } }"
 PASS Valid:   "try { with (x) { } } catch(e) {} finally { if (a) ; }"
index c019cc89223ca46e6773ff752c4788c8b2e458d2..8ce095eeda5484022ad16356d1dc37d9defe9a88 100644 (file)
@@ -27,6 +27,6 @@ function repeatedString(value, count)
 shouldBe('eval(repeatedExpression("letterA", "+", 100))', 'repeatedString("a", 100)');
 shouldBe('eval(repeatedExpression("letterA", "+", 1000))', 'repeatedString("a", 1000)');
 shouldBe('eval(repeatedExpression("letterA", "+", 10000))', 'repeatedString("a", 10000)');
-shouldThrow('eval(repeatedExpression("letterA", "+", 100000))', '"SyntaxError: Expression too deep"');
+shouldThrow('eval(repeatedExpression("letterA", "+", 100000))');
 
 var successfullyParsed = true;
index d3e623f3d00736f5df026b12a9759c13a2983d1c..7d06e632d595d4a54e0c00939a6b27b8cbe43264 100644 (file)
@@ -23,6 +23,6 @@ debug("recursion is possible, though");
 shouldBe("var ctr = 3; var x = (function Named(a,b){ if(--ctr) return 2 * Named(a,b); else return a + b; }); x(5,6)", "44");
 
 debug("regression test where kjs regarded an anonymous function declaration (which is illegal) as a FunctionExpr");
-shouldBe('try { eval("function(){ return 2; };"); return 0; } catch(e) { 1; }', "1");
+shouldBe('var hadError = 0; try { eval("function(){ return 2; };"); } catch(e) { hadError = 1; }; hadError;', "1");
 
 var successfullyParsed = true;
index 1c1316a53c9ccb7a86e1f834c668ae7719e52dd5..135abf8ba27c29fa554d0744423936650b8fac35 100644 (file)
@@ -195,7 +195,7 @@ invalid("do g; while ((4)");
 valid  ("{ { do do do ; while(0) while(0) while(0) } }");
 valid  ("do while (0) if (a) {} else y; while(0)");
 valid  ("if (a) while (b) if (c) with(d) {} else e; else f");
-valid  ("break ; break your_limits ; continue ; continue living ; debugger");
+invalid("break ; break your_limits ; continue ; continue living ; debugger");
 invalid("debugger X");
 invalid("break 0.2");
 invalid("continue a++");
@@ -296,7 +296,7 @@ valid  ("for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}");
 
 debug  ("try statement");
 
-valid  ("try { break } catch(e) {}");
+invalid("try { break } catch(e) {}");
 valid  ("try {} finally { c++ }");
 valid  ("try { with (x) { } } catch(e) {} finally { if (a) ; }");
 invalid("try {}");
index bc87bdc86ce3dea4dbd11b6a62df24d25768c6bb..d418c16b1b94f817fec0bb9cb6bfc2f9405de9ae 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 80: SyntaxError: Parse error
 S12.7_A1_T1
 
-PASS SyntaxError: Invalid continue statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 7dea5c21b7f29214961456c2720307489a82d5bb..4523f7f3ce07912ab69980ec020049bd076e11d0 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 81: SyntaxError: Parse error
 S12.7_A1_T2
 
-PASS SyntaxError: Undefined label: 'LABEL'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index a2f7bc6c1be26546ff05d5d1974dba58975f838f..23fe75d8c543fe14138c6678a2dc0f56d706f8d6 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 82: SyntaxError: Parse error
 S12.7_A1_T3
 
-PASS SyntaxError: Undefined label: 'LABEL'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 46c6008ad196b533196db9df23973126af503db5..9d1e6c0bd167efbc9fa9da3c0d729276954edba6 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 81: SyntaxError: Parse error
 S12.7_A1_T4
 
-PASS SyntaxError: Invalid continue statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 509ed6c463f23017e64e84c6d191ec73b5c7ad60..4c221e38f48db5686b26ea888a1d6b57d0630626 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 80: SyntaxError: Parse error
 S12.7_A5_T1
 
-PASS SyntaxError: Undefined label: 'LABEL_ANOTHER_LOOP'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 25f840f08a7a54f634c58e2b88384c486971d3ce..3bcf4f989df289562b1f3ccef820f3353ba0cad1 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 80: SyntaxError: Parse error
 S12.7_A5_T2
 
-PASS SyntaxError: Undefined label: 'IN_DO_FUNC'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index b01b8cc626d54b0063db6e17e5092441692e6f14..5dfe9b13a2a048a9cbf2f3f27960fcb78cb36f06 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 81: SyntaxError: Parse error
 S12.7_A5_T3
 
-PASS SyntaxError: Undefined label: 'LABEL_IN'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 99508f13d13ca1904de4f0b3998b5cfa1eba49de..9a1f6aff40bd7fcae5da4b3c4e393fd4e90ede33 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 80: SyntaxError: Parse error
 S12.7_A6
 
-PASS SyntaxError: Undefined label: 'LABEL1'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 471e2075de5b3a282cd589555990edbc8a159bb8..b37ddc6cf2946c9be3c78f6390e5d29ca4127ad2 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 86: SyntaxError: Parse error
 S12.7_A8_T1
 
-PASS SyntaxError: Undefined label: 'LABEL2'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index d670f184f7f51c219c27fab72d4f68e7eb5a34db..4d16c5a1d18920351ce29d87828c1046f01a051f 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 87: SyntaxError: Parse error
 S12.7_A8_T2
 
-PASS SyntaxError: Invalid continue statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 3c96b9b974644da6ad34c4a38245fa5c3b66259c..34631b21ae2a156c8239ad1c7ab641a9d474f59f 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 80: SyntaxError: Parse error
 S12.8_A1_T1
 
-PASS SyntaxError: Invalid break statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 0853aa65a50545aa089b29c7d8a60f91bfdf88c8..60b22f75f91d9a7a82bcb750362ae99455b2c868 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 81: SyntaxError: Parse error
 S12.8_A1_T2
 
-PASS SyntaxError: Undefined label: 'LABEL'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 040d055d990303ebd41e29a89690657cfbb9aa70..826f02698be2d7aa4cddcce3ccef4134ebfa71e6 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 81: SyntaxError: Parse error
 S12.8_A1_T3
 
-PASS SyntaxError: Invalid break statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 056926001280533169a60ebe82768d566be99aa5..132f8b906bd29e4c262a6247fbe25674d5b341d3 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 82: SyntaxError: Parse error
 S12.8_A1_T4
 
-PASS SyntaxError: Undefined label: 'LABEL'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index d4d192de362836c6037b46474447a130ff8474fb..01edce5e961a470bf2de0fc57b534ee1c566d92f 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 82: SyntaxError: Parse error
 S12.8_A5_T1
 
-PASS SyntaxError: Undefined label: 'LABEL_ANOTHER_LOOP'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 2cff4b5c3125d65fc0e6dc0a31196fc1e04841d7..2bc52ebfc401a4a726c3c8051560dcfc201044d6 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 82: SyntaxError: Parse error
 S12.8_A5_T2
 
-PASS SyntaxError: Undefined label: 'IN_DO_FUNC'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index c10e6b6acad3ebbcab88ec629e81f379352bbe37..486a801609a2a3167130c58b387f253b1cbc26dc 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 82: SyntaxError: Parse error
 S12.8_A5_T3
 
-PASS SyntaxError: Undefined label: 'LABEL_IN'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 1731dfdb32a6ce8a7fa7c7aeaaf71e7fe7292b1f..bfe542ae614ccfed7d7550f22019bf3f233e3870 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 80: SyntaxError: Parse error
 S12.8_A6
 
-PASS SyntaxError: Undefined label: 'LABEL1'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index aeaa45961df82405a775546f859cdfb471920706..a35c646f7b5ffd0ec4b87aa0368183ba07540f68 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 86: SyntaxError: Parse error
 S12.8_A8_T1
 
-PASS SyntaxError: Undefined label: 'LABEL2'.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 2d17fd8b4c4b70f921ae6c42a78ac67593c00948..d7ba63dcfc0f946c070b591d11640e9188c69947 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 87: SyntaxError: Parse error
 S12.8_A8_T2
 
-PASS SyntaxError: Invalid break statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 31f1afcb8d1a0ba7cabff75ca8bd8ea4b3f1f9e4..f4caedc8ff6099b4e8003589a9c7aa7d794150d6 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 79: SyntaxError: Parse error
 S12.9_A1_T1
 
-PASS SyntaxError: Invalid return statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 0072b4d437186c0a01c53d63ccf70cb5cf651c15..bbdfac52822d5157ba15eb29ecd0946266a013bb 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 78: SyntaxError: Parse error
 S12.9_A1_T10
 
-PASS SyntaxError: Invalid return statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 31889a4ebeae30a1e43227b298b154c34b68479b..d9139996f96b44a9a6bbe68e4962257ca9f641a1 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 79: SyntaxError: Parse error
 S12.9_A1_T2
 
-PASS SyntaxError: Invalid return statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 6abf6ccaf19c171447a0d7e23fcff325662c1530..cdfc75d2ffc1b5fc5eceae1f53b562c20b732481 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 79: SyntaxError: Parse error
 S12.9_A1_T3
 
-PASS SyntaxError: Invalid return statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 097b0a1fec4701176868e9f068bed0f29064cf7c..8510ffdf6499351e040598cad1671fd2f7a459a7 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 78: SyntaxError: Parse error
 S12.9_A1_T4
 
-PASS SyntaxError: Invalid return statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 5ac0fe68c1f040da2065d86c7a1632067dc8b00c..35883279d530e9e1166d78b3d2ea2ad24db22770 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 80: SyntaxError: Parse error
 S12.9_A1_T5
 
-PASS SyntaxError: Invalid return statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 74cf051fa96996d9d63545165b8e29b8f7694181..393a42d620c81803413acc64775222f1a4e761c1 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 80: SyntaxError: Parse error
 S12.9_A1_T6
 
-PASS SyntaxError: Invalid return statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 3c4810da002280e94096e818eb380e4b8140c076..e178a319caf8b007db9e4d7434535884fbb902b2 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 80: SyntaxError: Parse error
 S12.9_A1_T7
 
-PASS SyntaxError: Invalid return statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 0a728afcaa6d8b4ac198a57af000044bafedbaa2..90dd345389fe29f6d8e327e2dcdddb1369be3d3b 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 80: SyntaxError: Parse error
 S12.9_A1_T8
 
-PASS SyntaxError: Invalid return statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index f22f75f7658f86a51bb9d0378f759c94f1e5e828..16dcb716234ce977453d7b282bcb9baa70116a02 100644 (file)
@@ -1,6 +1,7 @@
+CONSOLE MESSAGE: line 81: SyntaxError: Parse error
 S12.9_A1_T9
 
-PASS SyntaxError: Invalid return statement.
+PASS Expected parsing failure
 
 TEST COMPLETE
 
index 0742f9dbba49ce3714114f2ed5b27ca584f9ec53..adf92c8471006570a52c0d53b3f42e867c1f48f2 100644 (file)
 <script>\r
 \r
 // This test is meaningless without layoutTestController.\r
-if (!window.layoutTestController && !window.eventSender)\r
-    return;\r
+if (window.layoutTestController && window.eventSender) {\r
 \r
-layoutTestController.dumpAsText();\r
-layoutTestController.waitUntilDone();\r
+    layoutTestController.dumpAsText();\r
+    layoutTestController.waitUntilDone();\r
 \r
-window.textAttributeEventsCount = 0;\r
-window.xhrEventsCount = 0;\r
-window.functionAttributeEventsCount = 0;\r
-window.addEventListener("message", function(message)\r
-{\r
-    layoutTestController.notifyDone();\r
-}, false);\r
-\r
-window.textAttributeEventsCallback = function()\r
-{\r
-    if (textAttributeEventsCount++)\r
-        document.getElementById("log").innerHTML += "PASS";\r
-}\r
-\r
-function newTest(title)\r
-{\r
-    document.getElementById("log").innerHTML += "<br>" + title + ": ";\r
-}\r
+    window.textAttributeEventsCount = 0;\r
+    window.xhrEventsCount = 0;\r
+    window.functionAttributeEventsCount = 0;\r
+    window.addEventListener("message", function(message)\r
+    {\r
+        layoutTestController.notifyDone();\r
+    }, false);\r
 \r
-function textAttributeEventListener()\r
-{\r
     window.textAttributeEventsCallback = function()\r
     {\r
-        if (window.alreadyFailed)\r
-            return;\r
-         document.getElementById("log").innerHTML += "FAIL";\r
-         window.alreadyFailed = true;\r
+        if (textAttributeEventsCount++)\r
+            document.getElementById("log").innerHTML += "PASS";\r
     }\r
 \r
-    var test = document.getElementById("test");\r
-    test.innerHTML = "<button id='button1' onclick='textAttributeEventsCallback()'></button>";\r
-    document.getElementById("button1").click();\r
-}\r
+    function newTest(title)\r
+    {\r
+        document.getElementById("log").innerHTML += "<br>" + title + ": ";\r
+    }\r
 \r
-function functionAttributeEventListener()\r
-{\r
-    var test = document.getElementById("test");\r
-    var button = test.appendChild(document.createElement("button"));\r
-    window.functionAttributeEventsCount = 0;\r
-    button.onclick = function()\r
+    function textAttributeEventListener()\r
     {\r
-        if (window.functionAttributeEventsCount++)\r
-            document.getElementById("log").innerHTML += "PASS";\r
+        window.textAttributeEventsCallback = function()\r
+        {\r
+            if (window.alreadyFailed)\r
+                return;\r
+             document.getElementById("log").innerHTML += "FAIL";\r
+             window.alreadyFailed = true;\r
+        }\r
+\r
+        var test = document.getElementById("test");\r
+        test.innerHTML = "<button id='button1' onclick='textAttributeEventsCallback()'></button>";\r
+        document.getElementById("button1").click();\r
     }\r
-    button.style.cssText = "width: 30px;height:30px";\r
-    button.click();\r
-}\r
 \r
-function xhrEventListener()\r
-{\r
-    window.xhrWorld = 1;\r
-    var done;\r
-    var xhr = new XMLHttpRequest();\r
-    xhr.open("GET", "anyfile", true);\r
-    xhr.onreadystatechange = function() {\r
-        if (done)\r
-            return;\r
-        done = true;\r
-        document.getElementById("log").innerHTML += window.xhrWorld  ? "PASS" : "FAIL";\r
-        window.postMessage("done", "*");\r
-    };\r
-    xhr.send(null);\r
-}\r
+    function functionAttributeEventListener()\r
+    {\r
+        var test = document.getElementById("test");\r
+        var button = test.appendChild(document.createElement("button"));\r
+        window.functionAttributeEventsCount = 0;\r
+        button.onclick = function()\r
+        {\r
+            if (window.functionAttributeEventsCount++)\r
+                document.getElementById("log").innerHTML += "PASS";\r
+        }\r
+        button.style.cssText = "width: 30px;height:30px";\r
+        button.click();\r
+    }\r
 \r
-function runTestInWorld(worldId, funcName)\r
-{\r
-    layoutTestController.evaluateScriptInIsolatedWorld(worldId, String(eval(funcName)) + "\n" + funcName + "();");\r
-}\r
+    function xhrEventListener()\r
+    {\r
+        window.xhrWorld = 1;\r
+        var done;\r
+        var xhr = new XMLHttpRequest();\r
+        xhr.open("GET", "anyfile", true);\r
+        xhr.onreadystatechange = function() {\r
+            if (done)\r
+                return;\r
+            done = true;\r
+            document.getElementById("log").innerHTML += window.xhrWorld  ? "PASS" : "FAIL";\r
+            window.postMessage("done", "*");\r
+        };\r
+        xhr.send(null);\r
+    }\r
 \r
-function runTest() \r
-{\r
-    newTest("Text attribute event listeners should always fire in main world");\r
-    runTestInWorld(1, "textAttributeEventListener");\r
-    var button1 = document.getElementById("button1");\r
-    button1.click();\r
-    button1.parentElement.removeChild(button1);\r
-    \r
-    newTest("Function attribute event listeners should fire in the world where they were created");\r
-    runTestInWorld(1, "functionAttributeEventListener");\r
-    var testDiv = document.getElementById("test");\r
-    // Land somewhere on the button.\r
-    eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5);\r
-    eventSender.mouseDown();\r
-    eventSender.mouseUp();\r
+    function runTestInWorld(worldId, funcName)\r
+    {\r
+        layoutTestController.evaluateScriptInIsolatedWorld(worldId, String(eval(funcName)) + "\n" + funcName + "();");\r
+    }\r
 \r
-    newTest("XHR attribute event listeners should fire in the world where they were created");\r
-    runTestInWorld(1, "xhrEventListener");\r
-}\r
+    function runTest() \r
+    {\r
+        newTest("Text attribute event listeners should always fire in main world");\r
+        runTestInWorld(1, "textAttributeEventListener");\r
+        var button1 = document.getElementById("button1");\r
+        button1.click();\r
+        button1.parentElement.removeChild(button1);\r
+        \r
+        newTest("Function attribute event listeners should fire in the world where they were created");\r
+        runTestInWorld(1, "functionAttributeEventListener");\r
+        var testDiv = document.getElementById("test");\r
+        // Land somewhere on the button.\r
+        eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5);\r
+        eventSender.mouseDown();\r
+        eventSender.mouseUp();\r
 \r
+        newTest("XHR attribute event listeners should fire in the world where they were created");\r
+        runTestInWorld(1, "xhrEventListener");\r
+    }\r
+}\r
 </script>\r
 <body onload="runTest()">\r
     <div id="test"></div>\r
index 910aceb3089a3dde69f1c2b463f55641198ef3f3..8fcb401fcd15ab2f33da2bb25c0f76c56f6e68b8 100644 (file)
@@ -4,53 +4,52 @@
 <script>\r
 \r
 // This test is meaningless without a layoutTestController.\r
-if (!window.layoutTestController && !window.eventSender) {\r
-    document.getElementById("log").innerHTML += "FAIL\n";\r
-    return;\r
-}\r
-\r
-layoutTestController.setCanOpenWindows(true);\r
-layoutTestController.waitUntilDone();\r
-layoutTestController.dumpAsText();\r
-\r
-function newTest(title)\r
-{\r
-    document.getElementById("log").innerHTML += "<br>" + title + ": ";\r
-}\r
-\r
-function pass()\r
-{\r
-    document.getElementById("log").innerHTML += "PASS\n";\r
-    layoutTestController.notifyDone();\r
-}\r
-\r
-// (This function is run within an isolated world)\r
-function userGestureEventListener()\r
-{\r
-    // Register an event handler that will try to perform an action that can only be initiated by a user gesture (opening a window).\r
-    document.getElementById("button1").onclick = function()\r
+if (window.layoutTestController && window.eventSender) {\r
+\r
+    layoutTestController.setCanOpenWindows(true);\r
+    layoutTestController.waitUntilDone();\r
+    layoutTestController.dumpAsText();\r
+\r
+    function newTest(title)\r
     {\r
-        window.open("resources/userGestureEvents-second-window.html", "resources/userGestureEvents-second-window.html");\r
+        document.getElementById("log").innerHTML += "<br>" + title + ": ";\r
     }\r
-}\r
 \r
-function runTestInWorld(worldId, funcName)\r
-{\r
-    layoutTestController.evaluateScriptInIsolatedWorld(worldId, String(eval(funcName)) + "\n" + funcName + "();");\r
-}\r
+    function pass()\r
+    {\r
+        document.getElementById("log").innerHTML += "PASS\n";\r
+        layoutTestController.notifyDone();\r
+    }\r
 \r
-function runTest() \r
-{\r
-    newTest("Event handlers in isolated worlds for user gesture generated events should should the same permissions as handlers within the page.");\r
-    runTestInWorld(1, "userGestureEventListener");\r
+    // (This function is run within an isolated world)\r
+    function userGestureEventListener()\r
+    {\r
+        // Register an event handler that will try to perform an action that can only be initiated by a user gesture (opening a window).\r
+        document.getElementById("button1").onclick = function()\r
+        {\r
+            window.open("resources/userGestureEvents-second-window.html", "resources/userGestureEvents-second-window.html");\r
+        }\r
+    }\r
 \r
-    // Click somewhere on the button!\r
-    var testDiv = document.getElementById("test");\r
-    eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5);\r
-    eventSender.mouseDown();\r
-    eventSender.mouseUp();\r
-}\r
+    function runTestInWorld(worldId, funcName)\r
+    {\r
+        layoutTestController.evaluateScriptInIsolatedWorld(worldId, String(eval(funcName)) + "\n" + funcName + "();");\r
+    }\r
+\r
+    function runTest() \r
+    {\r
+        newTest("Event handlers in isolated worlds for user gesture generated events should should the same permissions as handlers within the page.");\r
+        runTestInWorld(1, "userGestureEventListener");\r
+\r
+        // Click somewhere on the button!\r
+        var testDiv = document.getElementById("test");\r
+        eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5);\r
+        eventSender.mouseDown();\r
+        eventSender.mouseUp();\r
+    }\r
 \r
+} else\r
+    document.getElementById("log").innerHTML += "FAIL\n";\r
 </script>\r
 <body onload="runTest()">\r
     <div id="test"><button id='button1'></button></div>\r
index 9dc1cc1dc9073021509d334214ff88715ca29687..08b204af8f13523eb704b79996cbabdfe4e3217c 100644 (file)
@@ -169,11 +169,9 @@ function driveTests()
     }
 }
 
-if (!window.eventSender) {
-    alert("This test must be run via DRT!");
-    return;
-}
-
 // Start tests
-eventSender.mouseMoveTo(115, 55);
-driveTests();
+if (window.eventSender) {
+    eventSender.mouseMoveTo(115, 55);
+    driveTests();
+} else
+    alert("This test must be run via DRT!");
index b4756dba355672ed9d86201c3cf146cfc6c9e458..97863fb21c9edcc47413d99bae2ac92c69166c06 100644 (file)
     }
 
     /* test that incorrect color strings throw an exception */
-    var col = document.styleSheets[0].cssRules[0].style.getPropertyCSSValue("fill");
-    if (!expectsException(col, "rgb(100%,100%,0%")) return;
-    if (!expectsException(col, "rgba(100%,100%,0%")) return;
-    if (!expectsException(col, "rgb(100%,100%,r)")) return;
-    if (!expectsException(col, "rgb (100%,100%,r)")) return;
-    if (!expectsException(col, "rgb(100%, 1, 1)")) return;
-    if (!expectsException(col, "hsl(100%,100%,100%)")) return;
-    if (!expectsException(col, "yello")) return;
-    if (!expectsException(col, "!#fff")) return;
-    if (!expectsException(col, "#sdf")) return;
-    if (!expectsException(col, "#")) return;
-    if (!expectsException(col, "#f")) return;
-    if (!expectsException(col, "#ff")) return;
-    if (!expectsException(col, "#ffff")) return;
-    if (!expectsException(col, "#fffff")) return;
-    if (!expectsException(col, "#fffffff")) return;
-    if (!expectsException(col, "green,")) return;
-    if (!expectsValid(col, "rgb(0, 10, 20)", "#000A14")) return;
-    if (!expectsValid(col, "#FFF", "#FFFFFF")) return;
-    if (!expectsValid(col, "#FFFFFF", "#FFFFFF")) return;
-    if (!expectsValid(col, " green", "#008000")) return;
-    if (!expectsValid(col, "green ", "#008000")) return;
-    if (!expectsValid(col, "green", "#008000")) return;
+    function testIncorrectColor() {
+        var col = document.styleSheets[0].cssRules[0].style.getPropertyCSSValue("fill");
+        if (!expectsException(col, "rgb(100%,100%,0%")) return;
+        if (!expectsException(col, "rgba(100%,100%,0%")) return;
+        if (!expectsException(col, "rgb(100%,100%,r)")) return;
+        if (!expectsException(col, "rgb (100%,100%,r)")) return;
+        if (!expectsException(col, "rgb(100%, 1, 1)")) return;
+        if (!expectsException(col, "hsl(100%,100%,100%)")) return;
+        if (!expectsException(col, "yello")) return;
+        if (!expectsException(col, "!#fff")) return;
+        if (!expectsException(col, "#sdf")) return;
+        if (!expectsException(col, "#")) return;
+        if (!expectsException(col, "#f")) return;
+        if (!expectsException(col, "#ff")) return;
+        if (!expectsException(col, "#ffff")) return;
+        if (!expectsException(col, "#fffff")) return;
+        if (!expectsException(col, "#fffffff")) return;
+        if (!expectsException(col, "green,")) return;
+        if (!expectsValid(col, "rgb(0, 10, 20)", "#000A14")) return;
+        if (!expectsValid(col, "#FFF", "#FFFFFF")) return;
+        if (!expectsValid(col, "#FFFFFF", "#FFFFFF")) return;
+        if (!expectsValid(col, " green", "#008000")) return;
+        if (!expectsValid(col, "green ", "#008000")) return;
+        if (!expectsValid(col, "green", "#008000")) return;
+    }
+    testIncorrectColor();
 </script>   
 </svg>
index 7aea17baf100eca2fb72906658c34a07cacdee72..137328b44e3e39839ea4e964614a8cba6f108031 100644 (file)
 <text id="text" x="70" y="70">Test failed.</text>
 
 <script>
-var useElement = document.getElementsByTagName("use")[1];
-if (useElement != useElement.instanceRoot.correspondingUseElement)
-    return;
-
-var element = useElement.instanceRoot.correspondingElement;
-if (element != document.getElementById("g"))
-    return;
-
-// element.firstChild is a #text node! the next sibling gives the rect
-var rect = element.firstChild.nextSibling;
-if (rect != document.getElementById("rect"))
-    return;
-
-// rect.nextSibling is a #text node! the next sibling gives the circle
-var circle = rect.nextSibling.nextSibling;
-if (circle != document.getElementById("circle"))
-    return;
-
-rect.setAttribute("fill", "green");
-circle.setAttribute("opacity", "0.8");
-
-document.getElementById("text").firstChild.nodeValue = "Test passed.";
+function runInstanceRootTest() {
+    var useElement = document.getElementsByTagName("use")[1];
+    if (useElement != useElement.instanceRoot.correspondingUseElement)
+        return;
+
+    var element = useElement.instanceRoot.correspondingElement;
+    if (element != document.getElementById("g"))
+        return;
+
+    // element.firstChild is a #text node! the next sibling gives the rect
+    var rect = element.firstChild.nextSibling;
+    if (rect != document.getElementById("rect"))
+        return;
+
+    // rect.nextSibling is a #text node! the next sibling gives the circle
+    var circle = rect.nextSibling.nextSibling;
+    if (circle != document.getElementById("circle"))
+        return;
+
+    rect.setAttribute("fill", "green");
+    circle.setAttribute("opacity", "0.8");
+
+    document.getElementById("text").firstChild.nodeValue = "Test passed.";
+}
+runInstanceRootTest();
 </script>
 </svg>
index 34d023bf409424adf408593c9090e5a9d10c185e..c76cf4c083794cac53881e5c1cde032228091abb 100644 (file)
      var use1 = document.getElementById("use1");
      var use2 = document.getElementById("use2");
 
-     if (!use1 || !use2)
-         return;
-
-     use1.href.baseVal = "#rect";
-
-     use2.x.baseVal.value = 200;
-     use2.y.baseVal.value = -50;
+     if (use1 && use2) {
+         use1.href.baseVal = "#rect";
+         use2.x.baseVal.value = 200;
+         use2.y.baseVal.value = -50;
+     }
     ]]>
   </script>
 </svg>
index 16a067221fd2c6d9737072bc94a37b16425ee6c5..8e6f029c745492be82c2bb5189fb288a2141b686 100644 (file)
@@ -89,12 +89,11 @@ way of fulling testing the bug.  One should wait "awhile" before making the WebA
                        <dict>
                                <key>WebResourceData</key>
                                <string>&lt;html&gt;&lt;head&gt;&lt;script&gt;
-if (!window.parent.bodyToAdopt) {
+if (window.parent.bodyToAdopt) {
+    document.getElementsByTagName("html")[0].appendChild(document.adoptNode(window.parent.bodyToAdopt));
+    window.parent.bodyToAdopt = null;
+} else
     alert("window.parent.bodyToAdopt is not set - Are you viewing this page as part of the adopt-attribute-styled-body test?");
-    return;
-}
-document.getElementsByTagName("html")[0].appendChild(document.adoptNode(window.parent.bodyToAdopt));
-window.parent.bodyToAdopt = null;
 &lt;/script&gt;
 &lt;/head&gt;&lt;body id="otherBody" vlink="green" alink="green"&gt;
 &lt;a href="SomeUnvisitedPage.html"&gt;Spaceballs: The Unvisited Link&lt;/a&gt;&lt;br&gt;
index ef47dbd52f2f189c59c8d21b790a76de7981e7bd..e057a63ba554f2dfa3dc2c32a691ee86db9c629e 100644 (file)
@@ -1,8 +1,7 @@
 <script>
-if (!window.parent.bodyToAdopt) {
+if (window.parent.bodyToAdopt) {
+    document.getElementsByTagName("html")[0].appendChild(document.adoptNode(window.parent.bodyToAdopt));
+    window.parent.bodyToAdopt = null;
+} else
     alert("window.parent.bodyToAdopt is not set - Are you viewing this page as part of the adopt-attribute-styled-body test?");
-    return;
-}
-document.getElementsByTagName("html")[0].appendChild(document.adoptNode(window.parent.bodyToAdopt));
-window.parent.bodyToAdopt = null;
 </script>
index 490989a262679d857505092d131664f60ab17ce3..be8a9b45ce5d3ecf7e07864cdbbcf4d2f6c93f42 100644 (file)
@@ -192,7 +192,8 @@ LOCAL_SRC_FILES := \
        \
        yarr/RegexPattern.cpp \
        yarr/RegexInterpreter.cpp \
-       yarr/RegexJIT.cpp
+       yarr/RegexJIT.cpp \
+    yarr/YarrSyntaxChecker.cpp
 
 # generated headers
 JSC_OBJECTS := $(addprefix $(intermediates)/runtime/, \
index fd26d774d2f6d6c3394c82e574b931cde11168b4..31dc4e11a301d75d417d65de0bc5bbfdb91f8c7c 100644 (file)
@@ -170,6 +170,7 @@ SET(JavaScriptCore_SOURCES
     yarr/RegexPattern.cpp
     yarr/RegexInterpreter.cpp
     yarr/RegexJIT.cpp
+    yarr/YarrSyntaxChecker.cpp
 
     wtf/DateMath.cpp
     wtf/PageAllocationAligned.cpp
index fddc05b12263f1df32d659a9d562974b50b30b4b..11897bac695a0c95cd2bb7c517f5398df88762ca 100644 (file)
@@ -1,3 +1,131 @@
+2011-01-10  Gavin Barraclough  <barraclough@apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Bug 52079 - Syntax errors should be early errors.
+
+        From chapter 16 the spec:
+            An implementation must report most errors at the time the relevant ECMAScript language construct is
+            evaluated. An early error is an error that can be detected and reported prior to the evaluation of
+            any construct in the Program containing the error. An implementation must report early errors in a
+            Program prior to the first evaluation of that Program. Early errors in eval code are reported at
+            the time eval is called but prior to evaluation of any construct within the eval code. All errors
+            that are not early errors are runtime errors.
+
+            An implementation must treat any instance of the following kinds of errors as an early error:
+                * Any syntax error."
+
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+            Added new files.
+        * bytecode/CodeBlock.cpp:
+            Removed op_throw_syntax_error.
+        * bytecode/Opcode.h:
+            Removed op_throw_syntax_error.
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::generate):
+            If m_expressionTooDeep then throw a runtime error.
+        (JSC::BytecodeGenerator::BytecodeGenerator):
+            Initialize m_expressionTooDeep.
+        (JSC::BytecodeGenerator::emitThrowExpressionTooDeepException):
+            Sets m_expressionTooDeep.
+        * bytecompiler/BytecodeGenerator.h:
+            Added m_expressionTooDeep, removed emitThrowSyntaxError.
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::RegExpNode::emitBytecode):
+        (JSC::ContinueNode::emitBytecode):
+        (JSC::BreakNode::emitBytecode):
+        (JSC::ReturnNode::emitBytecode):
+        (JSC::LabelNode::emitBytecode):
+            Conditions that threw syntax error are now handled during parsing;
+            during bytecompilation these are now just ASSERTs.
+        * interpreter/Interpreter.cpp:
+        (JSC::Interpreter::privateExecute):
+        * jit/JIT.cpp:
+        (JSC::JIT::privateCompileMainPass):
+        * jit/JIT.h:
+        * jit/JITOpcodes.cpp:
+        * jit/JITOpcodes32_64.cpp:
+        * jit/JITStubs.cpp:
+        * jit/JITStubs.h:
+            Removed op_throw_syntax_error.
+        * parser/ASTBuilder.h:
+        (JSC::ASTBuilder::createRegExp):
+            Renamed; added syntax check.
+        * parser/JSParser.cpp:
+        (JSC::JSParser::breakIsValid):
+        (JSC::JSParser::hasLabel):
+        (JSC::JSParser::Scope::Scope):
+        (JSC::JSParser::Scope::setIsFunction):
+        (JSC::JSParser::Scope::isFunctionBoundary):
+        (JSC::JSParser::ScopeRef::hasContainingScope):
+        (JSC::JSParser::ScopeRef::containingScope):
+        (JSC::JSParser::AutoPopScopeRef::AutoPopScopeRef):
+        (JSC::JSParser::AutoPopScopeRef::~AutoPopScopeRef):
+        (JSC::JSParser::AutoPopScopeRef::setPopped):
+        (JSC::JSParser::popScopeInternal):
+        (JSC::JSParser::popScope):
+        (JSC::jsParse):
+        (JSC::JSParser::JSParser):
+        (JSC::JSParser::parseProgram):
+        (JSC::JSParser::parseBreakStatement):
+        (JSC::JSParser::parseContinueStatement):
+        (JSC::JSParser::parseReturnStatement):
+        (JSC::JSParser::parseTryStatement):
+        (JSC::JSParser::parseFunctionInfo):
+        (JSC::JSParser::parseExpressionOrLabelStatement):
+        (JSC::JSParser::parsePrimaryExpression):
+        * parser/JSParser.h:
+        * parser/Nodes.h:
+        * parser/Parser.cpp:
+        (JSC::Parser::parse):
+        * parser/SyntaxChecker.h:
+        (JSC::SyntaxChecker::createRegExp):
+            Renamed; added syntax check.
+        * runtime/ExceptionHelpers.cpp:
+        (JSC::createOutOfMemoryError):
+        (JSC::throwOutOfMemoryError):
+        * runtime/ExceptionHelpers.h:
+            Broke out createOutOfMemoryError.
+        * runtime/Executable.cpp:
+        (JSC::EvalExecutable::compileInternal):
+        (JSC::ProgramExecutable::compileInternal):
+        (JSC::FunctionExecutable::compileForCallInternal):
+        (JSC::FunctionExecutable::compileForConstructInternal):
+            Add check for exception after bytecode generation.
+        * runtime/RegExpConstructor.cpp:
+        (JSC::constructRegExp):
+        * runtime/RegExpPrototype.cpp:
+        (JSC::regExpProtoFuncCompile):
+            RegExp error prefixes not included in error string.
+        * yarr/RegexParser.h:
+        (JSC::Yarr::Parser::parse):
+            Removed regexBegin/regexEnd/regexError.
+        * yarr/RegexPattern.cpp:
+        (JSC::Yarr::RegexPatternConstructor::regexBegin):
+            Removed regexEnd/regexError.
+        (JSC::Yarr::compileRegex):
+            Add call to regexBegin (no longer called from the parser).
+        * yarr/YarrSyntaxChecker.cpp: Added.
+        (JSC::Yarr::SyntaxChecker::assertionBOL):
+        (JSC::Yarr::SyntaxChecker::assertionEOL):
+        (JSC::Yarr::SyntaxChecker::assertionWordBoundary):
+        (JSC::Yarr::SyntaxChecker::atomPatternCharacter):
+        (JSC::Yarr::SyntaxChecker::atomBuiltInCharacterClass):
+        (JSC::Yarr::SyntaxChecker::atomCharacterClassBegin):
+        (JSC::Yarr::SyntaxChecker::atomCharacterClassAtom):
+        (JSC::Yarr::SyntaxChecker::atomCharacterClassRange):
+        (JSC::Yarr::SyntaxChecker::atomCharacterClassBuiltIn):
+        (JSC::Yarr::SyntaxChecker::atomCharacterClassEnd):
+        (JSC::Yarr::SyntaxChecker::atomParenthesesSubpatternBegin):
+        (JSC::Yarr::SyntaxChecker::atomParentheticalAssertionBegin):
+        (JSC::Yarr::SyntaxChecker::atomParenthesesEnd):
+        (JSC::Yarr::SyntaxChecker::atomBackReference):
+        (JSC::Yarr::SyntaxChecker::quantifyAtom):
+        (JSC::Yarr::SyntaxChecker::disjunction):
+        (JSC::Yarr::checkSyntax):
+        * yarr/YarrSyntaxChecker.h: Added.
+            Check RegExp syntax.
+
 2011-01-10  Adam Roben  <aroben@apple.com>
 
         Roll out r75289
index 30e3f097cb24e887671e05ad5e2543f5fe32c567..62ae602a13a75e659cfb3ed3b2c54bc2e9d2223d 100644 (file)
@@ -558,7 +558,9 @@ javascriptcore_sources += \
        Source/JavaScriptCore/yarr/RegexJIT.h \
        Source/JavaScriptCore/yarr/RegexParser.h \
        Source/JavaScriptCore/yarr/RegexPattern.cpp \
-       Source/JavaScriptCore/yarr/RegexPattern.h
+       Source/JavaScriptCore/yarr/RegexPattern.h \
+       Source/JavaScriptCore/yarr/YarrSyntaxChecker.cpp \
+       Source/JavaScriptCore/yarr/YarrSyntaxChecker.h
 
 if TARGET_WIN32
 javascriptcore_sources += \
index 4f4da733ad38b3d753172238db83b9a6f564603e..3d8ae87e53508f210c251bd195958ee56fd2bf60 100644 (file)
             'yarr/RegexParser.h',
             'yarr/RegexPattern.cpp',
             'yarr/RegexPattern.h',
+            'yarr/YarrSyntaxChecker.cpp',
+            'yarr/YarrSyntaxChecker.h',
         ]
     }
 }
index fa4ebfb07f6a399a2a14bd92d151533713d7e30d..bf24bea6d6dc3886224ea03a4c528bf8a827aa90 100644 (file)
@@ -210,7 +210,8 @@ SOURCES += \
     runtime/UString.cpp \
     yarr/RegexPattern.cpp \
     yarr/RegexInterpreter.cpp \
-    yarr/RegexJIT.cpp
+    yarr/RegexJIT.cpp \
+    yarr/ YarrSyntaxChecker.cpp
 
 # Generated files, simply list them for JavaScriptCore
 
index 328363e5d692b8aa0dd1dab5cacf17d017715666..2478ea57a43f56a767f15ff24c782b138adc3b1d 100644 (file)
                                RelativePath="..\..\yarr\RegexPattern.h"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\yarr\YarrSyntaxChecker.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\yarr\YarrSyntaxChecker.h"
+                               >
+                       </File>
                </Filter>
                <Filter
                        Name="jit"
index e08d0b7ec0316d25ead77745716e2317b7e603f7..7a96e454d4b6061dd524c58db0f711b51c0a4800 100644 (file)
                86565743115BE3DA00291F40 /* CString.h in Headers */ = {isa = PBXBuildFile; fileRef = 86565741115BE3DA00291F40 /* CString.h */; settings = {ATTRIBUTES = (Private, ); }; };
                865F408810E7D56300947361 /* APIShims.h in Headers */ = {isa = PBXBuildFile; fileRef = 865F408710E7D56300947361 /* APIShims.h */; };
                86676D5211FED9BC004B6863 /* BumpPointerAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 86676D4D11FED55D004B6863 /* BumpPointerAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86704B4012DB8A8100A9FE7B /* YarrSyntaxChecker.cpp */; };
+               86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 86704B4112DB8A8100A9FE7B /* YarrSyntaxChecker.h */; };
                868BFA08117CEFD100B908B1 /* AtomicString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 868BFA00117CEFD100B908B1 /* AtomicString.cpp */; };
                868BFA09117CEFD100B908B1 /* AtomicString.h in Headers */ = {isa = PBXBuildFile; fileRef = 868BFA01117CEFD100B908B1 /* AtomicString.h */; settings = {ATTRIBUTES = (Private, ); }; };
                868BFA0A117CEFD100B908B1 /* AtomicStringImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 868BFA02117CEFD100B908B1 /* AtomicStringImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };
                86565741115BE3DA00291F40 /* CString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CString.h; path = text/CString.h; sourceTree = "<group>"; };
                865F408710E7D56300947361 /* APIShims.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIShims.h; sourceTree = "<group>"; };
                86676D4D11FED55D004B6863 /* BumpPointerAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BumpPointerAllocator.h; sourceTree = "<group>"; };
+               86704B4012DB8A8100A9FE7B /* YarrSyntaxChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YarrSyntaxChecker.cpp; path = yarr/YarrSyntaxChecker.cpp; sourceTree = "<group>"; };
+               86704B4112DB8A8100A9FE7B /* YarrSyntaxChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YarrSyntaxChecker.h; path = yarr/YarrSyntaxChecker.h; sourceTree = "<group>"; };
                867FC35F11B763950025105E /* JavaScriptCore.JSVALUE32_64only.exp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.exports; path = JavaScriptCore.JSVALUE32_64only.exp; sourceTree = "<group>"; };
                867FC36011B763950025105E /* JavaScriptCore.JSVALUE32only.exp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.exports; path = JavaScriptCore.JSVALUE32only.exp; sourceTree = "<group>"; };
                867FC36111B763950025105E /* JavaScriptCore.JSVALUE64only.exp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.exports; path = JavaScriptCore.JSVALUE64only.exp; sourceTree = "<group>"; };
                86EAC48C0F93E8B9008EC948 /* yarr */ = {
                        isa = PBXGroup;
                        children = (
+                               86704B4012DB8A8100A9FE7B /* YarrSyntaxChecker.cpp */,
+                               86704B4112DB8A8100A9FE7B /* YarrSyntaxChecker.h */,
                                86EAC48F0F93E8D1008EC948 /* RegexInterpreter.cpp */,
                                86EAC4900F93E8D1008EC948 /* RegexInterpreter.h */,
                                86EAC4910F93E8D1008EC948 /* RegexJIT.cpp */,
                                14FFF98D12BFFF7500795BB8 /* PageAllocationAligned.h in Headers */,
                                5135FAF212D26ACE003C083B /* Decoder.h in Headers */,
                                5135FAF312D26AD1003C083B /* Encoder.h in Headers */,
+                               86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                E1EF79AA0CE97BA60088D500 /* UTF8.cpp in Sources */,
                                868BFA17117CF19900B908B1 /* WTFString.cpp in Sources */,
                                86D08D5311793613006E5ED0 /* WTFThreadData.cpp in Sources */,
+                               86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index cbae99096117957e4b0a425da6333d295962d013..f3f5f271ae23febe028da377b68ec66922d23aec 100644 (file)
@@ -1197,11 +1197,6 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
             printf("[%4d] throw_reference_error\t %s\n", location, constantName(exec, k0, getConstant(k0)).data());
             break;
         }
-        case op_throw_syntax_error: {
-            int k0 = (++it)->u.operand;
-            printf("[%4d] throw_syntax_error\t %s\n", location, constantName(exec, k0, getConstant(k0)).data());
-            break;
-        }
         case op_jsr: {
             int retAddrDst = (++it)->u.operand;
             int offset = (++it)->u.operand;
index 6c1c6b2c845891a3cc8660502189ead0d025e141..8082ae07477df8ccb021c603a5e8afce3bc551df 100644 (file)
@@ -185,7 +185,6 @@ namespace JSC {
         macro(op_catch, 2) \
         macro(op_throw, 2) \
         macro(op_throw_reference_error, 2) \
-        macro(op_throw_syntax_error, 2) \
         \
         macro(op_jsr, 3) \
         macro(op_sret, 2) \
index 3a99957d16b498dc1a33654fb9c7f6a95fc086b5..34afb52012bd997f508802e3a0e04ca5408385e4 100644 (file)
@@ -137,7 +137,7 @@ bool BytecodeGenerator::dumpsGeneratedCode()
 #endif
 }
 
-void BytecodeGenerator::generate()
+JSObject* BytecodeGenerator::generate()
 {
     m_codeBlock->setThisRegister(m_thisRegister.index());
 
@@ -154,6 +154,10 @@ void BytecodeGenerator::generate()
         symbolTable().clear();
 
     m_codeBlock->shrinkToFit();
+
+    if (m_expressionTooDeep)
+        return createOutOfMemoryError(m_scopeChain->globalObject());
+    return 0;
 }
 
 bool BytecodeGenerator::addVar(const Identifier& ident, bool isConstant, RegisterID*& r0)
@@ -222,6 +226,7 @@ BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const ScopeChain&
     , m_usesExceptions(false)
     , m_regeneratingForExceptionInfo(false)
     , m_codeBlockBeingRegeneratedFrom(0)
+    , m_expressionTooDeep(false)
 {
     if (m_shouldEmitDebugHooks)
         m_codeBlock->setNeedsFullScopeChain(true);
@@ -316,6 +321,7 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Scope
     , m_usesExceptions(false)
     , m_regeneratingForExceptionInfo(false)
     , m_codeBlockBeingRegeneratedFrom(0)
+    , m_expressionTooDeep(false)
 {
     if (m_shouldEmitDebugHooks)
         m_codeBlock->setNeedsFullScopeChain(true);
@@ -481,6 +487,7 @@ BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, const ScopeChain& scope
     , m_usesExceptions(false)
     , m_regeneratingForExceptionInfo(false)
     , m_codeBlockBeingRegeneratedFrom(0)
+    , m_expressionTooDeep(false)
 {
     if (m_shouldEmitDebugHooks || m_baseScopeDepth)
         m_codeBlock->setNeedsFullScopeChain(true);
@@ -2053,12 +2060,6 @@ void BytecodeGenerator::emitThrowReferenceError(const UString& message)
     instructions().append(addConstantValue(jsString(globalData(), message))->index());
 }
 
-void BytecodeGenerator::emitThrowSyntaxError(const UString& message)
-{
-    emitOpcode(op_throw_syntax_error);
-    instructions().append(addConstantValue(jsString(globalData(), message))->index());
-}
-
 PassRefPtr<Label> BytecodeGenerator::emitJumpSubroutine(RegisterID* retAddrDst, Label* finally)
 {
     size_t begin = instructions().size();
@@ -2210,8 +2211,7 @@ RegisterID* BytecodeGenerator::emitThrowExpressionTooDeepException()
     // And we could make the caller pass the node pointer in, if there was some way of getting
     // that from an arbitrary node. However, calling emitExpressionInfo without any useful data
     // is still good enough to get us an accurate line number.
-    emitExpressionInfo(0, 0, 0);
-    emitThrowSyntaxError("Expression too deep");
+    m_expressionTooDeep = true;
     return newTemporary();
 }
 
index 37756fa72c235c9dbab75760fdcb7f9e297bc0b9..8b0cc40120d7c65f63161936a24085d241a5840a 100644 (file)
@@ -102,7 +102,7 @@ namespace JSC {
 
         bool isConstructor() { return m_codeBlock->m_isConstructor; }
 
-        void generate();
+        JSObject* generate();
 
         // Returns the register corresponding to a local variable, or 0 if no
         // such register exists. Registers returned by registerFor do not
@@ -364,7 +364,6 @@ namespace JSC {
         }
 
         void emitThrowReferenceError(const UString& message);
-        void emitThrowSyntaxError(const UString& message);
 
         void emitPushNewScope(RegisterID* dst, const Identifier& property, RegisterID* value);
 
@@ -581,6 +580,7 @@ namespace JSC {
         bool m_usesExceptions;
         bool m_regeneratingForExceptionInfo;
         CodeBlock* m_codeBlockBeingRegeneratedFrom;
+        bool m_expressionTooDeep;
     };
 
 }
index a850c9666609591323f76f07a3faec142a87509b..2875434a2523746ef2fab8e1f0935b978eb280ac 100644 (file)
@@ -83,13 +83,6 @@ RegisterID* ThrowableExpressionData::emitThrowReferenceError(BytecodeGenerator&
     return generator.newTemporary();
 }
 
-RegisterID* ThrowableExpressionData::emitThrowSyntaxError(BytecodeGenerator& generator, const UString& message)
-{
-    generator.emitExpressionInfo(divot(), startOffset(), endOffset());
-    generator.emitThrowSyntaxError(message);
-    return generator.newTemporary();
-}
-
 // ------------------------------ NullNode -------------------------------------
 
 RegisterID* NullNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
@@ -130,11 +123,10 @@ RegisterID* StringNode::emitBytecode(BytecodeGenerator& generator, RegisterID* d
 
 RegisterID* RegExpNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
 {
-    RefPtr<RegExp> regExp = generator.globalData()->regExpCache()->lookupOrCreate(m_pattern.ustring(), m_flags.ustring());
-    if (!regExp->isValid())
-        return emitThrowSyntaxError(generator, makeUString("Invalid regular expression: ", regExp->errorMessage()));
     if (dst == generator.ignoredResult())
         return 0;
+    RefPtr<RegExp> regExp = generator.globalData()->regExpCache()->lookupOrCreate(m_pattern.ustring(), m_flags.ustring());
+    ASSERT(regExp->isValid());
     return generator.emitNewRegExp(generator.finalDestination(dst), regExp.get());
 }
 
@@ -1641,12 +1633,7 @@ RegisterID* ContinueNode::emitBytecode(BytecodeGenerator& generator, RegisterID*
     generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
     
     LabelScope* scope = generator.continueTarget(m_ident);
-
-    if (!scope) {
-        if (m_ident.isEmpty())
-            return emitThrowSyntaxError(generator, "Invalid continue statement.");
-        return emitThrowSyntaxError(generator, makeUString("Undefined label: '", m_ident.ustring(), "'."));
-    }
+    ASSERT(scope);
 
     generator.emitJumpScopes(scope->continueTarget(), scope->scopeDepth());
     return dst;
@@ -1660,12 +1647,7 @@ RegisterID* BreakNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
     generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
     
     LabelScope* scope = generator.breakTarget(m_ident);
-    
-    if (!scope) {
-        if (m_ident.isEmpty())
-            return emitThrowSyntaxError(generator, "Invalid break statement.");
-        return emitThrowSyntaxError(generator, makeUString("Undefined label: '", m_ident.ustring(), "'."));
-    }
+    ASSERT(scope);
 
     generator.emitJumpScopes(scope->breakTarget(), scope->scopeDepth());
     return dst;
@@ -1676,8 +1658,7 @@ RegisterID* BreakNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
 RegisterID* ReturnNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
 {
     generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
-    if (generator.codeType() != FunctionCode)
-        return emitThrowSyntaxError(generator, "Invalid return statement.");
+    ASSERT(generator.codeType() == FunctionCode);
 
     if (dst == generator.ignoredResult())
         dst = 0;
@@ -1882,8 +1863,7 @@ RegisterID* LabelNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
 {
     generator.emitDebugHook(WillExecuteStatement, firstLine(), lastLine());
 
-    if (generator.breakTarget(m_name))
-        return emitThrowSyntaxError(generator, makeUString("Duplicate label: ", m_name.ustring(), "."));
+    ASSERT(!generator.breakTarget(m_name));
 
     RefPtr<LabelScope> scope = generator.newLabelScope(LabelScope::NamedLabel, &m_name);
     RegisterID* r0 = generator.emitNode(dst, m_statement);
index 57c068adc7558733947d5d9995111a42e3d4946b..99bc81a268dcb594c75d4aa13cfe89961d9f311f 100644 (file)
@@ -4632,17 +4632,6 @@ skip_id_custom_self:
         exceptionValue = JSValue(createReferenceError(callFrame, message));
         goto vm_throw;
     }
-    DEFINE_OPCODE(op_throw_syntax_error) {
-        /* op_throw_syntax_error message(k)
-
-           Constructs a new syntax Error instance using the
-           original constructor, using constant message as the
-           message string. The result is thrown.
-        */
-        UString message = callFrame->r(vPC[1].u.operand).jsValue().toString(callFrame);
-        exceptionValue = JSValue(createSyntaxError(callFrame, message));
-        goto vm_throw;
-    }
     DEFINE_OPCODE(op_end) {
         /* end result(r)
            
index 01401a7298138497d0f17f61a9b849a9fd328ba6..e66b65e238371d027d845f255567a600530738b8 100644 (file)
@@ -318,7 +318,6 @@ void JIT::privateCompileMainPass()
         DEFINE_OP(op_tear_off_arguments)
         DEFINE_OP(op_throw)
         DEFINE_OP(op_throw_reference_error)
-        DEFINE_OP(op_throw_syntax_error)
         DEFINE_OP(op_to_jsnumber)
         DEFINE_OP(op_to_primitive)
 
index 907a774bb20a9db660fb4defa4d9f869a8e6ff7e..45ed4369d983fd82b80d2e395837254661f1e19a 100644 (file)
@@ -829,7 +829,6 @@ namespace JSC {
         void emit_op_tear_off_arguments(Instruction*);
         void emit_op_throw(Instruction*);
         void emit_op_throw_reference_error(Instruction*);
-        void emit_op_throw_syntax_error(Instruction*);
         void emit_op_to_jsnumber(Instruction*);
         void emit_op_to_primitive(Instruction*);
         void emit_op_unexpected_load(Instruction*);
index 972b8799b9ba3468899dd109015d3b9d4deffe38..98cb2f3191fdff10d26928c6947c840b8d683442 100644 (file)
@@ -1147,13 +1147,6 @@ void JIT::emit_op_throw_reference_error(Instruction* currentInstruction)
     stubCall.call();
 }
 
-void JIT::emit_op_throw_syntax_error(Instruction* currentInstruction)
-{
-    JITStubCall stubCall(this, cti_op_throw_syntax_error);
-    stubCall.addArgument(ImmPtr(JSValue::encode(m_codeBlock->getConstant(currentInstruction[1].u.operand))));
-    stubCall.call();
-}
-
 void JIT::emit_op_debug(Instruction* currentInstruction)
 {
 #if ENABLE(DEBUG_WITH_BREAKPOINT)
index 5a0aae563136b24f3971ee62ba3d984507261696..dda74c856622cda5ef6d626f67062b98f0b0a2bb 100644 (file)
@@ -1494,15 +1494,6 @@ void JIT::emit_op_throw_reference_error(Instruction* currentInstruction)
     stubCall.call();
 }
 
-void JIT::emit_op_throw_syntax_error(Instruction* currentInstruction)
-{
-    unsigned message = currentInstruction[1].u.operand;
-
-    JITStubCall stubCall(this, cti_op_throw_syntax_error);
-    stubCall.addArgument(m_codeBlock->getConstant(message));
-    stubCall.call();
-}
-
 void JIT::emit_op_debug(Instruction* currentInstruction)
 {
 #if ENABLE(DEBUG_WITH_BREAKPOINT)
index 0959a6e97a3cdb28bfa012a13d6b7ba902bbac32..201f322909a570fad4c04484b1426234015e3aea 100644 (file)
@@ -3567,16 +3567,6 @@ DEFINE_STUB_FUNCTION(void, op_throw_reference_error)
     VM_THROW_EXCEPTION_AT_END();
 }
 
-DEFINE_STUB_FUNCTION(void, op_throw_syntax_error)
-{
-    STUB_INIT_STACK_FRAME(stackFrame);
-
-    CallFrame* callFrame = stackFrame.callFrame;
-    UString message = stackFrame.args[0].jsValue().toString(callFrame);
-    stackFrame.globalData->exception = createSyntaxError(callFrame, message);
-    VM_THROW_EXCEPTION_AT_END();
-}
-
 DEFINE_STUB_FUNCTION(void, op_debug)
 {
     STUB_INIT_STACK_FRAME(stackFrame);
index 937134bb3b9efb96be1f548d1fad51ca19439abb..66edf451324f8921214282d2c02aa478c56a4963 100644 (file)
@@ -394,7 +394,6 @@ extern "C" {
     void JIT_STUB cti_op_tear_off_activation(STUB_ARGS_DECLARATION);
     void JIT_STUB cti_op_tear_off_arguments(STUB_ARGS_DECLARATION);
     void JIT_STUB cti_op_throw_reference_error(STUB_ARGS_DECLARATION);
-    void JIT_STUB cti_op_throw_syntax_error(STUB_ARGS_DECLARATION);
     void* JIT_STUB cti_op_call_arityCheck(STUB_ARGS_DECLARATION);
     void* JIT_STUB cti_op_construct_arityCheck(STUB_ARGS_DECLARATION);
     void* JIT_STUB cti_op_call_jitCompile(STUB_ARGS_DECLARATION);
index 04cf272862a5b16523946927828687ed556d3250..409c6ab537ed581eab7b951f9c11c536c199d845 100644 (file)
@@ -208,8 +208,10 @@ public:
         return node;
     }
 
-    ExpressionNode* createRegex(const Identifier& pattern, const Identifier& flags, int start)
+    ExpressionNode* createRegExp(const Identifier& pattern, const Identifier& flags, int start)
     {
+        if (Yarr::checkSyntax(pattern.ustring()))
+            return 0;
         RegExpNode* node = new (m_globalData) RegExpNode(m_globalData, pattern, flags);
         int size = pattern.length() + 2; // + 2 for the two /'s
         setExceptionLocation(node, start, start + size, start + size);
index 42015556a98b1011b1c0c1a83250deb0ca9122cb..142f4038b63685a34acc8b040c92ddf8f29bae12 100644 (file)
@@ -68,7 +68,7 @@ COMPILE_ASSERT(LastUntaggedToken < 64, LessThan64UntaggedTokens);
 class JSParser {
 public:
     JSParser(Lexer*, JSGlobalData*, FunctionParameters*, bool isStrictContext, bool isFunction, SourceProvider*);
-    bool parseProgram();
+    const char* parseProgram();
 private:
     struct AllowInOverride {
         AllowInOverride(JSParser* parser)
@@ -130,10 +130,28 @@ private:
     bool strictMode() { return currentScope()->strictMode(); }
     bool isValidStrictMode() { return currentScope()->isValidStrictMode(); }
     bool declareParameter(const Identifier* ident) { return currentScope()->declareParameter(ident); }
-    bool breakIsValid() { return currentScope()->breakIsValid(); }
+    bool breakIsValid()
+    {
+        ScopeRef current = currentScope();
+        while (!current->breakIsValid()) {
+            if (!current.hasContainingScope())
+                return false;
+            current = current.containingScope();
+        }
+        return true;
+    }
     void pushLabel(const Identifier* label) { currentScope()->pushLabel(label); }
     void popLabel() { currentScope()->popLabel(); }
-    bool hasLabel(const Identifier* label) { return currentScope()->hasLabel(label); }
+    bool hasLabel(const Identifier* label)
+    {
+        ScopeRef current = currentScope();
+        while (!current->hasLabel(label)) {
+            if (!current.hasContainingScope())
+                return false;
+            current = current.containingScope();
+        }
+        return true;
+    }
 
     enum SourceElementsMode { CheckForStrictMode, DontCheckForStrictMode };
     template <SourceElementsMode mode, class TreeBuilder> TreeSourceElements parseSourceElements(TreeBuilder&);
@@ -202,6 +220,7 @@ private:
     Lexer* m_lexer;
     StackBounds m_stack;
     bool m_error;
+    const char* m_errorMessage;
     JSGlobalData* m_globalData;
     JSToken m_token;
     bool m_allowsIn;
@@ -241,6 +260,7 @@ private:
             , m_allowsNewDecls(true)
             , m_strictMode(strictMode)
             , m_isFunction(isFunction)
+            , m_isFunctionBoundary(false)
             , m_isValidStrictMode(true)
             , m_loopDepth(0)
             , m_switchDepth(0)
@@ -280,8 +300,13 @@ private:
             return false;
         }
 
-        void setIsFunction() { m_isFunction = true; }
+        void setIsFunction()
+        {
+            m_isFunction = true;
+            m_isFunctionBoundary = true;
+        }
         bool isFunction() { return m_isFunction; }
+        bool isFunctionBoundary() { return m_isFunctionBoundary; }
         
         bool declareVariable(const Identifier* ident)
         {
@@ -376,6 +401,7 @@ private:
         bool m_allowsNewDecls : 1;
         bool m_strictMode : 1;
         bool m_isFunction : 1;
+        bool m_isFunctionBoundary : 1;
         bool m_isValidStrictMode : 1;
         int m_loopDepth;
         int m_switchDepth;
@@ -397,11 +423,45 @@ private:
         }
         Scope* operator->() { return &m_scopeStack->at(m_index); }
         unsigned index() const { return m_index; }
+
+        bool hasContainingScope()
+        {
+            return m_index && !m_scopeStack->at(m_index).isFunctionBoundary();
+        }
+
+        ScopeRef containingScope()
+        {
+            ASSERT(hasContainingScope());
+            return ScopeRef(m_scopeStack, m_index - 1);
+        }
+
     private:
         ScopeStack* m_scopeStack;
         unsigned m_index;
     };
-    
+
+    struct AutoPopScopeRef : public ScopeRef {
+        AutoPopScopeRef(JSParser* parser, ScopeRef scope)
+            : ScopeRef(scope)
+            , m_parser(parser)
+        {
+        }
+
+        ~AutoPopScopeRef()
+        {
+            if (m_parser)
+                m_parser->popScope(*this, false);
+        }
+
+        void setPopped()
+        {
+            m_parser = 0;
+        }
+
+    private:
+        JSParser* m_parser;
+    };
+
     ScopeRef currentScope()
     {
         return ScopeRef(&m_scopeStack, m_scopeStack.size() - 1);
@@ -419,7 +479,7 @@ private:
         return currentScope();
     }
 
-    bool popScope(ScopeRef scope, bool shouldTrackClosedVariables)
+    bool popScopeInternal(ScopeRef& scope, bool shouldTrackClosedVariables)
     {
         ASSERT_UNUSED(scope, scope.index() == m_scopeStack.size() - 1);
         ASSERT(m_scopeStack.size() > 1);
@@ -427,7 +487,18 @@ private:
         m_scopeStack.removeLast();
         return result;
     }
-    
+
+    bool popScope(ScopeRef& scope, bool shouldTrackClosedVariables)
+    {
+        return popScopeInternal(scope, shouldTrackClosedVariables);
+    }
+
+    bool popScope(AutoPopScopeRef& scope, bool shouldTrackClosedVariables)
+    {
+        scope.setPopped();
+        return popScopeInternal(scope, shouldTrackClosedVariables);
+    }
+
     bool declareVariable(const Identifier* ident)
     {
         unsigned i = m_scopeStack.size() - 1;
@@ -448,7 +519,7 @@ private:
     ScopeStack m_scopeStack;
 };
 
-int jsParse(JSGlobalData* globalData, FunctionParameters* parameters, JSParserStrictness strictness, JSParserMode parserMode, const SourceCode* source)
+const char* jsParse(JSGlobalData* globalData, FunctionParameters* parameters, JSParserStrictness strictness, JSParserMode parserMode, const SourceCode* source)
 {
     JSParser parser(globalData->lexer, globalData, parameters, strictness == JSParseStrict, parserMode == JSParseFunctionCode, source->provider());
     return parser.parseProgram();
@@ -458,6 +529,7 @@ JSParser::JSParser(Lexer* lexer, JSGlobalData* globalData, FunctionParameters* p
     : m_lexer(lexer)
     , m_stack(globalData->stack())
     , m_error(false)
+    , m_errorMessage("Parse error")
     , m_globalData(globalData)
     , m_allowsIn(true)
     , m_tokenCount(0)
@@ -483,7 +555,7 @@ JSParser::JSParser(Lexer* lexer, JSGlobalData* globalData, FunctionParameters* p
     m_lexer->setLastLineNumber(tokenLine());
 }
 
-bool JSParser::parseProgram()
+const char* JSParser::parseProgram()
 {
     ASTBuilder context(m_globalData, m_lexer);
     if (m_lexer->isReparsing())
@@ -491,7 +563,7 @@ bool JSParser::parseProgram()
     ScopeRef scope = currentScope();
     SourceElements* sourceElements = parseSourceElements<CheckForStrictMode>(context);
     if (!sourceElements || !consume(EOFTOK))
-        return true;
+        return m_errorMessage;
     IdentifierSet capturedVariables;
     scope->getCapturedVariables(capturedVariables);
     CodeFeatures features = context.features();
@@ -502,7 +574,7 @@ bool JSParser::parseProgram()
 
     m_globalData->parser->didFinishParsing(sourceElements, context.varDeclarations(), context.funcDeclarations(), features,
                                            m_lastLine, context.numConstants(), capturedVariables);
-    return false;
+    return 0;
 }
 
 bool JSParser::allowAutomaticSemicolon()
@@ -785,12 +857,12 @@ template <class TreeBuilder> TreeStatement JSParser::parseBreakStatement(TreeBui
     next();
 
     if (autoSemiColon()) {
-        failIfFalseIfStrict(breakIsValid());
+        failIfFalse(breakIsValid());
         return context.createBreakStatement(startCol, endCol, startLine, endLine);
     }
     matchOrFail(IDENT);
     const Identifier* ident = m_token.m_data.ident;
-    failIfFalseIfStrict(hasLabel(ident));
+    failIfFalse(hasLabel(ident));
     endCol = tokenEnd();
     endLine = tokenLine();
     next();
@@ -808,12 +880,12 @@ template <class TreeBuilder> TreeStatement JSParser::parseContinueStatement(Tree
     next();
 
     if (autoSemiColon()) {
-        failIfFalseIfStrict(breakIsValid());
+        failIfFalse(breakIsValid());
         return context.createContinueStatement(startCol, endCol, startLine, endLine);
     }
     matchOrFail(IDENT);
     const Identifier* ident = m_token.m_data.ident;
-    failIfFalseIfStrict(hasLabel(ident));
+    failIfFalse(hasLabel(ident));
     endCol = tokenEnd();
     endLine = tokenLine();
     next();
@@ -824,7 +896,7 @@ template <class TreeBuilder> TreeStatement JSParser::parseContinueStatement(Tree
 template <class TreeBuilder> TreeStatement JSParser::parseReturnStatement(TreeBuilder& context)
 {
     ASSERT(match(RETURN));
-    failIfFalseIfStrict(currentScope()->isFunction());
+    failIfFalse(currentScope()->isFunction());
     int startLine = tokenLine();
     int endLine = startLine;
     int start = tokenStart();
@@ -974,7 +1046,7 @@ template <class TreeBuilder> TreeStatement JSParser::parseTryStatement(TreeBuild
         matchOrFail(IDENT);
         ident = m_token.m_data.ident;
         next();
-        ScopeRef catchScope = pushScope();
+        AutoPopScopeRef catchScope(this, pushScope());
         failIfFalseIfStrict(catchScope->declareVariable(ident));
         catchScope->preventNewDecls();
         consumeOrFail(CLOSEPAREN);
@@ -1118,7 +1190,7 @@ template <class TreeBuilder> TreeFunctionBody JSParser::parseFunctionBody(TreeBu
 
 template <JSParser::FunctionRequirements requirements, bool nameIsInContainingScope, class TreeBuilder> bool JSParser::parseFunctionInfo(TreeBuilder& context, const Identifier*& name, TreeFormalParameterList& parameters, TreeFunctionBody& body, int& openBracePos, int& closeBracePos, int& bodyStartLine)
 {
-    ScopeRef functionScope = pushScope();
+    AutoPopScopeRef functionScope(this, pushScope());
     functionScope->setIsFunction();
     if (match(IDENT)) {
         name = m_token.m_data.ident;
@@ -1188,10 +1260,12 @@ template <class TreeBuilder> TreeStatement JSParser::parseExpressionOrLabelState
     int end = tokenEnd();
     consumeOrFail(COLON);
     const Identifier* unused = 0;
-    if (strictMode() && !m_syntaxAlreadyValidated)
+    if (!m_syntaxAlreadyValidated) {
+        failIfTrue(hasLabel(ident));
         pushLabel(ident);
+    }
     TreeStatement statement = parseStatement(context, unused);
-    if (strictMode() && !m_syntaxAlreadyValidated)
+    if (!m_syntaxAlreadyValidated)
         popLabel();
     failIfFalse(statement);
     return context.createLabelStatement(ident, statement, start, end);
@@ -1679,7 +1753,13 @@ template <class TreeBuilder> TreeExpression JSParser::parsePrimaryExpression(Tre
 
         int start = tokenStart();
         next();
-        return context.createRegex(*pattern, *flags, start);
+        TreeExpression re = context.createRegExp(*pattern, *flags, start);
+        if (!re) {
+            m_errorMessage = Yarr::checkSyntax(pattern->ustring());
+            ASSERT(m_errorMessage);
+            fail();
+        }
+        return re;
     }
     default:
         fail();
index 0676b4119bfeb9f5cfa1692dff360233dd0b149b..8bb7dbbb3a3e79fa9f22d8385e5555456994ca42 100644 (file)
@@ -159,6 +159,6 @@ struct JSToken {
 enum JSParserStrictness { JSParseNormal, JSParseStrict };
 enum JSParserMode { JSParseProgramCode, JSParseFunctionCode };
 
-int jsParse(JSGlobalData*, FunctionParameters*, JSParserStrictness, JSParserMode, const SourceCode*);
+const char* jsParse(JSGlobalData*, FunctionParameters*, JSParserStrictness, JSParserMode, const SourceCode*);
 }
 #endif // JSParser_h
index b8e9cdfb64bf757c10bf7fc302ed186cf25500c8..54b7231a339607be9c5dfd25f32a74992afdeb4f 100644 (file)
@@ -273,7 +273,6 @@ namespace JSC {
 
     protected:
         RegisterID* emitThrowReferenceError(BytecodeGenerator&, const UString& message);
-        RegisterID* emitThrowSyntaxError(BytecodeGenerator&, const UString& message);
 
     private:
         uint32_t m_divot;
index 7d9505177368b44a3f02005d020a4a5c7d432319..fc1e986683ee6dce40932af61bbf93633b8e978b 100644 (file)
@@ -48,14 +48,14 @@ void Parser::parse(JSGlobalData* globalData, FunctionParameters* parameters, JSP
     Lexer& lexer = *globalData->lexer;
     lexer.setCode(*m_source, m_arena);
 
-    int parseError = jsParse(globalData, parameters, strictness, mode, m_source);
+    const char* parseError = jsParse(globalData, parameters, strictness, mode, m_source);
     int lineNumber = lexer.lineNumber();
     bool lexError = lexer.sawError();
     lexer.clear();
 
     if (parseError || lexError) {
         *errLine = lineNumber;
-        *errMsg = "Parse error";
+        *errMsg = parseError ? parseError : "Parse error";
         m_sourceElements = 0;
     }
 }
index b00e710e352068d6c39cbd281eac67d00031b3d4..1fab41fb300dd79b6c5335ff701eb334e27da5c5 100644 (file)
@@ -26,6 +26,8 @@
 #ifndef SyntaxChecker_h
 #define SyntaxChecker_h
 
+#include "YarrSyntaxChecker.h"
+
 namespace JSC {
 class SyntaxChecker {
 public:
@@ -107,7 +109,7 @@ public:
     ExpressionType createNull() { return NullExpr; }
     ExpressionType createBracketAccess(ExpressionType, ExpressionType, bool, int, int, int) { return BracketExpr; }
     ExpressionType createDotAccess(ExpressionType, const Identifier&, int, int, int) { return DotExpr; }
-    ExpressionType createRegex(const Identifier&, const Identifier&, int) { return RegExpExpr; }
+    ExpressionType createRegExp(const Identifier& pattern, const Identifier&, int) { return Yarr::checkSyntax(pattern.ustring()) ? 0 : RegExpExpr; }
     ExpressionType createNewExpr(ExpressionType, int, int, int, int) { return NewExpr; }
     ExpressionType createNewExpr(ExpressionType, int, int) { return NewExpr; }
     ExpressionType createConditionalExpr(ExpressionType, ExpressionType, ExpressionType) { return ConditionalExpr; }
index 1ef264cb5ed92e96427c484f1257f0d66102564d..4a58800164a0d0a94dcfc0d976eff5eb59676b76 100644 (file)
@@ -130,11 +130,16 @@ JSObject* createNotAnObjectError(ExecState* exec, JSValue value)
 JSObject* createErrorForInvalidGlobalAssignment(ExecState* exec, const UString& propertyName)
 {
     return createReferenceError(exec, makeUString("Strict mode forbids implicit creation of global property '", propertyName, "'"));
-}    
+}
+
+JSObject* createOutOfMemoryError(JSGlobalObject* globalObject)
+{
+    return createError(globalObject, "Out of memory");
+}
 
 JSObject* throwOutOfMemoryError(ExecState* exec)
 {
-    return throwError(exec, createError(exec, "Out of memory"));
+    return throwError(exec, createOutOfMemoryError(exec->lexicalGlobalObject()));
 }
 
 JSObject* throwStackOverflowError(ExecState* exec)
index 7edffad803ccbf54971766d8f5ea52bb806e59ea..5f1ec6f1c24443558239ff69e804a5f7249c1480 100644 (file)
@@ -47,6 +47,7 @@ namespace JSC {
     JSObject* createTerminatedExecutionException(JSGlobalData*);
     JSObject* createStackOverflowError(ExecState*);
     JSObject* createStackOverflowError(JSGlobalObject*);
+    JSObject* createOutOfMemoryError(JSGlobalObject*);
     JSObject* createUndefinedVariableError(ExecState*, const Identifier&);
     JSObject* createNotAnObjectError(ExecState*, JSValue);
     JSObject* createInvalidParamError(ExecState*, const char* op, JSValue);
index c7262beed916d93c6532096b787d696f75ca501e..25c551b243348438fc9089a379537b42929511e2 100644 (file)
@@ -109,8 +109,12 @@ JSObject* EvalExecutable::compileInternal(ExecState* exec, ScopeChainNode* scope
     ASSERT(!m_evalCodeBlock);
     m_evalCodeBlock = adoptPtr(new EvalCodeBlock(this, globalObject, source().provider(), scopeChain.localDepth()));
     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(evalNode.get(), scopeChain, m_evalCodeBlock->symbolTable(), m_evalCodeBlock.get())));
-    generator->generate();
-    
+    if ((exception = generator->generate())) {
+        m_evalCodeBlock.clear();
+        evalNode->destroyData();
+        return exception;
+    }
+
     evalNode->destroyData();
 
 #if ENABLE(JIT)
@@ -157,7 +161,11 @@ JSObject* ProgramExecutable::compileInternal(ExecState* exec, ScopeChainNode* sc
     
     m_programCodeBlock = adoptPtr(new ProgramCodeBlock(this, GlobalCode, globalObject, source().provider()));
     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(programNode.get(), scopeChain, &globalObject->symbolTable(), m_programCodeBlock.get())));
-    generator->generate();
+    if ((exception = generator->generate())) {
+        m_programCodeBlock.clear();
+        programNode->destroyData();
+        return exception;
+    }
 
     programNode->destroyData();
 
@@ -194,7 +202,12 @@ JSObject* FunctionExecutable::compileForCallInternal(ExecState* exec, ScopeChain
     ASSERT(!m_codeBlockForCall);
     m_codeBlockForCall = adoptPtr(new FunctionCodeBlock(this, FunctionCode, globalObject, source().provider(), source().startOffset(), false));
     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), scopeChain, m_codeBlockForCall->symbolTable(), m_codeBlockForCall.get())));
-    generator->generate();
+    if ((exception = generator->generate())) {
+        m_codeBlockForCall.clear();
+        body->destroyData();
+        return exception;
+    }
+
     m_numParametersForCall = m_codeBlockForCall->m_numParameters;
     ASSERT(m_numParametersForCall);
     m_numCapturedVariables = m_codeBlockForCall->m_numCapturedVars;
@@ -235,7 +248,12 @@ JSObject* FunctionExecutable::compileForConstructInternal(ExecState* exec, Scope
     ASSERT(!m_codeBlockForConstruct);
     m_codeBlockForConstruct = adoptPtr(new FunctionCodeBlock(this, FunctionCode, globalObject, source().provider(), source().startOffset(), true));
     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), scopeChain, m_codeBlockForConstruct->symbolTable(), m_codeBlockForConstruct.get())));
-    generator->generate();
+    if ((exception = generator->generate())) {
+        m_codeBlockForConstruct.clear();
+        body->destroyData();
+        return exception;
+    }
+
     m_numParametersForConstruct = m_codeBlockForConstruct->m_numParameters;
     ASSERT(m_numParametersForConstruct);
     m_numCapturedVariables = m_codeBlockForConstruct->m_numCapturedVars;
index 21ca170b6b85ae891fb31af41ba8da049bb996fa..30d3eab53a64ad72731392043563be8d5b313e00 100644 (file)
@@ -307,7 +307,7 @@ JSObject* constructRegExp(ExecState* exec, const ArgList& args)
 
     RefPtr<RegExp> regExp = exec->globalData().regExpCache()->lookupOrCreate(pattern, flags);
     if (!regExp->isValid())
-        return throwError(exec, createSyntaxError(exec, makeUString("Invalid regular expression: ", regExp->errorMessage())));
+        return throwError(exec, createSyntaxError(exec, regExp->errorMessage()));
     return new (exec) RegExpObject(exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regExp.release());
 }
 
index 0a4c8bf5736a02f8f5e98cb62988ca9b33208701..04bcc3b655de1d8ee35aa4880eef592ce7054653 100644 (file)
@@ -95,7 +95,7 @@ EncodedJSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec)
     }
 
     if (!regExp->isValid())
-        return throwVMError(exec, createSyntaxError(exec, makeUString("Invalid regular expression: ", regExp->errorMessage())));
+        return throwVMError(exec, createSyntaxError(exec, regExp->errorMessage()));
 
     asRegExpObject(thisValue)->setRegExp(regExp.release());
     asRegExpObject(thisValue)->setLastIndex(0);
index ec5f58999ac5901793c38286095ca092820ab5e7..2e42f8ac9f21e2da28d9418acb1163ba2a1a50a6 100644 (file)
@@ -34,6 +34,7 @@
 namespace JSC { namespace Yarr {
 
 static const unsigned quantifyInfinite = UINT_MAX;
+#define REGEXP_ERROR_PREFIX "Invalid regular expression: "
 
 enum BuiltInCharacterClassID {
     DigitClassID,
@@ -673,31 +674,24 @@ private:
      */
     const char* parse()
     {
-        m_delegate.regexBegin();
-
         if (m_size > MAX_PATTERN_SIZE)
             m_err = PatternTooLarge;
         else
             parseTokens();
         ASSERT(atEndOfPattern() || m_err);
 
-        if (m_err)
-            m_delegate.regexError();
-        else
-            m_delegate.regexEnd();
-
         // The order of this array must match the ErrorCode enum.
         static const char* errorMessages[NumberOfErrorCodes] = {
             0, // NoError
-            "regular expression too large",
-            "numbers out of order in {} quantifier",
-            "nothing to repeat",
-            "missing )",
-            "unmatched parentheses",
-            "unrecognized character after (?",
-            "missing terminating ] for character class",
-            "range out of order in character class",
-            "\\ at end of pattern"
+            REGEXP_ERROR_PREFIX "regular expression too large",
+            REGEXP_ERROR_PREFIX "numbers out of order in {} quantifier",
+            REGEXP_ERROR_PREFIX "nothing to repeat",
+            REGEXP_ERROR_PREFIX "missing )",
+            REGEXP_ERROR_PREFIX "unmatched parentheses",
+            REGEXP_ERROR_PREFIX "unrecognized character after (?",
+            REGEXP_ERROR_PREFIX "missing terminating ] for character class",
+            REGEXP_ERROR_PREFIX "range out of order in character class",
+            REGEXP_ERROR_PREFIX "\\ at end of pattern"
         };
 
         return errorMessages[m_err];
@@ -839,14 +833,6 @@ private:
  *
  *    void disjunction();
  *
- *    void regexBegin();
- *    void regexEnd();
- *    void regexError();
- *
- * Before any call recording tokens are made, regexBegin() will be called on the
- * delegate once.  Once parsing is complete either regexEnd() or regexError() will
- * be called, as appropriate.
- *
  * The regular expression is described by a sequence of assertion*() and atom*()
  * callbacks to the delegate, describing the terms in the regular expression.
  * Following an atom a quantifyAtom() call may occur to indicate that the previous
index e737d0e54d800503e5cbc57fb639db40726f4c6e..f9aa92d488a97d4468f44d3d96fb53caab41effb 100644 (file)
@@ -611,12 +611,6 @@ public:
         m_alternative = m_pattern.m_body->addNewAlternative();
         m_pattern.m_disjunctions.append(m_pattern.m_body);
     }
-    void regexEnd()
-    {
-    }
-    void regexError()
-    {
-    }
 
     unsigned setupAlternativeOffsets(PatternAlternative* alternative, unsigned currentCallFrameSize, unsigned initialInputPosition)
     {
@@ -940,6 +934,7 @@ static const char* compileRegex(const UString& patternString, RegexPattern& patt
 {
     RegexPatternConstructor constructor(pattern);
 
+    constructor.regexBegin();
     if (const char* error = parse(constructor, patternString))
         return error;
     
@@ -951,6 +946,7 @@ static const char* compileRegex(const UString& patternString, RegexPattern& patt
         unsigned numSubpatterns = pattern.m_numSubpatterns;
 
         constructor.reset();
+        constructor.regexBegin();
 #if !ASSERT_DISABLED
         const char* error =
 #endif
diff --git a/Source/JavaScriptCore/yarr/YarrSyntaxChecker.cpp b/Source/JavaScriptCore/yarr/YarrSyntaxChecker.cpp
new file mode 100644 (file)
index 0000000..a023082
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "YarrSyntaxChecker.h"
+
+#include "RegexParser.h"
+
+namespace JSC { namespace Yarr {
+
+class SyntaxChecker {
+public:
+    void assertionBOL() {}
+    void assertionEOL() {}
+    void assertionWordBoundary(bool) {}
+    void atomPatternCharacter(UChar) {}
+    void atomBuiltInCharacterClass(BuiltInCharacterClassID, bool) {}
+    void atomCharacterClassBegin(bool = false) {}
+    void atomCharacterClassAtom(UChar) {}
+    void atomCharacterClassRange(UChar, UChar) {}
+    void atomCharacterClassBuiltIn(BuiltInCharacterClassID, bool) {}
+    void atomCharacterClassEnd() {}
+    void atomParenthesesSubpatternBegin(bool = true) {}
+    void atomParentheticalAssertionBegin(bool = false) {}
+    void atomParenthesesEnd() {}
+    void atomBackReference(unsigned) {}
+    void quantifyAtom(unsigned, unsigned, bool) {}
+    void disjunction() {}
+};
+
+const char* checkSyntax(const UString& pattern)
+{
+    SyntaxChecker syntaxChecker;
+    return parse(syntaxChecker, pattern);
+}
+
+}} // JSC::YARR
diff --git a/Source/JavaScriptCore/yarr/YarrSyntaxChecker.h b/Source/JavaScriptCore/yarr/YarrSyntaxChecker.h
new file mode 100644 (file)
index 0000000..e48cb9e
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef YarrSyntaxChecker_h
+#define YarrSyntaxChecker_h
+
+#include <UString.h>
+
+namespace JSC { namespace Yarr {
+
+const char* checkSyntax(const UString& pattern);
+
+}} // JSC::YARR
+
+#endif // YarrSyntaxChecker_h
+