Changeset 244563 in webkit


Ignore:
Timestamp:
Apr 23, 2019 1:40:58 PM (5 years ago)
Author:
Devin Rousso
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:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r244561 r244563  
     12019-04-23  Devin Rousso  <drousso@apple.com>
     2
     3        ContentSecurityPolicy::logToConsole should include line/column number and source location
     4        https://bugs.webkit.org/show_bug.cgi?id=114317
     5        <rdar://problem/13614617>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * inspector/debugger/csp-exceptions.html:
     10
    1112019-04-23  Andres Gonzalez  <andresg_22@apple.com>
    212
  • trunk/LayoutTests/inspector/debugger/csp-exceptions.html

    r236766 r244563  
    3333
    3434            WI.consoleManager.singleFireEventListener(WI.ConsoleManager.Event.MessageAdded, (event) => {
    35                 InspectorTest.assert(event.data.message.level === WI.ConsoleMessage.MessageLevel.Error);
    36                 InspectorTest.pass("CSP Exception Console Message: " + event.data.message.messageText);
     35                let {message} = event.data;
     36                InspectorTest.assert(message.level === WI.ConsoleMessage.MessageLevel.Error);
     37                InspectorTest.assert(message.line > 0);
     38                InspectorTest.assert(message.column > 0);
     39                InspectorTest.pass("CSP Exception Console Message: " + message.messageText);
    3740                resolve();
    3841            });
     
    5457            WI.consoleManager.singleFireEventListener(WI.ConsoleManager.Event.MessageAdded, (event) => {
    5558                WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, tempPauseFailListener, null);
    56                 InspectorTest.assert(event.data.message.level === WI.ConsoleMessage.MessageLevel.Error);
     59
     60                let {message} = event.data;
     61                InspectorTest.assert(message.level === WI.ConsoleMessage.MessageLevel.Error);
     62                InspectorTest.assert(message.line > 0);
     63                InspectorTest.assert(message.column > 0);
    5764                InspectorTest.expectFalse(didPause, "CSP Exception caused outside of script evaluation should not pause.");
    58                 InspectorTest.pass("CSP Exception Console Message: " + event.data.message.messageText);
     65                InspectorTest.pass("CSP Exception Console Message: " + message.messageText);
    5966                resolve();
    6067            });
  • trunk/Source/WebCore/ChangeLog

    r244562 r244563  
     12019-04-23  Devin Rousso  <drousso@apple.com>
     2
     3        ContentSecurityPolicy::logToConsole should include line/column number and source location
     4        https://bugs.webkit.org/show_bug.cgi?id=114317
     5        <rdar://problem/13614617>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        No change in functionality.
     10
     11        * page/csp/ContentSecurityPolicy.h:
     12        * page/csp/ContentSecurityPolicy.cpp:
     13        (WebCore::ContentSecurityPolicy::reportViolation const):
     14        (WebCore::ContentSecurityPolicy::logToConsole const):
     15
    1162019-04-23  Devin Rousso  <drousso@apple.com>
    217
  • trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp

    r239427 r244563  
    671671void 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
    672672{
    673     logToConsole(consoleMessage, sourceURL, sourcePosition.m_line, state);
     673    logToConsole(consoleMessage, sourceURL, sourcePosition.m_line, sourcePosition.m_column, state);
    674674
    675675    if (!m_isReportingEnabled)
     
    850850}
    851851
    852 void ContentSecurityPolicy::logToConsole(const String& message, const String& contextURL, const WTF::OrdinalNumber& contextLine, JSC::ExecState* state) const
     852void ContentSecurityPolicy::logToConsole(const String& message, const String& contextURL, const WTF::OrdinalNumber& contextLine, const WTF::OrdinalNumber& contextColumn, JSC::ExecState* state) const
    853853{
    854854    if (!m_isReportingEnabled)
    855855        return;
    856856
    857     // FIXME: <http://webkit.org/b/114317> ContentSecurityPolicy::logToConsole should include a column number
    858857    if (m_client)
    859858        m_client->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, 0);
    860859    else if (m_scriptExecutionContext)
    861         m_scriptExecutionContext->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, contextURL, contextLine.oneBasedInt(), 0, state);
     860        m_scriptExecutionContext->addConsoleMessage(MessageSource::Security, MessageLevel::Error, message, contextURL, contextLine.oneBasedInt(), contextColumn.oneBasedInt(), state);
    862861}
    863862
  • trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h

    r239427 r244563  
    174174
    175175private:
    176     void logToConsole(const String& message, const String& contextURL = String(), const WTF::OrdinalNumber& contextLine = WTF::OrdinalNumber::beforeFirst(), JSC::ExecState* = nullptr) const;
     176    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;
    177177    void updateSourceSelf(const SecurityOrigin&);
    178178    void applyPolicyToScriptExecutionContext();
Note: See TracChangeset for help on using the changeset viewer.