Changeset 105310 in webkit
- Timestamp:
- Jan 18, 2012 12:59:10 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r105307 r105310 1 2012-01-18 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Unsafe cross origin access errors should show stack trace in console. 4 https://bugs.webkit.org/show_bug.cgi?id=73099 5 6 Reviewed by Pavel Feldman. 7 8 * http/tests/inspector/console-cross-origin-iframe-logging-expected.txt: Added. 9 * http/tests/inspector/console-cross-origin-iframe-logging.html: Added. 10 * http/tests/inspector/resources/cross-origin-iframe.html: Added. 11 * platform/chromium/http/tests/inspector/console-cross-origin-iframe-logging-expected.txt: Added. 12 1 13 2012-01-18 Alexey Proskuryakov <ap@apple.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r105308 r105310 1 2012-01-18 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Unsafe cross origin access errors should show stack trace in console. 4 https://bugs.webkit.org/show_bug.cgi?id=73099 5 6 Reviewed by Pavel Feldman. 7 8 Test: http/tests/inspector/console-cross-origin-iframe-logging.html 9 10 * bindings/v8/V8Proxy.cpp: 11 (WebCore::V8Proxy::reportUnsafeAccessTo): 12 * dom/ScriptExecutionContext.cpp: 13 (WebCore::ScriptExecutionContext::addConsoleMessage): 14 * dom/ScriptExecutionContext.h: 15 * loader/FrameLoader.cpp: 16 (WebCore::FrameLoader::shouldAllowNavigation): 17 * page/Console.cpp: 18 (WebCore::Console::addMessage): 19 * page/Console.h: 20 * page/DOMWindow.cpp: 21 (WebCore::PostMessageTimer::PostMessageTimer): 22 (WebCore::PostMessageTimer::stackTrace): 23 (WebCore::DOMWindow::postMessage): 24 (WebCore::DOMWindow::postMessageTimerFired): 25 (WebCore::DOMWindow::printErrorMessage): 26 1 27 2012-01-18 Pablo Flouret <pablof@motorola.com> 2 28 -
trunk/Source/WebCore/bindings/v8/V8Proxy.cpp
r104694 r105310 44 44 #include "InspectorInstrumentation.h" 45 45 #include "PlatformSupport.h" 46 #include "ScriptCallStack.h" 47 #include "ScriptCallStackFactory.h" 46 48 #include "ScriptSourceCode.h" 47 49 #include "SecurityOrigin.h" … … 138 140 " from frame with URL " + sourceDocument->url().string() + ". Domains, protocols and ports must match.\n"; 139 141 142 RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true); 143 140 144 // NOTE: Safari prints the message in the target page, but it seems like 141 145 // it should be in the source page. Even for delayed messages, we put it in 142 146 // the source page. 143 sourceDocument->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, str );147 sourceDocument->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, str, stackTrace.release()); 144 148 } 145 149 -
trunk/Source/WebCore/dom/ScriptExecutionContext.cpp
r104803 r105310 333 333 } 334 334 335 void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack) 336 { 337 addMessage(source, type, level, message, String(), 0, callStack); 338 } 339 340 335 341 bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL) 336 342 { -
trunk/Source/WebCore/dom/ScriptExecutionContext.h
r104803 r105310 94 94 void reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>); 95 95 void addConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, const String& sourceURL = String(), unsigned lineNumber = 0, PassRefPtr<ScriptCallStack> = 0); 96 void addConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>); 96 97 97 98 // Active objects are not garbage collected even if inaccessible, e.g. because their activity may result in callbacks being invoked. -
trunk/Source/WebCore/loader/FrameLoader.cpp
r104803 r105310 88 88 #include "ResourceRequest.h" 89 89 #include "SchemeRegistry.h" 90 #include "ScrollAnimator.h" 90 #include "ScriptCallStack.h" 91 #include "ScriptCallStackFactory.h" 91 92 #include "ScriptController.h" 92 93 #include "ScriptSourceCode.h" 94 #include "ScrollAnimator.h" 93 95 #include "SecurityOrigin.h" 94 96 #include "SecurityPolicy.h" … … 1561 1563 return true; 1562 1564 1563 Settings* settings = targetFrame->settings(); 1564 if (settings && !settings->privateBrowsingEnabled()) { 1565 Document* targetDocument = targetFrame->document(); 1566 // FIXME: this error message should contain more specifics of why the navigation change is not allowed. 1567 String message = "Unsafe JavaScript attempt to initiate a navigation change for frame with URL " + 1568 targetDocument->url().string() + " from frame with URL " + activeDocument->url().string() + ".\n"; 1569 1570 // FIXME: should we print to the console of the activeFrame as well? 1571 targetFrame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message); 1572 } 1573 1565 Document* targetDocument = targetFrame->document(); 1566 // FIXME: this error message should contain more specifics of why the navigation change is not allowed. 1567 String message = "Unsafe JavaScript attempt to initiate a navigation change for frame with URL " + 1568 targetDocument->url().string() + " from frame with URL " + activeDocument->url().string() + ".\n"; 1569 1570 // FIXME: should we print to the console of the activeFrame as well? 1571 targetFrame->domWindow()->printErrorMessage(message); 1572 1574 1573 return false; 1575 1574 } -
trunk/Source/WebCore/page/Console.cpp
r104803 r105310 129 129 } 130 130 131 void addMessage(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>); 132 133 void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack) 134 { 135 addMessage(source, type, level, message, String(), 0, callStack); 136 } 137 131 138 void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack> callStack) 132 139 { -
trunk/Source/WebCore/page/Console.h
r104803 r105310 57 57 58 58 void addMessage(MessageSource, MessageType, MessageLevel, const String& message, const String& sourceURL = String(), unsigned lineNumber = 0, PassRefPtr<ScriptCallStack> = 0); 59 void addMessage(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>); 59 60 60 61 void debug(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>); -
trunk/Source/WebCore/page/DOMWindow.cpp
r104803 r105310 84 84 #include "ScheduledAction.h" 85 85 #include "Screen.h" 86 #include "ScriptCallStack.h" 87 #include "ScriptCallStackFactory.h" 86 88 #include "SecurityOrigin.h" 87 89 #include "SerializedScriptValue.h" … … 124 126 class PostMessageTimer : public TimerBase { 125 127 public: 126 PostMessageTimer(DOMWindow* window, PassRefPtr<SerializedScriptValue> message, const String& sourceOrigin, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortChannelArray> channels, SecurityOrigin* targetOrigin )128 PostMessageTimer(DOMWindow* window, PassRefPtr<SerializedScriptValue> message, const String& sourceOrigin, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortChannelArray> channels, SecurityOrigin* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace) 127 129 : m_window(window) 128 130 , m_message(message) … … 131 133 , m_channels(channels) 132 134 , m_targetOrigin(targetOrigin) 135 , m_stackTrace(stackTrace) 133 136 { 134 137 } … … 140 143 } 141 144 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); } 145 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); } 142 146 143 147 private: … … 154 158 OwnPtr<MessagePortChannelArray> m_channels; 155 159 RefPtr<SecurityOrigin> m_targetOrigin; 160 RefPtr<ScriptCallStack> m_stackTrace; 156 161 }; 157 162 … … 859 864 String sourceOrigin = sourceDocument->securityOrigin()->toString(); 860 865 866 // Capture stack trace only when inspector front-end is loaded as it may be time consuming. 867 RefPtr<ScriptCallStack> stackTrace; 868 if (InspectorInstrumentation::hasFrontends()) 869 stackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true); 870 861 871 // Schedule the message. 862 PostMessageTimer* timer = new PostMessageTimer(this, message, sourceOrigin, source, channels.release(), target.get() );872 PostMessageTimer* timer = new PostMessageTimer(this, message, sourceOrigin, source, channels.release(), target.get(), stackTrace.release()); 863 873 timer->startOneShot(0); 864 874 } … … 884 894 String message = "Unable to post message to " + timer->targetOrigin()->toString() + 885 895 ". Recipient has origin " + document()->securityOrigin()->toString() + ".\n"; 886 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message );896 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, timer->stackTrace()); 887 897 return; 888 898 } … … 1711 1721 1712 1722 // FIXME: Add arguments so that we can provide a correct source URL and line number. 1713 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message); 1723 RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true); 1724 console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, stackTrace.release()); 1714 1725 } 1715 1726
Note: See TracChangeset
for help on using the changeset viewer.