Title: [182034] trunk
Revision
182034
Author
[email protected]
Date
2015-03-26 16:12:39 -0700 (Thu, 26 Mar 2015)

Log Message

Assertion firing in _javascript_Core/parser/parser.h for statesman.com site
https://bugs.webkit.org/show_bug.cgi?id=142974

Reviewed by Joseph Pecoraro.

Source/_javascript_Core:

This patch does two things:

(1) Restore _javascript_Core's sanitization of line and column numbers to
one-based values.

We need this because WebCore sometimes provides huge negative column
numbers.

(2) Solve the attribute event listener line numbering problem a different
way: Rather than offseting all line numbers by -1 in an attribute event
listener in order to arrange for a custom result, instead use an explicit
feature for saying "all errors in this code should map to this line number".

* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedFunctionExecutable::link):
(JSC::UnlinkedFunctionExecutable::fromGlobalCode):
* bytecode/UnlinkedCodeBlock.h:
* interpreter/Interpreter.cpp:
(JSC::StackFrame::computeLineAndColumn):
(JSC::GetStackTraceFunctor::operator()):
* interpreter/Interpreter.h:
* interpreter/StackVisitor.cpp:
(JSC::StackVisitor::Frame::computeLineAndColumn):
* parser/ParserError.h:
(JSC::ParserError::toErrorObject): Plumb through an override line number.
When a function has an override line number, all syntax and runtime
errors in the function will map to it. This is useful for attribute event
listeners.
 
* parser/SourceCode.h:
(JSC::SourceCode::SourceCode): Restore the old sanitization of line and
column numbers to one-based integers. It was kind of a hack to remove this.

* runtime/Executable.cpp:
(JSC::ScriptExecutable::ScriptExecutable):
(JSC::FunctionExecutable::fromGlobalCode):
* runtime/Executable.h:
(JSC::ScriptExecutable::setOverrideLineNo):
(JSC::ScriptExecutable::hasOverrideLineNo):
(JSC::ScriptExecutable::overrideLineNo):
* runtime/FunctionConstructor.cpp:
(JSC::constructFunctionSkippingEvalEnabledCheck):
* runtime/FunctionConstructor.h: Plumb through an override line number.

Source/WebCore:

* bindings/js/JSLazyEventListener.cpp:
(WebCore::JSLazyEventListener::initializeJSFunction): Use the new override
line number API to guarantee that errors will map to the .html file locations
that we like.

* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::eventHandlerPosition): Added a FIXME to cover
some cases where our line and column numbers are still nonsense.

LayoutTests:

No test covering this ASSERT because I couldn't design a way to reproduce
it after trying for a few hours. Simply loading the original ASSERTing
content from disk is not enough to reproduce this bug.

* fast/profiler/dead-time-expected.txt:
* fast/profiler/inline-event-handler-expected.txt:
* fast/profiler/stop-profiling-after-setTimeout-expected.txt: These are
progressions, where we used to get the line number wrong.

* fast/dom/attribute-event-listener-errors-expected.txt: Added.
* fast/dom/attribute-event-listener-errors.html: Added. This test covers
a subtle way in which the new mechanism for attribute event listener
line numbers is more accurate than the old one.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (182033 => 182034)


--- trunk/LayoutTests/ChangeLog	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/LayoutTests/ChangeLog	2015-03-26 23:12:39 UTC (rev 182034)
@@ -1,3 +1,24 @@
+2015-03-26  Geoffrey Garen  <[email protected]>
+
+        Assertion firing in _javascript_Core/parser/parser.h for statesman.com site
+        https://bugs.webkit.org/show_bug.cgi?id=142974
+
+        Reviewed by Joseph Pecoraro.
+
+        No test covering this ASSERT because I couldn't design a way to reproduce
+        it after trying for a few hours. Simply loading the original ASSERTing
+        content from disk is not enough to reproduce this bug.
+
+        * fast/profiler/dead-time-expected.txt:
+        * fast/profiler/inline-event-handler-expected.txt:
+        * fast/profiler/stop-profiling-after-setTimeout-expected.txt: These are
+        progressions, where we used to get the line number wrong.
+
+        * fast/dom/attribute-event-listener-errors-expected.txt: Added.
+        * fast/dom/attribute-event-listener-errors.html: Added. This test covers
+        a subtle way in which the new mechanism for attribute event listener
+        line numbers is more accurate than the old one.
+
 2015-03-26  Brady Eidson  <[email protected]>
 
         Apply ContentExtension actions after redirects.

