Changeset 178648 in webkit


Ignore:
Timestamp:
Jan 19, 2015, 9:25:23 AM (10 years ago)
Author:
ap@apple.com
Message:

Console log sometimes prefixed with line number
https://bugs.webkit.org/show_bug.cgi?id=105280

Reviewed by Darin Adler.

Source/WebCore:

Improve the logic for determining whether a console message should be associated
with a source code location.

  • dom/ScriptableDocumentParser.h:
  • html/parser/HTMLDocumentParser.cpp:

(WebCore::HTMLDocumentParser::shouldAssociateConsoleMessagesWithTextPosition):

  • html/parser/HTMLDocumentParser.h:
  • page/PageConsoleClient.cpp:

(WebCore::getParserLocationForConsoleMessage):
(WebCore::PageConsoleClient::addMessage):

  • xml/parser/XMLDocumentParser.cpp:

(WebCore::XMLDocumentParser::pauseParsing):

  • xml/parser/XMLDocumentParser.h:
  • xml/parser/XMLDocumentParserLibxml2.cpp:

(WebCore::XMLDocumentParser::shouldAssociateConsoleMessagesWithTextPosition):

LayoutTests:

Some messages lost line numbers now. Some of these were definitely wrong, others
were roughly right. Unfortunately, it is not currently possible to figure out whether
ScriptController actually executes a script after passing control to it. So the cases
where it refuses to execute the script and logs a message are handled like those
where it does.

I think that it shouldn't be a big obstacle in practice, it is easy enough to find
a script in a page when Web Inspector tells you that scripts were not allowed.

  • fast/frames/sandboxed-iframe-attribute-parsing-06-expected.txt:
  • fast/frames/sandboxed-iframe-attribute-parsing-07-expected.txt:
  • fast/frames/sandboxed-iframe-attribute-parsing-08-expected.txt:
  • fast/frames/sandboxed-iframe-attribute-parsing-09-expected.txt:
  • fast/frames/sandboxed-iframe-attribute-parsing-10-expected.txt:
  • fast/frames/sandboxed-iframe-attribute-parsing-11-expected.txt:
  • fast/frames/sandboxed-iframe-attribute-parsing-12-expected.txt:
  • fast/frames/sandboxed-iframe-attribute-parsing-13-expected.txt:
  • fast/frames/sandboxed-iframe-attribute-parsing-14-expected.txt:
  • fast/frames/sandboxed-iframe-parsing-space-characters-expected.txt:
  • fast/frames/sandboxed-iframe-scripting-04-expected.txt:
  • http/tests/security/contentSecurityPolicy/sandbox-empty-expected.txt:
  • http/tests/security/contentSecurityPolicy/sandbox-empty-subframe-expected.txt:
  • http/tests/security/contentSecurityPolicy/sandbox-in-http-header-control-expected.txt:
  • http/tests/security/contentSecurityPolicy/sandbox-in-http-header-expected.txt:
  • http/tests/security/contentSecurityPolicy/sandbox-invalid-header-expected.txt:
  • http/tests/security/isolatedWorld/sandboxed-iframe-expected.txt:
  • http/tests/security/mixedContent/insecure-script-in-iframe-expected.txt:
  • http/tests/security/mixedContent/redirect-http-to-https-script-in-iframe-expected.txt:
  • http/tests/security/no-javascript-refresh-expected.txt:
  • http/tests/security/no-javascript-refresh-spaces-expected.txt:
  • platform/efl/TestExpectations:
  • platform/gtk/TestExpectations:

Unmark tests that were broken by this.

