Changeset 136031 in webkit


Ignore:
Timestamp:
Nov 28, 2012 11:30:48 AM (11 years ago)
Author:
Nate Chapin
Message:

Move empty loading to DocumentLoader, simplify FrameLoader::init()
https://bugs.webkit.org/show_bug.cgi?id=101512

Reviewed by Adam Barth.

Source/WebCore:

No new tests, though several outputs changed because we no longer send resource

load callbacks for empty loads.

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::DocumentLoader):
(WebCore::DocumentLoader::~DocumentLoader):
(WebCore::DocumentLoader::finishedLoading):
(WebCore::DocumentLoader::commitData):
(WebCore::DocumentLoader::clearMainResourceLoader):
(WebCore::DocumentLoader::isLoadingInAPISense):
(WebCore::DocumentLoader::documentURL):
(WebCore::DocumentLoader::isLoadingMainResource):
(WebCore::DocumentLoader::maybeLoadEmpty):
(WebCore):
(WebCore::DocumentLoader::startLoadingMainResource): Handle empty main resource

loads directly here.

  • loader/DocumentLoader.h:

(WebCore::DocumentLoader::serverRedirectSourceForHistory):
(DocumentLoader):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::FrameLoader): Initialize some variables whose values

were previously being reset in init(). Given that the FrameLoader is in
an inconsistent state before init() is called anyway, there doesn't seem
to be a disadvantage to just initializing them to their post-init() values.

(WebCore::FrameLoader::init): Just call startLoadingMainResource(), instead of

doing a bunch of direct calls to functions FrameLoader shouldn't know about.

  • loader/FrameLoaderStateMachine.cpp:

(WebCore::FrameLoaderStateMachine::FrameLoaderStateMachine):

  • loader/FrameLoaderStateMachine.h:
  • loader/MainResourceLoader.cpp: Throughout, remove the concept of an empty load.

(WebCore::MainResourceLoader::loadNow): This only returned true when an empty

load got deferred, which won't happen now. Return void and always treat
as returning false.

  • loader/MainResourceLoader.h:

(MainResourceLoader):

Tools:

  • DumpRenderTree/chromium/WebViewHost.cpp:

(WebViewHost::updateForCommittedLoad): This function doesn't play nicely with empty urls and incorrectly

interprets them as a non-empty load. This change is required for

http/tests/navigation/new-window-redirect-history.html to continue to pass in chromium.

  • TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp: This test relies on a callback that no longer

is sent for about:blank loads. Hook into didFinishLoadForFrame() instead.

(TestWebKitAPI::didFinishLoadForFrame):
(TestWebKitAPI::TEST):

LayoutTests:

