OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/string_util.h" | 5 #include "base/string_util.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "content/public/browser/navigation_controller.h" | 7 #include "content/public/browser/navigation_controller.h" |
8 #include "content/public/browser/notification_service.h" | 8 #include "content/public/browser/notification_service.h" |
9 #include "content/public/browser/notification_types.h" | 9 #include "content/public/browser/notification_types.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 NavigateToURL(shell(), GURL("javascript:void(frames[0].navigate())")); | 422 NavigateToURL(shell(), GURL("javascript:void(frames[0].navigate())")); |
423 EXPECT_EQ("foo", GetTabTitle()); | 423 EXPECT_EQ("foo", GetTabTitle()); |
424 | 424 |
425 GoBack(); | 425 GoBack(); |
426 EXPECT_EQ("Default Title", GetTabTitle()); | 426 EXPECT_EQ("Default Title", GetTabTitle()); |
427 } | 427 } |
428 | 428 |
429 // http://code.google.com/p/chromium/issues/detail?id=56267 | 429 // http://code.google.com/p/chromium/issues/detail?id=56267 |
430 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, HistoryLength) { | 430 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, HistoryLength) { |
431 int length; | 431 int length; |
432 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( | 432 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
433 shell()->web_contents()->GetRenderViewHost(), | 433 shell()->web_contents(), |
434 "", | |
435 "domAutomationController.send(history.length)", | 434 "domAutomationController.send(history.length)", |
436 &length)); | 435 &length)); |
437 EXPECT_EQ(1, length); | 436 EXPECT_EQ(1, length); |
438 | 437 |
439 NavigateToURL(shell(), GetURL("title1.html")); | 438 NavigateToURL(shell(), GetURL("title1.html")); |
440 | 439 |
441 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( | 440 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
442 shell()->web_contents()->GetRenderViewHost(), | 441 shell()->web_contents(), |
443 "", | |
444 "domAutomationController.send(history.length)", | 442 "domAutomationController.send(history.length)", |
445 &length)); | 443 &length)); |
446 EXPECT_EQ(2, length); | 444 EXPECT_EQ(2, length); |
447 | 445 |
448 // Now test that history.length is updated when the navigation is committed. | 446 // Now test that history.length is updated when the navigation is committed. |
449 NavigateToURL(shell(), GetURL("record_length.html")); | 447 NavigateToURL(shell(), GetURL("record_length.html")); |
450 | 448 |
451 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( | 449 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
452 shell()->web_contents()->GetRenderViewHost(), | 450 shell()->web_contents(), |
453 "", | |
454 "domAutomationController.send(history.length)", | 451 "domAutomationController.send(history.length)", |
455 &length)); | 452 &length)); |
456 EXPECT_EQ(3, length); | 453 EXPECT_EQ(3, length); |
457 | 454 |
458 GoBack(); | 455 GoBack(); |
459 GoBack(); | 456 GoBack(); |
460 | 457 |
461 // Ensure history.length is properly truncated. | 458 // Ensure history.length is properly truncated. |
462 NavigateToURL(shell(), GetURL("title2.html")); | 459 NavigateToURL(shell(), GetURL("title2.html")); |
463 | 460 |
464 ASSERT_TRUE(ExecuteJavaScriptAndExtractInt( | 461 ASSERT_TRUE(ExecuteScriptAndExtractInt( |
465 shell()->web_contents()->GetRenderViewHost(), | 462 shell()->web_contents(), |
466 "", | |
467 "domAutomationController.send(history.length)", | 463 "domAutomationController.send(history.length)", |
468 &length)); | 464 &length)); |
469 EXPECT_EQ(2, length); | 465 EXPECT_EQ(2, length); |
470 } | 466 } |
471 | 467 |
472 } // namespace content | 468 } // namespace content |
OLD | NEW |