Title: [244563] trunk
Revision
244563
Author
[email protected]
Date
2019-04-23 13:40:58 -0700 (Tue, 23 Apr 2019)

Log Message

ContentSecurityPolicy::logToConsole should include line/column number and source location
https://bugs.webkit.org/show_bug.cgi?id=114317
<rdar://problem/13614617>

Reviewed by Timothy Hatcher.

Source/WebCore:

No change in functionality.

* page/csp/ContentSecurityPolicy.h:
* page/csp/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::reportViolation const):
(WebCore::ContentSecurityPolicy::logToConsole const):

LayoutTests:

* inspector/debugger/csp-exceptions.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (244562 => 244563)


--- trunk/LayoutTests/ChangeLog	2019-04-23 20:32:39 UTC (rev 244562)
+++ trunk/LayoutTests/ChangeLog	2019-04-23 20:40:58 UTC (rev 244563)
@@ -1,3 +1,13 @@
+2019-04-23  Devin Rousso  <[email protected]>
+
+        ContentSecurityPolicy::logToConsole should include line/column number and source location
+        https://bugs.webkit.org/show_bug.cgi?id=114317
+        <rdar://problem/13614617>
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/debugger/csp-exceptions.html:
+
 2019-04-23  Andres Gonzalez  <[email protected]>
 
         Accessibility text search and selection API enhancements.

Modified: trunk/LayoutTests/inspector/debugger/csp-exceptions.html (244562 => 244563)


--- trunk/LayoutTests/inspector/debugger/csp-exceptions.html	2019-04-23 20:32:39 UTC (rev 244562)
+++ trunk/LayoutTests/inspector/debugger/csp-exceptions.html	2019-04-23 20:40:58 UTC (rev 244563)
@@ -32,8 +32,11 @@
             });
 
             WI.consoleManager.singleFireEventListener(WI.ConsoleManager.Event.MessageAdded, (event) => {
-                InspectorTest.assert(event.data.message.level === WI.ConsoleMessage.MessageLevel.Error);
-                InspectorTest.pass("CSP Exception Console Message: " + event.data.message.messageText);
+                let {message} = event.data;
+                InspectorTest.assert(message.level === WI.ConsoleMessage.MessageLevel.Error);
+                InspectorTest.assert(message.line > 0);
+                InspectorTest.assert(message.column > 0);
+                InspectorTest.pass("CSP Exception Console Message: " + message.messageText);
                 resolve();
             });
         }
@@ -53,9 +56,13 @@
             });
             WI.consoleManager.singleFireEventListener(WI.ConsoleManager.Event.MessageAdded, (event) => {
                 WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, tempPauseFailListener, null);
-                InspectorTest.assert(event.data.message.level === WI.ConsoleMessage.MessageLevel.Error);
+
+                let {message} = event.data;
+                InspectorTest.assert(message.level === WI.ConsoleMessage.MessageLevel.Error);
+                InspectorTest.assert(message.line > 0);
+                InspectorTest.assert(message.column > 0);
                 InspectorTest.expectFalse(didPause, "CSP Exception caused outside of script evaluation should not pause.");
-                InspectorTest.pass("CSP Exception Console Message: " + event.data.message.messageText);
+                InspectorTest.pass("CSP Exception Console Message: " + message.messageText);
                 resolve();
             });
         }

Modified: trunk/Source/WebCore/ChangeLog (244562 => 244563)


--- trunk/Source/WebCore/ChangeLog	2019-04-23 20:32:39 UTC (rev 244562)
+++ trunk/Source/WebCore/ChangeLog	2019-04-23 20:40:58 UTC (rev 244563)
@@ -1,5 +1,20 @@
 2019-04-23  Devin Rousso  <[email protected]>
 
+        ContentSecurityPolicy::logToConsole should include line/column number and source location
+        https://bugs.webkit.org/show_bug.cgi?id=114317
+        <rdar://problem/13614617>
+
+        Reviewed by Timothy Hatcher.
+
+        No change in functionality.
+
+        * page/csp/ContentSecurityPolicy.h:
+        * page/csp/ContentSecurityPolicy.cpp:
+        (WebCore::ContentSecurityPolicy::reportViolation const):
+        (WebCore::ContentSecurityPolicy::logToConsole const):
+
+2019-04-23  Devin Rousso  <[email protected]>
+
         Web Inspector: Canvas: support recording TypedOMCSSImageValue
         https://bugs.webkit.org/show_bug.cgi?id=192609
 

Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp (244562 => 244563)


--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp	2019-04-23 20:32:39 UTC (rev 244562)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp	2019-04-23 20:40:58 UTC (rev 244563)
@@ -670,7 +670,7 @@
 
 void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList& violatedDirectiveList, const URL& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, JSC::ExecState* state) const
 {
-    logToConsole(consoleMessage, sourceURL, sourcePosition.m_line, state);
+    logToConsole(consoleMessage, sourceURL, sourcePosition.m_line, sourcePosition.m_column, state);
 
     if (!m_isReportingEnabled)
         return;
@@ -849,16 +849,15 @@
     logToConsole("The Content Security Policy '" + policy + "' was delivered in report-only mode, but does not specify a 'report-uri'; the policy will have no effect. Please either add a 'report-uri' directive, or deliver the policy via the 'Content-Security-Policy' header.");
 }
 
-void ContentSecurityPolicy::logToConsole(const String& message, const String& contextURL, const WTF::OrdinalNumber& contextLine, JSC::ExecState* state) const
+void ContentSecurityPolicy::logToConsole(const String& message, const String& contextURL, const WTF::OrdinalNumber& contextLine, const WTF::OrdinalNumber& contextColumn, JSC::ExecState* state) const
 {
     if (!m_isReportingEnabled)
         return;
 
-    // FIXME: <http://webkit.org/b/114317> ContentSecurityPolicy::logToConsole should include a column number
     if (m_client)
         m_client->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, 0);
     else if (m_scriptExecutionContext)
-        m_scriptExecutionContext->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, contextURL, contextLine.oneBasedInt(), 0, state);
+        m_scriptExecutionContext->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, contextURL, contextLine.oneBasedInt(), contextColumn.oneBasedInt(), state);
 }
 
 void ContentSecurityPolicy::reportBlockedScriptExecutionToInspector(const String& directiveText) const

Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h (244562 => 244563)


--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h	2019-04-23 20:32:39 UTC (rev 244562)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h	2019-04-23 20:40:58 UTC (rev 244563)
@@ -173,7 +173,7 @@
     void setClient(ContentSecurityPolicyClient* client) { m_client = client; }
 
 private:
-    void logToConsole(const String& message, const String& contextURL = String(), const WTF::OrdinalNumber& contextLine = WTF::OrdinalNumber::beforeFirst(), JSC::ExecState* = nullptr) const;
+    void logToConsole(const String& message, const String& contextURL = String(), const WTF::OrdinalNumber& contextLine = WTF::OrdinalNumber::beforeFirst(), const WTF::OrdinalNumber& contextColumn = WTF::OrdinalNumber::beforeFirst(), JSC::ExecState* = nullptr) const;
     void updateSourceSelf(const SecurityOrigin&);
     void applyPolicyToScriptExecutionContext();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to