Title: [223836] trunk/Source

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (223835 => 223836)


--- trunk/Source/_javascript_Core/ChangeLog	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-10-23 16:44:58 UTC (rev 223836)
@@ -1,3 +1,15 @@
+2017-10-23  Matt Lewis  <[email protected]>
+
+        Unreviewed, rolling out r223820.
+
+        This caused a build break on Windows.
+
+        Reverted changeset:
+
+        "Web Inspector: Remove unused Console.setMonitoringXHREnabled"
+        https://bugs.webkit.org/show_bug.cgi?id=178617
+        https://trac.webkit.org/changeset/223820
+
 2017-10-23  Yusuke Suzuki  <[email protected]>
 
         [JSC] Use fastJoin in Array#toString

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (223835 => 223836)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2017-10-23 16:44:58 UTC (rev 223836)
@@ -1335,6 +1335,7 @@
 		A5FD007A189B051000633231 /* ConsoleMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = A5FD0078189B051000633231 /* ConsoleMessage.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A5FD007E189B0B4C00633231 /* ScriptCallStackFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = A5FD007C189B0B4C00633231 /* ScriptCallStackFactory.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A5FD0082189B191A00633231 /* InspectorConsoleAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = A5FD0080189B191A00633231 /* InspectorConsoleAgent.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		A5FD0086189B1B7E00633231 /* JSGlobalObjectConsoleAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = A5FD0084189B1B7E00633231 /* JSGlobalObjectConsoleAgent.h */; };
 		A700873A17CBE85300C3E643 /* MapConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = A700873817CBE85300C3E643 /* MapConstructor.h */; };
 		A700873E17CBE8D300C3E643 /* MapPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = A700873C17CBE8D300C3E643 /* MapPrototype.h */; };
 		A700874217CBE8EB00C3E643 /* JSMap.h in Headers */ = {isa = PBXBuildFile; fileRef = A700874017CBE8EB00C3E643 /* JSMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3956,6 +3957,8 @@
 		A5FD007C189B0B4C00633231 /* ScriptCallStackFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallStackFactory.h; sourceTree = "<group>"; };
 		A5FD007F189B191A00633231 /* InspectorConsoleAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorConsoleAgent.cpp; sourceTree = "<group>"; };
 		A5FD0080189B191A00633231 /* InspectorConsoleAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorConsoleAgent.h; sourceTree = "<group>"; };
+		A5FD0083189B1B7E00633231 /* JSGlobalObjectConsoleAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGlobalObjectConsoleAgent.cpp; sourceTree = "<group>"; };
+		A5FD0084189B1B7E00633231 /* JSGlobalObjectConsoleAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObjectConsoleAgent.h; sourceTree = "<group>"; };
 		A700873717CBE85300C3E643 /* MapConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MapConstructor.cpp; sourceTree = "<group>"; };
 		A700873817CBE85300C3E643 /* MapConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapConstructor.h; sourceTree = "<group>"; };
 		A700873B17CBE8D300C3E643 /* MapPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MapPrototype.cpp; sourceTree = "<group>"; };
@@ -7557,6 +7560,8 @@
 				A50E4B5E18809DD50068A46D /* InspectorRuntimeAgent.h */,
 				A55165D01BDEFDBD003B75C1 /* InspectorScriptProfilerAgent.cpp */,
 				A55165D11BDEFDBD003B75C1 /* InspectorScriptProfilerAgent.h */,
+				A5FD0083189B1B7E00633231 /* JSGlobalObjectConsoleAgent.cpp */,
+				A5FD0084189B1B7E00633231 /* JSGlobalObjectConsoleAgent.h */,
 				A57D23E71891B0770031C7FA /* JSGlobalObjectDebuggerAgent.cpp */,
 				A57D23E81891B0770031C7FA /* JSGlobalObjectDebuggerAgent.h */,
 				A50E4B5F18809DD50068A46D /* JSGlobalObjectRuntimeAgent.cpp */,
@@ -8759,6 +8764,7 @@
 				797E07AA1B8FCFB9008400BA /* JSGlobalLexicalEnvironment.h in Headers */,
 				BC18C4210E16F5CD00B34460 /* JSGlobalObject.h in Headers */,
 				996B731D1BDA08EF00331B84 /* JSGlobalObject.lut.h in Headers */,
+				A5FD0086189B1B7E00633231 /* JSGlobalObjectConsoleAgent.h in Headers */,
 				A5C3A1A618C0490200C9593A /* JSGlobalObjectConsoleClient.h in Headers */,
 				A59455931824744700CC3843 /* JSGlobalObjectDebuggable.h in Headers */,
 				A57D23EA1891B0770031C7FA /* JSGlobalObjectDebuggerAgent.h in Headers */,

Modified: trunk/Source/_javascript_Core/Sources.txt (223835 => 223836)


--- trunk/Source/_javascript_Core/Sources.txt	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/_javascript_Core/Sources.txt	2017-10-23 16:44:58 UTC (rev 223836)
@@ -557,6 +557,7 @@
 inspector/agents/InspectorHeapAgent.cpp
 inspector/agents/InspectorRuntimeAgent.cpp
 inspector/agents/InspectorScriptProfilerAgent.cpp
+inspector/agents/JSGlobalObjectConsoleAgent.cpp
 inspector/agents/JSGlobalObjectDebuggerAgent.cpp
 inspector/agents/JSGlobalObjectRuntimeAgent.cpp
 

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp (223835 => 223836)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp	2017-10-23 16:44:58 UTC (rev 223836)
@@ -35,7 +35,6 @@
 #include "InjectedScriptManager.h"
 #include "InspectorAgent.h"
 #include "InspectorBackendDispatcher.h"
-#include "InspectorConsoleAgent.h"
 #include "InspectorFrontendChannel.h"
 #include "InspectorFrontendRouter.h"
 #include "InspectorHeapAgent.h"
@@ -42,6 +41,7 @@
 #include "InspectorScriptProfilerAgent.h"
 #include "JSCInlines.h"
 #include "JSGlobalObject.h"
+#include "JSGlobalObjectConsoleAgent.h"
 #include "JSGlobalObjectConsoleClient.h"
 #include "JSGlobalObjectDebuggerAgent.h"
 #include "JSGlobalObjectRuntimeAgent.h"
@@ -83,7 +83,7 @@
     auto inspectorAgent = std::make_unique<InspectorAgent>(context);
     auto runtimeAgent = std::make_unique<JSGlobalObjectRuntimeAgent>(context);
     auto heapAgent = std::make_unique<InspectorHeapAgent>(context);
-    auto consoleAgent = std::make_unique<InspectorConsoleAgent>(context, heapAgent.get());
+    auto consoleAgent = std::make_unique<JSGlobalObjectConsoleAgent>(context, heapAgent.get());
     auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(context, consoleAgent.get());
     auto scriptProfilerAgent = std::make_unique<InspectorScriptProfilerAgent>(context);
 

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.h (223835 => 223836)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.h	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.h	2017-10-23 16:44:58 UTC (rev 223836)
@@ -61,6 +61,7 @@
     void enable(ErrorString&) override;
     void disable(ErrorString&) override;
     void clearMessages(ErrorString&) override;
+    void setMonitoringXHREnabled(ErrorString&, bool enabled) override = 0;
 
     bool enabled() const { return m_enabled; }
     void reset();

Added: trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.cpp (0 => 223836)


--- trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.cpp	                        (rev 0)
+++ trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.cpp	2017-10-23 16:44:58 UTC (rev 223836)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSGlobalObjectConsoleAgent.h"
+
+namespace Inspector {
+
+JSGlobalObjectConsoleAgent::JSGlobalObjectConsoleAgent(AgentContext& context, InspectorHeapAgent* heapAgent)
+    : InspectorConsoleAgent(context, heapAgent)
+{
+}
+
+void JSGlobalObjectConsoleAgent::setMonitoringXHREnabled(ErrorString& errorString, bool)
+{
+    errorString = ASCIILiteral("Not supported for _javascript_ context");
+}
+
+} // namespace Inspector

Added: trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.h (0 => 223836)


--- trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.h	2017-10-23 16:44:58 UTC (rev 223836)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "InspectorConsoleAgent.h"
+
+namespace Inspector {
+
+class JSGlobalObjectConsoleAgent final : public InspectorConsoleAgent {
+    WTF_MAKE_NONCOPYABLE(JSGlobalObjectConsoleAgent);
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    JSGlobalObjectConsoleAgent(AgentContext&, InspectorHeapAgent*);
+    virtual ~JSGlobalObjectConsoleAgent() { }
+
+    // FIXME: XHRs and Nodes only makes sense debugging a Web context. Can this be moved to a different agent?
+    void setMonitoringXHREnabled(ErrorString&, bool enabled) override;
+};
+
+} // namespace Inspector

Modified: trunk/Source/_javascript_Core/inspector/protocol/Console.json (223835 => 223836)


--- trunk/Source/_javascript_Core/inspector/protocol/Console.json	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/_javascript_Core/inspector/protocol/Console.json	2017-10-23 16:44:58 UTC (rev 223836)
@@ -57,6 +57,13 @@
         {
             "name": "clearMessages",
             "description": "Clears console messages collected in the browser."
+        },
+        {
+            "name": "setMonitoringXHREnabled",
+            "description": "Toggles monitoring of XMLHttpRequest. If <code>true</code>, console will receive messages upon each XHR issued.",
+            "parameters": [
+                { "name": "enabled", "type": "boolean", "description": "Monitoring enabled state." }
+            ]
         }
     ],
     "events": [

Modified: trunk/Source/WebCore/ChangeLog (223835 => 223836)


--- trunk/Source/WebCore/ChangeLog	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/WebCore/ChangeLog	2017-10-23 16:44:58 UTC (rev 223836)
@@ -1,3 +1,15 @@
+2017-10-23  Matt Lewis  <[email protected]>
+
+        Unreviewed, rolling out r223820.
+
+        This caused a build break on Windows.
+
+        Reverted changeset:
+
+        "Web Inspector: Remove unused Console.setMonitoringXHREnabled"
+        https://bugs.webkit.org/show_bug.cgi?id=178617
+        https://trac.webkit.org/changeset/223820
+
 2017-10-23  Zalan Bujtas  <[email protected]>
 
         Call FrameView::scheduleSelectionUpdate when selection needs repainting after layout instead of setting the RenderView dirty.

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (223835 => 223836)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2017-10-23 16:44:58 UTC (rev 223836)
@@ -625,8 +625,10 @@
         consoleAgent->didFailLoading(identifier, error); // This should come AFTER resource notification, front-end relies on this.
 }
 
