Move empty loading to DocumentLoader, simplify FrameLoader::init()
authorjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Nov 2012 18:00:55 +0000 (18:00 +0000)
committerjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Nov 2012 18:00:55 +0000 (18:00 +0000)
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::clearMainResourceLoader):
(WebCore::DocumentLoader::isLoadingInAPISense):
(WebCore::DocumentLoader::isLoadingMainResource):
(WebCore::DocumentLoader::maybeLoadEmpty):
(WebCore):
(WebCore::DocumentLoader::startLoadingMainResource): Handle empty main resource
     loads directly here.
* loader/DocumentLoader.h:
(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:

Chromium DRT has some code that doesn't play nicely with empty urls and incorrectly
interprets them as a non-empty load. This ensures
http/tests/navigation/new-window-redirect-history.html continues to pass
in chromium.

* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::updateForCommittedLoad):

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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135172 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/network-iframe-load-and-delete.html
LayoutTests/http/tests/loading/redirect-methods-expected.txt
LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-expected.txt
LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body-expected.txt
LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/DocumentLoader.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoaderStateMachine.cpp
Source/WebCore/loader/FrameLoaderStateMachine.h
Source/WebCore/loader/MainResourceLoader.cpp
Source/WebCore/loader/MainResourceLoader.h
Tools/ChangeLog
Tools/DumpRenderTree/chromium/WebViewHost.cpp

index a4a41fb..ea1b2ce 100644 (file)
@@ -1,3 +1,18 @@
+2012-11-19  Nate Chapin  <japhet@chromium.org>
+
+        Move empty loading to DocumentLoader, simplify FrameLoader::init()
+        https://bugs.webkit.org/show_bug.cgi?id=101512
+
+        Reviewed by Adam Barth.
+
+        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:
+
 2012-11-19  Balazs Kelemen  <kbalazs@webkit.org>
 
         [Qt][WK2] REGRESSION(r132907): It made animations/negative-delay.html flaky
index 3bd4cc2..db64a3b 100644 (file)
@@ -43,7 +43,7 @@ function test()
 
     function step2()
     {
-        var request1 = WebInspector.panel("network").requests[WebInspector.panel("network").requests.length - 3];
+        var request1 = WebInspector.panel("network").requests[WebInspector.panel("network").requests.length - 2];
         InspectorTest.addResult(request1.url);
         InspectorTest.addResult("resource.type: " + request1.type);
         InspectorTest.addResult("resource.content before requesting content: " + request1.content);
@@ -52,7 +52,7 @@ function test()
 
     function step3()
     {
-        var request1 = WebInspector.panel("network").requests[WebInspector.panel("network").requests.length - 3];
+        var request1 = WebInspector.panel("network").requests[WebInspector.panel("network").requests.length - 2];
         InspectorTest.addResult("resource.content after requesting content: " + request1.content);
 
         var request2 = WebInspector.panel("network").requests[WebInspector.panel("network").requests.length - 1];
index 667b7df..517fe74 100644 (file)
@@ -5,13 +5,10 @@ main frame - didHandleOnloadEventsForFrame
 main frame - didFinishLoadForFrame
 <unknown> - didFinishLoading
 frame "0" - didStartProvisionalLoadForFrame
-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)
-about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
 frame "0" - didCommitLoadForFrame
 frame "0" - didFinishDocumentLoadForFrame
 frame "0" - didHandleOnloadEventsForFrame
 frame "0" - didFinishLoadForFrame
-about:blank - didFinishLoading
 frame "0" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-form.html 
 frame "0" - didStartProvisionalLoadForFrame
 http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/loading/resources/redirect-methods-form.html, main document URL http://127.0.0.1:8000/loading/redirect-methods.html, http method GET> redirectResponse (null)
@@ -32,13 +29,10 @@ frame "0" - didCancelClientRedirectForFrame
 frame "0" - didCommitLoadForFrame
 frame "0" - didFinishDocumentLoadForFrame
 frame "1" - didStartProvisionalLoadForFrame
-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)
-about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
 frame "1" - didCommitLoadForFrame
 frame "1" - didFinishDocumentLoadForFrame
 frame "1" - didHandleOnloadEventsForFrame
 frame "1" - didFinishLoadForFrame
-about:blank - didFinishLoading
 frame "1" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-form.html 
 frame "0" - didHandleOnloadEventsForFrame
 frame "0" - didFinishLoadForFrame