Added: trunk/LayoutTests/fast/dom/attribute-event-listener-errors-expected.txt (0 => 182034)


--- trunk/LayoutTests/fast/dom/attribute-event-listener-errors-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/attribute-event-listener-errors-expected.txt	2015-03-26 23:12:39 UTC (rev 182034)
@@ -0,0 +1,4 @@
+CONSOLE MESSAGE: line 4: ReferenceError: Can't find variable: error
+CONSOLE MESSAGE: line 5: SyntaxError: Invalid character: '@'
+This test verifies that an attribute event listener error shows the right line number even if the attribute contains newlines.
+  

Added: trunk/LayoutTests/fast/dom/attribute-event-listener-errors.html (0 => 182034)


--- trunk/LayoutTests/fast/dom/attribute-event-listener-errors.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/attribute-event-listener-errors.html	2015-03-26 23:12:39 UTC (rev 182034)
@@ -0,0 +1,15 @@
+<body>
+	<pre>This test verifies that an attribute event listener error shows the right line number even if the attribute contains newlines.</pre>
+
+	<button id ="1" _onclick_="&#10;&#10;&#10;error()"></button>
+	<button id ="2" _onclick_="&#10;&#10;&#10;$@_."></button>
+
+<script>
+if (window.testRunner)
+	testRunner.dumpAsText();
+
+document.getElementById("1").click();
+document.getElementById("2").click();
+</script>
+
+</body>

Modified: trunk/LayoutTests/fast/profiler/dead-time-expected.txt (182033 => 182034)


--- trunk/LayoutTests/fast/profiler/dead-time-expected.txt	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/LayoutTests/fast/profiler/dead-time-expected.txt	2015-03-26 23:12:39 UTC (rev 182034)
@@ -4,7 +4,7 @@
 
 Profile title: Dead time in profile.
 Thread_1 (no file) (line 0:0)
-   onload dead-time.html (line 20:52)
+   onload dead-time.html (line 21:52)
       startTest dead-time.html (line 13:1)
          setTimeout (no file) (line 0:0)
    (program) dead-time.html (line 1:1)

Modified: trunk/LayoutTests/fast/profiler/inline-event-handler-expected.txt (182033 => 182034)


--- trunk/LayoutTests/fast/profiler/inline-event-handler-expected.txt	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/LayoutTests/fast/profiler/inline-event-handler-expected.txt	2015-03-26 23:12:39 UTC (rev 182034)
@@ -7,7 +7,7 @@
    startTest inline-event-handler.html (line 11:1)
       getElementById (no file) (line 0:0)
       click (no file) (line 0:0)
-         onclick inline-event-handler.html (line 30:135)
+         onclick inline-event-handler.html (line 31:135)
             eventListener inline-event-handler.html (line 17:26)
                anonymousFunction profiler-test-JS-resources.js (line 29:37)
                   insertNewText profiler-test-JS-resources.js (line 17:26)

Modified: trunk/LayoutTests/fast/profiler/stop-profiling-after-setTimeout-expected.txt (182033 => 182034)


--- trunk/LayoutTests/fast/profiler/stop-profiling-after-setTimeout-expected.txt	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/LayoutTests/fast/profiler/stop-profiling-after-setTimeout-expected.txt	2015-03-26 23:12:39 UTC (rev 182034)
@@ -4,7 +4,7 @@
 
 Profile title: Stop profiling from a timeout
 Thread_1 (no file) (line 0:0)