-void InspectorInstrumentation::didFinishXHRLoadingImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, std::optional<String> decodedText)
+void InspectorInstrumentation::didFinishXHRLoadingImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, std::optional<String> decodedText, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber)
 {
+    if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
+        consoleAgent->didFinishXHRLoading(identifier, url, sendURL, sendLineNumber, sendColumnNumber);
     if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent()) {
         if (decodedText)
             networkAgent->didFinishXHRLoading(identifier, *decodedText);

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (223835 => 223836)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2017-10-23 16:44:58 UTC (rev 223836)
@@ -186,7 +186,7 @@
     enum class LoadType { Ping, Beacon };
     static void willSendRequestOfType(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
 
-    static void didFinishXHRLoading(ScriptExecutionContext*, unsigned long identifier, std::optional<String> decodedText);
+    static void didFinishXHRLoading(ScriptExecutionContext*, unsigned long identifier, std::optional<String> decodedText, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber);
     static void willLoadXHRSynchronously(ScriptExecutionContext*);
     static void didLoadXHRSynchronously(ScriptExecutionContext*);
     static void scriptImported(ScriptExecutionContext&, unsigned long identifier, const String& sourceString);
@@ -355,7 +355,7 @@
     static void didReceiveDataImpl(InstrumentingAgents&, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
     static void didFinishLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const NetworkLoadMetrics&, ResourceLoader*);
     static void didFailLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceError&);
-    static void didFinishXHRLoadingImpl(InstrumentingAgents&, unsigned long identifier, std::optional<String> decodedText);
+    static void didFinishXHRLoadingImpl(InstrumentingAgents&, unsigned long identifier, std::optional<String> decodedText, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber);
     static void willLoadXHRSynchronouslyImpl(InstrumentingAgents&);
     static void didLoadXHRSynchronouslyImpl(InstrumentingAgents&);
     static void scriptImportedImpl(InstrumentingAgents&, unsigned long identifier, const String& sourceString);
@@ -957,10 +957,10 @@
         didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
 }
 
