Changeset 149131 in webkit
- Timestamp:
- Apr 25, 2013 12:31:50 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r149126 r149131 1 2013-04-25 Joseph Pecoraro <pecoraro@apple.com> 2 3 ScriptExecutionContext log exception should include a column number 4 https://bugs.webkit.org/show_bug.cgi?id=114315 5 6 Reviewed by Oliver Hunt. 7 8 * inspector/console/console-exception-stack-traces-expected.txt: Added. 9 * inspector/console/console-exception-stack-traces.html: Added. 10 Verifies that exceptions have stack traces and match a console.trace stack. 11 12 * http/tests/inspector-enabled/console-exception-while-no-inspector-expected.txt: Removed. 13 * http/tests/inspector-enabled/console-exception-while-no-inspector.html: Removed. 14 We now save exception backtraces even if the inspector is not open. 15 16 * fast/dom/javascript-url-exception-isolation-expected.txt 17 * fast/events/remove-target-with-shadow-in-drag-expected.txt 18 * fast/events/set-attribute-listener-window-onerror-crash-expected.txt 19 * inspector-protocol/media-query-listener-exception-expected.txt: 20 * inspector/console/console-uncaught-exception-expected.txt: 21 * inspector/console/console-uncaught-exception-in-eval-expected.txt: 22 Update results that now include backtraces or different data. Most better, some worse. 23 1 24 2013-04-25 Ryosuke Niwa <rniwa@webkit.org> 2 25 -
trunk/LayoutTests/fast/dom/javascript-url-exception-isolation-expected.txt
r147872 r149131 1 1 CONSOLE MESSAGE: line 1: 42 2 CONSOLE MESSAGE: line 1 : SyntaxError: Unexpected token '<'2 CONSOLE MESSAGE: line 18: SyntaxError: Unexpected token '<' 3 3 Exceptions thrown in javascript URLs should not propagate to the main script. 4 4 -
trunk/LayoutTests/fast/events/remove-target-with-shadow-in-drag-expected.txt
r134618 r149131 1 CONSOLE MESSAGE: line 3 4: NotFoundError: DOM Exception 8: An attempt was made to reference a Node in a context where it does not exist.2 CONSOLE MESSAGE: line 3 4: NotFoundError: DOM Exception 8: An attempt was made to reference a Node in a context where it does not exist.1 CONSOLE MESSAGE: line 35: NotFoundError: DOM Exception 8: An attempt was made to reference a Node in a context where it does not exist. 2 CONSOLE MESSAGE: line 35: NotFoundError: DOM Exception 8: An attempt was made to reference a Node in a context where it does not exist. 3 3 PASS. DRT didn't crash. -
trunk/LayoutTests/fast/events/set-attribute-listener-window-onerror-crash-expected.txt
r127129 r149131 1 CONSOLE MESSAGE: line 1 6: SyntaxError: Unexpected token ';'1 CONSOLE MESSAGE: line 15: SyntaxError: Unexpected token ';' 2 2 Test passes if it does not crash. -
trunk/LayoutTests/inspector-protocol/media-query-listener-exception-expected.txt
r138010 r149131 1 CONSOLE MESSAGE: line 13: 2 CONSOLE MESSAGE: line 13: 1 CONSOLE MESSAGE: line 13: ReferenceError: Can't find variable: objectThatDoesNotExist 2 CONSOLE MESSAGE: line 13: ReferenceError: Can't find variable: objectThatDoesNotExist 3 3 Test that uncaught exception in MediaQueryListListener will be reported to the console. On success you should see two exceptions in the listener logged to the console (first time when the media type is overridden and second - when they are restored). Bug 105162. 4 4 -
trunk/LayoutTests/inspector/console/console-uncaught-exception-expected.txt
r127705 r149131 5 5 6 6 7 Error: Exception in inline script. resources/uncaught-in-iframe.html:18 8 Error: Exception in 'load' event listener. resources/uncaught-in-iframe.html:11 9 Error: Exception in setTimeout callback. uncaught-in-iframe.html:6 7 Error: Exception in inline script. resources/uncaught-in-iframe.html:18a resources/uncaught-in-iframe.html:18b resources/uncaught-in-iframe.html:23 8 Error: Exception in 'load' event listener. resources/uncaught-in-iframe.html:11f resources/uncaught-in-iframe.html:11(anonymous function) resources/uncaught-in-iframe.html:13 9 Error: Exception in setTimeout callback. uncaught-in-iframe.html:6bar uncaught-in-iframe.html:6(anonymous function) uncaught-in-iframe.html:8 10 10 -
trunk/LayoutTests/inspector/console/console-uncaught-exception-in-eval-expected.txt
r78535 r149131 4 4 5 5 Page reloaded. 6 Error: Exception in eval. 6 Error: Exception in eval. undefined:4b undefined:4aevalSource 7 7 -
trunk/Source/WebCore/ChangeLog
r149129 r149131 1 2013-04-25 Joseph Pecoraro <pecoraro@apple.com> 2 3 ScriptExecutionContext log exception should include a column number 4 https://bugs.webkit.org/show_bug.cgi?id=114315 5 6 Reviewed by Oliver Hunt. 7 8 Test: inspector/console/console-exception-stack-traces.html 9 10 * bindings/js/ScriptCallStackFactory.h: 11 * bindings/js/ScriptCallStackFactory.cpp: 12 (WebCore::createScriptCallStackFromException): 13 Generate a ScriptCallStack from an exception. Use the vm.exceptionStack 14 if available, and fallback to the exception object where needed. 15 16 * bindings/js/JSDOMBinding.cpp: 17 (WebCore::reportException): 18 Always include a non-empty call stack with exceptions. 19 Where not provided, fallback to the exception object. 20 21 * dom/Document.h: 22 * dom/Document.cpp: 23 (WebCore::Document::logExceptionToConsole): 24 * dom/ScriptExecutionContext.h: 25 * dom/ScriptExecutionContext.cpp: 26 (WebCore::ScriptExecutionContext::PendingException::PendingException): 27 (ScriptExecutionContext::PendingException): 28 (WebCore::ScriptExecutionContext::reportException): 29 * workers/DefaultSharedWorkerRepository.cpp: 30 * workers/SharedWorkerContext.cpp: 31 (WebCore::SharedWorkerContext::logExceptionToConsole): 32 * workers/SharedWorkerContext.h: 33 * workers/WorkerContext.cpp: 34 (WebCore::WorkerContext::logExceptionToConsole): 35 * workers/WorkerContext.h: 36 * workers/WorkerMessagingProxy.cpp: 37 (WebCore::WorkerExceptionTask::performTask): 38 Plumb columnNumber through as needed. 39 1 40 2013-04-25 Gregg Tavares <gman@chromium.org> 2 41 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp
r148696 r149131 34 34 #include "JSExceptionBase.h" 35 35 #include "ScriptCallStack.h" 36 #include "ScriptCallStackFactory.h" 36 37 #include <interpreter/Interpreter.h> 37 38 #include <runtime/DateInstance.h> … … 147 148 148 149 Interpreter::ErrorHandlingMode mode(exec); 149 String errorMessage = exception.toString(exec)->value(exec); 150 int lineNumber = 0; 151 String exceptionSourceURL; 152 153 RefCountedArray<StackFrame> stackTrace = exec->vm().exceptionStack; 150 151 RefPtr<ScriptCallStack> callStack(createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture)); 154 152 exec->clearException(); 155 153 exec->clearSupplementaryExceptionInfo(); 156 157 if (exception.isObject()) {158 JSObject* exceptionObject = exception.toObject(exec);159 lineNumber = exceptionObject->get(exec, Identifier(exec, "line")).toInt32(exec);160 exceptionSourceURL = exceptionObject->get(exec, Identifier(exec, "sourceURL")).toString(exec)->value(exec);161 } else if (stackTrace.size()) {162 lineNumber = stackTrace[0].line();163 exceptionSourceURL = stackTrace[0].friendlySourceURL();164 }165 166 if (ExceptionBase* exceptionBase = toExceptionBase(exception))167 errorMessage = exceptionBase->message() + ": " + exceptionBase->description();168 154 169 155 JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()); … … 172 158 return; 173 159 } 160 161 int lineNumber = 0; 162 int columnNumber = 0; 163 String exceptionSourceURL; 164 if (callStack->size()) { 165 const ScriptCallFrame& frame = callStack->at(0); 166 lineNumber = frame.lineNumber(); 167 columnNumber = frame.columnNumber(); 168 exceptionSourceURL = frame.sourceURL(); 169 } else { 170 // There may not be an exceptionStack for a <script> SyntaxError. Fallback to getting at least the line and sourceURL from the exception. 171 JSObject* exceptionObject = exception.toObject(exec); 172 JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line")); 173 lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0; 174 JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL")); 175 exceptionSourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined"); 176 } 177 178 String errorMessage; 179 if (ExceptionBase* exceptionBase = toExceptionBase(exception)) 180 errorMessage = exceptionBase->message() + ": " + exceptionBase->description(); 181 else { 182 // FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions 183 // If this is a custon exception object, call toString on it to try and get a nice string representation for the exception. 184 errorMessage = exception.toString(exec)->value(exec); 185 exec->clearException(); 186 exec->clearSupplementaryExceptionInfo(); 187 } 188 174 189 ScriptExecutionContext* scriptExecutionContext = globalObject->scriptExecutionContext(); 175 scriptExecutionContext->reportException(errorMessage, lineNumber, exceptionSourceURL,0, cachedScript);190 scriptExecutionContext->reportException(errorMessage, lineNumber, columnNumber, exceptionSourceURL, callStack->size() ? callStack : 0, cachedScript); 176 191 } 177 192 -
trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp
r148696 r149131 91 91 } 92 92 93 PassRefPtr<ScriptCallStack> createScriptCallStackFromException(JSC::ExecState* exec, JSC::JSValue& exception, size_t maxStackSize) 94 { 95 Vector<ScriptCallFrame> frames; 96 RefCountedArray<StackFrame> stackTrace = exec->vm().exceptionStack; 97 for (size_t i = 0; i < stackTrace.size() && i < maxStackSize; i++) { 98 if (!stackTrace[i].callee && frames.size()) 99 break; 100 101 String functionName = stackTrace[i].friendlyFunctionName(exec); 102 frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL, stackTrace[i].line(), stackTrace[i].column())); 103 } 104 105 // FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions 106 // Fallback to getting at least the line and sourceURL from the exception if it has values and the exceptionStack doesn't. 107 if (frames.size() > 0) { 108 const ScriptCallFrame& firstCallFrame = frames.first(); 109 JSObject* exceptionObject = exception.toObject(exec); 110 if (exception.isObject() && firstCallFrame.sourceURL().isEmpty()) { 111 JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line")); 112 int lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0; 113 JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL")); 114 String exceptionSourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined"); 115 frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, lineNumber, 0); 116 } 117 } 118 119 return ScriptCallStack::create(frames); 120 } 121 93 122 PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState* exec) 94 123 { -
trunk/Source/WebCore/bindings/js/ScriptCallStackFactory.h
r130021 r149131 33 33 34 34 #include <wtf/Forward.h> 35 #include <wtf/RefCountedArray.h> 35 36 36 37 namespace JSC { 37 38 class ExecState; 39 class JSValue; 40 struct StackFrame; 38 41 } 39 42 … … 45 48 PassRefPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize, bool emptyStackIsAllowed); 46 49 PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize); 50 PassRefPtr<ScriptCallStack> createScriptCallStackFromException(JSC::ExecState*, JSC::JSValue& exception, size_t maxStackSize); 47 51 PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState*); 48 52 PassRefPtr<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount); -
trunk/Source/WebCore/dom/Document.cpp
r149125 r149131 2656 2656 } 2657 2657 2658 void Document::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack> callStack)2659 { 2660 addMessage(JSMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, 0, callStack);2658 void Document::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack> callStack) 2659 { 2660 addMessage(JSMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, columnNumber, callStack); 2661 2661 } 2662 2662 -
trunk/Source/WebCore/dom/Document.h
r149125 r149131 1106 1106 1107 1107 virtual EventTarget* errorEventTarget(); 1108 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>);1108 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>); 1109 1109 1110 1110 void initDNSPrefetch(); -
trunk/Source/WebCore/dom/ScriptExecutionContext.cpp
r149125 r149131 65 65 WTF_MAKE_NONCOPYABLE(PendingException); 66 66 public: 67 PendingException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)67 PendingException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack) 68 68 : m_errorMessage(errorMessage) 69 69 , m_lineNumber(lineNumber) 70 , m_columnNumber(columnNumber) 70 71 , m_sourceURL(sourceURL) 71 72 , m_callStack(callStack) … … 74 75 String m_errorMessage; 75 76 int m_lineNumber; 77 int m_columnNumber; 76 78 String m_sourceURL; 77 79 RefPtr<ScriptCallStack> m_callStack; … … 280 282 } 281 283 282 void ScriptExecutionContext::reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack, CachedScript* cachedScript)284 void ScriptExecutionContext::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack, CachedScript* cachedScript) 283 285 { 284 286 if (m_inDispatchErrorEvent) { 285 287 if (!m_pendingExceptions) 286 288 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> >()); 287 m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage, lineNumber, sourceURL, callStack)));289 m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage, lineNumber, columnNumber, sourceURL, callStack))); 288 290 return; 289 291 } … … 291 293 // First report the original exception and only then all the nested ones. 292 294 if (!dispatchErrorEvent(errorMessage, lineNumber, sourceURL, cachedScript)) 293 logExceptionToConsole(errorMessage, sourceURL, lineNumber, c allStack);295 logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber, callStack); 294 296 295 297 if (!m_pendingExceptions) … … 298 300 for (size_t i = 0; i < m_pendingExceptions->size(); i++) { 299 301 PendingException* e = m_pendingExceptions->at(i).get(); 300 logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e->m_lineNumber, e->m_c allStack);302 logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e->m_lineNumber, e->m_columnNumber, e->m_callStack); 301 303 } 302 304 m_pendingExceptions.clear(); -
trunk/Source/WebCore/dom/ScriptExecutionContext.h
r149125 r149131 78 78 bool sanitizeScriptError(String& errorMessage, int& lineNumber, String& sourceURL, CachedScript* = 0); 79 79 // FIXME: <http://webkit.org/b/114315> ScriptExecutionContext log exception should include a column number 80 void reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>, CachedScript* = 0);80 void reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>, CachedScript* = 0); 81 81 82 82 void addConsoleMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, ScriptState* = 0, unsigned long requestIdentifier = 0); … … 186 186 virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack>, ScriptState* = 0, unsigned long requestIdentifier = 0) = 0; 187 187 virtual EventTarget* errorEventTarget() = 0; 188 // FIXME: <http://webkit.org/b/114315> ScriptExecutionContext log exception should include a column number 189 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) = 0; 188 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) = 0; 190 189 bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL, CachedScript*); 191 190 -
trunk/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp
r149125 r149131 177 177 } 178 178 179 static void postExceptionTask(ScriptExecutionContext* context, const String& errorMessage, int lineNumber, int /*columnNumber*/, const String& sourceURL) 180 { 181 // FIXME: <http://webkit.org/b/114315> ScriptExecutionContext log exception should include a column number 182 context->reportException(errorMessage, lineNumber, sourceURL, 0); 179 static void postExceptionTask(ScriptExecutionContext* context, const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) 180 { 181 context->reportException(errorMessage, lineNumber, columnNumber, sourceURL, 0); 183 182 } 184 183 -
trunk/Source/WebCore/workers/SharedWorkerContext.cpp
r149125 r149131 79 79 } 80 80 81 void SharedWorkerContext::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack> callStack)81 void SharedWorkerContext::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack> callStack) 82 82 { 83 // FIXME: <http://webkit.org/b/114315> ScriptExecutionContext log exception should include a column number 84 WorkerContext::logExceptionToConsole(errorMessage, sourceURL, lineNumber, callStack); 85 addMessageToWorkerConsole(JSMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, 0, callStack); 83 WorkerContext::logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber, callStack); 84 addMessageToWorkerConsole(JSMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, columnNumber, callStack); 86 85 } 87 86 -
trunk/Source/WebCore/workers/SharedWorkerContext.h
r145930 r149131 61 61 private: 62 62 SharedWorkerContext(const String& name, const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, SharedWorkerThread*); 63 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) OVERRIDE;63 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) OVERRIDE; 64 64 65 65 String m_name; -
trunk/Source/WebCore/workers/WorkerContext.cpp
r149125 r149131 274 274 } 275 275 276 void WorkerContext::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) 277 { 278 // FIXME: <http://webkit.org/b/114315> ScriptExecutionContext log exception should include a column number 279 thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, 0, sourceURL); 276 void WorkerContext::logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) 277 { 278 thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, columnNumber, sourceURL); 280 279 } 281 280 -
trunk/Source/WebCore/workers/WorkerContext.h
r149125 r149131 145 145 void applyContentSecurityPolicyFromString(const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType); 146 146 147 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, PassRefPtr<ScriptCallStack>) OVERRIDE;147 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) OVERRIDE; 148 148 void addMessageToWorkerConsole(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, PassRefPtr<ScriptCallStack>, ScriptState* = 0, unsigned long requestIdentifier = 0); 149 149 -
trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp
r149125 r149131 139 139 140 140 bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(m_errorMessage, m_sourceURL, m_lineNumber)); 141 if (!errorHandled) { 142 // FIXME: <http://webkit.org/b/114315> ScriptExecutionContext log exception should include a column number 143 context->reportException(m_errorMessage, m_lineNumber, m_sourceURL, 0); 144 } 141 if (!errorHandled) 142 context->reportException(m_errorMessage, m_lineNumber, m_columnNumber, m_sourceURL, 0); 145 143 } 146 144
Note: See TracChangeset
for help on using the changeset viewer.