-   onload stop-profiling-after-setTimeout.html (line 20:52)
+   onload stop-profiling-after-setTimeout.html (line 21:52)
       startTest stop-profiling-after-setTimeout.html (line 13:1)
          setTimeout (no file) (line 0:0)
    (program) stop-profiling-after-setTimeout.html (line 1:1)

Modified: trunk/Source/_javascript_Core/ChangeLog (182033 => 182034)


--- trunk/Source/_javascript_Core/ChangeLog	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-03-26 23:12:39 UTC (rev 182034)
@@ -1,3 +1,54 @@
+2015-03-26  Geoffrey Garen  <[email protected]>
+
+        Assertion firing in _javascript_Core/parser/parser.h for statesman.com site
+        https://bugs.webkit.org/show_bug.cgi?id=142974
+
+        Reviewed by Joseph Pecoraro.
+
+        This patch does two things:
+
+        (1) Restore _javascript_Core's sanitization of line and column numbers to
+        one-based values.
+
+        We need this because WebCore sometimes provides huge negative column
+        numbers.
+
+        (2) Solve the attribute event listener line numbering problem a different
+        way: Rather than offseting all line numbers by -1 in an attribute event
+        listener in order to arrange for a custom result, instead use an explicit
+        feature for saying "all errors in this code should map to this line number".
+
+        * bytecode/UnlinkedCodeBlock.cpp:
+        (JSC::UnlinkedFunctionExecutable::link):
+        (JSC::UnlinkedFunctionExecutable::fromGlobalCode):
+        * bytecode/UnlinkedCodeBlock.h:
+        * interpreter/Interpreter.cpp:
+        (JSC::StackFrame::computeLineAndColumn):
+        (JSC::GetStackTraceFunctor::operator()):
+        * interpreter/Interpreter.h:
+        * interpreter/StackVisitor.cpp:
+        (JSC::StackVisitor::Frame::computeLineAndColumn):
+        * parser/ParserError.h:
+        (JSC::ParserError::toErrorObject): Plumb through an override line number.
+        When a function has an override line number, all syntax and runtime
+        errors in the function will map to it. This is useful for attribute event
+        listeners.
+ 
+        * parser/SourceCode.h:
+        (JSC::SourceCode::SourceCode): Restore the old sanitization of line and
+        column numbers to one-based integers. It was kind of a hack to remove this.
+
+        * runtime/Executable.cpp:
+        (JSC::ScriptExecutable::ScriptExecutable):
+        (JSC::FunctionExecutable::fromGlobalCode):
+        * runtime/Executable.h:
+        (JSC::ScriptExecutable::setOverrideLineNo):
+        (JSC::ScriptExecutable::hasOverrideLineNo):
+        (JSC::ScriptExecutable::overrideLineNo):
+        * runtime/FunctionConstructor.cpp:
+        (JSC::constructFunctionSkippingEvalEnabledCheck):
+        * runtime/FunctionConstructor.h: Plumb through an override line number.
+
 2015-03-26  Filip Pizlo  <[email protected]>
 
         If we're in code for accessing scoped arguments, we should probably check if the object is a scoped arguments rather than checking if it's a direct arguments.

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp (182033 => 182034)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp	2015-03-26 23:12:39 UTC (rev 182034)
@@ -132,7 +132,7 @@
     visitor.append(&thisObject->m_symbolTableForConstruct);
 }
 
-FunctionExecutable* UnlinkedFunctionExecutable::link(VM& vm, const SourceCode& ownerSource)
+FunctionExecutable* UnlinkedFunctionExecutable::link(VM& vm, const SourceCode& ownerSource, int overrideLineNo)
 {
     SourceCode source = m_sourceOverride ? SourceCode(m_sourceOverride) : ownerSource;
     unsigned firstLine = source.firstLine() + m_firstLineOffset;
@@ -145,10 +145,15 @@
     unsigned endColumn = m_unlinkedBodyEndColumn + (endColumnIsOnStartLine ? startColumn : 1);
 
     SourceCode code(source.provider(), startOffset, startOffset + m_sourceLength, firstLine, startColumn);
-    return FunctionExecutable::create(vm, code, this, firstLine, firstLine + m_lineCount, startColumn, endColumn);
+    FunctionExecutable* result = FunctionExecutable::create(vm, code, this, firstLine, firstLine + m_lineCount, startColumn, endColumn);
+    if (overrideLineNo != -1)
+        result->setOverrideLineNo(overrideLineNo);
+    return result;
 }
 