-inline void InspectorInstrumentation::didFinishXHRLoading(ScriptExecutionContext* context, unsigned long identifier, std::optional<String> decodedText)
+inline void InspectorInstrumentation::didFinishXHRLoading(ScriptExecutionContext* context, unsigned long identifier, std::optional<String> decodedText, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber)
 {
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
-        didFinishXHRLoadingImpl(*instrumentingAgents, identifier, decodedText);
+        didFinishXHRLoadingImpl(*instrumentingAgents, identifier, decodedText, url, sendURL, sendLineNumber, sendColumnNumber);
 }
 
 inline void InspectorInstrumentation::willLoadXHRSynchronously(ScriptExecutionContext* context)

Modified: trunk/Source/WebCore/inspector/WebConsoleAgent.cpp (223835 => 223836)


--- trunk/Source/WebCore/inspector/WebConsoleAgent.cpp	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/WebCore/inspector/WebConsoleAgent.cpp	2017-10-23 16:44:58 UTC (rev 223836)
@@ -46,6 +46,11 @@
 {
 }
 
+void WebConsoleAgent::setMonitoringXHREnabled(ErrorString&, bool enabled)
+{
+    m_monitoringXHREnabled = enabled;
+}
+
 void WebConsoleAgent::frameWindowDiscarded(DOMWindow* window)
 {
     for (auto& message : m_consoleMessages) {
@@ -60,6 +65,17 @@
     static_cast<WebInjectedScriptManager&>(m_injectedScriptManager).discardInjectedScriptsFor(window);
 }
 
+void WebConsoleAgent::didFinishXHRLoading(unsigned long requestIdentifier, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber)
+{
+    if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
+        return;
+
+    if (m_monitoringXHREnabled) {
+        String message = "XHR finished loading: \"" + url + "\".";
+        addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::Network, MessageType::Log, MessageLevel::Debug, message, sendURL, sendLineNumber, sendColumnNumber, nullptr, requestIdentifier));
+    }
+}
+
 void WebConsoleAgent::didReceiveResponse(unsigned long requestIdentifier, const ResourceResponse& response)
 {
     if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())

