OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 11 matching lines...) Expand all Loading... | |
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 #include "core/frame/FrameConsole.h" | 30 #include "core/frame/FrameConsole.h" |
31 | 31 |
32 #include "bindings/core/v8/ScriptCallStackFactory.h" | |
32 #include "core/frame/FrameHost.h" | 33 #include "core/frame/FrameHost.h" |
33 #include "core/inspector/ConsoleAPITypes.h" | 34 #include "core/inspector/ConsoleAPITypes.h" |
34 #include "core/inspector/ConsoleMessage.h" | 35 #include "core/inspector/ConsoleMessage.h" |
35 #include "core/inspector/InspectorConsoleInstrumentation.h" | 36 #include "core/inspector/InspectorConsoleInstrumentation.h" |
36 #include "core/inspector/ScriptCallStack.h" | 37 #include "core/inspector/ScriptCallStack.h" |
37 #include "core/page/Chrome.h" | 38 #include "core/page/Chrome.h" |
38 #include "core/page/ChromeClient.h" | 39 #include "core/page/ChromeClient.h" |
39 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
40 #include "core/workers/WorkerGlobalScopeProxy.h" | 41 #include "core/workers/WorkerGlobalScopeProxy.h" |
41 #include "wtf/text/StringBuilder.h" | 42 #include "wtf/text/StringBuilder.h" |
42 | 43 |
43 namespace blink { | 44 namespace blink { |
44 | 45 |
45 namespace { | 46 namespace { |
46 | 47 |
47 int muteCount = 0; | 48 int muteCount = 0; |
48 | 49 |
49 } | 50 } |
50 | 51 |
51 FrameConsole::FrameConsole(LocalFrame& frame) | 52 FrameConsole::FrameConsole(LocalFrame& frame) |
52 : m_frame(frame) | 53 : m_frame(frame) |
53 { | 54 { |
54 } | 55 } |
55 | 56 |
56 void FrameConsole::addMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> prpConsoleM essage) | 57 void FrameConsole::addMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> prpConsoleM essage) |
57 { | 58 { |
58 if (muteCount) | 59 if (muteCount && prpConsoleMessage->source() != ConsoleAPIMessageSource) |
vsevik
2014/08/18 18:41:06
You should never use prp* parameters as is.
kozyatinskiy1
2014/08/19 07:31:06
Done.
| |
59 return; | 60 return; |
60 | 61 |
61 // FIXME: This should not need to reach for the main-frame. | 62 // FIXME: This should not need to reach for the main-frame. |
62 // Inspector code should just take the current frame and know how to walk it self. | 63 // Inspector code should just take the current frame and know how to walk it self. |
63 ExecutionContext* context = m_frame.document(); | 64 ExecutionContext* context = m_frame.document(); |
64 if (!context) | 65 if (!context) |
65 return; | 66 return; |
66 | 67 |
67 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; | 68 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; |
68 InspectorInstrumentation::addMessageToConsole(context, consoleMessage.get()) ; | 69 InspectorInstrumentation::addMessageToConsole(context, consoleMessage.get()) ; |
69 | 70 |
70 String messageURL; | |
71 if (consoleMessage->callStack()) | |
72 messageURL = consoleMessage->callStack()->at(0).sourceURL(); | |
73 else | |
74 messageURL = consoleMessage->url(); | |
75 | |
76 if (consoleMessage->source() == CSSMessageSource) | 71 if (consoleMessage->source() == CSSMessageSource) |
77 return; | 72 return; |
78 | 73 |
74 String messageURL; | |
75 unsigned lineNumber = 0; | |
76 if (consoleMessage->callStack()) { | |
77 lineNumber = consoleMessage->callStack()->at(0).lineNumber(); | |
78 messageURL = consoleMessage->callStack()->at(0).sourceURL(); | |
79 } else { | |
80 lineNumber = consoleMessage->lineNumber(); | |
81 messageURL = consoleMessage->url(); | |
82 } | |
83 | |
84 RefPtr<ScriptCallStack> reportedCallStack; | |
85 if (consoleMessage->source() != ConsoleAPIMessageSource) { | |
86 if (consoleMessage->callStack() && m_frame.chromeClient().shouldReportDe tailedMessageForSource(messageURL)) | |
87 reportedCallStack = consoleMessage->callStack(); | |
88 } else { | |
89 if (!m_frame.host() || (consoleMessage->scriptArguments() && consoleMess age->scriptArguments()->argumentCount() == 0)) | |
90 return; | |
91 | |
92 MessageType type = consoleMessage->type(); | |
93 if (type == StartGroupMessageType || type == EndGroupMessageType || type == StartGroupCollapsedMessageType) | |
94 return; | |
95 | |
96 if (m_frame.chromeClient().shouldReportDetailedMessageForSource(messageU RL)) | |
97 reportedCallStack = createScriptCallStack(ScriptCallStack::maxCallSt ackSizeToCapture); | |
98 } | |
99 | |
79 String stackTrace; | 100 String stackTrace; |
80 if (consoleMessage->callStack() && m_frame.chromeClient().shouldReportDetail edMessageForSource(consoleMessage->url())) | 101 if (reportedCallStack) |
81 stackTrace = FrameConsole::formatStackTraceString(consoleMessage->messag e(), consoleMessage->callStack()); | 102 stackTrace = FrameConsole::formatStackTraceString(consoleMessage->messag e(), reportedCallStack); |
82 | 103 m_frame.chromeClient().addMessageToConsole(&m_frame, consoleMessage->source( ), consoleMessage->level(), consoleMessage->message(), lineNumber, messageURL, s tackTrace); |
83 m_frame.chromeClient().addMessageToConsole(&m_frame, consoleMessage->source( ), consoleMessage->level(), consoleMessage->message(), consoleMessage->lineNumbe r(), messageURL, stackTrace); | |
84 } | 104 } |
85 | 105 |
86 String FrameConsole::formatStackTraceString(const String& originalMessage, PassR efPtrWillBeRawPtr<ScriptCallStack> callStack) | 106 String FrameConsole::formatStackTraceString(const String& originalMessage, PassR efPtrWillBeRawPtr<ScriptCallStack> callStack) |
87 { | 107 { |
88 StringBuilder stackTrace; | 108 StringBuilder stackTrace; |
89 for (size_t i = 0; i < callStack->size(); ++i) { | 109 for (size_t i = 0; i < callStack->size(); ++i) { |
90 const ScriptCallFrame& frame = callStack->at(i); | 110 const ScriptCallFrame& frame = callStack->at(i); |
91 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)")); | 111 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)")); |
92 stackTrace.append(" ("); | 112 stackTrace.append(" ("); |
93 stackTrace.append(frame.sourceURL()); | 113 stackTrace.append(frame.sourceURL()); |
(...skipping 17 matching lines...) Expand all Loading... | |
111 ASSERT(muteCount > 0); | 131 ASSERT(muteCount > 0); |
112 muteCount--; | 132 muteCount--; |
113 } | 133 } |
114 | 134 |
115 void FrameConsole::adoptWorkerConsoleMessages(WorkerGlobalScopeProxy* proxy) | 135 void FrameConsole::adoptWorkerConsoleMessages(WorkerGlobalScopeProxy* proxy) |
116 { | 136 { |
117 InspectorInstrumentation::adoptWorkerConsoleMessages(m_frame.document(), pro xy); | 137 InspectorInstrumentation::adoptWorkerConsoleMessages(m_frame.document(), pro xy); |
118 } | 138 } |
119 | 139 |
120 } // namespace blink | 140 } // namespace blink |
OLD | NEW |