OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "content/public/browser/web_contents.h" | 6 #include "content/public/browser/web_contents.h" |
7 #include "content/public/common/content_switches.h" | 7 #include "content/public/common/content_switches.h" |
8 #include "content/public/common/manifest.h" | 8 #include "content/public/common/manifest.h" |
9 #include "content/public/test/browser_test_utils.h" | 9 #include "content/public/test/browser_test_utils.h" |
10 #include "content/public/test/content_browser_test.h" | 10 #include "content/public/test/content_browser_test.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); | 305 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); |
306 shell()->LoadURL(test_url); | 306 shell()->LoadURL(test_url); |
307 navigation_observer.Wait(); | 307 navigation_observer.Wait(); |
308 | 308 |
309 GetManifestAndWait(); | 309 GetManifestAndWait(); |
310 EXPECT_TRUE(manifest().IsEmpty()); | 310 EXPECT_TRUE(manifest().IsEmpty()); |
311 EXPECT_EQ(0u, console_error_count()); | 311 EXPECT_EQ(0u, console_error_count()); |
312 } | 312 } |
313 } | 313 } |
314 | 314 |
| 315 // If a page has a manifest and the page is navigated using pushState (ie. same |
| 316 // page), it should keep its manifest state. |
| 317 IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, PushStateNavigation) { |
| 318 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 319 GURL test_url = |
| 320 embedded_test_server()->GetURL("/manifest/dummy-manifest.html"); |
| 321 |
| 322 { |
| 323 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); |
| 324 shell()->LoadURL(test_url); |
| 325 navigation_observer.Wait(); |
| 326 } |
| 327 |
| 328 { |
| 329 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); |
| 330 ASSERT_TRUE(content::ExecuteScript( |
| 331 shell()->web_contents(), |
| 332 "history.pushState({foo: \"bar\"}, 'page', 'page.html');")); |
| 333 navigation_observer.Wait(); |
| 334 } |
| 335 |
| 336 GetManifestAndWait(); |
| 337 EXPECT_FALSE(manifest().IsEmpty()); |
| 338 EXPECT_EQ(0u, console_error_count()); |
| 339 } |
| 340 |
| 341 // If a page has a manifest and is navigated using an anchor (ie. same page), it |
| 342 // should keep its manifest state. |
| 343 IN_PROC_BROWSER_TEST_F(ManifestBrowserTest, AnchorNavigation) { |
| 344 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 345 GURL test_url = |
| 346 embedded_test_server()->GetURL("/manifest/dummy-manifest.html"); |
| 347 |
| 348 { |
| 349 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); |
| 350 shell()->LoadURL(test_url); |
| 351 navigation_observer.Wait(); |
| 352 } |
| 353 |
| 354 { |
| 355 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); |
| 356 ASSERT_TRUE(content::ExecuteScript( |
| 357 shell()->web_contents(), |
| 358 "var a = document.createElement('a'); a.href='#foo';" |
| 359 "document.body.appendChild(a); a.click();")); |
| 360 navigation_observer.Wait(); |
| 361 } |
| 362 |
| 363 GetManifestAndWait(); |
| 364 EXPECT_FALSE(manifest().IsEmpty()); |
| 365 EXPECT_EQ(0u, console_error_count()); |
| 366 } |
| 367 |
315 } // namespace content | 368 } // namespace content |
OLD | NEW |