Changeset 192983 in webkit


Ignore:
Timestamp:
Dec 2, 2015 3:55:50 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Asynchronously call onerror when a content blocker blocks ascript element's load
https://bugs.webkit.org/show_bug.cgi?id=151649

Patch by Alex Christensen <achristensen@webkit.org> on 2015-12-02
Reviewed by Brady Eidson.

Source/WebCore:

Test: http/tests/contentextensions/script-onerror.html

  • dom/ScriptElement.cpp:

(WebCore::ScriptElement::ScriptElement):
(WebCore::ScriptElement::requestScript):

  • dom/ScriptElement.h:

LayoutTests:

  • http/tests/contentextensions/script-onerror-expected.txt: Added.
  • http/tests/contentextensions/script-onerror.html: Added.
  • http/tests/contentextensions/script-onerror.html.json: Added.
  • http/tests/misc/unloadable-script-expected.txt:
  • http/tests/misc/unloadable-script.html:
  • http/tests/security/local-JavaScript-from-remote-expected.txt:
  • http/tests/security/local-JavaScript-from-remote.html:

Added testRunner.waitUntilDone and testRunner.notifyDone to reflect the fact that onerror is no longer called synchronously.

Location:
trunk
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r192980 r192983  
     12015-12-02  Alex Christensen  <achristensen@webkit.org>
     2
     3        Asynchronously call onerror when a content blocker blocks ascript element's load
     4        https://bugs.webkit.org/show_bug.cgi?id=151649
     5
     6        Reviewed by Brady Eidson.
     7
     8        * http/tests/contentextensions/script-onerror-expected.txt: Added.
     9        * http/tests/contentextensions/script-onerror.html: Added.
     10        * http/tests/contentextensions/script-onerror.html.json: Added.
     11        * http/tests/misc/unloadable-script-expected.txt:
     12        * http/tests/misc/unloadable-script.html:
     13        * http/tests/security/local-JavaScript-from-remote-expected.txt:
     14        * http/tests/security/local-JavaScript-from-remote.html:
     15        Added testRunner.waitUntilDone and testRunner.notifyDone to reflect the fact that onerror is no longer called synchronously.
     16
    1172015-12-02  Eric Carlson  <eric.carlson@apple.com>
    218
  • trunk/LayoutTests/http/tests/misc/unloadable-script-expected.txt

    r178527 r192983  
    1 CONSOLE MESSAGE: line 30: Not allowed to load local resource: foobar
    2 CONSOLE MESSAGE: line 35: Not allowed to load local resource: foobar
     1CONSOLE MESSAGE: line 36: Not allowed to load local resource: foobar
     2CONSOLE MESSAGE: line 41: Not allowed to load local resource: foobar
    33Test for bug 13584: <script> code wrongly assumes requests can't fail.
    44
  • trunk/LayoutTests/http/tests/misc/unloadable-script.html

    r124692 r192983  
    88}
    99
     10var errorCount = 0;
    1011function handleScriptOnError()
    1112{
    1213    log('onerror called (good!)');
     14    errorCount++;
     15    if (errorCount == 2 && window.testRunner)
     16        testRunner.notifyDone();
    1317}
    1418</script>
     
    2428
    2529    <script>
    26         if (window.testRunner)
     30        if (window.testRunner) {
    2731            testRunner.dumpAsText();
     32            testRunner.waitUntilDone();
     33        }
    2834
    2935        <!-- we are an HTTP test so the security origin will fail the file method -->
  • trunk/LayoutTests/http/tests/security/local-JavaScript-from-remote-expected.txt

    r178527 r192983  
    1 CONSOLE MESSAGE: line 29: Not allowed to load local resource: localScript.js
     1CONSOLE MESSAGE: line 33: Not allowed to load local resource: localScript.js
    22This test is to see if a remote file can run a local script.
    33Currently this test cannot be run manually on Windows because we do not have a function like pathToLocalResource() outside of DRT.
  • trunk/LayoutTests/http/tests/security/local-JavaScript-from-remote.html

    r120174 r192983  
    55
    66        function test() {
    7             if (window.testRunner)
     7            if (window.testRunner) {
    88                testRunner.dumpAsText();
     9                testRunner.waitUntilDone();
     10            }
    911
    1012            var localScriptLocation = "file:///tmp/LayoutTests/http/tests/security/resources/localScript.js";
     
    2527                var tag = document.getElementById("result");
    2628                tag.innerHTML = "Test Passed: Local script not loaded.";
     29                if (window.testRunner)
     30                    testRunner.notifyDone();
    2731            });
    2832
  • trunk/Source/WebCore/ChangeLog

    r192971 r192983  
     12015-12-02  Alex Christensen  <achristensen@webkit.org>
     2
     3        Asynchronously call onerror when a content blocker blocks ascript element's load
     4        https://bugs.webkit.org/show_bug.cgi?id=151649
     5
     6        Reviewed by Brady Eidson.
     7
     8        Test: http/tests/contentextensions/script-onerror.html
     9
     10        * dom/ScriptElement.cpp:
     11        (WebCore::ScriptElement::ScriptElement):
     12        (WebCore::ScriptElement::requestScript):
     13        * dom/ScriptElement.h:
     14
    1152015-12-02  Jer Noble  <jer.noble@apple.com>
    216
  • trunk/Source/WebCore/dom/ScriptElement.cpp

    r191955 r192983  
    6262    , m_alreadyStarted(alreadyStarted)
    6363    , m_forceAsync(!parserInserted)
     64    , m_errorEventTimer(*this, &ScriptElement::dispatchErrorEvent)
    6465{
    6566    if (parserInserted && m_element.document().scriptableDocumentParser() && !m_element.document().isInDocumentWrite())
     
    266267    }
    267268
    268     if (m_cachedScript) {
     269    if (m_cachedScript)
    269270        return true;
    270     }
    271 
    272     dispatchErrorEvent();
     271
     272    m_errorEventTimer.startOneShot(0);
    273273    return false;
    274274}
  • trunk/Source/WebCore/dom/ScriptElement.h

    r191955 r192983  
    2424#include "CachedResourceClient.h"
    2525#include "CachedResourceHandle.h"
     26#include "Timer.h"
    2627#include <wtf/text/TextPosition.h>
    2728#include <wtf/text/WTFString.h>
     
    110111    String m_characterEncoding;
    111112    String m_fallbackCharacterEncoding;
     113    Timer m_errorEventTimer;
    112114};
    113115
Note: See TracChangeset for help on using the changeset viewer.