Changeset 127690 in webkit


Ignore:
Timestamp:
Sep 5, 2012 9:48:20 PM (12 years ago)
Author:
Nate Chapin
Message:

Source/WebCore: [chromium] Some SubstituteData loads broken after r121912
https://bugs.webkit.org/show_bug.cgi?id=91685

Reviewed by Adam Barth.

Test: WebFrameTest.ReplaceNavigationAfterHistoryNavigation in chromium's webkit_unit_tests.

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::commitData): receivedFirstData() should be called exactly once per load,

on the first commit. I had mistakely assumed in r121912 that isReplacing() was true only for multipart
loads, and only after the first commit (chromium uses it for some SubstituteData loads to ensure the error page
replaces the failed load). We need to check whether we are loading multipart content before assuming isReplacing()
will tell us what we need to know.

Source/WebKit/chromium: Test for https://bugs.webkit.org/show_bug.cgi?id=91685

Reviewed by Adam Barth.

  • tests/WebFrameTest.cpp:
Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r127687 r127690  
     12012-09-05  Nate Chapin  <japhet@chromium.org>
     2
     3        [chromium] Some SubstituteData loads broken after r121912
     4        https://bugs.webkit.org/show_bug.cgi?id=91685
     5
     6        Reviewed by Adam Barth.
     7
     8        Test: WebFrameTest.ReplaceNavigationAfterHistoryNavigation in chromium's webkit_unit_tests.
     9
     10        * loader/DocumentLoader.cpp:
     11        (WebCore::DocumentLoader::commitData): receivedFirstData() should be called exactly once per load,
     12            on the first commit. I had mistakely assumed in r121912 that isReplacing() was true only for multipart
     13            loads, and only after the first commit (chromium uses it for some SubstituteData loads to ensure the error page
     14            replaces the failed load). We need to check whether we are loading multipart content before assuming isReplacing()
     15            will tell us what we need to know.
     16
    1172012-09-05  James Robinson  <jamesr@chromium.org>
    218
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r127593 r127690  
    337337#endif
    338338
    339         if (!frameLoader()->isReplacing())
     339        // Call receivedFirstData() exactly once per load. We should only reach this point multiple times
     340        // for multipart loads, and isReplacing() will be true after the first time.
     341        if (!m_mainResourceLoader || !m_mainResourceLoader->isLoadingMultipartContent() || !frameLoader()->isReplacing())
    340342            frameLoader()->receivedFirstData();
    341343
  • trunk/Source/WebKit/chromium/ChangeLog

    r127689 r127690  
     12012-09-05  Nate Chapin  <japhet@chromium.org>
     2
     3        Test for https://bugs.webkit.org/show_bug.cgi?id=91685
     4
     5        Reviewed by Adam Barth.
     6
     7        * tests/WebFrameTest.cpp:
     8
    192012-09-05  Rick Byers  <rbyers@chromium.org>
    210
  • trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp

    r127494 r127690  
    4646#include "WebFrameClient.h"
    4747#include "WebFrameImpl.h"
     48#include "WebHistoryItem.h"
    4849#include "WebRange.h"
    4950#include "WebScriptSource.h"
     
    5556#include "WebViewImpl.h"
    5657#include "platform/WebFloatRect.h"
     58#include "platform/WebURLResponse.h"
    5759#include "v8.h"
    5860#include <gtest/gtest.h>
     
    11471149}
    11481150
     1151class TestSubstituteDataWebFrameClient : public WebFrameClient {
     1152public:
     1153    TestSubstituteDataWebFrameClient()
     1154        : m_commitCalled(false)
     1155    {
     1156    }
     1157
     1158    virtual void didFailProvisionalLoad(WebFrame* frame, const WebURLError& error)
     1159    {
     1160        frame->loadHTMLString("This should appear", toKURL("data:text/html,chromewebdata"), error.unreachableURL, true);
     1161        webkit_support::RunAllPendingMessages();
     1162    }
     1163
     1164    virtual void didCommitProvisionalLoad(WebFrame* frame, bool)
     1165    {
     1166        if (frame->dataSource()->response().url() != WebURL(URLTestHelpers::toKURL("about:blank")))
     1167            m_commitCalled = true;
     1168    }
     1169
     1170    bool commitCalled() const { return m_commitCalled; }
     1171
     1172private:
     1173    bool m_commitCalled;
     1174};
     1175
     1176TEST_F(WebFrameTest, ReplaceNavigationAfterHistoryNavigation)
     1177{
     1178    TestSubstituteDataWebFrameClient webFrameClient;
     1179
     1180    WebView* webView = FrameTestHelpers::createWebViewAndLoad("about:blank", true, &webFrameClient);
     1181    webkit_support::RunAllPendingMessages();
     1182    WebFrame* frame = webView->mainFrame();
     1183
     1184    // Load a url as a history navigation that will return an error. TestSubstituteDataWebFrameClient
     1185    // will start a SubstituteData load in response to the load failure, which should get fully committed.
     1186    // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didReceiveData() wasn't getting
     1187    // called in this case, which resulted in the SubstituteData document not getting displayed.
     1188    WebURLError error;
     1189    error.reason = 1337;
     1190    error.domain = "WebFrameTest";
     1191    std::string errorURL = "http://0.0.0.0";
     1192    WebURLResponse response;
     1193    response.initialize();
     1194    response.setURL(URLTestHelpers::toKURL(errorURL));
     1195    response.setMIMEType("text/html");
     1196    response.setHTTPStatusCode(500);
     1197    WebHistoryItem errorHistoryItem;
     1198    errorHistoryItem.initialize();
     1199    errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL.length()));
     1200    errorHistoryItem.setOriginalURLString(WebString::fromUTF8(errorURL.c_str(), errorURL.length()));
     1201    webkit_support::RegisterMockedErrorURL(URLTestHelpers::toKURL(errorURL), response, error);
     1202    frame->loadHistoryItem(errorHistoryItem);
     1203    webkit_support::ServeAsynchronousMockedRequests();
     1204
     1205    WebString text = frame->contentAsText(std::numeric_limits<size_t>::max());
     1206    EXPECT_EQ("This should appear", std::string(text.utf8().data()));
     1207    EXPECT_TRUE(webFrameClient.commitCalled());
     1208}
     1209
    11491210} // namespace
Note: See TracChangeset for help on using the changeset viewer.