-UnlinkedFunctionExecutable* UnlinkedFunctionExecutable::fromGlobalCode(const Identifier& name, ExecState& exec, const SourceCode& source, JSObject*& exception)
+UnlinkedFunctionExecutable* UnlinkedFunctionExecutable::fromGlobalCode(
+    const Identifier& name, ExecState& exec, const SourceCode& source, 
+    JSObject*& exception, int overrideLineNo)
 {
     ParserError error;
     VM& vm = exec.vm();
@@ -160,7 +165,7 @@
         globalObject.debugger()->sourceParsed(&exec, source.provider(), error.line(), error.message());
 
     if (error.isValid()) {
-        exception = error.toErrorObject(&globalObject, source);
+        exception = error.toErrorObject(&globalObject, source, overrideLineNo);
         return nullptr;
     }
 

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h (182033 => 182034)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h	2015-03-26 23:12:39 UTC (rev 182034)
@@ -136,9 +136,11 @@
         VM&, const SourceCode&, CodeSpecializationKind, DebuggerMode, ProfilerMode, 
         ParserError&);
 
-    static UnlinkedFunctionExecutable* fromGlobalCode(const Identifier&, ExecState&, const SourceCode&, JSObject*& exception);
+    static UnlinkedFunctionExecutable* fromGlobalCode(
+        const Identifier&, ExecState&, const SourceCode&, JSObject*& exception, 
+        int overrideLineNo);
 
-    FunctionExecutable* link(VM&, const SourceCode&);
+    FunctionExecutable* link(VM&, const SourceCode&, int overrideLineNo = -1);
 
     void clearCodeForRecompilation()
     {

Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (182033 => 182034)


--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp	2015-03-26 23:12:39 UTC (rev 182034)
@@ -440,6 +440,9 @@
 
     line = divotLine + lineOffset;
     column = divotColumn + (divotLine ? 1 : firstLineColumnOffset);
+
+    if (executable->hasOverrideLineNo())
+        line = executable->overrideLineNo();
 }
 
 void StackFrame::expressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column)
@@ -490,7 +493,7 @@
                 StackFrame s = {
                     Strong<JSObject>(vm, visitor->callee()),
                     getStackFrameCodeType(visitor),
-                    Strong<ExecutableBase>(vm, codeBlock->ownerExecutable()),
+                    Strong<ScriptExecutable>(vm, codeBlock->ownerExecutable()),
                     Strong<UnlinkedCodeBlock>(vm, codeBlock->unlinkedCodeBlock()),
                     codeBlock->source(),
                     codeBlock->ownerExecutable()->lineNo(),
@@ -501,7 +504,7 @@
                 };
                 m_results.append(s);
             } else {
-                StackFrame s = { Strong<JSObject>(vm, visitor->callee()), StackFrameNativeCode, Strong<ExecutableBase>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, 0, String()};
+                StackFrame s = { Strong<JSObject>(vm, visitor->callee()), StackFrameNativeCode, Strong<ScriptExecutable>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, 0, String()};
                 m_results.append(s);
             }
     

Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.h (182033 => 182034)


--- trunk/Source/_javascript_Core/interpreter/Interpreter.h	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.h	2015-03-26 23:12:39 UTC (rev 182034)
@@ -81,7 +81,7 @@
     struct StackFrame {
         Strong<JSObject> callee;
         StackFrameCodeType codeType;
-        Strong<ExecutableBase> executable;
+        Strong<ScriptExecutable> executable;
         Strong<UnlinkedCodeBlock> codeBlock;
         RefPtr<SourceProvider> code;
         int lineOffset;

Modified: trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp (182033 => 182034)


--- trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/interpreter/StackVisitor.cpp	2015-03-26 23:12:39 UTC (rev 182034)
@@ -293,6 +293,9 @@
 
     line = divotLine + codeBlock->ownerExecutable()->lineNo();
     column = divotColumn + (divotLine ? 1 : codeBlock->firstLineColumnOffset());
+
+    if (codeBlock->ownerExecutable()->hasOverrideLineNo())
+        line = codeBlock->ownerExecutable()->overrideLineNo();
 }
 
 void StackVisitor::Frame::retrieveExpressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column)

