OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 #include "chrome/test/base/in_process_browser_test.h" | 6 #include "chrome/test/base/in_process_browser_test.h" |
7 #include "chrome/test/base/ui_test_utils.h" | 7 #include "chrome/test/base/ui_test_utils.h" |
8 #include "content/browser/net/url_request_abort_on_end_job.h" | 8 #include "content/browser/net/url_request_abort_on_end_job.h" |
9 #include "content/browser/tab_contents/tab_contents.h" | 9 #include "content/browser/tab_contents/tab_contents.h" |
10 | 10 |
11 typedef InProcessBrowserTest WebKitBrowserTest; | 11 typedef InProcessBrowserTest WebKitBrowserTest; |
12 | 12 |
| 13 using content::WebContents; |
| 14 |
13 const char kAsyncScriptThatAbortsOnEndPage[] = | 15 const char kAsyncScriptThatAbortsOnEndPage[] = |
14 "files/webkit/async_script_abort_on_end.html"; | 16 "files/webkit/async_script_abort_on_end.html"; |
15 | 17 |
16 // This is a browser test because it is hard to reproduce reliably in a | 18 // This is a browser test because it is hard to reproduce reliably in a |
17 // layout test without races. http://crbug.com/75604 deals with a request | 19 // layout test without races. http://crbug.com/75604 deals with a request |
18 // for an async script which gets data in the response and immediately | 20 // for an async script which gets data in the response and immediately |
19 // after aborts. This test creates that condition, and it is passed | 21 // after aborts. This test creates that condition, and it is passed |
20 // if chrome does not crash. | 22 // if chrome does not crash. |
21 | 23 |
22 IN_PROC_BROWSER_TEST_F(WebKitBrowserTest, AbortOnEnd) { | 24 IN_PROC_BROWSER_TEST_F(WebKitBrowserTest, AbortOnEnd) { |
23 ASSERT_TRUE(test_server()->Start()); | 25 ASSERT_TRUE(test_server()->Start()); |
24 URLRequestAbortOnEndJob::AddUrlHandler(); | 26 URLRequestAbortOnEndJob::AddUrlHandler(); |
25 GURL url = test_server()->GetURL(kAsyncScriptThatAbortsOnEndPage); | 27 GURL url = test_server()->GetURL(kAsyncScriptThatAbortsOnEndPage); |
26 | 28 |
27 ui_test_utils::NavigateToURL(browser(), url); | 29 ui_test_utils::NavigateToURL(browser(), url); |
28 | 30 |
29 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 31 WebContents* web_contents = browser()->GetSelectedWebContents(); |
30 // If you are seeing this test fail, please strongly investigate the | 32 // If you are seeing this test fail, please strongly investigate the |
31 // possibility that http://crbug.com/75604 and | 33 // possibility that http://crbug.com/75604 and |
32 // https://bugs.webkit.org/show_bug.cgi?id=71122 have reverted before | 34 // https://bugs.webkit.org/show_bug.cgi?id=71122 have reverted before |
33 // marking this as flakey. | 35 // marking this as flakey. |
34 EXPECT_FALSE(tab_contents->IsCrashed()); | 36 EXPECT_FALSE(web_contents->IsCrashed()); |
35 } | 37 } |
36 | 38 |
37 // This is a browser test because the DumpRenderTree framework holds | 39 // This is a browser test because the DumpRenderTree framework holds |
38 // onto a Document* reference that blocks this reproduction from | 40 // onto a Document* reference that blocks this reproduction from |
39 // destroying the Document, so it is not a use after free unless | 41 // destroying the Document, so it is not a use after free unless |
40 // you don't have DumpRenderTree loaded. | 42 // you don't have DumpRenderTree loaded. |
41 | 43 |
42 // TODO(gavinp): remove this browser_test if we can get good LayoutTest | 44 // TODO(gavinp): remove this browser_test if we can get good LayoutTest |
43 // coverage of the same issue. | 45 // coverage of the same issue. |
44 const char kXsltBadImportPage[] = | 46 const char kXsltBadImportPage[] = |
45 "files/webkit/xslt-bad-import.html"; | 47 "files/webkit/xslt-bad-import.html"; |
46 IN_PROC_BROWSER_TEST_F(WebKitBrowserTest, XsltBadImport) { | 48 IN_PROC_BROWSER_TEST_F(WebKitBrowserTest, XsltBadImport) { |
47 ASSERT_TRUE(test_server()->Start()); | 49 ASSERT_TRUE(test_server()->Start()); |
48 URLRequestAbortOnEndJob::AddUrlHandler(); | 50 URLRequestAbortOnEndJob::AddUrlHandler(); |
49 GURL url = test_server()->GetURL(kXsltBadImportPage); | 51 GURL url = test_server()->GetURL(kXsltBadImportPage); |
50 | 52 |
51 ui_test_utils::NavigateToURL(browser(), url); | 53 ui_test_utils::NavigateToURL(browser(), url); |
52 | 54 |
53 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 55 WebContents* web_contents = browser()->GetSelectedWebContents(); |
54 EXPECT_FALSE(tab_contents->IsCrashed()); | 56 EXPECT_FALSE(web_contents->IsCrashed()); |
55 } | 57 } |
OLD | NEW |