Modified: trunk/Source/WebCore/inspector/WebConsoleAgent.h (223835 => 223836)


--- trunk/Source/WebCore/inspector/WebConsoleAgent.h	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/WebCore/inspector/WebConsoleAgent.h	2017-10-23 16:44:58 UTC (rev 223836)
@@ -41,10 +41,16 @@
     WebConsoleAgent(Inspector::AgentContext&, Inspector::InspectorHeapAgent*);
     virtual ~WebConsoleAgent() = default;
 
+    void setMonitoringXHREnabled(ErrorString&, bool enabled) final;
+
     void frameWindowDiscarded(DOMWindow*);
 
+    void didFinishXHRLoading(unsigned long requestIdentifier, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber);
     void didReceiveResponse(unsigned long requestIdentifier, const ResourceResponse&);
     void didFailLoading(unsigned long requestIdentifier, const ResourceError&);
+
+protected:
+    bool m_monitoringXHREnabled { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (223835 => 223836)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2017-10-23 16:44:58 UTC (rev 223836)
@@ -43,6 +43,7 @@
 #include "ParsedContentType.h"
 #include "ResourceError.h"
 #include "ResourceRequest.h"
+#include "ScriptController.h"
 #include "SecurityOriginPolicy.h"
 #include "Settings.h"
 #include "SharedBuffer.h"
@@ -53,6 +54,7 @@
 #include "XMLHttpRequestProgressEvent.h"
 #include "XMLHttpRequestUpload.h"
 #include "markup.h"
+#include <interpreter/StackVisitor.h>
 #include <mutex>
 #include <runtime/ArrayBuffer.h>
 #include <runtime/ArrayBufferView.h>
@@ -278,6 +280,12 @@
     return responseURL.string();
 }
 
+void XMLHttpRequest::setLastSendLineAndColumnNumber(unsigned lineNumber, unsigned columnNumber)
+{
+    m_lastSendLineNumber = lineNumber;
+    m_lastSendColumnNumber = columnNumber;
+}
+
 XMLHttpRequestUpload* XMLHttpRequest::upload()
 {
     if (!m_upload)
@@ -425,7 +433,47 @@
     return std::nullopt;
 }
 
