| 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/browser/ui/webui/chrome_web_ui.h" | 6 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 7 #include "chrome/browser/ui/webui/hung_renderer_dialog.h" | 7 #include "chrome/browser/ui/webui/hung_renderer_dialog.h" |
| 8 #include "chrome/browser/ui/webui/web_ui_browsertest.h" | 8 #include "chrome/browser/ui/webui/web_ui_browsertest.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "chrome/test/base/test_html_dialog_observer.h" | 10 #include "chrome/test/base/test_html_dialog_observer.h" |
| 11 #include "content/browser/renderer_host/render_view_host.h" | 11 #include "content/browser/renderer_host/render_view_host.h" |
| 12 #include "content/browser/tab_contents/tab_contents.h" | 12 #include "content/browser/tab_contents/tab_contents.h" |
| 13 #include "content/browser/webui/web_ui.h" | 13 #include "content/browser/webui/web_ui.h" |
| 14 | 14 |
| 15 using content::WebContents; |
| 16 |
| 15 // Test framework for chrome/test/data/webui/hung_renderer_dialog_test.js. | 17 // Test framework for chrome/test/data/webui/hung_renderer_dialog_test.js. |
| 16 class HungRendererDialogUITest : public WebUIBrowserTest { | 18 class HungRendererDialogUITest : public WebUIBrowserTest { |
| 17 public: | 19 public: |
| 18 HungRendererDialogUITest(); | 20 HungRendererDialogUITest(); |
| 19 virtual ~HungRendererDialogUITest(); | 21 virtual ~HungRendererDialogUITest(); |
| 20 | 22 |
| 21 protected: | 23 protected: |
| 22 void ShowHungRendererDialogInternal(); | 24 void ShowHungRendererDialogInternal(); |
| 23 }; | 25 }; |
| 24 | 26 |
| 25 void HungRendererDialogUITest::ShowHungRendererDialogInternal() { | 27 void HungRendererDialogUITest::ShowHungRendererDialogInternal() { |
| 26 // Force the flag so that we will use the WebUI version of the Dialog. | 28 // Force the flag so that we will use the WebUI version of the Dialog. |
| 27 ChromeWebUI::OverrideMoreWebUI(true); | 29 ChromeWebUI::OverrideMoreWebUI(true); |
| 28 | 30 |
| 29 // Choose which tab contents to report as hung. In this case, the default | 31 // Choose which tab contents to report as hung. In this case, the default |
| 30 // tab contents will be about:blank. | 32 // tab contents will be about:blank. |
| 31 ASSERT_TRUE(browser()); | 33 ASSERT_TRUE(browser()); |
| 32 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 34 WebContents* web_contents = browser()->GetSelectedWebContents(); |
| 33 | 35 |
| 34 // The TestHtmlDialogObserver will catch our dialog when it gets created. | 36 // The TestHtmlDialogObserver will catch our dialog when it gets created. |
| 35 TestHtmlDialogObserver dialog_observer(this); | 37 TestHtmlDialogObserver dialog_observer(this); |
| 36 | 38 |
| 37 // Show a disabled Hung Renderer Dialog that won't kill processes or restart | 39 // Show a disabled Hung Renderer Dialog that won't kill processes or restart |
| 38 // hang timers. | 40 // hang timers. |
| 39 HungRendererDialog::ShowHungRendererDialogInternal(tab_contents, false); | 41 HungRendererDialog::ShowHungRendererDialogInternal(web_contents, false); |
| 40 | 42 |
| 41 // Now we can get the WebUI object from the observer, and make some details | 43 // Now we can get the WebUI object from the observer, and make some details |
| 42 // about our test available to the JavaScript. | 44 // about our test available to the JavaScript. |
| 43 WebUI* webui = dialog_observer.GetWebUI(); | 45 WebUI* webui = dialog_observer.GetWebUI(); |
| 44 webui->web_contents()->GetRenderViewHost()->SetWebUIProperty( | 46 webui->web_contents()->GetRenderViewHost()->SetWebUIProperty( |
| 45 "expectedUrl", chrome::kChromeUIHungRendererDialogURL); | 47 "expectedUrl", chrome::kChromeUIHungRendererDialogURL); |
| 46 webui->web_contents()->GetRenderViewHost()->SetWebUIProperty( | 48 webui->web_contents()->GetRenderViewHost()->SetWebUIProperty( |
| 47 "expectedTitle", "about:blank"); | 49 "expectedTitle", "about:blank"); |
| 48 | 50 |
| 49 // Tell the test which WebUI instance we are dealing with and complete | 51 // Tell the test which WebUI instance we are dealing with and complete |
| 50 // initialization of this test. | 52 // initialization of this test. |
| 51 SetWebUIInstance(webui); | 53 SetWebUIInstance(webui); |
| 52 } | 54 } |
| OLD | NEW |