Chromium Code Reviews| Index: chrome/browser/errorpage_browsertest.cc |
| diff --git a/chrome/browser/errorpage_browsertest.cc b/chrome/browser/errorpage_browsertest.cc |
| index d87b5ac9137af10d024fcc58ee9ebad7cfa55d02..a1ecd1471231b6912c173d0fe64184d97aac11c7 100644 |
| --- a/chrome/browser/errorpage_browsertest.cc |
| +++ b/chrome/browser/errorpage_browsertest.cc |
| @@ -11,6 +11,7 @@ |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| +#include "content/public/browser/render_view_host.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/test/browser_test_utils.h" |
| #include "content/public/test/test_navigation_observer.h" |
| @@ -210,6 +211,11 @@ IN_PROC_BROWSER_TEST_F(ErrorPageTest, IFrameDNSError_Basic) { |
| base::FilePath(FILE_PATH_LITERAL("iframe_dns_error.html"))), |
| "Blah", |
| 1); |
| + // We expect to have two history entries, since we started off with navigation |
| + // to "about:blank" and then navigated to "iframe_dns_error.html". |
| + EXPECT_EQ(2, |
| + browser()->tab_strip_model()->GetActiveWebContents()-> |
| + GetController().GetEntryCount()); |
| } |
| // This test fails regularly on win_rel trybots. See crbug.com/121540 |
| @@ -241,6 +247,39 @@ IN_PROC_BROWSER_TEST_F(ErrorPageTest, MAYBE_IFrameDNSError_GoBackAndForward) { |
| GoForwardAndWaitForTitle("Blah", 1); |
| } |
| +// Test that a DNS error occuring in an iframe, once the main document is |
| +// completed loading, does not result in an additional session history entry. |
| +// To ensure that the main document has completed loading, JavaScript is used to |
| +// inject an iframe after loading is done. |
| +IN_PROC_BROWSER_TEST_F(ErrorPageTest, IFrameDNSError_JavaScript) { |
| + content::WebContents* wc = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + GURL fail_url = |
| + URLRequestFailedJob::GetMockHttpUrl(net::ERR_NAME_NOT_RESOLVED); |
| + std::string script = "var frame = document.createElement('iframe');" |
| + "frame.src = '" + fail_url.spec() + "';" |
| + "document.body.appendChild(frame);" |
| + "document.title = 'done';"; |
|
mmenke
2013/05/22 17:25:50
This failed consistently prior to the fix? My con
nasko
2013/05/22 17:52:53
I see your concern. I haven't tried the test on th
|
| + |
| + // Load a regular web page, in which we will inject an iframe. |
| + NavigateToFileURL(FILE_PATH_LITERAL("title2.html")); |
| + |
| + // We expect to have two history entries, since we started off with navigation |
| + // to "about:blank" and then navigated to "title2.html". |
| + EXPECT_EQ(2, wc->GetController().GetEntryCount()); |
| + |
| + string16 expected_title(ASCIIToUTF16("done")); |
| + content::TitleWatcher title_watcher(wc, expected_title); |
| + |
| + wc->GetRenderViewHost()->ExecuteJavascriptInWebFrame( |
| + string16(), ASCIIToUTF16(script)); |
| + EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| + |
| + // Failed initial navigation of an iframe shouldn't be adding any history |
| + // entries. |
| + EXPECT_EQ(2, wc->GetController().GetEntryCount()); |
| +} |
| + |
| // Checks that the Link Doctor is not loaded when we receive an actual 404 page. |
| IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) { |
| NavigateToURLAndWaitForTitle( |