Modified: trunk/Source/_javascript_Core/parser/ParserError.h (182033 => 182034)


--- trunk/Source/_javascript_Core/parser/ParserError.h	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/parser/ParserError.h	2015-03-26 23:12:39 UTC (rev 182034)
@@ -85,13 +85,18 @@
     const String& message() const { return m_message; }
     int line() const { return m_line; }
 
-    JSObject* toErrorObject(JSGlobalObject* globalObject, const SourceCode& source)
+    JSObject* toErrorObject(
+        JSGlobalObject* globalObject, const SourceCode& source, 
+        int overrideLineNo = -1)
     {
         switch (m_type) {
         case ErrorNone:
             return nullptr;
         case SyntaxError:
-            return addErrorInfo(globalObject->globalExec(), createSyntaxError(globalObject, m_message), m_line, source);
+            return addErrorInfo(
+                globalObject->globalExec(), 
+                createSyntaxError(globalObject, m_message), 
+                overrideLineNo == -1 ? m_line : overrideLineNo, source);
         case EvalError:
             return createSyntaxError(globalObject, m_message);
         case StackOverflow: {

Modified: trunk/Source/_javascript_Core/parser/SourceCode.h (182033 => 182034)


--- trunk/Source/_javascript_Core/parser/SourceCode.h	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/parser/SourceCode.h	2015-03-26 23:12:39 UTC (rev 182034)
@@ -63,8 +63,8 @@
             : m_provider(provider)
             , m_startChar(0)
             , m_endChar(m_provider->source().length())
-            , m_firstLine(std::max(firstLine, 0))
-            , m_startColumn(std::max(startColumn, 0))
+            , m_firstLine(std::max(firstLine, 1))
+            , m_startColumn(std::max(startColumn, 1))
         {
         }
 
@@ -72,8 +72,8 @@
             : m_provider(provider)
             , m_startChar(start)
             , m_endChar(end)
-            , m_firstLine(std::max(firstLine, 0))
-            , m_startColumn(std::max(startColumn, 0))
+            , m_firstLine(std::max(firstLine, 1))
+            , m_startColumn(std::max(startColumn, 1))
         {
         }
 

Modified: trunk/Source/_javascript_Core/runtime/Executable.cpp (182033 => 182034)


--- trunk/Source/_javascript_Core/runtime/Executable.cpp	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/runtime/Executable.cpp	2015-03-26 23:12:39 UTC (rev 182034)
@@ -100,6 +100,7 @@
     , m_hasCapturedVariables(false)
     , m_neverInline(false)
     , m_didTryToEnterInLoop(false)
+    , m_overrideLineNo(-1)
     , m_firstLine(-1)
     , m_lastLine(-1)
     , m_startColumn(UINT_MAX)
@@ -608,12 +609,17 @@
 #endif
 }
 
-FunctionExecutable* FunctionExecutable::fromGlobalCode(const Identifier& name, ExecState& exec, const SourceCode& source, JSObject*& exception)
+FunctionExecutable* FunctionExecutable::fromGlobalCode(
+    const Identifier& name, ExecState& exec, const SourceCode& source, 
+    JSObject*& exception, int overrideLineNo)
 {
-    UnlinkedFunctionExecutable* unlinkedExecutable = UnlinkedFunctionExecutable::fromGlobalCode(name, exec, source, exception);
+    UnlinkedFunctionExecutable* unlinkedExecutable = 
+        UnlinkedFunctionExecutable::fromGlobalCode(
+            name, exec, source, exception, overrideLineNo);
     if (!unlinkedExecutable)
         return nullptr;
-    return unlinkedExecutable->link(exec.vm(), source);
+
+    return unlinkedExecutable->link(exec.vm(), source, overrideLineNo);
 }
 
 void ExecutableBase::dump(PrintStream& out) const

Modified: trunk/Source/_javascript_Core/runtime/Executable.h (182033 => 182034)


--- trunk/Source/_javascript_Core/runtime/Executable.h	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/runtime/Executable.h	2015-03-26 23:12:39 UTC (rev 182034)
@@ -358,6 +358,9 @@
     intptr_t sourceID() const { return m_source.providerID(); }
     const String& sourceURL() const { return m_source.provider()->url(); }
     int lineNo() const { return m_firstLine; }
+    void setOverrideLineNo(int overrideLineNo) { m_overrideLineNo = overrideLineNo; }
+    bool hasOverrideLineNo() const { return m_overrideLineNo != -1; }
+    int overrideLineNo() const { return m_overrideLineNo; }
     int lastLine() const { return m_lastLine; }
     unsigned startColumn() const { return m_startColumn; }
     unsigned endColumn() const { return m_endColumn; }
@@ -429,6 +432,7 @@
     bool m_hasCapturedVariables;
     bool m_neverInline;
     bool m_didTryToEnterInLoop;
+    int m_overrideLineNo;
     int m_firstLine;
     int m_lastLine;
     unsigned m_startColumn;
@@ -549,7 +553,9 @@
         executable->finishCreation(vm);
         return executable;
     }
-    static FunctionExecutable* fromGlobalCode(const Identifier& name, ExecState&, const SourceCode&, JSObject*& exception);
+    static FunctionExecutable* fromGlobalCode(
+        const Identifier& name, ExecState&, const SourceCode&, 
+        JSObject*& exception, int overrideLineNo);
 
     static void destroy(JSCell*);
         

Modified: trunk/Source/_javascript_Core/runtime/FunctionConstructor.cpp (182033 => 182034)


--- trunk/Source/_javascript_Core/runtime/FunctionConstructor.cpp	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/runtime/FunctionConstructor.cpp	2015-03-26 23:12:39 UTC (rev 182034)
@@ -86,7 +86,10 @@
     return constructFunctionSkippingEvalEnabledCheck(exec, globalObject, args, functionName, sourceURL, position);
 }
 
