Changeset 164507 in webkit
- Timestamp:
- Feb 21, 2014, 3:35:32 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/JavaScriptCore/API/JSBase.cpp ¶
r164491 r164507 41 41 #include <wtf/text/StringHash.h> 42 42 43 #if ENABLE(REMOTE_INSPECTOR) 44 #include "JSGlobalObjectInspectorController.h" 45 #endif 46 43 47 using namespace JSC; 44 48 … … 66 70 if (exception) 67 71 *exception = toRef(exec, evaluationException); 72 #if ENABLE(REMOTE_INSPECTOR) 73 // FIXME: If we have a debugger attached we could learn about ParseError exceptions through 74 // ScriptDebugServer::sourceParsed and this path could produce a duplicate warning. The 75 // Debugger path is currently ignored by inspector. 76 // NOTE: If we don't have a debugger, this SourceCode will be forever lost to the inspector. 77 // We could stash it in the inspector in case an inspector is ever opened. 78 globalObject->inspectorController().reportAPIException(exec, evaluationException); 79 #endif 68 80 return 0; 69 81 } … … 95 107 if (exception) 96 108 *exception = toRef(exec, syntaxException); 109 #if ENABLE(REMOTE_INSPECTOR) 110 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, syntaxException); 111 #endif 97 112 return false; 98 113 } -
TabularUnified trunk/Source/JavaScriptCore/API/JSObjectRef.cpp ¶
r164491 r164507 56 56 #include "RegExpConstructor.h" 57 57 58 #if ENABLE(REMOTE_INSPECTOR) 59 #include "JSGlobalObjectInspectorController.h" 60 #endif 61 58 62 using namespace JSC; 59 63 … … 146 150 JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first())); 147 151 if (exec->hadException()) { 148 if (exception) 149 *exception = toRef(exec, exec->exception()); 150 exec->clearException(); 152 JSValue exceptionValue = exec->exception(); 153 if (exception) 154 *exception = toRef(exec, exceptionValue); 155 exec->clearException(); 156 #if ENABLE(REMOTE_INSPECTOR) 157 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 158 #endif 151 159 result = 0; 152 160 } … … 174 182 175 183 if (exec->hadException()) { 176 if (exception) 177 *exception = toRef(exec, exec->exception()); 178 exec->clearException(); 184 JSValue exceptionValue = exec->exception(); 185 if (exception) 186 *exception = toRef(exec, exceptionValue); 187 exec->clearException(); 188 #if ENABLE(REMOTE_INSPECTOR) 189 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 190 #endif 179 191 result = 0; 180 192 } … … 198 210 JSObject* result = constructDate(exec, exec->lexicalGlobalObject(), argList); 199 211 if (exec->hadException()) { 200 if (exception) 201 *exception = toRef(exec, exec->exception()); 202 exec->clearException(); 212 JSValue exceptionValue = exec->exception(); 213 if (exception) 214 *exception = toRef(exec, exceptionValue); 215 exec->clearException(); 216 #if ENABLE(REMOTE_INSPECTOR) 217 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 218 #endif 203 219 result = 0; 204 220 } … … 221 237 222 238 if (exec->hadException()) { 223 if (exception) 224 *exception = toRef(exec, exec->exception()); 225 exec->clearException(); 239 JSValue exceptionValue = exec->exception(); 240 if (exception) 241 *exception = toRef(exec, exceptionValue); 242 exec->clearException(); 243 #if ENABLE(REMOTE_INSPECTOR) 244 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 245 #endif 226 246 result = 0; 227 247 } … … 245 265 JSObject* result = constructRegExp(exec, exec->lexicalGlobalObject(), argList); 246 266 if (exec->hadException()) { 247 if (exception) 248 *exception = toRef(exec, exec->exception()); 249 exec->clearException(); 267 JSValue exceptionValue = exec->exception(); 268 if (exception) 269 *exception = toRef(exec, exceptionValue); 270 exec->clearException(); 271 #if ENABLE(REMOTE_INSPECTOR) 272 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 273 #endif 250 274 result = 0; 251 275 } … … 309 333 JSValue jsValue = jsObject->get(exec, propertyName->identifier(&exec->vm())); 310 334 if (exec->hadException()) { 311 if (exception) 312 *exception = toRef(exec, exec->exception()); 313 exec->clearException(); 335 JSValue exceptionValue = exec->exception(); 336 if (exception) 337 *exception = toRef(exec, exceptionValue); 338 exec->clearException(); 339 #if ENABLE(REMOTE_INSPECTOR) 340 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 341 #endif 314 342 } 315 343 return toRef(exec, jsValue); … … 338 366 339 367 if (exec->hadException()) { 340 if (exception) 341 *exception = toRef(exec, exec->exception()); 342 exec->clearException(); 368 JSValue exceptionValue = exec->exception(); 369 if (exception) 370 *exception = toRef(exec, exceptionValue); 371 exec->clearException(); 372 #if ENABLE(REMOTE_INSPECTOR) 373 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 374 #endif 343 375 } 344 376 } … … 357 389 JSValue jsValue = jsObject->get(exec, propertyIndex); 358 390 if (exec->hadException()) { 359 if (exception) 360 *exception = toRef(exec, exec->exception()); 361 exec->clearException(); 391 JSValue exceptionValue = exec->exception(); 392 if (exception) 393 *exception = toRef(exec, exceptionValue); 394 exec->clearException(); 395 #if ENABLE(REMOTE_INSPECTOR) 396 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 397 #endif 362 398 } 363 399 return toRef(exec, jsValue); … … 379 415 jsObject->methodTable()->putByIndex(jsObject, exec, propertyIndex, jsValue, false); 380 416 if (exec->hadException()) { 381 if (exception) 382 *exception = toRef(exec, exec->exception()); 383 exec->clearException(); 417 JSValue exceptionValue = exec->exception(); 418 if (exception) 419 *exception = toRef(exec, exceptionValue); 420 exec->clearException(); 421 #if ENABLE(REMOTE_INSPECTOR) 422 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 423 #endif 384 424 } 385 425 } … … 398 438 bool result = jsObject->methodTable()->deleteProperty(jsObject, exec, propertyName->identifier(&exec->vm())); 399 439 if (exec->hadException()) { 400 if (exception) 401 *exception = toRef(exec, exec->exception()); 402 exec->clearException(); 440 JSValue exceptionValue = exec->exception(); 441 if (exception) 442 *exception = toRef(exec, exceptionValue); 443 exec->clearException(); 444 #if ENABLE(REMOTE_INSPECTOR) 445 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 446 #endif 403 447 } 404 448 return result; … … 542 586 JSValueRef result = toRef(exec, call(exec, jsObject, callType, callData, jsThisObject, argList)); 543 587 if (exec->hadException()) { 544 if (exception) 545 *exception = toRef(exec, exec->exception()); 546 exec->clearException(); 588 JSValue exceptionValue = exec->exception(); 589 if (exception) 590 *exception = toRef(exec, exceptionValue); 591 exec->clearException(); 592 #if ENABLE(REMOTE_INSPECTOR) 593 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 594 #endif 547 595 result = 0; 548 596 } … … 579 627 JSObjectRef result = toRef(construct(exec, jsObject, constructType, constructData, argList)); 580 628 if (exec->hadException()) { 581 if (exception) 582 *exception = toRef(exec, exec->exception()); 583 exec->clearException(); 629 JSValue exceptionValue = exec->exception(); 630 if (exception) 631 *exception = toRef(exec, exceptionValue); 632 exec->clearException(); 633 #if ENABLE(REMOTE_INSPECTOR) 634 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 635 #endif 584 636 result = 0; 585 637 } -
TabularUnified trunk/Source/JavaScriptCore/API/JSValue.mm ¶
r164491 r164507 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 … … 48 48 #import <wtf/text/StringHash.h> 49 49 50 #if ENABLE(REMOTE_INSPECTOR) 51 #import "CallFrame.h" 52 #import "JSGlobalObject.h" 53 #import "JSGlobalObjectInspectorController.h" 54 #endif 55 50 56 #if JSC_OBJC_API_ENABLED 51 57 … … 629 635 return last; 630 636 } 637 638 #if ENABLE(REMOTE_INSPECTOR) 639 static void reportExceptionToInspector(JSGlobalContextRef context, JSC::JSValue exception) 640 { 641 JSC::ExecState* exec = toJS(context); 642 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exception); 643 } 644 #endif 631 645 632 646 static JSContainerConvertor::Task valueToObjectWithoutCopy(JSGlobalContextRef context, JSValueRef value) … … 782 796 783 797 JSC::APIEntryShim shim(toJS(context)); 784 if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value))) 785 *exception = toRef(JSC::createTypeError(toJS(context), ASCIILiteral("Cannot convert primitive to NSArray"))); 798 if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value))) { 799 JSC::JSObject* exceptionObject = JSC::createTypeError(toJS(context), ASCIILiteral("Cannot convert primitive to NSArray")); 800 *exception = toRef(exceptionObject); 801 #if ENABLE(REMOTE_INSPECTOR) 802 reportExceptionToInspector(context, exceptionObject); 803 #endif 804 } 786 805 return nil; 787 806 } … … 799 818 800 819 JSC::APIEntryShim shim(toJS(context)); 801 if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value))) 802 *exception = toRef(JSC::createTypeError(toJS(context), ASCIILiteral("Cannot convert primitive to NSDictionary"))); 820 if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value))) { 821 JSC::JSObject* exceptionObject = JSC::createTypeError(toJS(context), ASCIILiteral("Cannot convert primitive to NSDictionary")); 822 *exception = toRef(exceptionObject); 823 #if ENABLE(REMOTE_INSPECTOR) 824 reportExceptionToInspector(context, exceptionObject); 825 #endif 826 } 803 827 return nil; 804 828 } -
TabularUnified trunk/Source/JavaScriptCore/API/JSValueRef.cpp ¶
r164491 r164507 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 … … 47 47 #if PLATFORM(MAC) 48 48 #include <mach-o/dyld.h> 49 #endif 50 51 #if ENABLE(REMOTE_INSPECTOR) 52 #include "JSGlobalObjectInspectorController.h" 49 53 #endif 50 54 … … 203 207 bool result = JSValue::equal(exec, jsA, jsB); // false if an exception is thrown 204 208 if (exec->hadException()) { 205 if (exception) 206 *exception = toRef(exec, exec->exception()); 207 exec->clearException(); 209 JSValue exceptionValue = exec->exception(); 210 if (exception) 211 *exception = toRef(exec, exceptionValue); 212 exec->clearException(); 213 #if ENABLE(REMOTE_INSPECTOR) 214 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 215 #endif 208 216 } 209 217 return result; … … 241 249 bool result = jsConstructor->hasInstance(exec, jsValue); // false if an exception is thrown 242 250 if (exec->hadException()) { 243 if (exception) 244 *exception = toRef(exec, exec->exception()); 245 exec->clearException(); 251 JSValue exceptionValue = exec->exception(); 252 if (exception) 253 *exception = toRef(exec, exceptionValue); 254 exec->clearException(); 255 #if ENABLE(REMOTE_INSPECTOR) 256 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 257 #endif 246 258 } 247 259 return result; … … 345 357 *exception = 0; 346 358 if (exec->hadException()) { 347 if (exception) 348 *exception = toRef(exec, exec->exception()); 349 exec->clearException(); 359 JSValue exceptionValue = exec->exception(); 360 if (exception) 361 *exception = toRef(exec, exceptionValue); 362 exec->clearException(); 363 #if ENABLE(REMOTE_INSPECTOR) 364 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 365 #endif 350 366 return 0; 351 367 } … … 379 395 double number = jsValue.toNumber(exec); 380 396 if (exec->hadException()) { 381 if (exception) 382 *exception = toRef(exec, exec->exception()); 383 exec->clearException(); 397 JSValue exceptionValue = exec->exception(); 398 if (exception) 399 *exception = toRef(exec, exceptionValue); 400 exec->clearException(); 401 #if ENABLE(REMOTE_INSPECTOR) 402 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 403 #endif 384 404 number = QNaN; 385 405 } … … 400 420 RefPtr<OpaqueJSString> stringRef(OpaqueJSString::create(jsValue.toString(exec)->value(exec))); 401 421 if (exec->hadException()) { 402 if (exception) 403 *exception = toRef(exec, exec->exception()); 404 exec->clearException(); 422 JSValue exceptionValue = exec->exception(); 423 if (exception) 424 *exception = toRef(exec, exceptionValue); 425 exec->clearException(); 426 #if ENABLE(REMOTE_INSPECTOR) 427 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 428 #endif 405 429 stringRef.clear(); 406 430 } … … 421 445 JSObjectRef objectRef = toRef(jsValue.toObject(exec)); 422 446 if (exec->hadException()) { 423 if (exception) 424 *exception = toRef(exec, exec->exception()); 425 exec->clearException(); 447 JSValue exceptionValue = exec->exception(); 448 if (exception) 449 *exception = toRef(exec, exceptionValue); 450 exec->clearException(); 451 #if ENABLE(REMOTE_INSPECTOR) 452 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue); 453 #endif 426 454 objectRef = 0; 427 455 } 428 456 return objectRef; 429 } 457 } 430 458 431 459 void JSValueProtect(JSContextRef ctx, JSValueRef value) -
TabularUnified trunk/Source/JavaScriptCore/ChangeLog ¶
r164503 r164507 1 2014-02-21 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: JSContext inspection should report exceptions in the console 4 https://bugs.webkit.org/show_bug.cgi?id=128776 5 6 Reviewed by Timothy Hatcher. 7 8 When JavaScript API functions have an exception, let the inspector 9 know so it can log the JavaScript and Native backtrace that caused 10 the exception. 11 12 Include some clean up of ConsoleMessage and ScriptCallStack construction. 13 14 * API/JSBase.cpp: 15 (JSEvaluateScript): 16 (JSCheckScriptSyntax): 17 * API/JSObjectRef.cpp: 18 (JSObjectMakeFunction): 19 (JSObjectMakeArray): 20 (JSObjectMakeDate): 21 (JSObjectMakeError): 22 (JSObjectMakeRegExp): 23 (JSObjectGetProperty): 24 (JSObjectSetProperty): 25 (JSObjectGetPropertyAtIndex): 26 (JSObjectSetPropertyAtIndex): 27 (JSObjectDeleteProperty): 28 (JSObjectCallAsFunction): 29 (JSObjectCallAsConstructor): 30 * API/JSValue.mm: 31 (reportExceptionToInspector): 32 (valueToArray): 33 (valueToDictionary): 34 * API/JSValueRef.cpp: 35 (JSValueIsEqual): 36 (JSValueIsInstanceOfConstructor): 37 (JSValueCreateJSONString): 38 (JSValueToNumber): 39 (JSValueToStringCopy): 40 (JSValueToObject): 41 When seeing an exception, let the inspector know there was an exception. 42 43 * inspector/JSGlobalObjectInspectorController.h: 44 * inspector/JSGlobalObjectInspectorController.cpp: 45 (Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController): 46 (Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace): 47 (Inspector::JSGlobalObjectInspectorController::reportAPIException): 48 Log API exceptions by also grabbing the native backtrace. 49 50 * inspector/ScriptCallStack.h: 51 * inspector/ScriptCallStack.cpp: 52 (Inspector::ScriptCallStack::firstNonNativeCallFrame): 53 (Inspector::ScriptCallStack::append): 54 Minor extensions to ScriptCallStack to make it easier to work with. 55 56 * inspector/ConsoleMessage.cpp: 57 (Inspector::ConsoleMessage::ConsoleMessage): 58 (Inspector::ConsoleMessage::autogenerateMetadata): 59 Provide better default information if the first call frame was native. 60 61 * inspector/ScriptCallStackFactory.cpp: 62 (Inspector::createScriptCallStack): 63 (Inspector::extractSourceInformationFromException): 64 (Inspector::createScriptCallStackFromException): 65 Perform the handling here of inserting a fake call frame for exceptions 66 if there was no call stack (e.g. a SyntaxError) or if the first call 67 frame had no information. 68 69 * inspector/ConsoleMessage.cpp: 70 (Inspector::ConsoleMessage::ConsoleMessage): 71 (Inspector::ConsoleMessage::autogenerateMetadata): 72 * inspector/ConsoleMessage.h: 73 * inspector/ScriptCallStackFactory.cpp: 74 (Inspector::createScriptCallStack): 75 (Inspector::createScriptCallStackForConsole): 76 * inspector/ScriptCallStackFactory.h: 77 * inspector/agents/InspectorConsoleAgent.cpp: 78 (Inspector::InspectorConsoleAgent::enable): 79 (Inspector::InspectorConsoleAgent::addMessageToConsole): 80 (Inspector::InspectorConsoleAgent::count): 81 * inspector/agents/JSGlobalObjectDebuggerAgent.cpp: 82 (Inspector::JSGlobalObjectDebuggerAgent::breakpointActionLog): 83 ConsoleMessage cleanup. 84 1 85 2014-02-21 Oliver Hunt <oliver@apple.com> 2 86 -
TabularUnified trunk/Source/JavaScriptCore/inspector/ConsoleMessage.cpp ¶
r164491 r164507 46 46 namespace Inspector { 47 47 48 ConsoleMessage::ConsoleMessage( bool canGenerateCallStack,MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned long requestIdentifier)48 ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned long requestIdentifier) 49 49 : m_source(source) 50 50 , m_type(type) … … 57 57 , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) 58 58 { 59 autogenerateMetadata(canGenerateCallStack); 60 } 61 62 ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source, MessageType type, MessageLevel level, const String& message, const String& url, unsigned line, unsigned column, JSC::ExecState* state, unsigned long requestIdentifier) 59 } 60 61 ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, const String& url, unsigned line, unsigned column, JSC::ExecState* state, unsigned long requestIdentifier) 63 62 : m_source(source) 64 63 , m_type(type) … … 71 70 , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) 72 71 { 73 autogenerateMetadata( canGenerateCallStack,state);74 } 75 76 ConsoleMessage::ConsoleMessage( bool,MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier)77 : m_source(source) 78 , m_type(type) 79 , m_level(level) 80 , m_message(message) 81 , m_ arguments(nullptr)72 autogenerateMetadata(state); 73 } 74 75 ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack, unsigned long requestIdentifier) 76 : m_source(source) 77 , m_type(type) 78 , m_level(level) 79 , m_message(message) 80 , m_url() 82 81 , m_line(0) 83 82 , m_column(0) … … 85 84 , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) 86 85 { 87 if (callStack && callStack->size()) {88 const ScriptCallFrame& frame = callStack->at(0);89 m_url = frame.sourceURL();90 m_line = frame.lineNumber();91 m_column = frame.columnNumber();92 }93 86 m_callStack = callStack; 94 } 95 96 ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptArguments> arguments, JSC::ExecState* state, unsigned long requestIdentifier) 87 88 const ScriptCallFrame* frame = m_callStack ? m_callStack->firstNonNativeCallFrame() : nullptr; 89 if (frame) { 90 m_url = frame->sourceURL(); 91 m_line = frame->lineNumber(); 92 m_column = frame->columnNumber(); 93 } 94 } 95 96 ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptArguments> arguments, JSC::ExecState* state, unsigned long requestIdentifier) 97 97 : m_source(source) 98 98 , m_type(type) … … 106 106 , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) 107 107 { 108 autogenerateMetadata( canGenerateCallStack,state);108 autogenerateMetadata(state); 109 109 } 110 110 … … 113 113 } 114 114 115 // FIXME: Remove the generate without ExecState path. The caller should always provide an ExecState. 116 void ConsoleMessage::autogenerateMetadata(bool /*canGenerateCallStack*/, JSC::ExecState* state) 117 { 115 void ConsoleMessage::autogenerateMetadata(JSC::ExecState* state) 116 { 117 if (!state) 118 return; 119 118 120 if (m_type == MessageType::EndGroup) 119 121 return; 120 122 121 if (state) 122 m_callStack = createScriptCallStackForConsole(state); 123 // else if (canGenerateCallStack) 124 // m_callStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true); 125 else 123 // FIXME: Should this really be using "for console" in the generic ConsoleMessage autogeneration? This can skip the first frame. 124 m_callStack = createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture); 125 126 if (const ScriptCallFrame* frame = m_callStack->firstNonNativeCallFrame()) { 127 m_url = frame->sourceURL(); 128 m_line = frame->lineNumber(); 129 m_column = frame->columnNumber(); 126 130 return; 127 128 if (m_callStack && m_callStack->size()) { 129 const ScriptCallFrame& frame = m_callStack->at(0); 130 m_url = frame.sourceURL(); 131 m_line = frame.lineNumber(); 132 m_column = frame.columnNumber(); 133 return; 134 } 135 136 m_callStack.clear(); 131 } 137 132 } 138 133 -
TabularUnified trunk/Source/JavaScriptCore/inspector/ConsoleMessage.h ¶
r164491 r164507 52 52 WTF_MAKE_FAST_ALLOCATED; 53 53 public: 54 ConsoleMessage( bool canGenerateCallStack,MessageSource, MessageType, MessageLevel, const String& message, unsigned long requestIdentifier = 0);55 ConsoleMessage( bool canGenerateCallStack,MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned line, unsigned column, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0);56 ConsoleMessage( bool canGenerateCallStack,MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>, unsigned long requestIdentifier = 0);57 ConsoleMessage( bool canGenerateCallStack,MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, JSC::ExecState*, unsigned long requestIdentifier = 0);54 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned long requestIdentifier = 0); 55 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned line, unsigned column, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0); 56 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>, unsigned long requestIdentifier = 0); 57 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, JSC::ExecState*, unsigned long requestIdentifier = 0); 58 58 ~ConsoleMessage(); 59 59 … … 75 75 76 76 private: 77 void autogenerateMetadata( bool canGenerateCallStack,JSC::ExecState* = nullptr);77 void autogenerateMetadata(JSC::ExecState* = nullptr); 78 78 79 79 MessageSource m_source; -
TabularUnified trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp ¶
r164491 r164507 30 30 31 31 #include "Completion.h" 32 #include "ErrorHandlingScope.h" 32 33 #include "InjectedScriptHost.h" 33 34 #include "InjectedScriptManager.h" … … 39 40 #include "JSGlobalObjectDebuggerAgent.h" 40 41 #include "JSGlobalObjectRuntimeAgent.h" 42 #include "ScriptCallStack.h" 43 #include "ScriptCallStackFactory.h" 44 #include <cxxabi.h> 45 #include <dlfcn.h> 46 #include <execinfo.h> 41 47 42 48 using namespace JSC; … … 52 58 auto consoleAgent = std::make_unique<JSGlobalObjectConsoleAgent>(m_injectedScriptManager.get()); 53 59 auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(m_injectedScriptManager.get(), m_globalObject, consoleAgent.get()); 60 61 m_consoleAgent = consoleAgent.get(); 54 62 55 63 runtimeAgent->setScriptDebugServer(&debuggerAgent->scriptDebugServer()); … … 102 110 } 103 111 112 void JSGlobalObjectInspectorController::appendAPIBacktrace(ScriptCallStack* callStack) 113 { 114 static const int framesToShow = 31; 115 static const int framesToSkip = 3; // WTFGetBacktrace, appendAPIBacktrace, reportAPIException. 116 117 void* samples[framesToShow + framesToSkip]; 118 int frames = framesToShow + framesToSkip; 119 WTFGetBacktrace(samples, &frames); 120 121 void** stack = samples + framesToSkip; 122 int size = frames - framesToSkip; 123 for (int i = 0; i < size; ++i) { 124 const char* mangledName = nullptr; 125 char* cxaDemangled = nullptr; 126 Dl_info info; 127 if (dladdr(stack[i], &info) && info.dli_sname) 128 mangledName = info.dli_sname; 129 if (mangledName) 130 cxaDemangled = abi::__cxa_demangle(mangledName, nullptr, nullptr, nullptr); 131 if (mangledName || cxaDemangled) 132 callStack->append(ScriptCallFrame(cxaDemangled ? cxaDemangled : mangledName, ASCIILiteral("[native code]"), 0, 0)); 133 else 134 callStack->append(ScriptCallFrame(ASCIILiteral("?"), ASCIILiteral("[native code]"), 0, 0)); 135 free(cxaDemangled); 136 } 137 } 138 139 void JSGlobalObjectInspectorController::reportAPIException(ExecState* exec, JSValue exception) 140 { 141 if (isTerminatedExecutionException(exception)) 142 return; 143 144 ErrorHandlingScope errorScope(exec->vm()); 145 146 RefPtr<ScriptCallStack> callStack = createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture); 147 appendAPIBacktrace(callStack.get()); 148 149 // FIXME: <http://webkit.org/b/115087> Web Inspector: Should not evaluate JavaScript handling exceptions 150 // If this is a custom exception object, call toString on it to try and get a nice string representation for the exception. 151 String errorMessage = exception.toString(exec)->value(exec); 152 exec->clearException(); 153 154 m_consoleAgent->addMessageToConsole(MessageSource::JS, MessageType::Log, MessageLevel::Error, errorMessage, callStack); 155 } 156 104 157 InspectorFunctionCallHandler JSGlobalObjectInspectorController::functionCallHandler() const 105 158 { -
TabularUnified trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h ¶
r164491 r164507 38 38 class ExecState; 39 39 class JSGlobalObject; 40 class JSValue; 40 41 } 41 42 … … 44 45 class InjectedScriptManager; 45 46 class InspectorBackendDispatcher; 47 class InspectorConsoleAgent; 46 48 class InspectorFrontendChannel; 49 class ScriptCallStack; 47 50 48 51 class JSGlobalObjectInspectorController final : public InspectorEnvironment { … … 59 62 void globalObjectDestroyed(); 60 63 64 void reportAPIException(JSC::ExecState*, JSC::JSValue exception); 65 61 66 virtual bool developerExtrasEnabled() const override { return true; } 62 67 virtual bool canAccessInspectedScriptState(JSC::ExecState*) const override { return true; } … … 67 72 68 73 private: 74 void appendAPIBacktrace(ScriptCallStack* callStack); 75 69 76 JSC::JSGlobalObject& m_globalObject; 70 77 std::unique_ptr<InjectedScriptManager> m_injectedScriptManager; 78 InspectorConsoleAgent* m_consoleAgent; 71 79 InspectorAgentRegistry m_agents; 72 80 InspectorFrontendChannel* m_inspectorFrontendChannel; -
TabularUnified trunk/Source/JavaScriptCore/inspector/ScriptCallStack.cpp ¶
r164491 r164507 37 37 namespace Inspector { 38 38 39 PassRefPtr<ScriptCallStack> ScriptCallStack::create() 40 { 41 return adoptRef(new ScriptCallStack); 42 } 43 39 44 PassRefPtr<ScriptCallStack> ScriptCallStack::create(Vector<ScriptCallFrame>& frames) 40 45 { 41 46 return adoptRef(new ScriptCallStack(frames)); 47 } 48 49 ScriptCallStack::ScriptCallStack() 50 { 42 51 } 43 52 … … 60 69 { 61 70 return m_frames.size(); 71 } 72 73 const ScriptCallFrame* ScriptCallStack::firstNonNativeCallFrame() const 74 { 75 if (!m_frames.size()) 76 return nullptr; 77 78 for (size_t i = 0; i < m_frames.size(); ++i) { 79 const ScriptCallFrame& frame = m_frames[i]; 80 if (frame.sourceURL() != "[native code]") 81 return &frame; 82 } 83 84 return nullptr; 85 } 86 87 void ScriptCallStack::append(const ScriptCallFrame& frame) 88 { 89 m_frames.append(frame); 62 90 } 63 91 -
TabularUnified trunk/Source/JavaScriptCore/inspector/ScriptCallStack.h ¶
r164491 r164507 48 48 static const size_t maxCallStackSizeToCapture = 200; 49 49 50 static PassRefPtr<ScriptCallStack> create(); 50 51 static PassRefPtr<ScriptCallStack> create(Vector<ScriptCallFrame>&); 51 52 … … 54 55 const ScriptCallFrame& at(size_t) const; 55 56 size_t size() const; 57 58 const ScriptCallFrame* firstNonNativeCallFrame() const; 59 60 void append(const ScriptCallFrame&); 56 61 57 62 bool isEqual(ScriptCallStack*) const; … … 62 67 63 68 private: 69 ScriptCallStack(); 64 70 ScriptCallStack(Vector<ScriptCallFrame>&); 65 71 -
TabularUnified trunk/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp ¶
r164491 r164507 84 84 }; 85 85 86 PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize , bool emptyIsAllowed)86 PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize) 87 87 { 88 if (!exec) 89 return ScriptCallStack::create(); 90 88 91 Vector<ScriptCallFrame> frames; 89 92 90 if (exec) { 91 CallFrame* frame = exec->vm().topCallFrame; 92 CreateScriptCallStackFunctor functor(false, frames, maxStackSize); 93 frame->iterate(functor); 94 } 95 96 if (frames.isEmpty() && !emptyIsAllowed) { 97 // No frames found. It may happen in the case where 98 // a bound function is called from native code for example. 99 // Fallback to setting lineNumber to 0, and source and function name to "undefined". 100 frames.append(ScriptCallFrame(ASCIILiteral("undefined"), ASCIILiteral("undefined"), 0, 0)); 101 } 93 CallFrame* frame = exec->vm().topCallFrame; 94 CreateScriptCallStackFunctor functor(false, frames, maxStackSize); 95 frame->iterate(functor); 102 96 103 97 return ScriptCallStack::create(frames); 104 98 } 105 99 106 PassRefPtr<ScriptCallStack> createScriptCallStack (JSC::ExecState* exec, size_t maxStackSize)100 PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState* exec, size_t maxStackSize) 107 101 { 102 if (!exec) 103 return ScriptCallStack::create(); 104 108 105 Vector<ScriptCallFrame> frames; 109 106 … … 120 117 } 121 118 122 PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState* exec)119 static void extractSourceInformationFromException(JSC::ExecState* exec, JSObject* exceptionObject, int* lineNumber, int* columnNumber, String* sourceURL) 123 120 { 124 // FIXME: Caller should use createScriptCallStack alternative with the exec and appropriate max. 125 return createScriptCallStack(exec, ScriptCallStack::maxCallStackSizeToCapture); 121 // FIXME: <http://webkit.org/b/115087> Web Inspector: Should not need to evaluate JavaScript handling exceptions 122 JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line")); 123 *lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0; 124 JSValue columnValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "column")); 125 *columnNumber = columnValue && columnValue.isNumber() ? int(columnValue.toNumber(exec)) : 0; 126 JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL")); 127 *sourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : String("undefined"); 128 exec->clearException(); 126 129 } 127 130 … … 131 134 RefCountedArray<StackFrame> stackTrace = exec->vm().exceptionStack(); 132 135 for (size_t i = 0; i < stackTrace.size() && i < maxStackSize; i++) { 133 if (!stackTrace[i].callee && frames.size())134 break;135 136 136 unsigned line; 137 137 unsigned column; 138 138 stackTrace[i].computeLineAndColumn(line, column); 139 139 String functionName = stackTrace[i].friendlyFunctionName(exec); 140 frames.append(ScriptCallFrame(functionName, stackTrace[i]. sourceURL, line, column));140 frames.append(ScriptCallFrame(functionName, stackTrace[i].friendlySourceURL(), line, column)); 141 141 } 142 142 143 // FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions 144 // Fallback to getting at least the line and sourceURL from the exception if it has values and the exceptionStack doesn't. 145 if (frames.size() > 0) { 146 const ScriptCallFrame& firstCallFrame = frames.first(); 147 JSObject* exceptionObject = exception.toObject(exec); 148 if (exception.isObject() && firstCallFrame.sourceURL().isEmpty()) { 149 JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line")); 150 int lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0; 151 JSValue columnValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "column")); 152 int columnNumber = columnValue && columnValue.isNumber() ? int(columnValue.toNumber(exec)) : 0; 153 JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL")); 154 String exceptionSourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined"); 155 frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, lineNumber, columnNumber); 143 // Fallback to getting at least the line and sourceURL from the exception object if it has values and the exceptionStack doesn't. 144 JSObject* exceptionObject = exception.toObject(exec); 145 if (exception.isObject()) { 146 int lineNumber; 147 int columnNumber; 148 String exceptionSourceURL; 149 if (!frames.size()) { 150 extractSourceInformationFromException(exec, exceptionObject, &lineNumber, &columnNumber, &exceptionSourceURL); 151 frames.append(ScriptCallFrame(String(), exceptionSourceURL, lineNumber, columnNumber)); 152 } else { 153 if (stackTrace[0].sourceURL.isEmpty()) { 154 const ScriptCallFrame& firstCallFrame = frames.first(); 155 extractSourceInformationFromException(exec, exceptionObject, &lineNumber, &columnNumber, &exceptionSourceURL); 156 frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, lineNumber, columnNumber); 157 } 156 158 } 157 159 } -
TabularUnified trunk/Source/JavaScriptCore/inspector/ScriptCallStackFactory.h ¶
r164491 r164507 46 46 47 47 // FIXME: The subtle differences between these should be eliminated. 48 JS_EXPORT_PRIVATE PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize, bool emptyIsAllowed);49 48 JS_EXPORT_PRIVATE PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize); 50 JS_EXPORT_PRIVATE PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState* );49 JS_EXPORT_PRIVATE PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState*, size_t maxStackSize); 51 50 JS_EXPORT_PRIVATE PassRefPtr<ScriptCallStack> createScriptCallStackFromException(JSC::ExecState*, JSC::JSValue& exception, size_t maxStackSize); 52 51 JS_EXPORT_PRIVATE PassRefPtr<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount); -
TabularUnified trunk/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp ¶
r164491 r164507 81 81 82 82 if (m_expiredConsoleMessageCount) { 83 ConsoleMessage expiredMessage( !isWorkerAgent(),MessageSource::Other, MessageType::Log, MessageLevel::Warning, String::format("%d console messages are not shown.", m_expiredConsoleMessageCount));83 ConsoleMessage expiredMessage(MessageSource::Other, MessageType::Log, MessageLevel::Warning, String::format("%d console messages are not shown.", m_expiredConsoleMessageCount)); 84 84 expiredMessage.addToFrontend(m_frontendDispatcher.get(), m_injectedScriptManager, false); 85 85 } … … 129 129 } 130 130 131 addConsoleMessage(std::make_unique<ConsoleMessage>( !isWorkerAgent(),source, type, level, message, callStack, requestIdentifier));131 addConsoleMessage(std::make_unique<ConsoleMessage>(source, type, level, message, callStack, requestIdentifier)); 132 132 } 133 133 … … 142 142 } 143 143 144 addConsoleMessage(std::make_unique<ConsoleMessage>( !isWorkerAgent(),source, type, level, message, arguments, state, requestIdentifier));144 addConsoleMessage(std::make_unique<ConsoleMessage>(source, type, level, message, arguments, state, requestIdentifier)); 145 145 } 146 146 … … 155 155 } 156 156 157 bool canGenerateCallStack = !isWorkerAgent() && m_frontendDispatcher; 158 addConsoleMessage(std::make_unique<ConsoleMessage>(canGenerateCallStack, source, type, level, message, scriptID, lineNumber, columnNumber, state, requestIdentifier)); 157 addConsoleMessage(std::make_unique<ConsoleMessage>(source, type, level, message, scriptID, lineNumber, columnNumber, state, requestIdentifier)); 159 158 } 160 159 … … 198 197 void InspectorConsoleAgent::count(JSC::ExecState* state, PassRefPtr<ScriptArguments> arguments) 199 198 { 200 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state ));199 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture)); 201 200 const ScriptCallFrame& lastCaller = callStack->at(0); 202 201 // Follow Firebug's behavior of counting with null and undefined title in -
TabularUnified trunk/Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.cpp ¶
r164491 r164507 70 70 void JSGlobalObjectDebuggerAgent::breakpointActionLog(JSC::ExecState* exec, const String& message) 71 71 { 72 m_consoleAgent->addMessageToConsole(MessageSource::JS, MessageType::Log, MessageLevel::Log, message, createScriptCallStack(exec, ScriptCallStack::maxCallStackSizeToCapture , true), 0);72 m_consoleAgent->addMessageToConsole(MessageSource::JS, MessageType::Log, MessageLevel::Log, message, createScriptCallStack(exec, ScriptCallStack::maxCallStackSizeToCapture), 0); 73 73 } 74 74 -
TabularUnified trunk/Source/WebCore/ChangeLog ¶
r164505 r164507 1 2014-02-21 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: JSContext inspection should report exceptions in the console 4 https://bugs.webkit.org/show_bug.cgi?id=128776 5 6 Reviewed by Timothy Hatcher. 7 8 Include some clean up of ConsoleMessage and ScriptCallStack construction. 9 10 Covered by existing tests. 11 12 * bindings/js/JSDOMBinding.cpp: 13 (WebCore::reportException): 14 Simplify code now that createStackTraceFromException handles it. 15 16 * page/ContentSecurityPolicy.cpp: 17 (WebCore::gatherSecurityPolicyViolationEventData): 18 (WebCore::ContentSecurityPolicy::reportViolation): 19 ScriptCallStack can give us the first non-native callframe. 20 21 * inspector/InspectorResourceAgent.cpp: 22 (WebCore::InspectorResourceAgent::buildInitiatorObject): 23 * inspector/PageDebuggerAgent.cpp: 24 (WebCore::PageDebuggerAgent::breakpointActionLog): 25 * inspector/TimelineRecordFactory.cpp: 26 (WebCore::TimelineRecordFactory::createGenericRecord): 27 * page/Console.cpp: 28 (WebCore::internalAddMessage): 29 (WebCore::Console::profile): 30 (WebCore::Console::profileEnd): 31 (WebCore::Console::timeEnd): 32 * page/ContentSecurityPolicy.cpp: 33 (WebCore::gatherSecurityPolicyViolationEventData): 34 (WebCore::ContentSecurityPolicy::reportViolation): 35 * page/DOMWindow.cpp: 36 (WebCore::DOMWindow::postMessage): 37 1 38 2014-02-21 Benjamin Poulain <benjamin@webkit.org> 2 39 -
TabularUnified trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp ¶
r164505 r164507 172 172 int columnNumber = 0; 173 173 String exceptionSourceURL; 174 if (callStack->size()) { 175 const ScriptCallFrame& frame = callStack->at(0); 176 lineNumber = frame.lineNumber(); 177 columnNumber = frame.columnNumber(); 178 exceptionSourceURL = frame.sourceURL(); 179 } else { 180 // There may not be an exceptionStack for a <script> SyntaxError. Fallback to getting at least the line and sourceURL from the exception. 181 JSObject* exceptionObject = exception.toObject(exec); 182 JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line")); 183 lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0; 184 JSValue columnValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "column")); 185 columnNumber = columnValue && columnValue.isNumber() ? int(columnValue.toNumber(exec)) : 0; 186 JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL")); 187 exceptionSourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined"); 174 if (const ScriptCallFrame* callFrame = callStack->firstNonNativeCallFrame()) { 175 lineNumber = callFrame->lineNumber(); 176 columnNumber = callFrame->columnNumber(); 177 exceptionSourceURL = callFrame->sourceURL(); 188 178 } 189 179 -
TabularUnified trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp ¶
r164491 r164507 440 440 PassRefPtr<Inspector::TypeBuilder::Network::Initiator> InspectorResourceAgent::buildInitiatorObject(Document* document) 441 441 { 442 RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture , true);442 RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture); 443 443 if (stackTrace && stackTrace->size() > 0) { 444 444 RefPtr<Inspector::TypeBuilder::Network::Initiator> initiatorObject = Inspector::TypeBuilder::Network::Initiator::create() -
TabularUnified trunk/Source/WebCore/inspector/PageDebuggerAgent.cpp ¶
r164491 r164507 118 118 void PageDebuggerAgent::breakpointActionLog(JSC::ExecState* exec, const String& message) 119 119 { 120 m_pageAgent->page()->console().addMessage(MessageSource::JS, MessageLevel::Log, message, createScriptCallStack(exec, ScriptCallStack::maxCallStackSizeToCapture , true));120 m_pageAgent->page()->console().addMessage(MessageSource::JS, MessageLevel::Log, message, createScriptCallStack(exec, ScriptCallStack::maxCallStackSizeToCapture)); 121 121 } 122 122 -
TabularUnified trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp ¶
r164491 r164507 58 58 59 59 if (maxCallStackDepth) { 60 RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), maxCallStackDepth , true);60 RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), maxCallStackDepth); 61 61 if (stackTrace && stackTrace->size()) 62 62 record->setValue("stackTrace", stackTrace->buildInspectorArray()); -
TabularUnified trunk/Source/WebCore/page/Console.cpp ¶
r164491 r164507 78 78 79 79 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1; 80 RefPtr<ScriptCallStack> callStack(createScriptCallStack (state, stackSize));80 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, stackSize)); 81 81 const ScriptCallFrame& lastCaller = callStack->at(0); 82 82 … … 204 204 ScriptProfiler::start(state, resolvedTitle); 205 205 206 RefPtr<ScriptCallStack> callStack(createScriptCallStack (state, 1));206 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, 1)); 207 207 const ScriptCallFrame& lastCaller = callStack->at(0); 208 208 InspectorInstrumentation::addStartProfilingMessageToConsole(page, resolvedTitle, lastCaller.lineNumber(), lastCaller.columnNumber(), lastCaller.sourceURL()); … … 223 223 224 224 m_profiles.append(profile); 225 RefPtr<ScriptCallStack> callStack(createScriptCallStack (state, 1));225 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, 1)); 226 226 InspectorInstrumentation::addProfile(page, profile, callStack); 227 227 } … … 234 234 void Console::timeEnd(JSC::ExecState* state, const String& title) 235 235 { 236 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state ));236 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, 1)); 237 237 InspectorInstrumentation::stopConsoleTiming(m_frame, title, callStack.release()); 238 238 } -
TabularUnified trunk/Source/WebCore/page/ContentSecurityPolicy.cpp ¶
r164491 r164507 170 170 ASSERT_NOT_REACHED(); 171 171 return FeatureObserver::NumberOfFeatures; 172 }173 174 const ScriptCallFrame& getFirstNonNativeFrame(PassRefPtr<ScriptCallStack> stack)175 {176 int frameNumber = 0;177 if (!stack->at(0).lineNumber() && stack->size() > 1 && stack->at(1).lineNumber())178 frameNumber = 1;179 180 return stack->at(frameNumber);181 172 } 182 173 … … 1728 1719 init.lineNumber = 0; 1729 1720 1730 RefPtr<ScriptCallStack> stack = createScriptCallStack(JSMainThreadExecState::currentState(), 2, false); 1731 if (!stack) 1732 return; 1733 1734 const ScriptCallFrame& callFrame = getFirstNonNativeFrame(stack); 1735 1736 if (callFrame.lineNumber()) { 1737 URL source = URL(ParsedURLString, callFrame.sourceURL()); 1721 RefPtr<ScriptCallStack> stack = createScriptCallStack(JSMainThreadExecState::currentState(), 2); 1722 const ScriptCallFrame* callFrame = stack->firstNonNativeCallFrame(); 1723 if (callFrame && callFrame->lineNumber()) { 1724 URL source = URL(URL(), callFrame->sourceURL()); 1738 1725 init.sourceFile = stripURLForUseInReport(document, source); 1739 init.lineNumber = callFrame .lineNumber();1726 init.lineNumber = callFrame->lineNumber(); 1740 1727 } 1741 1728 } … … 1778 1765 1779 1766 RefPtr<InspectorObject> cspReport = InspectorObject::create(); 1780 cspReport->setString( "document-uri", document->url().strippedForUseAsReferrer());1781 cspReport->setString( "referrer", document->referrer());1782 cspReport->setString( "violated-directive", directiveText);1767 cspReport->setString(ASCIILiteral("document-uri"), document->url().strippedForUseAsReferrer()); 1768 cspReport->setString(ASCIILiteral("referrer"), document->referrer()); 1769 cspReport->setString(ASCIILiteral("violated-directive"), directiveText); 1783 1770 #if ENABLE(CSP_NEXT) 1784 1771 if (experimentalFeaturesEnabled()) 1785 cspReport->setString( "effective-directive", effectiveDirective);1772 cspReport->setString(ASCIILiteral("effective-directive"), effectiveDirective); 1786 1773 #else 1787 1774 UNUSED_PARAM(effectiveDirective); 1788 1775 #endif 1789 cspReport->setString("original-policy", header); 1790 cspReport->setString("blocked-uri", stripURLForUseInReport(document, blockedURL)); 1791 1792 RefPtr<ScriptCallStack> stack = createScriptCallStack(JSMainThreadExecState::currentState(), 2, false); 1793 if (stack) { 1794 const ScriptCallFrame& callFrame = getFirstNonNativeFrame(stack); 1795 1796 if (callFrame.lineNumber()) { 1797 URL source = URL(ParsedURLString, callFrame.sourceURL()); 1798 cspReport->setString("source-file", stripURLForUseInReport(document, source)); 1799 cspReport->setNumber("line-number", callFrame.lineNumber()); 1800 } 1776 cspReport->setString(ASCIILiteral("original-policy"), header); 1777 cspReport->setString(ASCIILiteral("blocked-uri"), stripURLForUseInReport(document, blockedURL)); 1778 1779 RefPtr<ScriptCallStack> stack = createScriptCallStack(JSMainThreadExecState::currentState(), 2); 1780 const ScriptCallFrame* callFrame = stack->firstNonNativeCallFrame(); 1781 if (callFrame && callFrame->lineNumber()) { 1782 URL source = URL(URL(), callFrame->sourceURL()); 1783 cspReport->setString(ASCIILiteral("source-file"), stripURLForUseInReport(document, source)); 1784 cspReport->setNumber(ASCIILiteral("line-number"), callFrame->lineNumber()); 1801 1785 } 1802 1786 1803 1787 RefPtr<InspectorObject> reportObject = InspectorObject::create(); 1804 reportObject->setObject( "csp-report", cspReport.release());1788 reportObject->setObject(ASCIILiteral("csp-report"), cspReport.release()); 1805 1789 1806 1790 RefPtr<FormData> report = FormData::create(reportObject->toJSONString().utf8()); -
TabularUnified trunk/Source/WebCore/page/DOMWindow.cpp ¶
r164491 r164507 847 847 RefPtr<ScriptCallStack> stackTrace; 848 848 if (InspectorInstrumentation::consoleAgentEnabled(sourceDocument)) 849 stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture , true);849 stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture); 850 850 851 851 // Schedule the message. -
TabularUnified trunk/Source/WebInspectorUI/ChangeLog ¶
r164491 r164507 1 2014-02-21 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: JSContext inspection should report exceptions in the console 4 https://bugs.webkit.org/show_bug.cgi?id=128776 5 6 Reviewed by Timothy Hatcher. 7 8 * UserInterface/ConsoleMessageImpl.js: 9 (WebInspector.ConsoleMessageImpl.prototype._formatMessage): 10 (WebInspector.ConsoleMessageImpl.prototype._shouldHideURL): 11 (WebInspector.ConsoleMessageImpl.prototype._firstNonNativeCallFrame): 12 (WebInspector.ConsoleMessageImpl.prototype._populateStackTraceTreeElement): 13 Provide better handling for "[native code]" and legacy "undefined" 14 call frame URLs. Never linkify these. Also, when showing a link 15 for an exception, always use the first non-native call frame as 16 the link location. 17 1 18 2014-02-21 Joseph Pecoraro <pecoraro@apple.com> 2 19 -
TabularUnified trunk/Source/WebInspectorUI/UserInterface/ConsoleMessageImpl.js ¶
r164491 r164507 110 110 111 111 if (this.source !== WebInspector.ConsoleMessage.MessageSource.Network || this._request) { 112 if (this._stackTrace && this._stackTrace.length && this._stackTrace[0].url) { 113 var urlElement = this._linkifyCallFrame(this._stackTrace[0]); 112 var firstNonNativeCallFrame = this._firstNonNativeCallFrame(); 113 if (firstNonNativeCallFrame) { 114 var urlElement = this._linkifyCallFrame(firstNonNativeCallFrame); 114 115 this._formattedMessage.appendChild(urlElement); 115 } else if (this.url && this.url !== "undefined") {116 } else if (this.url && !this._shouldHideURL(this.url)) { 116 117 var urlElement = this._linkifyLocation(this.url, this.line, this.column); 117 118 this._formattedMessage.appendChild(urlElement); … … 144 145 { 145 146 return !!this._stackTrace && this._stackTrace.length && (this.source === WebInspector.ConsoleMessage.MessageSource.Network || this.level === WebInspector.ConsoleMessage.MessageLevel.Error || this.type === WebInspector.ConsoleMessage.MessageType.Trace); 147 }, 148 149 _shouldHideURL: function(url) 150 { 151 return url === "undefined" || url === "[native code]"; 152 }, 153 154 _firstNonNativeCallFrame: function() 155 { 156 if (!this._stackTrace) 157 return null; 158 159 for (var i = 0; i < this._stackTrace.length; i++) { 160 var frame = this._stackTrace[i]; 161 if (!frame.url || frame.url === "[native code]") 162 continue; 163 return frame; 164 } 165 166 return null; 146 167 }, 147 168 … … 527 548 content.appendChild(messageTextElement); 528 549 529 if (frame.url ) {550 if (frame.url && !this._shouldHideURL(frame.url)) { 530 551 var urlElement = this._linkifyCallFrame(frame); 531 552 content.appendChild(urlElement);
Note:
See TracChangeset
for help on using the changeset viewer.