Changeset 204163 in webkit


Ignore:
Timestamp:
Aug 5, 2016 12:25:15 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

DocumentThreadableLoader should report an error when getting a null CachedResource
https://bugs.webkit.org/show_bug.cgi?id=160444

Patch by Youenn Fablet <youenn@apple.com> on 2016-08-05
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

  • web-platform-tests/XMLHttpRequest/event-error-expected.txt:
  • web-platform-tests/XMLHttpRequest/getresponseheader-error-state-expected.txt:
  • web-platform-tests/XMLHttpRequest/timeout-cors-async-expected.txt:
  • web-platform-tests/fetch/api/cors/cors-cookies-expected.txt:
  • web-platform-tests/fetch/api/cors/cors-cookies-worker-expected.txt:

Source/WebCore:

Covered by existing and rebased tests.

  • loader/DocumentThreadableLoader.cpp:

(WebCore::DocumentThreadableLoader::loadRequest): Calling didFail with an AccessControl error if unable to have a CachedResource.
The resource error type AccessControl is important as it indicates to some clients that they should not retry loading the same resource (EventSource notably).

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::createRequest): Removed handling of ThreadableLoader::create returning null.
This should be handled in didFail callback. This allows aligning behavior of
WorkerThreadableLoaderi::MainThreadBridge and XMLHttpRequest as ThreadableLoader clients.
(WebCore::XMLHttpRequest::didFail): Handle the case of didFail being called synchronously from ThreadableLoader::create.
In that case, use a timer to dispatch network events asynchronously.

