Commit 78a3ea38 authored by mlamouri's avatar mlamouri Committed by Commit bot

Do not reset ManifestManager state for same page navigation.

BUG=459240

Review URL: https://codereview.chromium.org/930223003

Cr-Commit-Position: refs/heads/master@{#316611}
parent bcdefd0c
...@@ -312,4 +312,57 @@ IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, Navigation) { ...@@ -312,4 +312,57 @@ IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, Navigation) {
} }
} }
// If a page has a manifest and the page is navigated using pushState (ie. same
// page), it should keep its manifest state.
IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, PushStateNavigation) {
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
GURL test_url =
embedded_test_server()->GetURL("/manifest/dummy-manifest.html");
{
TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
shell()->LoadURL(test_url);
navigation_observer.Wait();
}
{
TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
ASSERT_TRUE(content::ExecuteScript(
shell()->web_contents(),
"history.pushState({foo: \"bar\"}, 'page', 'page.html');"));
navigation_observer.Wait();
}
GetManifestAndWait();
EXPECT_FALSE(manifest().IsEmpty());
EXPECT_EQ(0u, console_error_count());
}
// If a page has a manifest and is navigated using an anchor (ie. same page), it
// should keep its manifest state.
IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, AnchorNavigation) {
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
GURL test_url =
embedded_test_server()->GetURL("/manifest/dummy-manifest.html");
{
TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
shell()->LoadURL(test_url);
navigation_observer.Wait();
}
{
TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
ASSERT_TRUE(content::ExecuteScript(
shell()->web_contents(),
"var a = document.createElement('a'); a.href='#foo';"
"document.body.appendChild(a); a.click();"));
navigation_observer.Wait();
}
GetManifestAndWait();
EXPECT_FALSE(manifest().IsEmpty());
EXPECT_EQ(0u, console_error_count());
}
} // namespace content } // namespace content
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/strings/nullable_string16.h" #include "base/strings/nullable_string16.h"
#include "content/common/manifest_manager_messages.h" #include "content/common/manifest_manager_messages.h"
#include "content/public/renderer/document_state.h"
#include "content/public/renderer/navigation_state.h"
#include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_frame.h"
#include "content/renderer/fetchers/manifest_fetcher.h" #include "content/renderer/fetchers/manifest_fetcher.h"
#include "content/renderer/manifest/manifest_parser.h" #include "content/renderer/manifest/manifest_parser.h"
...@@ -102,6 +104,11 @@ void ManifestManager::DidChangeManifest() { ...@@ -102,6 +104,11 @@ void ManifestManager::DidChangeManifest() {
} }
void ManifestManager::DidCommitProvisionalLoad(bool is_new_navigation) { void ManifestManager::DidCommitProvisionalLoad(bool is_new_navigation) {
NavigationState* navigation_state = DocumentState::FromDataSource(
render_frame()->GetWebFrame()->dataSource())->navigation_state();
if (navigation_state->was_within_same_page())
return;
may_have_manifest_ = false; may_have_manifest_ = false;
manifest_dirty_ = true; manifest_dirty_ = true;
} }
......
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