@@ -62,13 +56,10 @@ frame "1" - didCancelClientRedirectForFrame
 frame "1" - didCommitLoadForFrame
 frame "1" - didFinishDocumentLoadForFrame
 frame "2" - didStartProvisionalLoadForFrame
-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)
-about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
 frame "2" - didCommitLoadForFrame
 frame "2" - didFinishDocumentLoadForFrame
 frame "2" - didHandleOnloadEventsForFrame
 frame "2" - didFinishLoadForFrame
-about:blank - didFinishLoading
 frame "2" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-form.html 
 frame "1" - didHandleOnloadEventsForFrame
 frame "1" - didFinishLoadForFrame
@@ -92,13 +83,10 @@ frame "2" - didCancelClientRedirectForFrame
 frame "2" - didCommitLoadForFrame
 frame "2" - didFinishDocumentLoadForFrame
 frame "3" - didStartProvisionalLoadForFrame
-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)
-about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
 frame "3" - didCommitLoadForFrame
 frame "3" - didFinishDocumentLoadForFrame
 frame "3" - didHandleOnloadEventsForFrame
 frame "3" - didFinishLoadForFrame
-about:blank - didFinishLoading
 frame "3" - willPerformClientRedirectToURL: http://127.0.0.1:8000/loading/resources/redirect-methods-form.html 
 frame "2" - didHandleOnloadEventsForFrame
 frame "2" - didFinishLoadForFrame
index be7e4a5..a26829f 100644 (file)
@@ -3,8 +3,6 @@ http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta
 http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe.html - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe.html, http status code 200>
 http://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">
 CONSOLE 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'.
-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)
-about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
 There should be no content in the iframe below
 
 
index 247b6d5..a7011dd 100644 (file)
@@ -3,8 +3,6 @@ http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta
 http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-in-body.html - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-in-body.html, http status code 200>
 http://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">
 CONSOLE 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'.
-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)
-about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
 There should be no content in the iframe below
 
 
index bcdc0b2..d0c95ae 100644 (file)
@@ -3,8 +3,6 @@ http://localhost:8000/security/XFrameOptions/resources/x-frame-options-deny-meta
 http://localhost:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-parent-same-origin-deny.html - didReceiveResponse <NSURLResponse http://localhost:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-parent-same-origin-deny.html, http status code 200>
 http://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">
 CONSOLE 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'.
-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)
-about:blank - didReceiveResponse <NSURLResponse about:blank, http status code 0>
 There should be no content in the iframe below
 
 
index 0093c31..9ea14c4 100644 (file)
@@ -1,3 +1,43 @@
+2012-11-19  Nate Chapin  <japhet@chromium.org>
+
+        Move empty loading to DocumentLoader, simplify FrameLoader::init()
+        https://bugs.webkit.org/show_bug.cgi?id=101512
+
+        Reviewed by Adam Barth.
+
+        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::clearMainResourceLoader):
+        (WebCore::DocumentLoader::isLoadingInAPISense):
+        (WebCore::DocumentLoader::isLoadingMainResource):
+        (WebCore::DocumentLoader::maybeLoadEmpty):
+        (WebCore):
+        (WebCore::DocumentLoader::startLoadingMainResource): Handle empty main resource
+             loads directly here.
+        * loader/DocumentLoader.h:
+        (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):
+
 2012-11-19  Erik Arvidsson  <arv@chromium.org>
 
         Update DOMException name: TimeoutError
index 218db82..accabf8 100644 (file)
@@ -49,6 +49,7 @@
 #include "MainResourceLoader.h"
 #include "Page.h"
 #include "ResourceBuffer.h"
+#include "SchemeRegistry.h"
 #include "Settings.h"
 #include "TextResourceDecoder.h"
 #include "WebCoreMemoryInstrumentation.h"
@@ -97,6 +98,7 @@ DocumentLoader::DocumentLoader(const ResourceRequest& req, const SubstituteData&
     , m_isStopping(false)
     , m_gotFirstByte(false)
     , m_isClientRedirect(false)
+    , m_loadingEmptyDocument(false)
     , m_wasOnloadHandled(false)
     , m_stopRecordingResponses(false)
     , m_substituteResourceDeliveryTimer(this, &DocumentLoader::substituteResourceDeliveryTimerFired)
@@ -114,7 +116,7 @@ FrameLoader* DocumentLoader::frameLoader() const
 
 DocumentLoader::~DocumentLoader()
 {
-    ASSERT(!m_frame || frameLoader()->activeDocumentLoader() != this || !frameLoader()->isLoading());
+    ASSERT(!m_frame || frameLoader()->activeDocumentLoader() != this || !isLoading());
     if (m_iconLoadDecisionCallback)
         m_iconLoadDecisionCallback->invalidate();
     if (m_iconDataCallback)
@@ -285,7 +287,7 @@ void DocumentLoader::commitIfReady()
 void DocumentLoader::finishedLoading()
 {
     commitIfReady();
-    if (!frameLoader() || frameLoader()->stateMachine()->creatingInitialEmptyDocument())
+    if (!frameLoader())
         return;
 
     if (!maybeCreateArchive()) {
@@ -300,7 +302,8 @@ void DocumentLoader::finishedLoading()
     if (!m_mainDocumentError.isNull())
         return;
     clearMainResourceLoader();
-    frameLoader()->checkLoadComplete();
+    if (!frameLoader()->stateMachine()->creatingInitialEmptyDocument())
+        frameLoader()->checkLoadComplete();
 }
 
 void DocumentLoader::commitLoad(const char* data, int length)
@@ -449,6 +452,7 @@ void DocumentLoader::clearMainResourceLoader()
         m_mainResourceData = m_mainResourceLoader->resourceData();
         m_mainResourceLoader = 0;
     }
+    m_loadingEmptyDocument = false;
 
     if (this == frameLoader()->activeDocumentLoader())
         checkLoadComplete();
@@ -463,7 +467,7 @@ bool DocumentLoader::isLoadingInAPISense() const
             return true;
     
         Document* doc = m_frame->document();
-        if ((m_mainResourceLoader || !m_frame->document()->loadEventFinished()) && isLoading())
+        if ((isLoadingMainResource() || !m_frame->document()->loadEventFinished()) && isLoading())
             return true;
         if (m_cachedResourceLoader->requestCount())
             return true;
@@ -769,8 +773,6 @@ KURL DocumentLoader::documentURL() const
         url = requestURL();
     if (url.isEmpty())
         url = responseURL();
-    if (url.isEmpty())
-        url = blankURL();
     return url;
 }
 
@@ -830,7 +832,7 @@ void DocumentLoader::removePlugInStreamLoader(ResourceLoader* loader)
 
 bool DocumentLoader::isLoadingMainResource() const
 {
-    return !!m_mainResourceLoader;
+    return !!m_mainResourceLoader || m_loadingEmptyDocument;
 }
 
 bool DocumentLoader::isLoadingMultipartContent() const
@@ -843,17 +845,41 @@ bool DocumentLoader::isMultipartReplacingLoad() const
     return isLoadingMultipartContent() && frameLoader()->isReplacing();
 }
 
+bool DocumentLoader::maybeLoadEmpty()
+{
+    bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmpty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().protocol()));
+    if (!shouldLoadEmpty && !frameLoader()->client()->representationExistsForURLScheme(m_request.url().protocol()))
+        return false;
+
+    m_loadingEmptyDocument = true;
+    if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingInitialEmptyDocument())
+        m_request.setURL(blankURL());
+    String mimeType = shouldLoadEmpty ? "text/html" : frameLoader()->client()->generatedMIMETypeForURLScheme(m_request.url().protocol());
+    setResponse(ResourceResponse(m_request.url(), mimeType, 0, String(), String()));
+    finishedLoading();
+    return true;
+}
+
 void DocumentLoader::startLoadingMainResource()
 {
     m_mainDocumentError = ResourceError();
     timing()->markNavigationStart();
     ASSERT(!m_mainResourceLoader);
+
+    if (maybeLoadEmpty())
+        return;
+
     m_mainResourceLoader = MainResourceLoader::create(m_frame);
 
     // FIXME: Is there any way the extra fields could have not been added by now?
     // If not, it would be great to remove this line of code.
     frameLoader()->addExtraFieldsToMainResourceRequest(m_request);
     m_mainResourceLoader->load(m_request, m_substituteData);
+
+    if (m_request.isNull()) {
+        m_mainResourceLoader = 0;
+        maybeLoadEmpty();
+    }
 }
 
 void DocumentLoader::cancelMainResourceLoad(const ResourceError& error)