-JSObject* constructFunctionSkippingEvalEnabledCheck(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args, const Identifier& functionName, const String& sourceURL, const TextPosition& position)
+JSObject* constructFunctionSkippingEvalEnabledCheck(
+    ExecState* exec, JSGlobalObject* globalObject, const ArgList& args, 
+    const Identifier& functionName, const String& sourceURL, 
+    const TextPosition& position, int overrideLineNo)
 {
     // How we stringify functions is sometimes important for web compatibility.
     // See https://bugs.webkit.org/show_bug.cgi?id=24350.
@@ -113,7 +116,7 @@
 
     SourceCode source = makeSource(program, sourceURL, position);
     JSObject* exception = nullptr;
-    FunctionExecutable* function = FunctionExecutable::fromGlobalCode(functionName, *exec, source, exception);
+    FunctionExecutable* function = FunctionExecutable::fromGlobalCode(functionName, *exec, source, exception, overrideLineNo);
     if (!function) {
         ASSERT(exception);
         return exec->vm().throwException(exec, exception);

Modified: trunk/Source/_javascript_Core/runtime/FunctionConstructor.h (182033 => 182034)


--- trunk/Source/_javascript_Core/runtime/FunctionConstructor.h	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/_javascript_Core/runtime/FunctionConstructor.h	2015-03-26 23:12:39 UTC (rev 182034)
@@ -59,7 +59,9 @@
 JSObject* constructFunction(ExecState*, JSGlobalObject*, const ArgList&, const Identifier& functionName, const String& sourceURL, const WTF::TextPosition&);
 JSObject* constructFunction(ExecState*, JSGlobalObject*, const ArgList&);
 
-JS_EXPORT_PRIVATE JSObject* constructFunctionSkippingEvalEnabledCheck(ExecState*, JSGlobalObject*, const ArgList&, const Identifier&, const String&, const WTF::TextPosition&);
+JS_EXPORT_PRIVATE JSObject* constructFunctionSkippingEvalEnabledCheck(
+    ExecState*, JSGlobalObject*, const ArgList&, const Identifier&, 
+    const String&, const WTF::TextPosition&, int overrideLineNo = -1);
 
 } // namespace JSC
 

Modified: trunk/Source/WebCore/ChangeLog (182033 => 182034)


--- trunk/Source/WebCore/ChangeLog	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/WebCore/ChangeLog	2015-03-26 23:12:39 UTC (rev 182034)
@@ -1,3 +1,19 @@
+2015-03-26  Geoffrey Garen  <[email protected]>
+
+        Assertion firing in _javascript_Core/parser/parser.h for statesman.com site
+        https://bugs.webkit.org/show_bug.cgi?id=142974
+
+        Reviewed by Joseph Pecoraro.
+
+        * bindings/js/JSLazyEventListener.cpp:
+        (WebCore::JSLazyEventListener::initializeJSFunction): Use the new override
+        line number API to guarantee that errors will map to the .html file locations
+        that we like.
+
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::eventHandlerPosition): Added a FIXME to cover
+        some cases where our line and column numbers are still nonsense.
+
 2015-03-26  Beth Dakin  <[email protected]>
 
         Relevant repainted objects callback is inaccurate and inconsistent for PDF 

