Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 437086

Summary: Esprima hangs when pasting in some css code
Product: [ECD] Orion Reporter: Bogdan Gheorghe <gheorghe>
Component: JS ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: Michael_Rennie
Version: 6.0   
Target Milestone: 6.0 RC1   
Hardware: All   
OS: All   
Whiteboard:

Description Bogdan Gheorghe CLA 2014-06-10 16:32:38 EDT
Esprima hangs my tab when pasting in some css code into a js file (never recovers).

Here are the steps:

1. Open a js file (I'm using gitCommitList.js).

2. Copy the following text:

#left-triangle {
   width: 0;
   height: 0;
   border-right: 100px solid orange;
   border-top: 50px solid transparent;
   border-bottom: 50px solid transparent;
}


3. Paste towards end of file (say line 595).

4. Don't save the file yet, but move the cursor to the line above the "#left-triangle"

5. Type in "document."

6. Freeze!
Comment 1 Michael Rennie CLA 2014-06-11 10:27:37 EDT
Reproduced. We get into an infinite loop (again) because we recover from the CSS in the JS file, but the index does not get advanced.
Comment 2 Michael Rennie CLA 2014-06-11 10:28:48 EDT
Heres the trace:

parseSwitchCase (esprima.js:3147)
parseSwitchStatement (esprima.js:3186)
parseStatement (esprima.js:3326)
(anonymous function) (esprima.js:4001)
parseSourceElement (esprima.js:3580)
parseFunctionSourceElements (esprima.js:3412)
parseFunctionExpression (esprima.js:3557)
parsePrimaryExpression (esprima.js:2236)
parseLeftHandSideExpressionAllowCall (esprima.js:2354)
parsePostfixExpression (esprima.js:2409)
parseUnaryExpression (esprima.js:2464)
parseBinaryExpression (esprima.js:2553)
parseConditionalExpression (esprima.js:2619)
parseAssignmentExpression (esprima.js:2645)
recoverProperty (esprima.js:2110)
parseObjectProperty (esprima.js:2087)
parseObjectInitialiser (esprima.js:2153)
parsePrimaryExpression (esprima.js:2249)
parseLeftHandSideExpressionAllowCall (esprima.js:2354)
parsePostfixExpression (esprima.js:2409)
parseUnaryExpression (esprima.js:2464)
parseBinaryExpression (esprima.js:2553)
parseConditionalExpression (esprima.js:2619)
parseAssignmentExpression (esprima.js:2645)
parseArguments (esprima.js:2276)
parseLeftHandSideExpressionAllowCall (esprima.js:2359)
parsePostfixExpression (esprima.js:2409)
parseUnaryExpression (esprima.js:2438)
parseBinaryExpression (esprima.js:2553)
parseConditionalExpression (esprima.js:2619)
parseAssignmentExpression (esprima.js:2645)
parseExpression (esprima.js:2672)
(anonymous function) (esprima.js:3980)
parseStatement (esprima.js:3342)
(anonymous function) (esprima.js:4001)
parseSourceElement (esprima.js:3585)
parseFunctionSourceElements (esprima.js:3412)
parseFunctionExpression (esprima.js:3557)
parsePrimaryExpression (esprima.js:2236)
parseLeftHandSideExpressionAllowCall (esprima.js:2354)
parsePostfixExpression (esprima.js:2409)
parseUnaryExpression (esprima.js:2464)
parseBinaryExpression (esprima.js:2553)
parseConditionalExpression (esprima.js:2619)
parseAssignmentExpression (esprima.js:2645)
parseArguments (esprima.js:2276)
parseLeftHandSideExpressionAllowCall (esprima.js:2359)
parsePostfixExpression (esprima.js:2409)
parseUnaryExpression (esprima.js:2438)
parseBinaryExpression (esprima.js:2553)
parseConditionalExpression (esprima.js:2619)
parseAssignmentExpression (esprima.js:2645)
parseExpression (esprima.js:2672)
(anonymous function) (esprima.js:3980)
parseStatement (esprima.js:3342)
(anonymous function) (esprima.js:4001)
parseSourceElement (esprima.js:3585)
parseSourceElements (esprima.js:3618)
parseProgram (esprima.js:3635)
parse (esprima.js:3901)
Objects.mixin.parse (astManager.js:70)
(anonymous function) (astManager.js:58)
settleDeferred (Deferred.js:71)
notify (Deferred.js:145)
run (Deferred.js:29)
Comment 3 Michael Rennie CLA 2014-06-11 10:49:05 EDT
Now this is just sad.

heres a simple snippet to reproduce:

switch(foo) {
    case 1:
    var
}