index e5acf4c..bd86a51 100644 (file)
@@ -265,6 +265,8 @@ namespace WebCore {
         void clearArchiveResources();
 #endif
 
+        bool maybeLoadEmpty();
+
         bool isMultipartReplacingLoad() const;
 
         void deliverSubstituteResourcesAfterDelay();
@@ -307,6 +309,7 @@ namespace WebCore {
         bool m_isStopping;
         bool m_gotFirstByte;
         bool m_isClientRedirect;
+        bool m_loadingEmptyDocument;
 
         // FIXME: Document::m_processingLoadEvent and DocumentLoader::m_wasOnloadHandled are roughly the same
         // and should be merged.
index 13d4c1e..66d205a 100644 (file)
@@ -215,14 +215,14 @@ FrameLoader::FrameLoader(Frame* frame, FrameLoaderClient* client)
     , m_subframeLoader(frame)
     , m_icon(frame)
     , m_mixedContentChecker(frame)
-    , m_state(FrameStateCommittedPage)
+    , m_state(FrameStateProvisional)
     , m_loadType(FrameLoadTypeStandard)
     , m_delegateIsHandlingProvisionalLoadError(false)
     , m_quickRedirectComing(false)
     , m_sentRedirectNotification(false)
     , m_inStopAllLoaders(false)
     , m_isExecutingJavaScriptFormAction(false)
-    , m_didCallImplicitClose(false)
+    , m_didCallImplicitClose(true)
     , m_wasUnloadEventEmitted(false)
     , m_pageDismissalEventBeingDispatched(NoDismissal)
     , m_isComplete(false)
@@ -255,19 +255,11 @@ FrameLoader::~FrameLoader()
 void FrameLoader::init()
 {
     // This somewhat odd set of steps gives the frame an initial empty document.
-    // It would be better if this could be done with even fewer steps.
-    m_stateMachine.advanceTo(FrameLoaderStateMachine::CreatingInitialEmptyDocument);
     setPolicyDocumentLoader(m_client->createDocumentLoader(ResourceRequest(KURL(ParsedURLString, emptyString())), SubstituteData()).get());
     setProvisionalDocumentLoader(m_policyDocumentLoader.get());
-    setState(FrameStateProvisional);
-    m_provisionalDocumentLoader->setResponse(ResourceResponse(KURL(), "text/html", 0, String(), String()));
-    m_provisionalDocumentLoader->finishedLoading();
-    ASSERT(!m_frame->document());
-    m_documentLoader->writer()->begin(KURL(), false);
-    m_documentLoader->writer()->end();
+    m_provisionalDocumentLoader->startLoadingMainResource();
     m_frame->document()->cancelParsing();
     m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocument);
-    m_didCallImplicitClose = true;
 
     m_networkingContext = m_client->createNetworkingContext();
     m_progressTracker = FrameProgressTracker::create(m_frame);
index 790b144..5400abd 100644 (file)
@@ -35,7 +35,7 @@ namespace WebCore {
 
     
 FrameLoaderStateMachine::FrameLoaderStateMachine() 
-    : m_state(Uninitialized)
+    : m_state(CreatingInitialEmptyDocument)
 { 
 }
     
index fe37ece..8bce923 100644 (file)
@@ -44,7 +44,6 @@ public:
     // alternate between CommittedFirstRealLoad and FirstLayoutDone.
     // Otherwise, the states only go down the list.
     enum State {
-        Uninitialized,
         CreatingInitialEmptyDocument,
         DisplayingInitialEmptyDocument,
         DisplayingInitialEmptyDocumentPostCommit,
index 1b113a0..3ff68d8 100644 (file)
 
 namespace WebCore {
 
-static bool shouldLoadAsEmptyDocument(const KURL& url)
-{
-    return url.isEmpty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(url.protocol());
-}
-
 MainResourceLoader::MainResourceLoader(Frame* frame)
     : ResourceLoader(frame, ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForCrossOriginCredentials, SkipSecurityCheck))
     , m_dataLoadTimer(this, &MainResourceLoader::handleSubstituteDataLoadNow)
@@ -338,13 +333,10 @@ void MainResourceLoader::continueAfterContentPolicy(PolicyAction contentPolicy,
     if (!reachedTerminalState())
         ResourceLoader::didReceiveResponse(r);
 
-    if (frameLoader() && !frameLoader()->activeDocumentLoader()->isStopping()) {
-        if (m_substituteData.isValid()) {
-            if (m_substituteData.content()->size())
-                didReceiveData(m_substituteData.content()->data(), m_substituteData.content()->size(), m_substituteData.content()->size(), true);
-            if (frameLoader() && !frameLoader()->activeDocumentLoader()->isStopping()) 
-                didFinishLoading(0);
-        } else if (shouldLoadAsEmptyDocument(url) || frameLoader()->client()->representationExistsForURLScheme(url.protocol()))
+    if (frameLoader() && !frameLoader()->activeDocumentLoader()->isStopping() && m_substituteData.isValid()) {
+        if (m_substituteData.content()->size())
+            didReceiveData(m_substituteData.content()->data(), m_substituteData.content()->size(), m_substituteData.content()->size(), true);
+        if (frameLoader() && !frameLoader()->activeDocumentLoader()->isStopping()) 
             didFinishLoading(0);
     }
 }
@@ -385,7 +377,7 @@ void MainResourceLoader::didReceiveResponse(const ResourceResponse& r)
     // There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred.
     // See <rdar://problem/6304600> for more details.
 #if !USE(CF)
-    ASSERT(shouldLoadAsEmptyDocument(r.url()) || !defersLoading());
+    ASSERT(!defersLoading());
 #endif
 
     if (m_loadingMultipartContent) {
@@ -500,7 +492,7 @@ void MainResourceLoader::didFinishLoading(double finishTime)
     // There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred.
     // See <rdar://problem/6304600> for more details.
 #if !USE(CF)
-    ASSERT(shouldLoadAsEmptyDocument(frameLoader()->activeDocumentLoader()->url()) || !defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_frame.get()));
+    ASSERT(!defersLoading() || InspectorInstrumentation::isDebuggerPaused(m_frame.get()));
 #endif
 
     // The additional processing can do anything including possibly removing the last
@@ -561,18 +553,6 @@ void MainResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) c
     info.addMember(m_dataLoadTimer);
 }
 
-void MainResourceLoader::handleEmptyLoad(const KURL& url, bool forURLScheme)
-{
-    String mimeType;
-    if (forURLScheme)
-        mimeType = frameLoader()->client()->generatedMIMETypeForURLScheme(url.protocol());
-    else
-        mimeType = "text/html";
-    
-    ResourceResponse response(url, mimeType, 0, String(), String());
-    didReceiveResponse(response);
-}
-
 void MainResourceLoader::handleSubstituteDataLoadNow(MainResourceLoaderTimer*)
 {
     RefPtr<MainResourceLoader> protect(this);
@@ -609,29 +589,10 @@ void MainResourceLoader::handleSubstituteDataLoadSoon(const ResourceRequest& r)
         handleSubstituteDataLoadNow(0);
 }
 
-bool MainResourceLoader::loadNow(ResourceRequest& r)
+void MainResourceLoader::loadNow(ResourceRequest& r)
 {
-    bool shouldLoadEmptyBeforeRedirect = shouldLoadAsEmptyDocument(r.url());
-
     ASSERT(!m_handle);
-    ASSERT(shouldLoadEmptyBeforeRedirect || !defersLoading());
-
-    // Send this synthetic delegate callback since clients expect it, and
-    // we no longer send the callback from within NSURLConnection for
-    // initial requests.
-    willSendRequest(r, ResourceResponse());
-    ASSERT(!deletionHasBegun());
-
-    // <rdar://problem/4801066>
-    // willSendRequest() is liable to make the call to frameLoader() return NULL, so we need to check that here
-    if (!frameLoader())
-        return false;
-    
-    const KURL& url = r.url();
-    bool shouldLoadEmpty = shouldLoadAsEmptyDocument(url) && !m_substituteData.isValid();
-
-    if (shouldLoadEmptyBeforeRedirect && !shouldLoadEmpty && defersLoading())
-        return true;
+    ASSERT(!defersLoading());
 
 #if USE(PLATFORM_STRATEGIES)
     platformStrategies()->loaderStrategy()->resourceLoadScheduler()->addMainResourceLoad(this);
@@ -641,12 +602,10 @@ bool MainResourceLoader::loadNow(ResourceRequest& r)
 
     if (m_substituteData.isValid())
         handleSubstituteDataLoadSoon(r);
-    else if (shouldLoadEmpty || frameLoader()->client()->representationExistsForURLScheme(url.protocol()))
-        handleEmptyLoad(url, !shouldLoadEmpty);
     else
         m_handle = ResourceHandle::create(m_frame->loader()->networkingContext(), r, this, false, true);
 
-    return false;
+    return;
 }
 
 void MainResourceLoader::load(const ResourceRequest& r, const SubstituteData& substituteData)
@@ -664,23 +623,26 @@ void MainResourceLoader::load(const ResourceRequest& r, const SubstituteData& su
     documentLoader()->timing()->markFetchStart();
     ResourceRequest request(r);
 
-    documentLoader()->applicationCacheHost()->maybeLoadMainResource(request, m_substituteData);
+    // Send this synthetic delegate callback since clients expect it, and
+    // we no longer send the callback from within NSURLConnection for
+    // initial requests.
+    willSendRequest(request, ResourceResponse());
+    ASSERT(!deletionHasBegun());
 
-    bool defer = defersLoading();
-    if (defer) {
-        bool shouldLoadEmpty = shouldLoadAsEmptyDocument(request.url());
-        if (shouldLoadEmpty)
-            defer = false;
-    }
-    if (!defer) {
-        if (loadNow(request)) {
-            // Started as an empty document, but was redirected to something non-empty.
-            ASSERT(defersLoading());
-            defer = true;
-        }
+    // <rdar://problem/4801066>
+    // willSendRequest() is liable to make the call to frameLoader() return null, so we need to check that here
+    if (!frameLoader() || request.isNull()) {
+        if (!reachedTerminalState())
+            releaseResources();
+        return;
     }
-    if (defer)
+
+    documentLoader()->applicationCacheHost()->maybeLoadMainResource(request, m_substituteData);
+
+    if (defersLoading())
         m_initialRequest = request;
+    else
+        loadNow(request);
 }
 
 void MainResourceLoader::setDefersLoading(bool defers)
index 09406e8..350cecd 100644 (file)
@@ -81,9 +81,8 @@ private:
     virtual void willCancel(const ResourceError&) OVERRIDE;
     virtual void didCancel(const ResourceError&) OVERRIDE;
 
-    bool loadNow(ResourceRequest&);
+    void loadNow(ResourceRequest&);
 
-    void handleEmptyLoad(const KURL&, bool forURLScheme);
     void handleSubstituteDataLoadSoon(const ResourceRequest&);
     void handleSubstituteDataLoadNow(MainResourceLoaderTimer*);
 
index 7696295..1b63f2d 100644 (file)
@@ -1,3 +1,18 @@
+2012-11-19  Nate Chapin  <japhet@chromium.org>
+
+        Move empty loading to DocumentLoader, simplify FrameLoader::init()
+        https://bugs.webkit.org/show_bug.cgi?id=101512
+
+        Reviewed by Adam Barth.
+
+        Chromium DRT has some code that doesn't play nicely with empty urls and incorrectly
+        interprets them as a non-empty load. This ensures
+        http/tests/navigation/new-window-redirect-history.html continues to pass
+        in chromium.
+
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::updateForCommittedLoad):
+
 2012-11-19  Vincent Scheib  <scheib@chromium.org>
 
         [Chromium] Remove WebKit::WebRuntimeFeatures::enablePointerLock.
index baf8d0d..e093f8f 100644 (file)
@@ -1605,7 +1605,8 @@ void WebViewHost::updateForCommittedLoad(WebFrame* frame, bool isNewNavigation)
 {
     // Code duplicated from RenderView::DidCommitLoadForFrame.
     TestShellExtraData* extraData = static_cast<TestShellExtraData*>(frame->dataSource()->extraData());
-    bool nonBlankPageAfterReset = m_pageId == -1 && strcmp(frame->dataSource()->request().url().spec().data(), "about:blank");
+    const WebURL& url = frame->dataSource()->request().url();
+    bool nonBlankPageAfterReset = m_pageId == -1 && !url.isEmpty() && strcmp(url.spec().data(), "about:blank");
 
     if (isNewNavigation || nonBlankPageAfterReset) {
         // New navigation.