|
25 | 25 | #include "content/public/browser/storage_partition_config.h" |
26 | 26 | #include "content/public/test/browser_test.h" |
27 | 27 | #include "content/public/test/browser_test_utils.h" |
| 28 | +#include "content/public/test/test_navigation_observer.h" |
28 | 29 | #include "net/dns/mock_host_resolver.h" |
29 | 30 | #include "net/test/embedded_test_server/embedded_test_server.h" |
30 | 31 | #include "services/network/public/cpp/network_switches.h" |
@@ -1202,9 +1203,11 @@ IN_PROC_BROWSER_TEST_F(ContainersBrowserTest, CrossSiteNavigationPersistence) { |
1202 | 1203 | content::EvalJs(web_contents, GetLocalStorageJS("site_b_key"))); |
1203 | 1204 |
|
1204 | 1205 | // Navigate back to site A using browser back |
1205 | | - ASSERT_TRUE(content::ExecJs(web_contents, "window.history.back();", |
1206 | | - content::EXECUTE_SCRIPT_NO_RESOLVE_PROMISES)); |
1207 | | - EXPECT_TRUE(content::WaitForLoadStop(web_contents)); |
| 1206 | + { |
| 1207 | + content::TestNavigationObserver nav_observer(web_contents, 1); |
| 1208 | + ASSERT_TRUE(content::ExecJs(web_contents, "window.history.back();")); |
| 1209 | + nav_observer.Wait(); |
| 1210 | + } |
1208 | 1211 |
|
1209 | 1212 | // Verify we're still in the same container |
1210 | 1213 | storage_partition = |
@@ -1274,21 +1277,25 @@ IN_PROC_BROWSER_TEST_F(ContainersBrowserTest, NavigationHistoryPersistence) { |
1274 | 1277 | EXPECT_EQ(1, controller.GetCurrentEntryIndex()); |
1275 | 1278 |
|
1276 | 1279 | // Navigate back to page 1 |
1277 | | - ASSERT_TRUE(content::ExecJs(web_contents, "window.history.back();", |
1278 | | - content::EXECUTE_SCRIPT_NO_RESOLVE_PROMISES)); |
1279 | | - EXPECT_TRUE(content::WaitForLoadStop(web_contents)); |
1280 | | - EXPECT_EQ(url_page1, web_contents->GetLastCommittedURL()); |
| 1280 | + { |
| 1281 | + content::TestNavigationObserver nav_observer(web_contents, 1); |
| 1282 | + ASSERT_TRUE(content::ExecJs(web_contents, "window.history.back();")); |
| 1283 | + nav_observer.Wait(); |
| 1284 | + EXPECT_EQ(url_page1, web_contents->GetLastCommittedURL()); |
| 1285 | + } |
1281 | 1286 |
|
1282 | 1287 | // Verify still in same container |
1283 | 1288 | storage_partition = |
1284 | 1289 | web_contents->GetPrimaryMainFrame()->GetStoragePartition(); |
1285 | 1290 | EXPECT_EQ(kTestContainerId, storage_partition->GetConfig().partition_name()); |
1286 | 1291 |
|
1287 | 1292 | // Navigate forward |
1288 | | - ASSERT_TRUE(content::ExecJs(web_contents, "window.history.forward();", |
1289 | | - content::EXECUTE_SCRIPT_NO_RESOLVE_PROMISES)); |
1290 | | - EXPECT_TRUE(content::WaitForLoadStop(web_contents)); |
1291 | | - EXPECT_EQ(url_page2, web_contents->GetLastCommittedURL()); |
| 1293 | + { |
| 1294 | + content::TestNavigationObserver nav_observer(web_contents, 1); |
| 1295 | + ASSERT_TRUE(content::ExecJs(web_contents, "window.history.forward();")); |
| 1296 | + nav_observer.Wait(); |
| 1297 | + EXPECT_EQ(url_page2, web_contents->GetLastCommittedURL()); |
| 1298 | + } |
1292 | 1299 |
|
1293 | 1300 | // Verify still in same container |
1294 | 1301 | storage_partition = |
|
0 commit comments