Commit b22a26e4 authored by japhet's avatar japhet Committed by Commit bot

Always send a fail or finish notification for each navigation.

Historically, we have dropped these when navigations are interleaved.

BUG=656919

Review-Url: https://codereview.chromium.org/2563423004
Cr-Commit-Position: refs/heads/master@{#440862}
parent 910bc047
......@@ -3,10 +3,12 @@ main frame - didCommitLoadForFrame
CONSOLE WARNING: line 47: A Parser-blocking, cross-origin script, http://localhost:8000/loading/resources/js-loaded.js?reload, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details.
CONSOLE WARNING: line 47: A Parser-blocking, cross-origin script, http://localhost:8000/loading/resources/js-loaded.js?reload, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details.
main frame - didStartProvisionalLoadForFrame
main frame - didFailLoadWithError
main frame - didCommitLoadForFrame
CONSOLE WARNING: line 47: A Parser-blocking, cross-origin script, http://localhost:8000/loading/resources/js-loaded.js?reload, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details.
CONSOLE WARNING: line 47: A Parser-blocking, cross-origin script, http://localhost:8000/loading/resources/js-loaded.js?reload, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details.
main frame - didStartProvisionalLoadForFrame
main frame - didFailLoadWithError
main frame - didCommitLoadForFrame
CONSOLE WARNING: line 47: A Parser-blocking, cross-origin script, http://localhost:8000/loading/resources/js-loaded.js?reload, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details.
CONSOLE WARNING: line 47: A Parser-blocking, cross-origin script, http://localhost:8000/loading/resources/js-loaded.js?reload, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details.
......
......@@ -132,6 +132,7 @@ DocumentLoader::~DocumentLoader() {
DCHECK(!m_frame);
DCHECK(!m_mainResource);
DCHECK(!m_applicationCacheHost);
DCHECK_EQ(m_state, SentDidFinishLoad);
}
DEFINE_TRACE(DocumentLoader) {
......@@ -285,7 +286,6 @@ void DocumentLoader::notifyFinished(Resource* resource) {
if (m_applicationCacheHost)
m_applicationCacheHost->failedLoadingMainResource();
m_state = MainResourceDone;
if (m_mainResource->resourceError().wasBlockedByResponse()) {
InspectorInstrumentation::canceledAfterReceivedResourceResponse(
......@@ -326,8 +326,6 @@ void DocumentLoader::finishedLoading(double finishTime) {
m_applicationCacheHost->finishedLoadingMainResource();
endWriting();
if (m_state < MainResourceDone)
m_state = MainResourceDone;
clearMainResourceHandle();
// Shows the deprecation message and measures the impact of the new security
......@@ -551,7 +549,7 @@ void DocumentLoader::ensureWriter(const AtomicString& mimeType,
}
void DocumentLoader::commitData(const char* bytes, size_t length) {
DCHECK_LT(m_state, MainResourceDone);
DCHECK_EQ(m_state, Committed);
ensureWriter(m_response.mimeType());
// This can happen if document.close() is called by an event handler while
......@@ -633,6 +631,9 @@ void DocumentLoader::detachFromFrame() {
// frame have any loads active, so go ahead and kill all the loads.
m_fetcher->stopFetching();
if (frameLoader() && !sentDidFinishLoad())
frameLoader()->loadFailed(this, ResourceError::cancelledError(url()));
// If that load cancellation triggered another detach, leave.
// (fast/frames/detach-frame-nested-no-crash.html is an example of this.)
if (!m_frame)
......
......@@ -271,7 +271,6 @@ class CORE_EXPORT DocumentLoader
NotStarted,
Provisional,
Committed,
MainResourceDone,
SentDidFinishLoad
};
State m_state;
......
......@@ -87,25 +87,16 @@ class FrameFetchContextTest : public ::testing::Test {
void SetUp() override {
dummyPageHolder = DummyPageHolder::create(IntSize(500, 500));
dummyPageHolder->page().setDeviceScaleFactor(1.0);
documentLoader = DocumentLoader::create(
&dummyPageHolder->frame(), ResourceRequest("http://www.example.com"),
SubstituteData(), ClientRedirectPolicy::NotClientRedirect);
document = &dummyPageHolder->document();
fetchContext =
static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context());
static_cast<FrameFetchContext*>(&document->fetcher()->context());
owner = DummyFrameOwner::create();
FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
}
void TearDown() override {
documentLoader->detachFromFrame();
documentLoader.clear();
if (childFrame) {
childDocumentLoader->detachFromFrame();
childDocumentLoader.clear();
if (childFrame)
childFrame->detach(FrameDetachType::Remove);
}
}
FrameFetchContext* createChildFrame() {
......@@ -114,12 +105,9 @@ class FrameFetchContextTest : public ::testing::Test {
document->frame()->host(), owner.get());
childFrame->setView(FrameView::create(*childFrame, IntSize(500, 500)));
childFrame->init();
childDocumentLoader = DocumentLoader::create(
childFrame.get(), ResourceRequest("http://www.example.com"),
SubstituteData(), ClientRedirectPolicy::NotClientRedirect);
childDocument = childFrame->document();
FrameFetchContext* childFetchContext = static_cast<FrameFetchContext*>(
&childDocumentLoader->fetcher()->context());
&childFrame->loader().documentLoader()->fetcher()->context());
FrameFetchContext::provideDocumentToContext(*childFetchContext,
childDocument.get());
return childFetchContext;
......@@ -129,13 +117,11 @@ class FrameFetchContextTest : public ::testing::Test {
// We don't use the DocumentLoader directly in any tests, but need to keep it
// around as long as the ResourceFetcher and Document live due to indirect
// usage.
Persistent<DocumentLoader> documentLoader;
Persistent<Document> document;
Persistent<FrameFetchContext> fetchContext;
Persistent<StubFrameLoaderClientWithParent> childClient;
Persistent<LocalFrame> childFrame;
Persistent<DocumentLoader> childDocumentLoader;
Persistent<Document> childDocument;
Persistent<DummyFrameOwner> owner;
};
......@@ -151,13 +137,10 @@ class FrameFetchContextMockedFrameLoaderClientTest
dummyPageHolder =
DummyPageHolder::create(IntSize(500, 500), nullptr, client);
dummyPageHolder->page().setDeviceScaleFactor(1.0);
documentLoader = DocumentLoader::create(
&dummyPageHolder->frame(), ResourceRequest(mainResourceUrl),
SubstituteData(), ClientRedirectPolicy::NotClientRedirect);
document = &dummyPageHolder->document();
document->setURL(mainResourceUrl);
fetchContext =
static_cast<FrameFetchContext*>(&documentLoader->fetcher()->context());
static_cast<FrameFetchContext*>(&document->fetcher()->context());
owner = DummyFrameOwner::create();
FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
}
......
......@@ -225,6 +225,10 @@ void FrameLoader::init() {
m_frame->document()->cancelParsing();
m_stateMachine.advanceTo(
FrameLoaderStateMachine::DisplayingInitialEmptyDocument);
// Suppress finish notifications for inital empty documents, since they don't
// generate start notifications.
if (m_documentLoader)
m_documentLoader->setSentDidFinishLoad();
// Self-suspend if created in an already suspended Page. Note that both
// startLoadingMainResource() and cancelParsing() may have already detached
// the frame, since they both fire JS events.
......@@ -672,11 +676,6 @@ static bool shouldComplete(Document* document) {
}
static bool shouldSendFinishNotification(LocalFrame* frame) {
// Don't send stop notifications for inital empty documents, since they don't
// generate start notifications.
if (!frame->loader().stateMachine()->committedFirstRealDocumentLoad())
return false;
// Don't send didFinishLoad more than once per DocumentLoader.
if (frame->loader().documentLoader()->sentDidFinishLoad())
return false;
......@@ -1468,19 +1467,18 @@ void FrameLoader::loadFailed(DocumentLoader* loader,
HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType);
if (loader == m_provisionalDocumentLoader) {
m_provisionalDocumentLoader->setSentDidFinishLoad();
client()->dispatchDidFailProvisionalLoad(error, historyCommitType);
if (loader != m_provisionalDocumentLoader)
return;
detachDocumentLoader(m_provisionalDocumentLoader);
m_progressTracker->progressCompleted();
} else {
DCHECK_EQ(loader, m_documentLoader);
if (m_frame->document()->parser())
m_frame->document()->parser()->stopParsing();
m_documentLoader->setSentDidFinishLoad();
if (!m_provisionalDocumentLoader && m_frame->isLoading()) {
if (!m_documentLoader->sentDidFinishLoad()) {
m_documentLoader->setSentDidFinishLoad();
client()->dispatchDidFailLoad(error, historyCommitType);
m_progressTracker->progressCompleted();
}
}
checkCompleted();
......
......@@ -87,11 +87,8 @@ class BaseAudioContextTest : public ::testing::Test {
}
void TearDown() override {
if (m_childFrame) {
m_childDocumentLoader->detachFromFrame();
m_childDocumentLoader.clear();
if (m_childFrame)
m_childFrame->detach(FrameDetachType::Remove);
}
}
void createChildFrame() {
......@@ -100,9 +97,6 @@ class BaseAudioContextTest : public ::testing::Test {
document().frame()->host(), m_dummyFrameOwner.get());
m_childFrame->setView(FrameView::create(*m_childFrame, IntSize(500, 500)));
m_childFrame->init();
m_childDocumentLoader = DocumentLoader::create(
m_childFrame.get(), ResourceRequest("https://www.example.com"),
SubstituteData(), ClientRedirectPolicy::NotClientRedirect);
childDocument().updateSecurityOrigin(
SecurityOrigin::create("https", "cross-origin.com", 80));
......@@ -129,7 +123,6 @@ class BaseAudioContextTest : public ::testing::Test {
Persistent<DummyFrameOwner> m_dummyFrameOwner;
Persistent<LocalFrame> m_childFrame;
Persistent<DocumentLoader> m_childDocumentLoader;
BaseAudioContextTestPlatform m_testPlatform;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment