Skip to content

Commit

Permalink
Use SameDocument term in tests instead of SamePage.
Browse files Browse the repository at this point in the history
This is follow up cleanup after renaming NavigationHandle::IsSamePage to
NavigationHandle::IsSameDocument in this CL:
https://codereview.chromium.org/2716493004/

BUG=695189
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation

Review-Url: https://codereview.chromium.org/2742923002
Cr-Commit-Position: refs/heads/master@{#456231}
  • Loading branch information
eugenebut authored and Commit bot committed Mar 11, 2017
1 parent 8bcaea1 commit d62ba1f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6048,13 +6048,13 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
static_cast<WebContentsImpl*>(shell()->web_contents());
FrameTreeNode* root = web_contents->GetFrameTree()->root();

// Navigate to a simple page and then perform an in-page navigation.
// Navigate to a simple page and then perform a fragment change navigation.
GURL start_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
EXPECT_TRUE(NavigateToURL(shell(), start_url));

GURL same_page_url(
GURL fragment_change_url(
embedded_test_server()->GetURL("a.com", "/title1.html#foo"));
EXPECT_TRUE(NavigateToURL(shell(), same_page_url));
EXPECT_TRUE(NavigateToURL(shell(), fragment_change_url));
EXPECT_EQ(2, web_contents->GetController().GetEntryCount());

// Replace the URL of the current NavigationEntry with one that will cause
Expand Down Expand Up @@ -6082,8 +6082,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
// classified as SAME_PAGE) was leaving the FrameNavigationEntry with the
// same document sequence number as the previous entry but updates the URL.
// Doing a back session history navigation now will cause the browser to
// consider it as in-page because of this matching document sequence number
// and lead to a mismatch of origin and URL in the renderer process.
// consider it as same document because of this matching document sequence
// number and lead to a mismatch of origin and URL in the renderer process.
{
TestNavigationObserver observer(web_contents);
web_contents->GetController().GoBack();
Expand Down Expand Up @@ -6151,26 +6151,27 @@ class GoBackAndCommitFilter : public BrowserMessageFilter {
};

// Test which simulates a race condition between a cross-origin, same-process
// navigation and a same page session history navigation. When such a race
// navigation and a same document session history navigation. When such a race
// occurs, the renderer will commit the cross-origin navigation, updating its
// version of the current document sequence number, and will send an IPC to the
// browser process. The session history navigation comes after the commit for
// the cross-origin navigation and updates the URL, but not the origin of the
// document. This results in mismatch between the two and causes the renderer
// process to be killed. See https://crbug.com/630103.
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
RaceCrossOriginNavigationAndSamePageHistoryNavigation) {
IN_PROC_BROWSER_TEST_F(
NavigationControllerBrowserTest,
RaceCrossOriginNavigationAndSameDocumentHistoryNavigation) {
WebContentsImpl* web_contents =
static_cast<WebContentsImpl*>(shell()->web_contents());
FrameTreeNode* root = web_contents->GetFrameTree()->root();

// Navigate to a simple page and then perform an in-page navigation.
// Navigate to a simple page and then perform a same document navigation.
GURL start_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
EXPECT_TRUE(NavigateToURL(shell(), start_url));

GURL same_page_url(
GURL same_document_url(
embedded_test_server()->GetURL("a.com", "/title1.html#foo"));
EXPECT_TRUE(NavigateToURL(shell(), same_page_url));
EXPECT_TRUE(NavigateToURL(shell(), same_document_url));
EXPECT_EQ(2, web_contents->GetController().GetEntryCount());

// Create a GoBackAndCommitFilter, which will delay the commit IPC for a
Expand Down Expand Up @@ -6214,7 +6215,7 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_TRUE(ExecuteScriptAndExtractString(
web_contents, "domAutomationController.send(document.origin)",
&origin));
EXPECT_EQ(same_page_url.GetOrigin().spec(), origin + "/");
EXPECT_EQ(same_document_url.GetOrigin().spec(), origin + "/");
} else {
// Wait for the back navigation to commit as well.
history_commit_observer.Wait();
Expand Down Expand Up @@ -6676,10 +6677,10 @@ class NavigationHandleCommitObserver : public WebContentsObserver {
bool was_renderer_initiated_;
};

// Test that a same-page navigation does not lead to the deletion of the
// NavigationHandle for an ongoing different page navigation.
// Test that a same document navigation does not lead to the deletion of the
// NavigationHandle for an ongoing different document navigation.
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
SamePageNavigationDoesntDeleteNavigationHandle) {
SameDocumentNavigationDoesntDeleteNavigationHandle) {
const GURL kURL1 = embedded_test_server()->GetURL("/title1.html");
const GURL kPushStateURL =
embedded_test_server()->GetURL("/title1.html#fragment");
Expand Down Expand Up @@ -6749,10 +6750,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,

}

// Tests that a same-page browser-initiated navigation is properly reported by
// the NavigationHandle.
// Tests that a same document browser-initiated navigation is properly reported
// by the NavigationHandle.
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
SamePageBrowserInitiated) {
SameDocumentBrowserInitiated) {
const GURL kURL = embedded_test_server()->GetURL("/title1.html");
const GURL kFragmentURL =
embedded_test_server()->GetURL("/title1.html#fragment");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,17 @@ IN_PROC_BROWSER_TEST_F(MediaSessionServiceImplBrowserTest,
}

IN_PROC_BROWSER_TEST_F(MediaSessionServiceImplBrowserTest,
DontResetServiceForSamePageNavigation) {
DontResetServiceForSameDocumentNavigation) {
NavigateToURL(shell(), GetTestUrl(".", "title1.html"));
EnsurePlayer();

EXPECT_TRUE(ExecuteScriptToSetUpMediaSessionSync());

// Start a same-page navigation and check the playback state, metadata,
// Start a fragment navigation and check the playback state, metadata,
// actions are not reset.
GURL same_page_url = GetTestUrl(".", "title1.html");
same_page_url = GURL(same_page_url.spec() + "#some-anchor");
NavigateToURLAndWaitForFinish(shell(), same_page_url);
GURL fragment_change_url = GetTestUrl(".", "title1.html");
fragment_change_url = GURL(fragment_change_url.spec() + "#some-anchor");
NavigateToURLAndWaitForFinish(shell(), fragment_change_url);

EXPECT_EQ(blink::mojom::MediaSessionPlaybackState::PLAYING,
GetService()->playback_state());
Expand Down

0 comments on commit d62ba1f

Please sign in to comment.