-ExceptionOr<void> XMLHttpRequest::send(std::optional<SendTypes>&& sendType)
+namespace {
+
+// FIXME: This should be abstracted out, so that any IDL function can be passed the line/column/url tuple.
+
+// FIXME: This should probably use ShadowChicken so that we get the right frame even when it did a tail call.
+// https://bugs.webkit.org/show_bug.cgi?id=155688
+
+class SendFunctor {
+public:
+    SendFunctor() = default;
+
+    unsigned line() const { return m_line; }
+    unsigned column() const { return m_column; }
+    String url() const { return m_url; }
+
+    JSC::StackVisitor::Status operator()(JSC::StackVisitor& visitor) const
+    {
+        if (!m_hasSkippedFirstFrame) {
+            m_hasSkippedFirstFrame = true;
+            return JSC::StackVisitor::Continue;
+        }
+
+        unsigned line = 0;
+        unsigned column = 0;
+        visitor->computeLineAndColumn(line, column);
+        m_line = line;
+        m_column = column;
+        m_url = visitor->sourceURL();
+        return JSC::StackVisitor::Done;
+    }
+
+private:
+    mutable bool m_hasSkippedFirstFrame { false };
+    mutable unsigned m_line { 0 };
+    mutable unsigned m_column { 0 };
+    mutable String m_url;
+};
+
+}
+
+ExceptionOr<void> XMLHttpRequest::send(JSC::ExecState& state, std::optional<SendTypes>&& sendType)
 {
     InspectorInstrumentation::willSendXMLHttpRequest(scriptExecutionContext(), url());
 
@@ -443,6 +491,11 @@
         );
     }
 
+    SendFunctor functor;
+    state.iterate(functor);
+    setLastSendLineAndColumnNumber(functor.line(), functor.column());
+    setLastSendURL(functor.url());
+
     return result;
 }
 
@@ -939,7 +992,7 @@
     std::optional<String> decodedText;
     if (!m_binaryResponseBuilder)
         decodedText = m_responseBuilder.toStringPreserveCapacity();
-    InspectorInstrumentation::didFinishXHRLoading(scriptExecutionContext(), identifier, decodedText);
+    InspectorInstrumentation::didFinishXHRLoading(scriptExecutionContext(), identifier, decodedText, m_url, m_lastSendURL, m_lastSendLineNumber, m_lastSendColumnNumber);
 
     bool hadLoader = m_loader;
     m_loader = nullptr;

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.h (223835 => 223836)


--- trunk/Source/WebCore/xml/XMLHttpRequest.h	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.h	2017-10-23 16:44:58 UTC (rev 223836)
@@ -35,6 +35,7 @@
 namespace JSC {
 class ArrayBuffer;
 class ArrayBufferView;
+class ExecState;
 }
 
 namespace WebCore {
@@ -79,7 +80,7 @@
     ExceptionOr<void> open(const String& method, const String& url);
     ExceptionOr<void> open(const String& method, const URL&, bool async);
     ExceptionOr<void> open(const String& method, const String&, bool async, const String& user, const String& password);
-    ExceptionOr<void> send(std::optional<SendTypes>&&);
+    ExceptionOr<void> send(JSC::ExecState&, std::optional<SendTypes>&&);
     void abort();
     ExceptionOr<void> setRequestHeader(const String& name, const String& value);
     ExceptionOr<void> overrideMimeType(const String& override);
@@ -108,6 +109,9 @@
 
     String responseURL() const;
 
+    void setLastSendLineAndColumnNumber(unsigned lineNumber, unsigned columnNumber);
+    void setLastSendURL(const String& url) { m_lastSendURL = url; }
+
     XMLHttpRequestUpload* upload();
     XMLHttpRequestUpload* optionalUpload() const { return m_upload.get(); }
 
@@ -214,6 +218,9 @@
     // Used for progress event tracking.
     long long m_receivedLength { 0 };
 
+    unsigned m_lastSendLineNumber { 0 };
+    unsigned m_lastSendColumnNumber { 0 };
+    String m_lastSendURL;
     std::optional<ExceptionCode> m_exceptionCode;
 
     XMLHttpRequestProgressEventThrottle m_progressEventThrottle;

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.idl (223835 => 223836)


--- trunk/Source/WebCore/xml/XMLHttpRequest.idl	2017-10-23 15:57:51 UTC (rev 223835)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.idl	2017-10-23 16:44:58 UTC (rev 223836)
@@ -66,7 +66,7 @@
     attribute unsigned long timeout;
     attribute boolean withCredentials;
     readonly attribute XMLHttpRequestUpload upload;
-    [MayThrowException] void send(optional (Document or BodyInit)? body = null);
+    [CallWith=ScriptState, MayThrowException] void send(optional (Document or BodyInit)? body = null);
     void abort();
 
     // response
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to