Modified: trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp (182033 => 182034)


--- trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp	2015-03-26 23:12:39 UTC (rev 182034)
@@ -24,6 +24,7 @@
 #include "Frame.h"
 #include "JSNode.h"
 #include "ScriptController.h"
+#include <runtime/Executable.h>
 #include <runtime/FunctionConstructor.h>
 #include <runtime/IdentifierInlines.h>
 #include <wtf/NeverDestroyed.h>
@@ -103,15 +104,13 @@
     args.append(jsNontrivialString(exec, m_eventParameterName));
     args.append(jsStringWithCache(exec, m_code));
 
-    // Move our text position backward one line. Creating an anonymous function
-    // will add a line for a function declaration, but we want our line number
-    // to match up with where the attribute was declared.
-    TextPosition position(
-        OrdinalNumber::fromOneBasedInt(
-            m_position.m_line.oneBasedInt() - 1), m_position.m_column);
+    // We want all errors to refer back to the line on which our attribute was
+    // declared, regardless of any newlines in our _javascript_ source text.
+    int overrideLineNo = m_position.m_line.oneBasedInt();
+
     JSObject* jsFunction = constructFunctionSkippingEvalEnabledCheck(
         exec, exec->lexicalGlobalObject(), args, Identifier(exec, m_functionName), 
-        m_sourceURL, position);
+        m_sourceURL, m_position, overrideLineNo);
 
     if (exec->hadException()) {
         reportCurrentException(exec);
@@ -120,6 +119,7 @@
     }
 
     JSFunction* listenerAsFunction = jsCast<JSFunction*>(jsFunction);
+
     if (m_originalNode) {
         if (!wrapper()) {
             // Ensure that 'node' has a _javascript_ wrapper to mark the event listener we're creating.

Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (182033 => 182034)


--- trunk/Source/WebCore/bindings/js/ScriptController.cpp	2015-03-26 23:06:27 UTC (rev 182033)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp	2015-03-26 23:12:39 UTC (rev 182034)
@@ -274,6 +274,11 @@
 
 TextPosition ScriptController::eventHandlerPosition() const
 {
+    // FIXME: If we are not currently parsing, we should use our current location
+    // in _javascript_, to cover cases like "element.setAttribute('click', ...)".
+
+    // FIXME: This location maps to the end of the HTML tag, and not to the
+    // exact column number belonging to the event handler attribute.
     ScriptableDocumentParser* parser = m_frame.document()->scriptableDocumentParser();
     if (parser)
         return parser->textPosition();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to