Changeset 164554 in webkit
- Timestamp:
- Feb 22, 2014, 9:44:05 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSBase.cpp
r164507 r164554 41 41 #include <wtf/text/StringHash.h> 42 42 43 #if ENABLE(REMOTE_INSPECTOR)44 #include "JSGlobalObjectInspectorController.h"45 #endif46 47 43 using namespace JSC; 48 44 … … 70 66 if (exception) 71 67 *exception = toRef(exec, evaluationException); 72 #if ENABLE(REMOTE_INSPECTOR)73 // FIXME: If we have a debugger attached we could learn about ParseError exceptions through74 // ScriptDebugServer::sourceParsed and this path could produce a duplicate warning. The75 // 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 #endif80 68 return 0; 81 69 } … … 107 95 if (exception) 108 96 *exception = toRef(exec, syntaxException); 109 #if ENABLE(REMOTE_INSPECTOR)110 exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, syntaxException);111 #endif112 97 return false; 113 98 } -
trunk/Source/JavaScriptCore/API/JSObjectRef.cpp
r164507 r164554 56 56 #include "RegExpConstructor.h" 57 57 58 #if ENABLE(REMOTE_INSPECTOR)59 #include "JSGlobalObjectInspectorController.h"60 #endif61 62 58 using namespace JSC; 63 59 … … 150 146 JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first())); 151 147 if (exec->hadException()) { 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 148 if (exception) 149 *exception = toRef(exec, exec->exception()); 150 exec->clearException(); 159 151 result = 0; 160 152 } … … 182 174 183 175 if (exec->hadException()) { 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 176 if (exception) 177 *exception = toRef(exec, exec->exception()); 178 exec->clearException(); 191 179 result = 0; 192 180 } … … 210 198 JSObject* result = constructDate(exec, exec->lexicalGlobalObject(), argList); 211 199 if (exec->hadException()) { 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 200 if (exception) 201 *exception = toRef(exec, exec->exception()); 202 exec->clearException(); 219 203 result = 0; 220 204 } … … 237 221 238 222 if (exec->hadException()) { 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 223 if (exception) 224 *exception = toRef(exec, exec->exception()); 225 exec->clearException(); 246 226 result = 0; 247 227 } … … 265 245 JSObject* result = constructRegExp(exec, exec->lexicalGlobalObject(), argList); 266 246 if (exec->hadException()) { 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 247 if (exception) 248 *exception = toRef(exec, exec->exception()); 249 exec->clearException(); 274 250 result = 0; 275 251 } … … 333 309 JSValue jsValue = jsObject->get(exec, propertyName->identifier(&exec->vm())); 334 310 if (exec->hadException()) { 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 311 if (exception) 312 *exception = toRef(exec, exec->exception()); 313 exec->clearException(); 342 314 } 343 315 return toRef(exec, jsValue); … … 366 338 367 339 if (exec->hadException()) { 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 340 if (exception) 341 *exception = toRef(exec, exec->exception()); 342 exec->clearException(); 375 343 } 376 344 } … … 389 357 JSValue jsValue = jsObject->get(exec, propertyIndex); 390 358 if (exec->hadException()) { 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 359 if (exception) 360 *exception = toRef(exec, exec->exception()); 361 exec->clearException(); 398 362 } 399 363 return toRef(exec, jsValue); … … 415 379 jsObject->methodTable()->putByIndex(jsObject, exec, propertyIndex, jsValue, false); 416 380 if (exec->hadException()) { 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 381 if (exception) 382 *exception = toRef(exec, exec->exception()); 383 exec->clearException(); 424 384 } 425 385 } … … 438 398 bool result = jsObject->methodTable()->deleteProperty(jsObject, exec, propertyName->identifier(&exec->vm())); 439 399 if (exec->hadException()) { 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 400 if (exception) 401 *exception = toRef(exec, exec->exception()); 402 exec->clearException(); 447 403 } 448 404 return result; … … 586 542 JSValueRef result = toRef(exec, call(exec, jsObject, callType, callData, jsThisObject, argList)); 587 543 if (exec->hadException()) { 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 544 if (exception) 545 *exception = toRef(exec, exec->exception()); 546 exec->clearException(); 595 547 result = 0; 596 548 } … … 627 579 JSObjectRef result = toRef(construct(exec, jsObject, constructType, constructData, argList)); 628 580 if (exec->hadException()) { 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 581 if (exception) 582 *exception = toRef(exec, exec->exception()); 583 exec->clearException(); 636 584 result = 0; 637 585 } -
trunk/Source/JavaScriptCore/API/JSValue.mm
r164507 r164554 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 #endif55 56 50 #if JSC_OBJC_API_ENABLED 57 51 … … 635 629 return last; 636 630 } 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 #endif645 631 646 632 static JSContainerConvertor::Task valueToObjectWithoutCopy(JSGlobalContextRef context, JSValueRef value) … … 796 782 797 783 JSC::APIEntryShim shim(toJS(context)); 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 } 784 if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value))) 785 *exception = toRef(JSC::createTypeError(toJS(context), ASCIILiteral("Cannot convert primitive to NSArray"))); 805 786 return nil; 806 787 } … … 818 799 819 800 JSC::APIEntryShim shim(toJS(context)); 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 } 801 if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value))) 802 *exception = toRef(JSC::createTypeError(toJS(context), ASCIILiteral("Cannot convert primitive to NSDictionary"))); 827 803 return nil; 828 804 } -
trunk/Source/JavaScriptCore/API/JSValueRef.cpp
r164507 r164554 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 #endif50 51 #if ENABLE(REMOTE_INSPECTOR)52 #include "JSGlobalObjectInspectorController.h"53 49 #endif 54 50 … … 207 203 bool result = JSValue::equal(exec, jsA, jsB); // false if an exception is thrown 208 204 if (exec->hadException()) { 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 205 if (exception) 206 *exception = toRef(exec, exec->exception()); 207 exec->clearException(); 216 208 } 217 209 return result; … … 249 241 bool result = jsConstructor->hasInstance(exec, jsValue); // false if an exception is thrown 250 242 if (exec->hadException()) { 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 243 if (exception) 244 *exception = toRef(exec, exec->exception()); 245 exec->clearException(); 258 246 } 259 247 return result; … … 357 345 *exception = 0; 358 346 if (exec->hadException()) { 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 347 if (exception) 348 *exception = toRef(exec, exec->exception()); 349 exec->clearException(); 366 350 return 0; 367 351 } … … 395 379 double number = jsValue.toNumber(exec); 396 380 if (exec->hadException()) { 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 381 if (exception) 382 *exception = toRef(exec, exec->exception()); 383 exec->clearException(); 404 384 number = QNaN; 405 385 } … … 420 400 RefPtr<OpaqueJSString> stringRef(OpaqueJSString::create(jsValue.toString(exec)->value(exec))); 421 401 if (exec->hadException()) { 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 402 if (exception) 403 *exception = toRef(exec, exec->exception()); 404 exec->clearException(); 429 405 stringRef.clear(); 430 406 } … … 445 421 JSObjectRef objectRef = toRef(jsValue.toObject(exec)); 446 422 if (exec->hadException()) { 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 423 if (exception) 424 *exception = toRef(exec, exec->exception()); 425 exec->clearException(); 454 426 objectRef = 0; 455 427 } 456 428 return objectRef; 457 } 429 } 458 430 459 431 void JSValueProtect(JSContextRef ctx, JSValueRef value) -
trunk/Source/JavaScriptCore/ChangeLog
r164553 r164554 1 2014-02-22 Dan Bernstein <mitz@apple.com> 2 3 REGRESSION (r164507): Crash beneath JSGlobalObjectInspectorController::reportAPIException at facebook.com, twitter.com, youtube.com 4 https://bugs.webkit.org/show_bug.cgi?id=129227 5 6 Reviewed by Eric Carlson. 7 8 Reverted r164507. 9 10 * API/JSBase.cpp: 11 (JSEvaluateScript): 12 (JSCheckScriptSyntax): 13 * API/JSObjectRef.cpp: 14 (JSObjectMakeFunction): 15 (JSObjectMakeArray): 16 (JSObjectMakeDate): 17 (JSObjectMakeError): 18 (JSObjectMakeRegExp): 19 (JSObjectGetProperty): 20 (JSObjectSetProperty): 21 (JSObjectGetPropertyAtIndex): 22 (JSObjectSetPropertyAtIndex): 23 (JSObjectDeleteProperty): 24 (JSObjectCallAsFunction): 25 (JSObjectCallAsConstructor): 26 * API/JSValue.mm: 27 (valueToArray): 28 (valueToDictionary): 29 * API/JSValueRef.cpp: 30 (JSValueIsEqual): 31 (JSValueIsInstanceOfConstructor): 32 (JSValueCreateJSONString): 33 (JSValueToNumber): 34 (JSValueToStringCopy): 35 (JSValueToObject): 36 * inspector/ConsoleMessage.cpp: 37 (Inspector::ConsoleMessage::ConsoleMessage): 38 (Inspector::ConsoleMessage::autogenerateMetadata): 39 * inspector/ConsoleMessage.h: 40 * inspector/JSGlobalObjectInspectorController.cpp: 41 (Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController): 42 * inspector/JSGlobalObjectInspectorController.h: 43 * inspector/ScriptCallStack.cpp: 44 * inspector/ScriptCallStack.h: 45 * inspector/ScriptCallStackFactory.cpp: 46 (Inspector::createScriptCallStack): 47 (Inspector::createScriptCallStackForConsole): 48 (Inspector::createScriptCallStackFromException): 49 * inspector/ScriptCallStackFactory.h: 50 * inspector/agents/InspectorConsoleAgent.cpp: 51 (Inspector::InspectorConsoleAgent::enable): 52 (Inspector::InspectorConsoleAgent::addMessageToConsole): 53 (Inspector::InspectorConsoleAgent::count): 54 * inspector/agents/JSGlobalObjectDebuggerAgent.cpp: 55 (Inspector::JSGlobalObjectDebuggerAgent::breakpointActionLog): 56 1 57 2014-02-22 Joseph Pecoraro <pecoraro@apple.com> 2 58 -
trunk/Source/JavaScriptCore/inspector/ConsoleMessage.cpp
r164507 r164554 46 46 namespace Inspector { 47 47 48 ConsoleMessage::ConsoleMessage( MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned long requestIdentifier)48 ConsoleMessage::ConsoleMessage(bool canGenerateCallStack, 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 } 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) 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) 62 63 : m_source(source) 63 64 , m_type(type) … … 70 71 , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) 71 72 { 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()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) 81 82 , m_line(0) 82 83 , m_column(0) … … 84 85 , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) 85 86 { 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 } 86 93 m_callStack = callStack; 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) 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) 97 97 : m_source(source) 98 98 , m_type(type) … … 106 106 , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) 107 107 { 108 autogenerateMetadata( state);108 autogenerateMetadata(canGenerateCallStack, state); 109 109 } 110 110 … … 113 113 } 114 114 115 void ConsoleMessage::autogenerateMetadata(JSC::ExecState* state) 116 { 117 if (!state) 118 return; 119 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 { 120 118 if (m_type == MessageType::EndGroup) 121 119 return; 122 120 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(); 121 if (state) 122 m_callStack = createScriptCallStackForConsole(state); 123 // else if (canGenerateCallStack) 124 // m_callStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true); 125 else 130 126 return; 131 } 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(); 132 137 } 133 138 -
trunk/Source/JavaScriptCore/inspector/ConsoleMessage.h
r164507 r164554 52 52 WTF_MAKE_FAST_ALLOCATED; 53 53 public: 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);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); 58 58 ~ConsoleMessage(); 59 59 … … 75 75 76 76 private: 77 void autogenerateMetadata( JSC::ExecState* = nullptr);77 void autogenerateMetadata(bool canGenerateCallStack, JSC::ExecState* = nullptr); 78 78 79 79 MessageSource m_source; -
trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
r164507 r164554 30 30 31 31 #include "Completion.h" 32 #include "ErrorHandlingScope.h"33 32 #include "InjectedScriptHost.h" 34 33 #include "InjectedScriptManager.h" … … 40 39 #include "JSGlobalObjectDebuggerAgent.h" 41 40 #include "JSGlobalObjectRuntimeAgent.h" 42 #include "ScriptCallStack.h"43 #include "ScriptCallStackFactory.h"44 #include <cxxabi.h>45 #include <dlfcn.h>46 #include <execinfo.h>47 41 48 42 using namespace JSC; … … 58 52 auto consoleAgent = std::make_unique<JSGlobalObjectConsoleAgent>(m_injectedScriptManager.get()); 59 53 auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(m_injectedScriptManager.get(), m_globalObject, consoleAgent.get()); 60 61 m_consoleAgent = consoleAgent.get();62 54 63 55 runtimeAgent->setScriptDebugServer(&debuggerAgent->scriptDebugServer()); … … 110 102 } 111 103 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 else134 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 exceptions150 // 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 157 104 InspectorFunctionCallHandler JSGlobalObjectInspectorController::functionCallHandler() const 158 105 { -
trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h
r164507 r164554 38 38 class ExecState; 39 39 class JSGlobalObject; 40 class JSValue;41 40 } 42 41 … … 45 44 class InjectedScriptManager; 46 45 class InspectorBackendDispatcher; 47 class InspectorConsoleAgent;48 46 class InspectorFrontendChannel; 49 class ScriptCallStack;50 47 51 48 class JSGlobalObjectInspectorController final : public InspectorEnvironment { … … 62 59 void globalObjectDestroyed(); 63 60 64 void reportAPIException(JSC::ExecState*, JSC::JSValue exception);65 66 61 virtual bool developerExtrasEnabled() const override { return true; } 67 62 virtual bool canAccessInspectedScriptState(JSC::ExecState*) const override { return true; } … … 72 67 73 68 private: 74 void appendAPIBacktrace(ScriptCallStack* callStack);75 76 69 JSC::JSGlobalObject& m_globalObject; 77 70 std::unique_ptr<InjectedScriptManager> m_injectedScriptManager; 78 InspectorConsoleAgent* m_consoleAgent;79 71 InspectorAgentRegistry m_agents; 80 72 InspectorFrontendChannel* m_inspectorFrontendChannel; -
trunk/Source/JavaScriptCore/inspector/ScriptCallStack.cpp
r164507 r164554 37 37 namespace Inspector { 38 38 39 PassRefPtr<ScriptCallStack> ScriptCallStack::create()40 {41 return adoptRef(new ScriptCallStack);42 }43 44 39 PassRefPtr<ScriptCallStack> ScriptCallStack::create(Vector<ScriptCallFrame>& frames) 45 40 { 46 41 return adoptRef(new ScriptCallStack(frames)); 47 }48 49 ScriptCallStack::ScriptCallStack()50 {51 42 } 52 43 … … 69 60 { 70 61 return m_frames.size(); 71 }72 73 const ScriptCallFrame* ScriptCallStack::firstNonNativeCallFrame() const74 {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);90 62 } 91 63 -
trunk/Source/JavaScriptCore/inspector/ScriptCallStack.h
r164507 r164554 48 48 static const size_t maxCallStackSizeToCapture = 200; 49 49 50 static PassRefPtr<ScriptCallStack> create();51 50 static PassRefPtr<ScriptCallStack> create(Vector<ScriptCallFrame>&); 52 51 … … 55 54 const ScriptCallFrame& at(size_t) const; 56 55 size_t size() const; 57 58 const ScriptCallFrame* firstNonNativeCallFrame() const;59 60 void append(const ScriptCallFrame&);61 56 62 57 bool isEqual(ScriptCallStack*) const; … … 67 62 68 63 private: 69 ScriptCallStack();70 64 ScriptCallStack(Vector<ScriptCallFrame>&); 71 65 -
trunk/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp
r164507 r164554 84 84 }; 85 85 86 PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize )86 PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize, bool emptyIsAllowed) 87 87 { 88 if (!exec)89 return ScriptCallStack::create();90 91 88 Vector<ScriptCallFrame> frames; 92 89 93 CallFrame* frame = exec->vm().topCallFrame; 94 CreateScriptCallStackFunctor functor(false, frames, maxStackSize); 95 frame->iterate(functor); 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 } 96 102 97 103 return ScriptCallStack::create(frames); 98 104 } 99 105 100 PassRefPtr<ScriptCallStack> createScriptCallStack ForConsole(JSC::ExecState* exec, size_t maxStackSize)106 PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize) 101 107 { 102 if (!exec)103 return ScriptCallStack::create();104 105 108 Vector<ScriptCallFrame> frames; 106 109 … … 117 120 } 118 121 119 static void extractSourceInformationFromException(JSC::ExecState* exec, JSObject* exceptionObject, int* lineNumber, int* columnNumber, String* sourceURL)122 PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState* exec) 120 123 { 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(); 124 // FIXME: Caller should use createScriptCallStack alternative with the exec and appropriate max. 125 return createScriptCallStack(exec, ScriptCallStack::maxCallStackSizeToCapture); 129 126 } 130 127 … … 134 131 RefCountedArray<StackFrame> stackTrace = exec->vm().exceptionStack(); 135 132 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]. friendlySourceURL(), line, column));140 frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL, line, column)); 141 141 } 142 142 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 } 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); 158 156 } 159 157 } -
trunk/Source/JavaScriptCore/inspector/ScriptCallStackFactory.h
r164507 r164554 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); 48 49 JS_EXPORT_PRIVATE PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize); 49 JS_EXPORT_PRIVATE PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState* , size_t maxStackSize);50 JS_EXPORT_PRIVATE PassRefPtr<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState*); 50 51 JS_EXPORT_PRIVATE PassRefPtr<ScriptCallStack> createScriptCallStackFromException(JSC::ExecState*, JSC::JSValue& exception, size_t maxStackSize); 51 52 JS_EXPORT_PRIVATE PassRefPtr<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount); -
trunk/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp
r164507 r164554 81 81 82 82 if (m_expiredConsoleMessageCount) { 83 ConsoleMessage expiredMessage( MessageSource::Other, MessageType::Log, MessageLevel::Warning, String::format("%d console messages are not shown.", m_expiredConsoleMessageCount));83 ConsoleMessage expiredMessage(!isWorkerAgent(), 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>( source, type, level, message, callStack, requestIdentifier));131 addConsoleMessage(std::make_unique<ConsoleMessage>(!isWorkerAgent(), source, type, level, message, callStack, requestIdentifier)); 132 132 } 133 133 … … 142 142 } 143 143 144 addConsoleMessage(std::make_unique<ConsoleMessage>( source, type, level, message, arguments, state, requestIdentifier));144 addConsoleMessage(std::make_unique<ConsoleMessage>(!isWorkerAgent(), source, type, level, message, arguments, state, requestIdentifier)); 145 145 } 146 146 … … 155 155 } 156 156 157 addConsoleMessage(std::make_unique<ConsoleMessage>(source, type, level, message, scriptID, lineNumber, columnNumber, state, requestIdentifier)); 157 bool canGenerateCallStack = !isWorkerAgent() && m_frontendDispatcher; 158 addConsoleMessage(std::make_unique<ConsoleMessage>(canGenerateCallStack, source, type, level, message, scriptID, lineNumber, columnNumber, state, requestIdentifier)); 158 159 } 159 160 … … 197 198 void InspectorConsoleAgent::count(JSC::ExecState* state, PassRefPtr<ScriptArguments> arguments) 198 199 { 199 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state , ScriptCallStack::maxCallStackSizeToCapture));200 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state)); 200 201 const ScriptCallFrame& lastCaller = callStack->at(0); 201 202 // Follow Firebug's behavior of counting with null and undefined title in -
trunk/Source/JavaScriptCore/inspector/agents/JSGlobalObjectDebuggerAgent.cpp
r164507 r164554 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 ), 0);72 m_consoleAgent->addMessageToConsole(MessageSource::JS, MessageType::Log, MessageLevel::Log, message, createScriptCallStack(exec, ScriptCallStack::maxCallStackSizeToCapture, true), 0); 73 73 } 74 74 -
trunk/Source/WebCore/ChangeLog
r164553 r164554 1 2014-02-22 Dan Bernstein <mitz@apple.com> 2 3 REGRESSION (r164507): Crash beneath JSGlobalObjectInspectorController::reportAPIException at facebook.com, twitter.com, youtube.com 4 https://bugs.webkit.org/show_bug.cgi?id=129227 5 6 Reviewed by Eric Carlson. 7 8 Reverted r164507. 9 10 * bindings/js/JSDOMBinding.cpp: 11 (WebCore::reportException): 12 * inspector/InspectorResourceAgent.cpp: 13 (WebCore::InspectorResourceAgent::buildInitiatorObject): 14 * inspector/PageDebuggerAgent.cpp: 15 (WebCore::PageDebuggerAgent::breakpointActionLog): 16 * inspector/TimelineRecordFactory.cpp: 17 (WebCore::TimelineRecordFactory::createGenericRecord): 18 * page/Console.cpp: 19 (WebCore::internalAddMessage): 20 (WebCore::Console::profile): 21 (WebCore::Console::profileEnd): 22 (WebCore::Console::timeEnd): 23 * page/ContentSecurityPolicy.cpp: 24 (WebCore::gatherSecurityPolicyViolationEventData): 25 (WebCore::ContentSecurityPolicy::reportViolation): 26 * page/DOMWindow.cpp: 27 (WebCore::DOMWindow::postMessage): 28 1 29 2014-02-22 Joseph Pecoraro <pecoraro@apple.com> 2 30 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp
r164507 r164554 172 172 int columnNumber = 0; 173 173 String exceptionSourceURL; 174 if (const ScriptCallFrame* callFrame = callStack->firstNonNativeCallFrame()) { 175 lineNumber = callFrame->lineNumber(); 176 columnNumber = callFrame->columnNumber(); 177 exceptionSourceURL = callFrame->sourceURL(); 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"); 178 188 } 179 189 -
trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp
r164507 r164554 440 440 PassRefPtr<Inspector::TypeBuilder::Network::Initiator> InspectorResourceAgent::buildInitiatorObject(Document* document) 441 441 { 442 RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture );442 RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture, true); 443 443 if (stackTrace && stackTrace->size() > 0) { 444 444 RefPtr<Inspector::TypeBuilder::Network::Initiator> initiatorObject = Inspector::TypeBuilder::Network::Initiator::create() -
trunk/Source/WebCore/inspector/PageDebuggerAgent.cpp
r164507 r164554 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 ));120 m_pageAgent->page()->console().addMessage(MessageSource::JS, MessageLevel::Log, message, createScriptCallStack(exec, ScriptCallStack::maxCallStackSizeToCapture, true)); 121 121 } 122 122 -
trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp
r164507 r164554 58 58 59 59 if (maxCallStackDepth) { 60 RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), maxCallStackDepth );60 RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), maxCallStackDepth, true); 61 61 if (stackTrace && stackTrace->size()) 62 62 record->setValue("stackTrace", stackTrace->buildInspectorArray()); -
trunk/Source/WebCore/page/Console.cpp
r164507 r164554 78 78 79 79 size_t stackSize = printTrace ? ScriptCallStack::maxCallStackSizeToCapture : 1; 80 RefPtr<ScriptCallStack> callStack(createScriptCallStack ForConsole(state, stackSize));80 RefPtr<ScriptCallStack> callStack(createScriptCallStack(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 ForConsole(state, 1));206 RefPtr<ScriptCallStack> callStack(createScriptCallStack(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 ForConsole(state, 1));225 RefPtr<ScriptCallStack> callStack(createScriptCallStack(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 , 1));236 RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state)); 237 237 InspectorInstrumentation::stopConsoleTiming(m_frame, title, callStack.release()); 238 238 } -
trunk/Source/WebCore/page/ContentSecurityPolicy.cpp
r164507 r164554 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); 172 181 } 173 182 … … 1719 1728 init.lineNumber = 0; 1720 1729 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()); 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()); 1725 1738 init.sourceFile = stripURLForUseInReport(document, source); 1726 init.lineNumber = callFrame ->lineNumber();1739 init.lineNumber = callFrame.lineNumber(); 1727 1740 } 1728 1741 } … … 1765 1778 1766 1779 RefPtr<InspectorObject> cspReport = InspectorObject::create(); 1767 cspReport->setString( ASCIILiteral("document-uri"), document->url().strippedForUseAsReferrer());1768 cspReport->setString( ASCIILiteral("referrer"), document->referrer());1769 cspReport->setString( ASCIILiteral("violated-directive"), directiveText);1780 cspReport->setString("document-uri", document->url().strippedForUseAsReferrer()); 1781 cspReport->setString("referrer", document->referrer()); 1782 cspReport->setString("violated-directive", directiveText); 1770 1783 #if ENABLE(CSP_NEXT) 1771 1784 if (experimentalFeaturesEnabled()) 1772 cspReport->setString( ASCIILiteral("effective-directive"), effectiveDirective);1785 cspReport->setString("effective-directive", effectiveDirective); 1773 1786 #else 1774 1787 UNUSED_PARAM(effectiveDirective); 1775 1788 #endif 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()); 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 } 1785 1801 } 1786 1802 1787 1803 RefPtr<InspectorObject> reportObject = InspectorObject::create(); 1788 reportObject->setObject( ASCIILiteral("csp-report"), cspReport.release());1804 reportObject->setObject("csp-report", cspReport.release()); 1789 1805 1790 1806 RefPtr<FormData> report = FormData::create(reportObject->toJSONString().utf8()); -
trunk/Source/WebCore/page/DOMWindow.cpp
r164507 r164554 847 847 RefPtr<ScriptCallStack> stackTrace; 848 848 if (InspectorInstrumentation::consoleAgentEnabled(sourceDocument)) 849 stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture );849 stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture, true); 850 850 851 851 // Schedule the message. -
trunk/Source/WebInspectorUI/ChangeLog
r164543 r164554 1 2014-02-22 Dan Bernstein <mitz@apple.com> 2 3 REGRESSION (r164507): Crash beneath JSGlobalObjectInspectorController::reportAPIException at facebook.com, twitter.com, youtube.com 4 https://bugs.webkit.org/show_bug.cgi?id=129227 5 6 Reviewed by Eric Carlson. 7 8 Reverted r164507. 9 10 * UserInterface/Views/ConsoleMessageImpl.js: 11 (WebInspector.ConsoleMessageImpl.prototype._formatMessage): 12 (WebInspector.ConsoleMessageImpl.prototype._populateStackTraceTreeElement): 13 1 14 2014-02-21 Timothy Hatcher <timothy@apple.com> 2 15 -
trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js
r164543 r164554 110 110 111 111 if (this.source !== WebInspector.ConsoleMessage.MessageSource.Network || this._request) { 112 var firstNonNativeCallFrame = this._firstNonNativeCallFrame(); 113 if (firstNonNativeCallFrame) { 114 var urlElement = this._linkifyCallFrame(firstNonNativeCallFrame); 112 if (this._stackTrace && this._stackTrace.length && this._stackTrace[0].url) { 113 var urlElement = this._linkifyCallFrame(this._stackTrace[0]); 115 114 this._formattedMessage.appendChild(urlElement); 116 } else if (this.url && !this._shouldHideURL(this.url)) {115 } else if (this.url && this.url !== "undefined") { 117 116 var urlElement = this._linkifyLocation(this.url, this.line, this.column); 118 117 this._formattedMessage.appendChild(urlElement); … … 145 144 { 146 145 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;167 146 }, 168 147 … … 548 527 content.appendChild(messageTextElement); 549 528 550 if (frame.url && !this._shouldHideURL(frame.url)) {529 if (frame.url) { 551 530 var urlElement = this._linkifyCallFrame(frame); 552 531 content.appendChild(urlElement);
Note:
See TracChangeset
for help on using the changeset viewer.