Location:
trunk
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/LayoutTests/ChangeLog

    r178645 r178648  
     12015-01-16  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Console log sometimes prefixed with line number
     4        https://bugs.webkit.org/show_bug.cgi?id=105280
     5
     6        Reviewed by Darin Adler.
     7
     8        Some messages lost line numbers now. Some of these were definitely wrong, others
     9        were roughly right. Unfortunately, it is not currently possible to figure out whether
     10        ScriptController actually executes a script after passing control to it. So the cases
     11        where it refuses to execute the script and logs a message are handled like those
     12        where it does.
     13
     14        I think that it shouldn't be a big obstacle in practice, it is easy enough to find
     15        a script in a page when Web Inspector tells you that scripts were not allowed.
     16
     17        * fast/frames/sandboxed-iframe-attribute-parsing-06-expected.txt:
     18        * fast/frames/sandboxed-iframe-attribute-parsing-07-expected.txt:
     19        * fast/frames/sandboxed-iframe-attribute-parsing-08-expected.txt:
     20        * fast/frames/sandboxed-iframe-attribute-parsing-09-expected.txt:
     21        * fast/frames/sandboxed-iframe-attribute-parsing-10-expected.txt:
     22        * fast/frames/sandboxed-iframe-attribute-parsing-11-expected.txt:
     23        * fast/frames/sandboxed-iframe-attribute-parsing-12-expected.txt:
     24        * fast/frames/sandboxed-iframe-attribute-parsing-13-expected.txt:
     25        * fast/frames/sandboxed-iframe-attribute-parsing-14-expected.txt:
     26        * fast/frames/sandboxed-iframe-parsing-space-characters-expected.txt:
     27        * fast/frames/sandboxed-iframe-scripting-04-expected.txt:
     28        * http/tests/security/contentSecurityPolicy/sandbox-empty-expected.txt:
     29        * http/tests/security/contentSecurityPolicy/sandbox-empty-subframe-expected.txt:
     30        * http/tests/security/contentSecurityPolicy/sandbox-in-http-header-control-expected.txt:
     31        * http/tests/security/contentSecurityPolicy/sandbox-in-http-header-expected.txt:
     32        * http/tests/security/contentSecurityPolicy/sandbox-invalid-header-expected.txt:
     33        * http/tests/security/isolatedWorld/sandboxed-iframe-expected.txt:
     34        * http/tests/security/mixedContent/insecure-script-in-iframe-expected.txt:
     35        * http/tests/security/mixedContent/redirect-http-to-https-script-in-iframe-expected.txt:
     36        * http/tests/security/no-javascript-refresh-expected.txt:
     37        * http/tests/security/no-javascript-refresh-spaces-expected.txt:
     38
     39        * platform/efl/TestExpectations:
     40        * platform/gtk/TestExpectations:
     41        Unmark tests that were broken by this.
     42
    1432015-01-19  Csaba Osztrogonác  <ossy@webkit.org>
    244
  • TabularUnified trunk/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing-06-expected.txt

    r156130 r178648  
    11CONSOLE MESSAGE: line 9: Error while parsing the 'sandbox' attribute: 'allowscripts' is an invalid sandbox flag.
    2 CONSOLE MESSAGE: line 4: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     2CONSOLE MESSAGE: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    33Misspelling.
    44
  • TabularUnified trunk/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing-07-expected.txt

    r156130 r178648  
    11CONSOLE MESSAGE: line 9: Error while parsing the 'sandbox' attribute: 'allows-cripts' is an invalid sandbox flag.
    2 CONSOLE MESSAGE: line 4: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     2CONSOLE MESSAGE: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    33Misspelling.
    44
  • TabularUnified trunk/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing-08-expected.txt

    r156130 r178648  
    11CONSOLE MESSAGE: line 9: Error while parsing the 'sandbox' attribute: '-allow-scripts' is an invalid sandbox flag.
    2 CONSOLE MESSAGE: line 4: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     2CONSOLE MESSAGE: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    33Misspelling.
    44
  • TabularUnified trunk/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing-09-expected.txt

    r156130 r178648  
    11CONSOLE MESSAGE: line 9: Error while parsing the 'sandbox' attribute: 'allow_scripts' is an invalid sandbox flag.
    2 CONSOLE MESSAGE: line 4: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     2CONSOLE MESSAGE: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    33Misspelling.
    44
  • TabularUnified trunk/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing-10-expected.txt

    r156130 r178648  
    11CONSOLE MESSAGE: line 9: Error while parsing the 'sandbox' attribute: 'allowScripts' is an invalid sandbox flag.
    2 CONSOLE MESSAGE: line 4: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     2CONSOLE MESSAGE: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    33Misspelling.
    44
  • TabularUnified trunk/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing-11-expected.txt

    r156130 r178648  
    11CONSOLE MESSAGE: line 9: Error while parsing the 'sandbox' attribute: 'aallow-scripts' is an invalid sandbox flag.
    2 CONSOLE MESSAGE: line 4: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     2CONSOLE MESSAGE: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    33Misspelling.
    44
  • TabularUnified trunk/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing-12-expected.txt

    r156130 r178648  
    11CONSOLE MESSAGE: line 9: Error while parsing the 'sandbox' attribute: 'allow-scriptss' is an invalid sandbox flag.
    2 CONSOLE MESSAGE: line 4: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     2CONSOLE MESSAGE: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    33Misspelling.
    44
  • TabularUnified trunk/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing-13-expected.txt

    r156130 r178648  
    11CONSOLE MESSAGE: line 9: Error while parsing the 'sandbox' attribute: 'allow-script' is an invalid sandbox flag.
    2 CONSOLE MESSAGE: line 4: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     2CONSOLE MESSAGE: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    33Misspelling.
    44
  • TabularUnified trunk/LayoutTests/fast/frames/sandboxed-iframe-attribute-parsing-14-expected.txt

    r156130 r178648  
    1 CONSOLE MESSAGE: line 4: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     1CONSOLE MESSAGE: Blocked script execution in 'sandboxed-iframe-attribute-parsing-disallowed.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    22Full sandbox.
    33
  • TabularUnified trunk/LayoutTests/fast/frames/sandboxed-iframe-parsing-space-characters-expected.txt

    r178527 r178648  
    22CONSOLE MESSAGE: line 16: Error while parsing the 'sandbox' attribute: 'allow-scripts
    33allow-forms' is an invalid sandbox flag.
    4 CONSOLE MESSAGE: line 1: Blocked script execution in 'data:text/html,<script>alert('FAIL: Vertical tab is not a delimiter.');</script>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     4CONSOLE MESSAGE: Blocked script execution in 'data:text/html,<script>alert('FAIL: Vertical tab is not a delimiter.');</script>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    55ALERT: PASS: Newline is a delimiter.
    66ALERT: PASS: Return is a delimiter.
    77CONSOLE MESSAGE: line 16: Error while parsing the 'sandbox' attribute: 'allow-scriptsxallow-forms' is an invalid sandbox flag.
    8 CONSOLE MESSAGE: line 1: Blocked script execution in 'data:text/html,<script>alert('FAIL: x is not a delimiter.');</script>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     8CONSOLE MESSAGE: Blocked script execution in 'data:text/html,<script>alert('FAIL: x is not a delimiter.');</script>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    99ALERT: PASS: Tab is a delimiter.
    1010ALERT: PASS: Space is a delimiter character.
  • TabularUnified trunk/LayoutTests/fast/frames/sandboxed-iframe-scripting-04-expected.txt

    r156130 r178648  
    1 CONSOLE MESSAGE: line 1: Blocked script execution in 'data:text/html,<script>alert('FAIL: Executed script without allow-scripts in data URL');window.parent.postMessage({'fail': true}, '*');</script>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     1CONSOLE MESSAGE: Blocked script execution in 'data:text/html,<script>alert('FAIL: Executed script without allow-scripts in data URL');window.parent.postMessage({'fail': true}, '*');</script>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    22Verify that sandboxed frames without sandbox='allow-scripts' cannot execute script from data: URLs.
    33
  • TabularUnified trunk/LayoutTests/http/tests/security/contentSecurityPolicy/sandbox-empty-expected.txt

    r156130 r178648  
    1 CONSOLE MESSAGE: line 9: Blocked script execution in 'http://127.0.0.1:8000/security/contentSecurityPolicy/sandbox-empty.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     1CONSOLE MESSAGE: Blocked script execution in 'http://127.0.0.1:8000/security/contentSecurityPolicy/sandbox-empty.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    22This test passes if it doesn't alert fail.
  • TabularUnified trunk/LayoutTests/http/tests/security/contentSecurityPolicy/sandbox-empty-subframe-expected.txt

    r156130 r178648  
    1 CONSOLE MESSAGE: line 1: Blocked script execution in 'data:text/html,<script>alert('FAIL');</script>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     1CONSOLE MESSAGE: Blocked script execution in 'data:text/html,<script>alert('FAIL');</script>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    22This test passes if it doesn't alert fail.
  • TabularUnified trunk/LayoutTests/http/tests/security/contentSecurityPolicy/sandbox-in-http-header-control-expected.txt

    r156130 r178648  
    1 CONSOLE MESSAGE: line 6: Blocked script execution in 'http://127.0.0.1:8000/security/contentSecurityPolicy/resources/sandbox.php?sandbox=allow-top-navigation%20allow-same-origin' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     1CONSOLE MESSAGE: Blocked script execution in 'http://127.0.0.1:8000/security/contentSecurityPolicy/resources/sandbox.php?sandbox=allow-top-navigation%20allow-same-origin' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    22ALERT: PASS: Iframe was not in a unique origin
    33
  • TabularUnified trunk/LayoutTests/http/tests/security/contentSecurityPolicy/sandbox-in-http-header-expected.txt

    r178527 r178648  
    1 CONSOLE MESSAGE: line 6: Blocked script execution in 'http://127.0.0.1:8000/security/contentSecurityPolicy/resources/sandbox.php?sandbox=allow-top-navigation' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     1CONSOLE MESSAGE: Blocked script execution in 'http://127.0.0.1:8000/security/contentSecurityPolicy/resources/sandbox.php?sandbox=allow-top-navigation' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    22CONSOLE MESSAGE: line 9: Sandbox access violation: Blocked a frame at "http://127.0.0.1:8000" from accessing a frame at "http://127.0.0.1:8000".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
    33ALERT: PASS: Iframe was in a unique origin
  • TabularUnified trunk/LayoutTests/http/tests/security/contentSecurityPolicy/sandbox-invalid-header-expected.txt

    r156130 r178648  
    11CONSOLE MESSAGE: Error while parsing the 'sandbox' Content Security Policy directive: 'allowScript' is an invalid sandbox flag.
    2 CONSOLE MESSAGE: line 6: Blocked script execution in 'http://127.0.0.1:8000/security/contentSecurityPolicy/resources/sandbox.php?sandbox=allowScript' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     2CONSOLE MESSAGE: Blocked script execution in 'http://127.0.0.1:8000/security/contentSecurityPolicy/resources/sandbox.php?sandbox=allowScript' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    33
  • TabularUnified trunk/LayoutTests/http/tests/security/isolatedWorld/sandboxed-iframe-expected.txt

    r156130 r178648  
    1 CONSOLE MESSAGE: line 3: Blocked script execution in 'http://127.0.0.1:8000/security/isolatedWorld/resources/fail.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
     1CONSOLE MESSAGE: Blocked script execution in 'http://127.0.0.1:8000/security/isolatedWorld/resources/fail.html' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
    22ALERT: PASS
    33Test that executing scripts in an isolated world works even inside sandboxed iframes. The test passes, if an alert with the text "PASS" is shown.
  • TabularUnified trunk/LayoutTests/http/tests/security/mixedContent/insecure-script-in-iframe-expected.txt

    r156130 r178648  
    1 CONSOLE MESSAGE: line 1: The page at https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-script.html ran insecure content from http://127.0.0.1:8080/security/mixedContent/resources/script.js.
     1CONSOLE MESSAGE: The page at https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-script.html ran insecure content from http://127.0.0.1:8080/security/mixedContent/resources/script.js.
    22
    33This test loads a secure iframe that loads an insecure script. We should trigger a mixed content callback even though the main frame is HTTP because the HTTPS frame's origin is contaminated with an insecure script.
  • TabularUnified trunk/LayoutTests/http/tests/security/mixedContent/redirect-http-to-https-script-in-iframe-expected.txt

    r156130 r178648  
    22main frame - didFinishDocumentLoadForFrame
    33frame "<!--framePath //<!--frame0-->-->" - didCommitLoadForFrame
    4 CONSOLE MESSAGE: line 1: The page at https://127.0.0.1:8443/security/mixedContent/resources/frame-with-redirect-http-to-https-script.html ran insecure content from http://127.0.0.1:8080/resources/redirect.php?url=https://127.0.0.1:8443/security/mixedContent/resources/script.js.
     4CONSOLE MESSAGE: The page at https://127.0.0.1:8443/security/mixedContent/resources/frame-with-redirect-http-to-https-script.html ran insecure content from http://127.0.0.1:8080/resources/redirect.php?url=https://127.0.0.1:8443/security/mixedContent/resources/script.js.
    55
    66didRunInsecureContent
  • TabularUnified trunk/LayoutTests/http/tests/security/no-javascript-refresh-expected.txt

    r166600 r178648  
    1 CONSOLE MESSAGE: line 1: Refused to refresh http://127.0.0.1:8000/security/no-javascript-refresh.php to a javascript: URL
     1CONSOLE MESSAGE: Refused to refresh http://127.0.0.1:8000/security/no-javascript-refresh.php to a javascript: URL
    22PASS: This is the content that appears in place of a refresh.
  • TabularUnified trunk/LayoutTests/http/tests/security/no-javascript-refresh-spaces-expected.txt

    r166600 r178648  
    1 CONSOLE MESSAGE: line 1: Refused to refresh http://127.0.0.1:8000/security/no-javascript-refresh-spaces.php to a javascript: URL
     1CONSOLE MESSAGE: Refused to refresh http://127.0.0.1:8000/security/no-javascript-refresh-spaces.php to a javascript: URL
    22PASS: This is the content that appears in place of a refresh.
  • TabularUnified trunk/LayoutTests/platform/efl/TestExpectations

    r178508 r178648  
    690690
    691691webkit.org/b/103383 fast/css/counters/element-removal-crash.xhtml [ Failure Pass ]
    692 
    693 # flaky console output problem
    694 webkit.org/b/105280 http/tests/xmlhttprequest/origin-whitelisting-https.html [ Failure Pass ]
    695 webkit.org/b/105280 http/tests/xmlhttprequest/access-control-preflight-async-header-denied.html [ Failure Pass ]
    696 webkit.org/b/105280 http/tests/xmlhttprequest/access-control-preflight-async-method-denied.html [ Failure Pass ]
    697 webkit.org/b/105280 http/tests/xmlhttprequest/cross-site-denied-response.html [ Failure Pass ]
    698 webkit.org/b/105280 http/tests/xmlhttprequest/access-control-preflight-async-not-supported.html [ Failure Pass ]
    699692
    700693webkit.org/b/105296 webaudio/delaynode-maxdelay.html [ Failure Pass ]
  • TabularUnified trunk/LayoutTests/platform/gtk/TestExpectations

    r178508 r178648  
    761761
    762762webkit.org/b/105191 media/video-playing-and-pause.html [ Failure Pass ]
    763 
    764 webkit.org/b/105280 http/tests/xmlhttprequest/access-control-preflight-async-header-denied.html [ Failure Pass ]
    765 webkit.org/b/105280 http/tests/xmlhttprequest/access-control-preflight-async-method-denied.html [ Failure Pass ]
    766 webkit.org/b/105280 http/tests/xmlhttprequest/access-control-preflight-async-not-supported.html [ Failure Pass ]
    767 webkit.org/b/105280 http/tests/xmlhttprequest/cross-site-denied-response.html [ Failure Pass ]
    768 webkit.org/b/105280 http/tests/xmlhttprequest/origin-whitelisting-https.html [ Failure Pass ]
    769 webkit.org/b/105280 http/tests/xmlhttprequest/simple-cross-origin-denied-events.html [ Failure Pass ]
    770 webkit.org/b/105280 http/tests/xmlhttprequest/simple-cross-origin-denied-events-post.html [ Failure Pass ]
    771763
    772764webkit.org/b/118460 media/media-element-play-after-eos.html [ Timeout Pass ]
  • TabularUnified trunk/Source/WebCore/ChangeLog

    r178647 r178648  
     12015-01-16  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Console log sometimes prefixed with line number
     4        https://bugs.webkit.org/show_bug.cgi?id=105280
     5
     6        Reviewed by Darin Adler.
     7
     8        Improve the logic for determining whether a console message should be associated
     9        with a source code location.
     10
     11        * dom/ScriptableDocumentParser.h:
     12        * html/parser/HTMLDocumentParser.cpp:
     13        (WebCore::HTMLDocumentParser::shouldAssociateConsoleMessagesWithTextPosition):
     14        * html/parser/HTMLDocumentParser.h:
     15        * page/PageConsoleClient.cpp:
     16        (WebCore::getParserLocationForConsoleMessage):
     17        (WebCore::PageConsoleClient::addMessage):
     18        * xml/parser/XMLDocumentParser.cpp:
     19        (WebCore::XMLDocumentParser::pauseParsing):
     20        * xml/parser/XMLDocumentParser.h:
     21        * xml/parser/XMLDocumentParserLibxml2.cpp:
     22        (WebCore::XMLDocumentParser::shouldAssociateConsoleMessagesWithTextPosition):
     23
    1242015-01-19  Myles C. Maxfield  <mmaxfield@apple.com>
    225
  • TabularUnified trunk/Source/WebCore/dom/ScriptableDocumentParser.h

    r175148 r178648  
    4747    virtual TextPosition textPosition() const = 0;
    4848
     49    // Returns true if the parser didn't yield or pause or synchronously execute a script,
     50    // so calls to PageConsoleClient should be associated with the parser's text position.
     51    virtual bool shouldAssociateConsoleMessagesWithTextPosition() const = 0;
     52
    4953    void setWasCreatedByScript(bool wasCreatedByScript) { m_wasCreatedByScript = wasCreatedByScript; }
    5054    bool wasCreatedByScript() const { return m_wasCreatedByScript; }
  • TabularUnified trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp

    r178265 r178648  
    463463}
    464464
     465bool HTMLDocumentParser::shouldAssociateConsoleMessagesWithTextPosition() const
     466{
     467    return inPumpSession() && !isExecutingScript();
     468}
     469
    465470bool HTMLDocumentParser::isWaitingForScripts() const
    466471{
  • TabularUnified trunk/Source/WebCore/html/parser/HTMLDocumentParser.h

    r178265 r178648  
    8888    virtual void resumeScheduledTasks() override final;
    8989
     90    virtual bool shouldAssociateConsoleMessagesWithTextPosition() const override final;
     91
    9092    // HTMLScriptRunnerHost
    9193    virtual void watchForLoad(CachedResource*) override final;
  • TabularUnified trunk/Source/WebCore/page/PageConsoleClient.cpp

    r178527 r178648  
    8484}
    8585
     86static void getParserLocationForConsoleMessage(Document* document, String& url, unsigned& line, unsigned& column)
     87{
     88    if (!document)
     89        return;
     90
     91    // We definitely cannot associate the message with a location being parsed if we are not even parsing.
     92    if (!document->parsing())
     93        return;
     94
     95    ScriptableDocumentParser* parser = document->scriptableDocumentParser();
     96
     97    // When the parser waits for scripts, any messages must be coming from some other source, and are not related to the location of the script element that made the parser wait.
     98    if (!parser->shouldAssociateConsoleMessagesWithTextPosition())
     99        return;
     100
     101    url = document->url().string();
     102    TextPosition position = parser->textPosition();
     103    line = position.m_line.oneBasedInt();
     104    column = position.m_column.oneBasedInt();
     105}
     106
    86107void PageConsoleClient::addMessage(MessageSource source, MessageLevel level, const String& message, unsigned long requestIdentifier, Document* document)
    87108{
    88109    String url;
    89     if (document)
    90         url = document->url().string();
    91 
    92     // FIXME: The below code attempts to determine line numbers for parser generated errors, but this is not the only reason why we can get here.
    93     // For example, if we are still parsing and get a WebSocket network error, it will be erroneously attributed to a line where parsing was paused.
    94     // Also, we should determine line numbers for script generated messages (e.g. calling getImageData on a canvas).
    95     // We probably need to split this function into multiple ones, as appropriate for different call sites. Or maybe decide based on MessageSource.
    96     // https://bugs.webkit.org/show_bug.cgi?id=125340
    97110    unsigned line = 0;
    98111    unsigned column = 0;
    99     if (document && document->parsing() && !document->isInDocumentWrite() && document->scriptableDocumentParser()) {
    100         ScriptableDocumentParser* parser = document->scriptableDocumentParser();
    101         if (!parser->isWaitingForScripts() && !JSMainThreadExecState::currentState()) {
    102             TextPosition position = parser->textPosition();
    103             line = position.m_line.oneBasedInt();
    104             column = position.m_column.oneBasedInt();
    105         }
    106     }
     112    getParserLocationForConsoleMessage(document, url, line, column);
     113
    107114    addMessage(source, level, message, url, line, column, 0, JSMainThreadExecState::currentState(), requestIdentifier);
    108115}
  • TabularUnified trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp

    r174278 r178648  
    262262void XMLDocumentParser::pauseParsing()
    263263{
     264    ASSERT(!m_parserPaused);
     265
    264266    if (m_parsingFragment)
    265267        return;
  • TabularUnified trunk/Source/WebCore/xml/parser/XMLDocumentParser.h

    r177559 r178648  
    6666    };
    6767
    68     class XMLDocumentParser : public ScriptableDocumentParser, public CachedResourceClient {
     68    class XMLDocumentParser final : public ScriptableDocumentParser, public CachedResourceClient {
    6969        WTF_MAKE_FAST_ALLOCATED;
    7070    public:
     
    9191        virtual bool wellFormed() const { return !m_sawError; }
    9292
    93         TextPosition textPosition() const;
    94 
    9593        static bool supportsXMLVersion(const String&);
    9694
     
    106104        virtual void stopParsing() override;
    107105        virtual void detach() override;
     106
     107        virtual TextPosition textPosition() const override;
     108        virtual bool shouldAssociateConsoleMessagesWithTextPosition() const override;
    108109
    109110        // from CachedResourceClient
  • TabularUnified trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp

    r177559 r178648  
    14351435}
    14361436
     1437bool XMLDocumentParser::shouldAssociateConsoleMessagesWithTextPosition() const
     1438{
     1439    return !m_parserPaused && !m_requestingScript;
     1440}
     1441
    14371442void XMLDocumentParser::stopParsing()
    14381443{
Note: See TracChangeset for help on using the changeset viewer.