| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #import "ios/web/public/navigation_item.h" | 9 #import "ios/web/public/navigation_item.h" |
| 10 #import "ios/web/public/navigation_manager.h" | 10 #import "ios/web/public/navigation_manager.h" |
| 11 #import "ios/web/public/test/http_server.h" | 11 #import "ios/web/public/test/http_server.h" |
| 12 #include "ios/web/public/test/http_server_util.h" | 12 #include "ios/web/public/test/http_server_util.h" |
| 13 #import "ios/web/public/web_state/navigation_context.h" | 13 #import "ios/web/public/web_state/navigation_context.h" |
| 14 #include "ios/web/public/web_state/web_state_observer.h" | 14 #include "ios/web/public/web_state/web_state_observer.h" |
| 15 #include "ios/web/test/test_url_constants.h" | 15 #include "ios/web/test/test_url_constants.h" |
| 16 #import "ios/web/test/web_int_test.h" | 16 #import "ios/web/test/web_int_test.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "ui/base/page_transition_types.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 20 #include "url/scheme_host_port.h" | 21 #include "url/scheme_host_port.h" |
| 21 | 22 |
| 22 namespace web { | 23 namespace web { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 const char kExpectedMimeType[] = "text/html"; | 27 const char kExpectedMimeType[] = "text/html"; |
| 27 | 28 |
| 28 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation | 29 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation |
| 29 // passed to |DidStartNavigation|. Stores |NavigationContext| in |context| | 30 // passed to |DidStartNavigation|. Stores |NavigationContext| in |context| |
| 30 // pointer. | 31 // pointer. |
| 31 ACTION_P3(VerifyNewPageStartedContext, web_state, url, context) { | 32 ACTION_P3(VerifyNewPageStartedContext, web_state, url, context) { |
| 32 *context = arg0; | 33 *context = arg0; |
| 33 ASSERT_TRUE(*context); | 34 ASSERT_TRUE(*context); |
| 34 EXPECT_EQ(web_state, (*context)->GetWebState()); | 35 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| 35 EXPECT_EQ(url, (*context)->GetUrl()); | 36 EXPECT_EQ(url, (*context)->GetUrl()); |
| 37 EXPECT_TRUE( |
| 38 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, |
| 39 (*context)->GetPageTransition())); |
| 36 EXPECT_FALSE((*context)->IsSameDocument()); | 40 EXPECT_FALSE((*context)->IsSameDocument()); |
| 37 EXPECT_FALSE((*context)->GetError()); | 41 EXPECT_FALSE((*context)->GetError()); |
| 38 ASSERT_FALSE((*context)->GetResponseHeaders()); | 42 ASSERT_FALSE((*context)->GetResponseHeaders()); |
| 39 NavigationManager* navigation_manager = web_state->GetNavigationManager(); | 43 NavigationManager* navigation_manager = web_state->GetNavigationManager(); |
| 40 NavigationItem* item = navigation_manager->GetPendingItem(); | 44 NavigationItem* item = navigation_manager->GetPendingItem(); |
| 41 EXPECT_EQ(url, item->GetURL()); | 45 EXPECT_EQ(url, item->GetURL()); |
| 42 } | 46 } |
| 43 | 47 |
| 44 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation | 48 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation |
| 45 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as | 49 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as |
| 46 // |context|. | 50 // |context|. |
| 47 ACTION_P3(VerifyNewPageFinishedContext, web_state, url, context) { | 51 ACTION_P3(VerifyNewPageFinishedContext, web_state, url, context) { |
| 48 ASSERT_EQ(*context, arg0); | 52 ASSERT_EQ(*context, arg0); |
| 49 EXPECT_EQ(web_state, (*context)->GetWebState()); | 53 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| 50 ASSERT_TRUE((*context)); | 54 ASSERT_TRUE((*context)); |
| 51 EXPECT_EQ(web_state, (*context)->GetWebState()); | 55 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| 52 EXPECT_EQ(url, (*context)->GetUrl()); | 56 EXPECT_EQ(url, (*context)->GetUrl()); |
| 57 EXPECT_TRUE( |
| 58 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, |
| 59 (*context)->GetPageTransition())); |
| 53 EXPECT_FALSE((*context)->IsSameDocument()); | 60 EXPECT_FALSE((*context)->IsSameDocument()); |
| 54 EXPECT_FALSE((*context)->GetError()); | 61 EXPECT_FALSE((*context)->GetError()); |
| 55 ASSERT_TRUE((*context)->GetResponseHeaders()); | 62 ASSERT_TRUE((*context)->GetResponseHeaders()); |
| 56 std::string mime_type; | 63 std::string mime_type; |
| 57 (*context)->GetResponseHeaders()->GetMimeType(&mime_type); | 64 (*context)->GetResponseHeaders()->GetMimeType(&mime_type); |
| 58 EXPECT_EQ(kExpectedMimeType, mime_type); | 65 EXPECT_EQ(kExpectedMimeType, mime_type); |
| 59 NavigationManager* navigation_manager = web_state->GetNavigationManager(); | 66 NavigationManager* navigation_manager = web_state->GetNavigationManager(); |
| 60 NavigationItem* item = navigation_manager->GetLastCommittedItem(); | 67 NavigationItem* item = navigation_manager->GetLastCommittedItem(); |
| 61 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); | 68 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); |
| 62 EXPECT_EQ(url, item->GetURL()); | 69 EXPECT_EQ(url, item->GetURL()); |
| 63 } | 70 } |
| 64 | 71 |
| 65 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation | 72 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation |
| 66 // passed to |DidFinishNavigation|. Stores |NavigationContext| in |context| | 73 // passed to |DidFinishNavigation|. Stores |NavigationContext| in |context| |
| 67 // pointer. | 74 // pointer. |
| 68 ACTION_P3(VerifySameDocumentStartedContext, web_state, url, context) { | 75 ACTION_P4(VerifySameDocumentStartedContext, |
| 76 web_state, |
| 77 url, |
| 78 context, |
| 79 page_transition) { |
| 69 *context = arg0; | 80 *context = arg0; |
| 70 ASSERT_TRUE(*context); | 81 ASSERT_TRUE(*context); |
| 71 EXPECT_EQ(web_state, (*context)->GetWebState()); | 82 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| 72 EXPECT_EQ(url, (*context)->GetUrl()); | 83 EXPECT_EQ(url, (*context)->GetUrl()); |
| 84 EXPECT_TRUE(PageTransitionTypeIncludingQualifiersIs( |
| 85 page_transition, (*context)->GetPageTransition())); |
| 73 EXPECT_FALSE((*context)->IsSameDocument()); | 86 EXPECT_FALSE((*context)->IsSameDocument()); |
| 74 EXPECT_FALSE((*context)->GetError()); | 87 EXPECT_FALSE((*context)->GetError()); |
| 75 EXPECT_FALSE((*context)->GetResponseHeaders()); | 88 EXPECT_FALSE((*context)->GetResponseHeaders()); |
| 76 } | 89 } |
| 77 | 90 |
| 78 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation | 91 // Verifies correctness of |NavigationContext| (|arg0|) for same page navigation |
| 79 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as | 92 // passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as |
| 80 // |context|. | 93 // |context|. |
| 81 ACTION_P3(VerifySameDocumentFinishedContext, web_state, url, context) { | 94 ACTION_P4(VerifySameDocumentFinishedContext, |
| 95 web_state, |
| 96 url, |
| 97 context, |
| 98 page_transition) { |
| 82 ASSERT_EQ(*context, arg0); | 99 ASSERT_EQ(*context, arg0); |
| 83 ASSERT_TRUE(*context); | 100 ASSERT_TRUE(*context); |
| 84 EXPECT_EQ(web_state, (*context)->GetWebState()); | 101 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| 85 EXPECT_EQ(url, (*context)->GetUrl()); | 102 EXPECT_EQ(url, (*context)->GetUrl()); |
| 103 EXPECT_TRUE(PageTransitionTypeIncludingQualifiersIs( |
| 104 page_transition, (*context)->GetPageTransition())); |
| 86 EXPECT_TRUE((*context)->IsSameDocument()); | 105 EXPECT_TRUE((*context)->IsSameDocument()); |
| 87 EXPECT_FALSE((*context)->GetError()); | 106 EXPECT_FALSE((*context)->GetError()); |
| 88 EXPECT_FALSE((*context)->GetResponseHeaders()); | 107 EXPECT_FALSE((*context)->GetResponseHeaders()); |
| 89 NavigationManager* navigation_manager = web_state->GetNavigationManager(); | 108 NavigationManager* navigation_manager = web_state->GetNavigationManager(); |
| 90 NavigationItem* item = navigation_manager->GetLastCommittedItem(); | 109 NavigationItem* item = navigation_manager->GetLastCommittedItem(); |
| 91 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); | 110 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); |
| 92 EXPECT_EQ(url, item->GetURL()); | 111 EXPECT_EQ(url, item->GetURL()); |
| 93 } | 112 } |
| 94 | 113 |
| 95 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation | 114 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation |
| 96 // to native URLs passed to |DidStartNavigation|. Stores |NavigationContext| in | 115 // to native URLs passed to |DidStartNavigation|. Stores |NavigationContext| in |
| 97 // |context| pointer. | 116 // |context| pointer. |
| 98 ACTION_P3(VerifyNewNativePageStartedContext, web_state, url, context) { | 117 ACTION_P3(VerifyNewNativePageStartedContext, web_state, url, context) { |
| 99 *context = arg0; | 118 *context = arg0; |
| 100 ASSERT_TRUE(*context); | 119 ASSERT_TRUE(*context); |
| 101 EXPECT_EQ(web_state, (*context)->GetWebState()); | 120 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| 102 EXPECT_EQ(url, (*context)->GetUrl()); | 121 EXPECT_EQ(url, (*context)->GetUrl()); |
| 122 EXPECT_TRUE( |
| 123 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, |
| 124 (*context)->GetPageTransition())); |
| 103 EXPECT_FALSE((*context)->IsSameDocument()); | 125 EXPECT_FALSE((*context)->IsSameDocument()); |
| 104 EXPECT_FALSE((*context)->GetError()); | 126 EXPECT_FALSE((*context)->GetError()); |
| 105 EXPECT_FALSE((*context)->GetResponseHeaders()); | 127 EXPECT_FALSE((*context)->GetResponseHeaders()); |
| 106 NavigationManager* navigation_manager = web_state->GetNavigationManager(); | 128 NavigationManager* navigation_manager = web_state->GetNavigationManager(); |
| 107 NavigationItem* item = navigation_manager->GetPendingItem(); | 129 NavigationItem* item = navigation_manager->GetPendingItem(); |
| 108 EXPECT_EQ(url, item->GetURL()); | 130 EXPECT_EQ(url, item->GetURL()); |
| 109 } | 131 } |
| 110 | 132 |
| 111 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation | 133 // Verifies correctness of |NavigationContext| (|arg0|) for new page navigation |
| 112 // to native URLs passed to |DidFinishNavigation|. Asserts that | 134 // to native URLs passed to |DidFinishNavigation|. Asserts that |
| 113 // |NavigationContext| the same as |context|. | 135 // |NavigationContext| the same as |context|. |
| 114 ACTION_P3(VerifyNewNativePageFinishedContext, web_state, url, context) { | 136 ACTION_P3(VerifyNewNativePageFinishedContext, web_state, url, context) { |
| 115 ASSERT_EQ(*context, arg0); | 137 ASSERT_EQ(*context, arg0); |
| 116 ASSERT_TRUE(*context); | 138 ASSERT_TRUE(*context); |
| 117 EXPECT_EQ(web_state, (*context)->GetWebState()); | 139 EXPECT_EQ(web_state, (*context)->GetWebState()); |
| 118 EXPECT_EQ(url, (*context)->GetUrl()); | 140 EXPECT_EQ(url, (*context)->GetUrl()); |
| 141 EXPECT_TRUE( |
| 142 PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, |
| 143 (*context)->GetPageTransition())); |
| 119 EXPECT_FALSE((*context)->IsSameDocument()); | 144 EXPECT_FALSE((*context)->IsSameDocument()); |
| 120 EXPECT_FALSE((*context)->GetError()); | 145 EXPECT_FALSE((*context)->GetError()); |
| 121 EXPECT_FALSE((*context)->GetResponseHeaders()); | 146 EXPECT_FALSE((*context)->GetResponseHeaders()); |
| 122 NavigationManager* navigation_manager = web_state->GetNavigationManager(); | 147 NavigationManager* navigation_manager = web_state->GetNavigationManager(); |
| 123 NavigationItem* item = navigation_manager->GetLastCommittedItem(); | 148 NavigationItem* item = navigation_manager->GetLastCommittedItem(); |
| 124 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); | 149 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); |
| 125 EXPECT_EQ(url, item->GetURL()); | 150 EXPECT_EQ(url, item->GetURL()); |
| 126 } | 151 } |
| 127 | 152 |
| 128 // Mocks DidFinishNavigation navigation callback. | 153 // Mocks DidFinishNavigation navigation callback. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 NavigationContext* context = nullptr; | 202 NavigationContext* context = nullptr; |
| 178 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 203 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
| 179 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context)); | 204 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context)); |
| 180 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 205 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
| 181 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context)); | 206 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context)); |
| 182 LoadUrl(url); | 207 LoadUrl(url); |
| 183 | 208 |
| 184 // Perform same-page navigation. | 209 // Perform same-page navigation. |
| 185 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1"); | 210 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1"); |
| 186 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 211 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
| 187 .WillOnce( | 212 .WillOnce(VerifySameDocumentStartedContext( |
| 188 VerifySameDocumentStartedContext(web_state(), hash_url, &context)); | 213 web_state(), hash_url, &context, |
| 214 ui::PageTransition::PAGE_TRANSITION_TYPED)); |
| 189 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 215 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
| 190 .WillOnce( | 216 .WillOnce(VerifySameDocumentFinishedContext( |
| 191 VerifySameDocumentFinishedContext(web_state(), hash_url, &context)); | 217 web_state(), hash_url, &context, |
| 218 ui::PageTransition::PAGE_TRANSITION_TYPED)); |
| 192 LoadUrl(hash_url); | 219 LoadUrl(hash_url); |
| 193 | 220 |
| 194 // Perform same-page navigation by going back. | 221 // Perform same-page navigation by going back. |
| 195 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 222 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
| 196 .WillOnce(VerifySameDocumentStartedContext(web_state(), url, &context)); | 223 .WillOnce(VerifySameDocumentStartedContext( |
| 224 web_state(), url, &context, |
| 225 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); |
| 197 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 226 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
| 198 .WillOnce(VerifySameDocumentFinishedContext(web_state(), url, &context)); | 227 .WillOnce(VerifySameDocumentFinishedContext( |
| 228 web_state(), url, &context, |
| 229 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); |
| 199 ExecuteBlockAndWaitForLoad(url, ^{ | 230 ExecuteBlockAndWaitForLoad(url, ^{ |
| 200 navigation_manager()->GoBack(); | 231 navigation_manager()->GoBack(); |
| 201 }); | 232 }); |
| 202 } | 233 } |
| 203 | 234 |
| 204 // Tests renderer-initiated hash change. | 235 // Tests renderer-initiated hash change. |
| 205 TEST_F(StartAndFinishNavigationTest, RendererInitiatedHashChangeNavigation) { | 236 TEST_F(StartAndFinishNavigationTest, RendererInitiatedHashChangeNavigation) { |
| 206 const GURL url = HttpServer::MakeUrl("http://chromium.test"); | 237 const GURL url = HttpServer::MakeUrl("http://chromium.test"); |
| 207 std::map<GURL, std::string> responses; | 238 std::map<GURL, std::string> responses; |
| 208 responses[url] = "Chromium Test"; | 239 responses[url] = "Chromium Test"; |
| 209 web::test::SetUpSimpleHttpServer(responses); | 240 web::test::SetUpSimpleHttpServer(responses); |
| 210 | 241 |
| 211 // Perform new page navigation. | 242 // Perform new page navigation. |
| 212 NavigationContext* context = nullptr; | 243 NavigationContext* context = nullptr; |
| 213 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 244 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
| 214 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context)); | 245 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context)); |
| 215 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 246 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
| 216 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context)); | 247 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context)); |
| 217 LoadUrl(url); | 248 LoadUrl(url); |
| 218 | 249 |
| 219 // Perform same-page navigation using JavaScript. | 250 // Perform same-page navigation using JavaScript. |
| 220 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1"); | 251 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1"); |
| 221 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 252 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
| 222 .WillOnce( | 253 .WillOnce(VerifySameDocumentStartedContext( |
| 223 VerifySameDocumentStartedContext(web_state(), hash_url, &context)); | 254 web_state(), hash_url, &context, |
| 255 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); |
| 224 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 256 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
| 225 .WillOnce( | 257 .WillOnce(VerifySameDocumentFinishedContext( |
| 226 VerifySameDocumentFinishedContext(web_state(), hash_url, &context)); | 258 web_state(), hash_url, &context, |
| 259 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); |
| 227 ExecuteJavaScript(@"window.location.hash = '#1'"); | 260 ExecuteJavaScript(@"window.location.hash = '#1'"); |
| 228 } | 261 } |
| 229 | 262 |
| 230 // Tests state change. | 263 // Tests state change. |
| 231 TEST_F(StartAndFinishNavigationTest, StateNavigation) { | 264 TEST_F(StartAndFinishNavigationTest, StateNavigation) { |
| 232 const GURL url = HttpServer::MakeUrl("http://chromium.test"); | 265 const GURL url = HttpServer::MakeUrl("http://chromium.test"); |
| 233 std::map<GURL, std::string> responses; | 266 std::map<GURL, std::string> responses; |
| 234 responses[url] = "Chromium Test"; | 267 responses[url] = "Chromium Test"; |
| 235 web::test::SetUpSimpleHttpServer(responses); | 268 web::test::SetUpSimpleHttpServer(responses); |
| 236 | 269 |
| 237 // Perform new page navigation. | 270 // Perform new page navigation. |
| 238 NavigationContext* context = nullptr; | 271 NavigationContext* context = nullptr; |
| 239 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 272 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
| 240 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context)); | 273 .WillOnce(VerifyNewPageStartedContext(web_state(), url, &context)); |
| 241 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 274 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
| 242 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context)); | 275 .WillOnce(VerifyNewPageFinishedContext(web_state(), url, &context)); |
| 243 LoadUrl(url); | 276 LoadUrl(url); |
| 244 | 277 |
| 245 // Perform push state using JavaScript. | 278 // Perform push state using JavaScript. |
| 246 const GURL push_url = HttpServer::MakeUrl("http://chromium.test/test.html"); | 279 const GURL push_url = HttpServer::MakeUrl("http://chromium.test/test.html"); |
| 247 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 280 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
| 248 .WillOnce( | 281 .WillOnce(VerifySameDocumentStartedContext( |
| 249 VerifySameDocumentStartedContext(web_state(), push_url, &context)); | 282 web_state(), push_url, &context, |
| 283 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); |
| 250 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 284 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
| 251 .WillOnce( | 285 .WillOnce(VerifySameDocumentFinishedContext( |
| 252 VerifySameDocumentFinishedContext(web_state(), push_url, &context)); | 286 web_state(), push_url, &context, |
| 287 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); |
| 253 ExecuteJavaScript(@"window.history.pushState('', 'Test', 'test.html')"); | 288 ExecuteJavaScript(@"window.history.pushState('', 'Test', 'test.html')"); |
| 254 | 289 |
| 255 // Perform replace state using JavaScript. | 290 // Perform replace state using JavaScript. |
| 256 const GURL replace_url = HttpServer::MakeUrl("http://chromium.test/1.html"); | 291 const GURL replace_url = HttpServer::MakeUrl("http://chromium.test/1.html"); |
| 257 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 292 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
| 258 .WillOnce( | 293 .WillOnce(VerifySameDocumentStartedContext( |
| 259 VerifySameDocumentStartedContext(web_state(), replace_url, &context)); | 294 web_state(), replace_url, &context, |
| 295 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); |
| 260 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 296 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
| 261 .WillOnce(VerifySameDocumentFinishedContext(web_state(), replace_url, | 297 .WillOnce(VerifySameDocumentFinishedContext( |
| 262 &context)); | 298 web_state(), replace_url, &context, |
| 299 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT)); |
| 263 ExecuteJavaScript(@"window.history.replaceState('', 'Test', '1.html')"); | 300 ExecuteJavaScript(@"window.history.replaceState('', 'Test', '1.html')"); |
| 264 } | 301 } |
| 265 | 302 |
| 266 // Tests native content navigation. | 303 // Tests native content navigation. |
| 267 TEST_F(StartAndFinishNavigationTest, NativeContentNavigation) { | 304 TEST_F(StartAndFinishNavigationTest, NativeContentNavigation) { |
| 268 GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize()); | 305 GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize()); |
| 269 NavigationContext* context = nullptr; | 306 NavigationContext* context = nullptr; |
| 270 EXPECT_CALL(*observer_, DidStartNavigation(_)) | 307 EXPECT_CALL(*observer_, DidStartNavigation(_)) |
| 271 .WillOnce(VerifyNewNativePageStartedContext(web_state(), url, &context)); | 308 .WillOnce(VerifyNewNativePageStartedContext(web_state(), url, &context)); |
| 272 EXPECT_CALL(*observer_, DidFinishNavigation(_)) | 309 EXPECT_CALL(*observer_, DidFinishNavigation(_)) |
| 273 .WillOnce(VerifyNewNativePageFinishedContext(web_state(), url, &context)); | 310 .WillOnce(VerifyNewNativePageFinishedContext(web_state(), url, &context)); |
| 274 LoadUrl(url); | 311 LoadUrl(url); |
| 275 } | 312 } |
| 276 | 313 |
| 277 } // namespace web | 314 } // namespace web |
| OLD | NEW |