Don't expect resource load callbacks for empty loads.

  • http/tests/inspector/network/network-iframe-load-and-delete.html:
  • http/tests/loading/redirect-methods-expected.txt:
  • http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-expected.txt:
  • http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body-expected.txt:
  • http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny-expected.txt:
Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r136030 r136031  
     12012-11-28  Nate Chapin  <japhet@chromium.org>
     2
     3        Move empty loading to DocumentLoader, simplify FrameLoader::init()
     4        https://bugs.webkit.org/show_bug.cgi?id=101512
     5
     6        Reviewed by Adam Barth.
     7
     8        Don't expect resource load callbacks for empty loads.
     9
     10        * http/tests/inspector/network/network-iframe-load-and-delete.html:
     11        * http/tests/loading/redirect-methods-expected.txt:
     12        * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-expected.txt:
     13        * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body-expected.txt:
     14        * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny-expected.txt:
     15
    1162012-11-28  Andrew Scherkus  <scherkus@chromium.org>
    217
  • trunk/LayoutTests/http/tests/inspector/network/network-iframe-load-and-delete.html

    r135192 r136031  
    4444    function step2()
    4545    {
    46         var request1 = WebInspector.panel("network").requests[WebInspector.panel("network").requests.length - 3];
     46        var request1 = WebInspector.panel("network").requests[WebInspector.panel("network").requests.length - 2];
    4747        InspectorTest.addResult(request1.url);
    4848        InspectorTest.addResult("resource.type: " + request1.type);
     
    5353    function step3()
    5454    {
    55         var request1 = WebInspector.panel("network").requests[WebInspector.panel("network").requests.length - 3];
     55        var request1 = WebInspector.panel("network").requests[WebInspector.panel("network").requests.length - 2];
    5656        InspectorTest.addResult("resource.content after requesting content: " + request1.content);
    5757
  • trunk/LayoutTests/http/tests/loading/redirect-methods-expected.txt

    r135192 r136031  
    66<unknown> - didFinishLoading
    77frame "0" - didStartProvisionalLoadForFrame
    8 about:blank - willSendRequest <NSURLRequest URL about:blank, main document URL http://127.0.0.1:8000/loading/redirect-methods.html, http method GET> redirectResponse (null)
    9 about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
    108frame "0" - didCommitLoadForFrame
    119frame "0" - didFinishDocumentLoadForFrame
    1210frame "0" - didHandleOnloadEventsForFrame
    1311frame "0" - didFinishLoadForFrame
    14 about:blank - didFinishLoading
    1512frame "0" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-form.html
    1613frame "0" - didStartProvisionalLoadForFrame
     
    3330frame "0" - didFinishDocumentLoadForFrame
    3431frame "1" - didStartProvisionalLoadForFrame
    35 about:blank - willSendRequest <NSURLRequest URL about:blank, main document URL http://127.0.0.1:8000/loading/redirect-methods.html, http method GET> redirectResponse (null)
    36 about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
    3732frame "1" - didCommitLoadForFrame
    3833frame "1" - didFinishDocumentLoadForFrame
    3934frame "1" - didHandleOnloadEventsForFrame
    4035frame "1" - didFinishLoadForFrame
    41 about:blank - didFinishLoading
    4236frame "1" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-form.html
    4337frame "0" - didHandleOnloadEventsForFrame
     
    6357frame "1" - didFinishDocumentLoadForFrame
    6458frame "2" - didStartProvisionalLoadForFrame
    65 about:blank - willSendRequest <NSURLRequest URL about:blank, main document URL http://127.0.0.1:8000/loading/redirect-methods.html, http method GET> redirectResponse (null)
    66 about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
    6759frame "2" - didCommitLoadForFrame
    6860frame "2" - didFinishDocumentLoadForFrame
    6961frame "2" - didHandleOnloadEventsForFrame
    7062frame "2" - didFinishLoadForFrame
    71 about:blank - didFinishLoading
    7263frame "2" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-form.html
    7364frame "1" - didHandleOnloadEventsForFrame
     
    9384frame "2" - didFinishDocumentLoadForFrame
    9485frame "3" - didStartProvisionalLoadForFrame
    95 about:blank - willSendRequest <NSURLRequest URL about:blank, main document URL http://127.0.0.1:8000/loading/redirect-methods.html, http method GET> redirectResponse (null)
    96 about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
    9786frame "3" - didCommitLoadForFrame
    9887frame "3" - didFinishDocumentLoadForFrame
    9988frame "3" - didHandleOnloadEventsForFrame
    10089frame "3" - didFinishLoadForFrame
    101 about:blank - didFinishLoading
    10290frame "3" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-form.html
    10391frame "2" - didHandleOnloadEventsForFrame
  • trunk/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-expected.txt

    r135192 r136031  
    44http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe.html - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -999, failing URL "http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe.html">
    55CONSOLE MESSAGE: Refused to display 'http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe.html' in a frame because it set 'X-Frame-Options' to 'deny'.
    6 about:blank - willSendRequest <NSURLRequest URL about:blank, main document URL http://127.0.0.1:8000/security/XFrameOptions/x-frame-options-deny-meta-tag.html, http method GET> redirectResponse (null)
    7 about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
    86There should be no content in the iframe below
    97
  • trunk/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body-expected.txt

    r135192 r136031  
    44http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-in-body.html - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -999, failing URL "http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-in-body.html">
    55CONSOLE MESSAGE: Refused to display 'http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-in-body.html' in a frame because it set 'X-Frame-Options' to 'deny'.
    6 about:blank - willSendRequest <NSURLRequest URL about:blank, main document URL http://127.0.0.1:8000/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body.html, http method GET> redirectResponse (null)
    7 about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
    86There should be no content in the iframe below
    97
  • trunk/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny-expected.txt

    r135192 r136031  
    44http://localhost:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-parent-same-origin-deny.html - didFailLoadingWithError: <NSError domain NSURLErrorDomain, code -999, failing URL "http://localhost:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-parent-same-origin-deny.html">
    55CONSOLE MESSAGE: Refused to display 'http://localhost:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-parent-same-origin-deny.html' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
    6 about:blank - willSendRequest <NSURLRequest URL about:blank, main document URL http://127.0.0.1:8000/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny.html, http method GET> redirectResponse (null)
    7 about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
    86There should be no content in the iframe below
    97
  • trunk/Source/WebCore/ChangeLog

    r136026 r136031  
     12012-11-28  Nate Chapin  <japhet@chromium.org>
     2
     3        Move empty loading to DocumentLoader, simplify FrameLoader::init()
     4        https://bugs.webkit.org/show_bug.cgi?id=101512
     5
     6        Reviewed by Adam Barth.
     7
     8        No new tests, though several outputs changed because we no longer send resource
     9            load callbacks for empty loads.
     10
     11        * loader/DocumentLoader.cpp:
     12        (WebCore::DocumentLoader::DocumentLoader):
     13        (WebCore::DocumentLoader::~DocumentLoader):
     14        (WebCore::DocumentLoader::finishedLoading):
     15        (WebCore::DocumentLoader::commitData):
     16        (WebCore::DocumentLoader::clearMainResourceLoader):
     17        (WebCore::DocumentLoader::isLoadingInAPISense):
     18        (WebCore::DocumentLoader::documentURL):
     19        (WebCore::DocumentLoader::isLoadingMainResource):
     20        (WebCore::DocumentLoader::maybeLoadEmpty):
     21        (WebCore):
     22        (WebCore::DocumentLoader::startLoadingMainResource): Handle empty main resource
     23             loads directly here.
     24        * loader/DocumentLoader.h:
     25        (WebCore::DocumentLoader::serverRedirectSourceForHistory):
     26        (DocumentLoader):
     27        * loader/FrameLoader.cpp:
     28        (WebCore::FrameLoader::FrameLoader): Initialize some variables whose values
     29            were previously being reset in init(). Given that the FrameLoader is in
     30            an inconsistent state before init() is called anyway, there doesn't seem
     31            to be a disadvantage to just initializing them to their post-init() values.
     32        (WebCore::FrameLoader::init): Just call startLoadingMainResource(), instead of
     33            doing a bunch of direct calls to functions FrameLoader shouldn't know about.
     34        * loader/FrameLoaderStateMachine.cpp:
     35        (WebCore::FrameLoaderStateMachine::FrameLoaderStateMachine):
     36        * loader/FrameLoaderStateMachine.h:
     37        * loader/MainResourceLoader.cpp: Throughout, remove the concept of an empty load.
     38        (WebCore::MainResourceLoader::loadNow): This only returned true when an empty
     39            load got deferred, which won't happen now. Return void and always treat
     40            as returning false.
     41        * loader/MainResourceLoader.h:
     42        (MainResourceLoader):
     43
    1442012-11-28  Antoine Quint  <graouts@apple.com>
    245
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r135192 r136031  
    5050#include "Page.h"
    5151#include "ResourceBuffer.h"
     52#include "SchemeRegistry.h"
    5253#include "Settings.h"
    5354#include "TextResourceDecoder.h"
     
    9899    , m_gotFirstByte(false)
    99100    , m_isClientRedirect(false)
     101    , m_loadingEmptyDocument(false)
    100102    , m_wasOnloadHandled(false)
    101103    , m_stopRecordingResponses(false)
     
    115117DocumentLoader::~DocumentLoader()
    116118{
    117     ASSERT(!m_frame || frameLoader()->activeDocumentLoader() != this || !frameLoader()->isLoading());
     119    ASSERT(!m_frame || frameLoader()->activeDocumentLoader() != this || !isLoading());
    118120    if (m_iconLoadDecisionCallback)
    119121        m_iconLoadDecisionCallback->invalidate();
     
    286288{
    287289    commitIfReady();
    288     if (!frameLoader() || frameLoader()->stateMachine()->creatingInitialEmptyDocument())
     290    if (!frameLoader())
    289291        return;
    290292
     
    301303        return;
    302304    clearMainResourceLoader();
    303     frameLoader()->checkLoadComplete();
     305    if (!frameLoader()->stateMachine()->creatingInitialEmptyDocument())
     306        frameLoader()->checkLoadComplete();
    304307}
    305308
     
    328331        m_writer.begin(documentURL(), false);
    329332        m_writer.setDocumentWasLoadedAsPartOfNavigation();
     333
     334        if (frameLoader()->stateMachine()->creatingInitialEmptyDocument())
     335            return;
    330336       
    331337#if ENABLE(MHTML)
     
    450456        m_mainResourceLoader = 0;
    451457    }
     458    m_loadingEmptyDocument = false;
    452459
    453460    if (this == frameLoader()->activeDocumentLoader())
     
    464471   
    465472        Document* doc = m_frame->document();
    466         if ((m_mainResourceLoader || !m_frame->document()->loadEventFinished()) && isLoading())
     473        if ((isLoadingMainResource() || !m_frame->document()->loadEventFinished()) && isLoading())
    467474            return true;
    468475        if (m_cachedResourceLoader->requestCount())
     
    770777    if (url.isEmpty())
    771778        url = responseURL();
    772     if (url.isEmpty())
    773         url = blankURL();
    774779    return url;
    775780}
     
    831836bool DocumentLoader::isLoadingMainResource() const
    832837{
    833     return !!m_mainResourceLoader;
     838    return !!m_mainResourceLoader || m_loadingEmptyDocument;
    834839}
    835840
     
    842847{
    843848    return isLoadingMultipartContent() && frameLoader()->isReplacing();
     849}
     850
     851bool DocumentLoader::maybeLoadEmpty()
     852{
     853    bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmpty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().protocol()));
     854    if (!shouldLoadEmpty && !frameLoader()->client()->representationExistsForURLScheme(m_request.url().protocol()))
     855        return false;
     856
     857    m_loadingEmptyDocument = true;
     858    if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingInitialEmptyDocument())
     859        m_request.setURL(blankURL());
     860    String mimeType = shouldLoadEmpty ? "text/html" : frameLoader()->client()->generatedMIMETypeForURLScheme(m_request.url().protocol());
     861    setResponse(ResourceResponse(m_request.url(), mimeType, 0, String(), String()));
     862    finishedLoading();
     863    return true;
    844864}
    845865
     
    849869    timing()->markNavigationStart();
    850870    ASSERT(!m_mainResourceLoader);
     871
     872    if (maybeLoadEmpty())
     873        return;
     874
    851875    m_mainResourceLoader = MainResourceLoader::create(m_frame);
    852876
     
    855879    frameLoader()->addExtraFieldsToMainResourceRequest(m_request);
    856880    m_mainResourceLoader->load(m_request, m_substituteData);
     881
     882    if (m_request.isNull()) {
     883        m_mainResourceLoader = 0;
     884        maybeLoadEmpty();
     885    }
    857886}
    858887
  • trunk/Source/WebCore/loader/DocumentLoader.h

    r135192 r136031  
    186186        void setClientRedirectSourceForHistory(const String& clientRedirectSourceForHistory) { m_clientRedirectSourceForHistory = clientRedirectSourceForHistory; }
    187187       
    188         String serverRedirectSourceForHistory() const { return urlForHistory() == url() ? String() : urlForHistory().string(); } // null if no server redirect occurred.
     188        String serverRedirectSourceForHistory() const { return (urlForHistory() == url() || url() == blankURL()) ? String() : urlForHistory().string(); } // null if no server redirect occurred.
    189189        String serverRedirectDestinationForHistory() const { return url(); }
    190190
     
    266266#endif
    267267
     268        bool maybeLoadEmpty();
     269
    268270        bool isMultipartReplacingLoad() const;
    269271
     
    308310        bool m_gotFirstByte;
    309311        bool m_isClientRedirect;
     312        bool m_loadingEmptyDocument;
    310313
    311314        // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadHandled are roughly the same
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r135952 r136031  
    215215    , m_icon(frame)
    216216    , m_mixedContentChecker(frame)
    217     , m_state(FrameStateCommittedPage)
     217    , m_state(FrameStateProvisional)
    218218    , m_loadType(FrameLoadTypeStandard)
    219219    , m_delegateIsHandlingProvisionalLoadError(false)
     
    222222    , m_inStopAllLoaders(false)
    223223    , m_isExecutingJavaScriptFormAction(false)
    224     , m_didCallImplicitClose(false)
     224    , m_didCallImplicitClose(true)
    225225    , m_wasUnloadEventEmitted(false)
    226226    , m_pageDismissalEventBeingDispatched(NoDismissal)
     
    255255{
    256256    // This somewhat odd set of steps gives the frame an initial empty document.
    257     // It would be better if this could be done with even fewer steps.
    258     m_stateMachine.advanceTo(FrameLoaderStateMachine::CreatingInitialEmptyDocument);
    259257    setPolicyDocumentLoader(m_client->createDocumentLoader(ResourceRequest(KURL(ParsedURLString, emptyString())), SubstituteData()).get());
    260258    setProvisionalDocumentLoader(m_policyDocumentLoader.get());
    261     setState(FrameStateProvisional);
    262     m_provisionalDocumentLoader->setResponse(ResourceResponse(KURL(), "text/html", 0, String(), String()));
    263     m_provisionalDocumentLoader->finishedLoading();
    264     ASSERT(!m_frame->document());
    265     m_documentLoader->writer()->begin(KURL(), false);
    266     m_documentLoader->writer()->end();
     259    m_provisionalDocumentLoader->startLoadingMainResource();
    267260    m_frame->document()->cancelParsing();
    268261    m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocument);
    269     m_didCallImplicitClose = true;
    270262
    271263    m_networkingContext = m_client->createNetworkingContext();
  • trunk/Source/WebCore/loader/FrameLoaderStateMachine.cpp

    r135192 r136031  
    3636   
    3737FrameLoaderStateMachine::FrameLoaderStateMachine()
    38     : m_state(Uninitialized)
     38    : m_state(CreatingInitialEmptyDocument)
    3939{
    4040}
  • trunk/Source/WebCore/loader/FrameLoaderStateMachine.h

    r135192 r136031  
    4545    // Otherwise, the states only go down the list.
    4646    enum State {
    47         Uninitialized,
    4847        CreatingInitialEmptyDocument,
    4948        DisplayingInitialEmptyDocument,
  • trunk/Source/WebCore/loader/MainResourceLoader.cpp

    r135192 r136031  
    6868namespace WebCore {
    6969
    70 static bool shouldLoadAsEmptyDocument(const KURL& url)
    71 {
    72     return url.isEmpty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(url.protocol());
    73 }
    74 
    7570MainResourceLoader::MainResourceLoader(Frame* frame)
    7671    : ResourceLoader(frame, ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForCrossOriginCredentials, SkipSecurityCheck))
     
    339334        ResourceLoader::didReceiveResponse(r);
    340335
    341     if (frameLoader() && !frameLoader()->activeDocumentLoader()->isStopping()) {
    342         if (m_substituteData.isValid()) {
    343             if (m_substituteData.content()->size())
    344                 didReceiveData(m_substituteData.content()->data(), m_substituteData.content()->size(), m_substituteData.content()->size(), true);
    345             if (frameLoader() && !frameLoader()->activeDocumentLoader()->isStopping())
    346                 didFinishLoading(0);
    347         } else if (shouldLoadAsEmptyDocument(url) || frameLoader()->client()->representationExistsForURLScheme(url.protocol()))
     336    if (frameLoader() && !frameLoader()->activeDocumentLoader()->isStopping() && m_substituteData.isValid()) {
     337        if (m_substituteData.content()->size())
     338            didReceiveData(m_substituteData.content()->data(), m_substituteData.content()->size(), m_substituteData.content()->size(), true);
     339        if (frameLoader() && !frameLoader()->activeDocumentLoader()->isStopping())
    348340            didFinishLoading(0);
    349341    }
     
    386378    // See <rdar://problem/6304600> for more details.
    387379#if !USE(CF)
    388     ASSERT(shouldLoadAsEmptyDocument(r.url()) || !defersLoading());
     380    ASSERT(!defersLoading());
    389381#endif
    390382
     
    501493    // See <rdar://problem/6304600> for more details.
    502494#if !USE(CF)
    503     ASSERT(shouldLoadAsEmptyDocument(frameLoader()->activeDocumentLoader()->url()) || !defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_frame.get()));
     495    ASSERT(!defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_frame.get()));
    504496#endif
    505497
     
    562554}
    563555
    564 void MainResourceLoader::handleEmptyLoad(const KURL& url, bool forURLScheme)
    565 {
    566     String mimeType;
    567     if (forURLScheme)
    568         mimeType = frameLoader()->client()->generatedMIMETypeForURLScheme(url.protocol());
    569     else
    570         mimeType = "text/html";
    571    
    572     ResourceResponse response(url, mimeType, 0, String(), String());
    573     didReceiveResponse(response);
    574 }
    575 
    576556void MainResourceLoader::handleSubstituteDataLoadNow(MainResourceLoaderTimer*)
    577557{
     
    610590}
    611591
    612 bool MainResourceLoader::loadNow(ResourceRequest& r)
    613 {
    614     bool shouldLoadEmptyBeforeRedirect = shouldLoadAsEmptyDocument(r.url());
    615 
     592void MainResourceLoader::loadNow(ResourceRequest& r)
     593{
    616594    ASSERT(!m_handle);
    617     ASSERT(shouldLoadEmptyBeforeRedirect || !defersLoading());
    618 
    619     // Send this synthetic delegate callback since clients expect it, and
    620     // we no longer send the callback from within NSURLConnection for
    621     // initial requests.
    622     willSendRequest(r, ResourceResponse());
    623     ASSERT(!deletionHasBegun());
    624 
    625     // <rdar://problem/4801066>
    626     // willSendRequest() is liable to make the call to frameLoader() return NULL, so we need to check that here
    627     if (!frameLoader())
    628         return false;
    629    
    630     const KURL& url = r.url();
    631     bool shouldLoadEmpty = shouldLoadAsEmptyDocument(url) && !m_substituteData.isValid();
    632 
    633     if (shouldLoadEmptyBeforeRedirect && !shouldLoadEmpty && defersLoading())
    634         return true;
     595    ASSERT(!defersLoading());
    635596
    636597#if USE(PLATFORM_STRATEGIES)
     
    642603    if (m_substituteData.isValid())
    643604        handleSubstituteDataLoadSoon(r);
    644     else if (shouldLoadEmpty || frameLoader()->client()->representationExistsForURLScheme(url.protocol()))
    645         handleEmptyLoad(url, !shouldLoadEmpty);
    646605    else
    647606        m_handle = ResourceHandle::create(m_frame->loader()->networkingContext(), r, this, false, true);
    648607
    649     return false;
     608    return;
    650609}
    651610
     
    665624    ResourceRequest request(r);
    666625
     626    // Send this synthetic delegate callback since clients expect it, and
     627    // we no longer send the callback from within NSURLConnection for
     628    // initial requests.
     629    willSendRequest(request, ResourceResponse());
     630    ASSERT(!deletionHasBegun());
     631
     632    // <rdar://problem/4801066>
     633    // willSendRequest() is liable to make the call to frameLoader() return null, so we need to check that here
     634    if (!frameLoader() || request.isNull()) {
     635        if (!reachedTerminalState())
     636            releaseResources();
     637        return;
     638    }
     639
    667640    documentLoader()->applicationCacheHost()->maybeLoadMainResource(request, m_substituteData);
    668641
    669     bool defer = defersLoading();
    670     if (defer) {
    671         bool shouldLoadEmpty = shouldLoadAsEmptyDocument(request.url());
    672         if (shouldLoadEmpty)
    673             defer = false;
    674     }
    675     if (!defer) {
    676         if (loadNow(request)) {
    677             // Started as an empty document, but was redirected to something non-empty.
    678             ASSERT(defersLoading());
    679             defer = true;
    680         }
    681     }
    682     if (defer)
     642    if (defersLoading())
    683643        m_initialRequest = request;
     644    else
     645        loadNow(request);
    684646}
    685647
  • trunk/Source/WebCore/loader/MainResourceLoader.h

    r135192 r136031  
    8282    virtual void didCancel(const ResourceError&) OVERRIDE;
    8383
    84     bool loadNow(ResourceRequest&);
     84    void loadNow(ResourceRequest&);
    8585
    86     void handleEmptyLoad(const KURL&, bool forURLScheme);
    8786    void handleSubstituteDataLoadSoon(const ResourceRequest&);
    8887    void handleSubstituteDataLoadNow(MainResourceLoaderTimer*);
  • trunk/Tools/ChangeLog

    r136013 r136031  
     12012-11-28  Nate Chapin  <japhet@chromium.org>
     2
     3        Move empty loading to DocumentLoader, simplify FrameLoader::init()
     4        https://bugs.webkit.org/show_bug.cgi?id=101512
     5
     6        Reviewed by Adam Barth.
     7
     8        * DumpRenderTree/chromium/WebViewHost.cpp:
     9        (WebViewHost::updateForCommittedLoad): This function doesn't play nicely with empty urls and incorrectly
     10            interprets them as a non-empty load. This change is required for
     11             http/tests/navigation/new-window-redirect-history.html to continue to pass in chromium.
     12        * TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp: This test relies on a callback that no longer
     13             is sent for about:blank loads.  Hook into didFinishLoadForFrame() instead.
     14        (TestWebKitAPI::didFinishLoadForFrame):
     15        (TestWebKitAPI::TEST):
     16
    1172012-11-28  Sadrul Habib Chowdhury  <sadrul@chromium.org>
    218
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp

    r135872 r136031  
    16241624    // Code duplicated from RenderView::DidCommitLoadForFrame.
    16251625    TestShellExtraData* extraData = static_cast<TestShellExtraData*>(frame->dataSource()->extraData());
    1626     bool nonBlankPageAfterReset = m_pageId == -1 && strcmp(frame->dataSource()->request().url().spec().data(), "about:blank");
     1626    const WebURL& url = frame->dataSource()->request().url();
     1627    bool nonBlankPageAfterReset = m_pageId == -1 && !url.isEmpty() && strcmp(url.spec().data(), "about:blank");
    16271628
    16281629    if (isNewNavigation || nonBlankPageAfterReset) {
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp

    r95188 r136031  
    3232static bool done;
    3333
    34 static void decidePolicyForResponse(WKPageRef, WKFrameRef, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef, const void*)
     34static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
    3535{
    36     EXPECT_WK_STREQ("text/html", Util::MIMETypeForWKURLResponse(response));
    37 
    38     WKFramePolicyListenerUse(listener);
     36    WKRetainPtr<WKStringRef> mimeType = adoptWK(WKFrameCopyMIMEType(frame));
     37    EXPECT_WK_STREQ("text/html", mimeType);
    3938    done = true;
    4039}
     
    4544    PlatformWebView webView(context.get());
    4645
    47     WKPagePolicyClient policyClient;
    48     memset(&policyClient, 0, sizeof(policyClient));
    49 
    50     policyClient.decidePolicyForResponse = decidePolicyForResponse;
    51     WKPageSetPagePolicyClient(webView.page(), &policyClient);
     46    WKPageLoaderClient loaderClient;
     47    memset(&loaderClient, 0 , sizeof(loaderClient));
     48    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
     49    WKPageSetPageLoaderClient(webView.page(), &loaderClient);
    5250
    5351    WKPageLoadURL(webView.page(), adoptWK(WKURLCreateWithUTF8CString("about:blank")).get());
Note: See TracChangeset for help on using the changeset viewer.