LayoutTests:

  • fast/frames/frame-unload-crash.html:
  • http/tests/contentextensions/async-xhr-onerror-expected.txt:
  • http/tests/eventsource/eventsource-reconnect-during-navigate-crash-expected.txt:
  • http/tests/navigation/subframe-pagehide-handler-starts-load-expected.txt:
  • http/tests/navigation/subframe-pagehide-handler-starts-load2-expected.txt:
  • http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt:
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r204150 r204163  
     12016-08-05  Youenn Fablet  <youenn@apple.com>
     2
     3        DocumentThreadableLoader should report an error when getting a null CachedResource
     4        https://bugs.webkit.org/show_bug.cgi?id=160444
     5
     6        Reviewed by Alex Christensen.
     7
     8        * fast/frames/frame-unload-crash.html:
     9        * http/tests/contentextensions/async-xhr-onerror-expected.txt:
     10        * http/tests/eventsource/eventsource-reconnect-during-navigate-crash-expected.txt:
     11        * http/tests/navigation/subframe-pagehide-handler-starts-load-expected.txt:
     12        * http/tests/navigation/subframe-pagehide-handler-starts-load2-expected.txt:
     13        * http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt:
     14
    1152016-08-04  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/LayoutTests/fast/frames/frame-unload-crash-expected.txt

    r42455 r204163  
    11frame "<!--framePath //<!--frame0-->/<!--frame0-->-->" - has 1 onunload handler(s)
     2CONSOLE MESSAGE: line 13: XMLHttpRequest cannot load frame-unload-crash-2.html due to access control checks.
    23This is a test for bug 25136: CRASH in DocumentLoader::removeSubresourceLoader due to null m_frame. If successful, PASS should be printed below.
    34
  • trunk/LayoutTests/http/tests/contentextensions/async-xhr-onerror-expected.txt

    r191077 r204163  
    11CONSOLE MESSAGE: line 30: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/async-xhr-onerror.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js
     2CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js due to access control checks.
    23CONSOLE MESSAGE: line 30: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/async-xhr-onerror.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js
     4CONSOLE MESSAGE: line 30: XMLHttpRequest cannot load http://127.0.0.1:8000/contentextensions/resources/url-blocking-test.js due to access control checks.
    35Asynchronous onreadystatechange status: 0, readyState:1, responseText:
    46Finished runTest. Waiting for callbacks
  • trunk/LayoutTests/http/tests/eventsource/eventsource-reconnect-during-navigate-crash-expected.txt

    r93726 r204163  
     1CONSOLE MESSAGE: EventSource cannot load http://127.0.0.1:8000/eventsource/resources/reconnect.php.
    12
  • trunk/LayoutTests/http/tests/navigation/subframe-pagehide-handler-starts-load-expected.txt

    r185337 r204163  
     1CONSOLE MESSAGE: line 8: XMLHttpRequest cannot load http://127.0.0.1:8000/navigation/resources/resources/slow-resource.pl?delay=3000 due to access control checks.
    12Tests that we don't crash when a load is started in a subframe on 'pagehide' handling
    23
  • trunk/LayoutTests/http/tests/navigation/subframe-pagehide-handler-starts-load2-expected.txt

    r185337 r204163  
     1CONSOLE MESSAGE: line 9: XMLHttpRequest cannot load http://127.0.0.1:8000/navigation/resources/resources/slow-resource.pl?delay=3000 due to access control checks.
    12Tests that we don't crash when a load is started in a subframe on 'pagehide' handling
    23
  • trunk/LayoutTests/http/tests/security/mixedContent/insecure-xhr-in-main-frame-expected.txt

    r185296 r204163  
    11CONSOLE MESSAGE: line 28: [blocked] The page at https://127.0.0.1:8443/security/mixedContent/resources/insecure-xhr-in-main-frame-window.html was not allowed to display insecure content from http://127.0.0.1:8000/.
    22
     3CONSOLE MESSAGE: line 28: XMLHttpRequest cannot load http://127.0.0.1:8000/ due to access control checks.
    34This test opens a HTTPS window that loads insecure data via XHR. We should trigger a mixed content callback because the main frame in the window is HTTPS but now has insecure data.
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r204161 r204163  
     12016-08-05  Youenn Fablet  <youenn@apple.com>
     2
     3        DocumentThreadableLoader should report an error when getting a null CachedResource
     4        https://bugs.webkit.org/show_bug.cgi?id=160444
     5
     6        Reviewed by Alex Christensen.
     7
     8        * web-platform-tests/XMLHttpRequest/event-error-expected.txt:
     9        * web-platform-tests/XMLHttpRequest/getresponseheader-error-state-expected.txt:
     10        * web-platform-tests/XMLHttpRequest/timeout-cors-async-expected.txt:
     11        * web-platform-tests/fetch/api/cors/cors-cookies-expected.txt:
     12        * web-platform-tests/fetch/api/cors/cors-cookies-worker-expected.txt:
     13
    1142016-08-04  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/event-error-expected.txt

    r191546 r204163  
    11Blocked access to external URL http://example.nonexist/
     2CONSOLE MESSAGE: line 22: XMLHttpRequest cannot load http://example.nonexist/ due to access control checks.
    23
    34PASS XMLHttpRequest Test: event - error
  • trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/getresponseheader-error-state-expected.txt

    r191546 r204163  
    11Blocked access to external URL http://www1.localhost:8800/XMLHttpRequest/resources/nocors/folder.txt
     2CONSOLE MESSAGE: line 32: XMLHttpRequest cannot load http://www1.localhost:8800/XMLHttpRequest/resources/nocors/folder.txt due to access control checks.
    23
    34PASS XMLHttpRequest: getResponseHeader() in error state (failing cross-origin test)
  • trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/timeout-cors-async-expected.txt

    r191546 r204163  
    11Blocked access to external URL http://www2.localhost:8800/XMLHttpRequest/resources/corsenabled.py?delay=2&code=200
     2CONSOLE MESSAGE: line 40: XMLHttpRequest cannot load http://www2.localhost:8800/XMLHttpRequest/resources/corsenabled.py?delay=2&code=200 due to access control checks.
    23
    34FAIL XMLHttpRequest: timeout event and cross-origin request assert_true: timeout event should fire expected true got false
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies-expected.txt

    r203900 r204163  
    11Blocked access to external URL http://www.localhost:8800/fetch/api/resources/inspect-headers.py?cors&headers=cookie
    2 
    3 Harness Error (TIMEOUT), message = null
    42
    53PASS Omit mode: no cookie sent
     
    86PASS Include mode: remote cookies are not sent with local request
    97PASS Same-origin mode: cookies are discarded in cors request
    10 TIMEOUT Include mode: remote cookies are not sent with other remote request Test timed out
     8FAIL Include mode: remote cookies are not sent with other remote request promise_test: Unhandled rejection with value: object "TypeError: Type error"
    119
  • trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/cors/cors-cookies-worker-expected.txt

    r204023 r204163  
    11Blocked access to external URL http://www.localhost:8800/fetch/api/resources/inspect-headers.py?cors&headers=cookie
    2 
    3 Harness Error (TIMEOUT), message = null
    42
    53PASS Omit mode: no cookie sent
     
    86PASS Include mode: remote cookies are not sent with local request
    97PASS Same-origin mode: cookies are discarded in cors request
    10 TIMEOUT Include mode: remote cookies are not sent with other remote request Test timed out
     8FAIL Include mode: remote cookies are not sent with other remote request promise_test: Unhandled rejection with value: object "TypeError: Type error"
    119
  • trunk/Source/WebCore/ChangeLog

    r204161 r204163  
     12016-08-05  Youenn Fablet  <youenn@apple.com>
     2
     3        DocumentThreadableLoader should report an error when getting a null CachedResource
     4        https://bugs.webkit.org/show_bug.cgi?id=160444
     5
     6        Reviewed by Alex Christensen.
     7
     8        Covered by existing and rebased tests.
     9
     10        * loader/DocumentThreadableLoader.cpp:
     11        (WebCore::DocumentThreadableLoader::loadRequest): Calling didFail with an AccessControl error if unable to have a CachedResource.
     12        The resource error type AccessControl is important as it indicates to some clients that they should not retry loading the same resource (EventSource notably).
     13        * xml/XMLHttpRequest.cpp:
     14        (WebCore::XMLHttpRequest::createRequest): Removed handling of ThreadableLoader::create returning null.
     15        This should be handled in didFail callback. This allows aligning behavior of
     16        WorkerThreadableLoaderi::MainThreadBridge and XMLHttpRequest as ThreadableLoader clients.
     17        (WebCore::XMLHttpRequest::didFail): Handle the case of didFail being called synchronously from ThreadableLoader::create.
     18        In that case, use a timer to dispatch network events asynchronously.
     19
    1202016-08-04  Chris Dumez  <cdumez@apple.com>
    221
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp

    r204117 r204163  
    369369        if (m_resource)
    370370            m_resource->addClient(this);
    371 
     371        else {
     372            // FIXME: Since we receive a synchronous error, this is probably due to some AccessControl checks. We should try to retrieve the actual error.
     373            m_client->didFail(ResourceError(String(), 0, newRequest.resourceRequest().url(), String(), ResourceError::Type::AccessControl));
     374        }
    372375        return;
    373376    }
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r204117 r204163  
    716716        m_loader = ThreadableLoader::create(*scriptExecutionContext(), *this, WTFMove(request), options);
    717717
     718        // Either loader is null or some error was synchronously sent to us.
     719        ASSERT(m_loader || !m_sendFlag);
     720
    718721        // Neither this object nor the JavaScript wrapper should be deleted while
    719722        // a request is in progress because we need to keep the listeners alive,
    720723        // and they are referenced by the JavaScript wrapper.
    721         setPendingActivity(this);
    722         if (!m_loader) {
    723             m_sendFlag = false;
    724             m_timeoutTimer.stop();
    725             m_networkErrorTimer.startOneShot(0);
    726         }
     724        if (m_loader)
     725            setPendingActivity(this);
    727726    } else {
    728727        InspectorInstrumentation::willLoadXHRSynchronously(scriptExecutionContext());
     
    957956void XMLHttpRequest::didFail(const ResourceError& error)
    958957{
    959 
    960958    // If we are already in an error state, for instance we called abort(), bail out early.
    961959    if (m_error)
     
    983981    }
    984982
     983    // In case didFail is called synchronously on an asynchronous XHR call, let's dispatch network error asynchronously
     984    if (m_async && m_sendFlag && !m_loader) {
     985        m_sendFlag = false;
     986        setPendingActivity(this);
     987        m_timeoutTimer.stop();
     988        m_networkErrorTimer.startOneShot(0);
     989        return;
     990    }
    985991    m_exceptionCode = NETWORK_ERR;
    986992    networkError();
Note: See TracChangeset for help on using the changeset viewer.