| Index: ios/web/web_state/navigation_callbacks_inttest.mm
|
| diff --git a/ios/web/web_state/navigation_callbacks_inttest.mm b/ios/web/web_state/navigation_callbacks_inttest.mm
|
| index d9eba625dc7bf24a66aacef381bdabef0e2c059a..23b2f6af14c3c99ba739c810ed1b8acce9648010 100644
|
| --- a/ios/web/web_state/navigation_callbacks_inttest.mm
|
| +++ b/ios/web/web_state/navigation_callbacks_inttest.mm
|
| @@ -81,6 +81,7 @@ class WebStateObserverMock : public WebStateObserver {
|
| public:
|
| WebStateObserverMock(WebState* web_state) : WebStateObserver(web_state) {}
|
| MOCK_METHOD1(DidFinishNavigation, void(NavigationContext* context));
|
| + MOCK_METHOD1(ProvisionalNavigationStarted, void(const GURL& url));
|
| };
|
|
|
| } // namespace
|
| @@ -88,8 +89,9 @@ class WebStateObserverMock : public WebStateObserver {
|
| using test::HttpServer;
|
| using testing::_;
|
|
|
| -// Test fixture for WebStateDelegate::DidFinishNavigation integration tests.
|
| -class DidFinishNavigationTest : public WebIntTest {
|
| +// Test fixture for WebStateDelegate::ProvisionalNavigationStarted and
|
| +// WebStateDelegate::DidFinishNavigation integration tests.
|
| +class StartAndFinishNavigationTest : public WebIntTest {
|
| void SetUp() override {
|
| WebIntTest::SetUp();
|
| observer_ = base::MakeUnique<WebStateObserverMock>(web_state());
|
| @@ -100,37 +102,41 @@ class DidFinishNavigationTest : public WebIntTest {
|
| };
|
|
|
| // Tests successful navigation to a new page.
|
| -TEST_F(DidFinishNavigationTest, NewPageNavigation) {
|
| +TEST_F(StartAndFinishNavigationTest, NewPageNavigation) {
|
| const GURL url = HttpServer::MakeUrl("http://chromium.test");
|
| std::map<GURL, std::string> responses;
|
| responses[url] = "Chromium Test";
|
| web::test::SetUpSimpleHttpServer(responses);
|
|
|
| // Perform new page navigation.
|
| + EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
|
| EXPECT_CALL(*observer_, DidFinishNavigation(_))
|
| .WillOnce(VerifyNewPageContext(web_state(), url));
|
| LoadUrl(url);
|
| }
|
|
|
| // Tests user-initiated hash change.
|
| -TEST_F(DidFinishNavigationTest, UserInitiatedHashChangeNavigation) {
|
| +TEST_F(StartAndFinishNavigationTest, UserInitiatedHashChangeNavigation) {
|
| const GURL url = HttpServer::MakeUrl("http://chromium.test");
|
| std::map<GURL, std::string> responses;
|
| responses[url] = "Chromium Test";
|
| web::test::SetUpSimpleHttpServer(responses);
|
|
|
| // Perform new page navigation.
|
| + EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
|
| EXPECT_CALL(*observer_, DidFinishNavigation(_))
|
| .WillOnce(VerifyNewPageContext(web_state(), url));
|
| LoadUrl(url);
|
|
|
| // Perform same-page navigation.
|
| const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1");
|
| + EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
|
| EXPECT_CALL(*observer_, DidFinishNavigation(_))
|
| .WillOnce(VerifySameDocumentContext(web_state(), hash_url));
|
| LoadUrl(hash_url);
|
|
|
| // Perform same-page navigation by going back.
|
| + EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
|
| EXPECT_CALL(*observer_, DidFinishNavigation(_))
|
| .WillOnce(VerifySameDocumentContext(web_state(), url));
|
| ExecuteBlockAndWaitForLoad(url, ^{
|
| @@ -139,52 +145,58 @@ TEST_F(DidFinishNavigationTest, UserInitiatedHashChangeNavigation) {
|
| }
|
|
|
| // Tests renderer-initiated hash change.
|
| -TEST_F(DidFinishNavigationTest, RendererInitiatedHashChangeNavigation) {
|
| +TEST_F(StartAndFinishNavigationTest, RendererInitiatedHashChangeNavigation) {
|
| const GURL url = HttpServer::MakeUrl("http://chromium.test");
|
| std::map<GURL, std::string> responses;
|
| responses[url] = "Chromium Test";
|
| web::test::SetUpSimpleHttpServer(responses);
|
|
|
| // Perform new page navigation.
|
| + EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
|
| EXPECT_CALL(*observer_, DidFinishNavigation(_))
|
| .WillOnce(VerifyNewPageContext(web_state(), url));
|
| LoadUrl(url);
|
|
|
| // Perform same-page navigation using JavaScript.
|
| const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1");
|
| + EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
|
| EXPECT_CALL(*observer_, DidFinishNavigation(_))
|
| .WillOnce(VerifySameDocumentContext(web_state(), hash_url));
|
| ExecuteJavaScript(@"window.location.hash = '#1'");
|
| }
|
|
|
| // Tests state change.
|
| -TEST_F(DidFinishNavigationTest, StateNavigation) {
|
| +TEST_F(StartAndFinishNavigationTest, StateNavigation) {
|
| const GURL url = HttpServer::MakeUrl("http://chromium.test");
|
| std::map<GURL, std::string> responses;
|
| responses[url] = "Chromium Test";
|
| web::test::SetUpSimpleHttpServer(responses);
|
|
|
| // Perform new page navigation.
|
| + EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
|
| EXPECT_CALL(*observer_, DidFinishNavigation(_))
|
| .WillOnce(VerifyNewPageContext(web_state(), url));
|
| LoadUrl(url);
|
|
|
| // Perform push state using JavaScript.
|
| const GURL push_url = HttpServer::MakeUrl("http://chromium.test/test.html");
|
| + EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
|
| EXPECT_CALL(*observer_, DidFinishNavigation(_))
|
| .WillOnce(VerifySameDocumentContext(web_state(), push_url));
|
| ExecuteJavaScript(@"window.history.pushState('', 'Test', 'test.html')");
|
|
|
| // Perform replace state using JavaScript.
|
| const GURL replace_url = HttpServer::MakeUrl("http://chromium.test/1.html");
|
| + EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
|
| EXPECT_CALL(*observer_, DidFinishNavigation(_))
|
| .WillOnce(VerifySameDocumentContext(web_state(), replace_url));
|
| ExecuteJavaScript(@"window.history.replaceState('', 'Test', '1.html')");
|
| }
|
|
|
| // Tests native content navigation.
|
| -TEST_F(DidFinishNavigationTest, NativeContentNavigation) {
|
| +TEST_F(StartAndFinishNavigationTest, NativeContentNavigation) {
|
| GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize());
|
| + EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
|
| EXPECT_CALL(*observer_, DidFinishNavigation(_))
|
| .WillOnce(VerifyNewNativePageContext(web_state(), url));
|
| LoadUrl(url);
|
|
|