| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 8 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
| 9 #include "chrome/browser/api/infobars/infobar_service.h" | 9 #include "chrome/browser/api/infobars/infobar_service.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 GURL(chrome::kChromeUIGpuCrashURL), | 41 GURL(chrome::kChromeUIGpuCrashURL), |
| 42 static_cast<content::PageTransition>( | 42 static_cast<content::PageTransition>( |
| 43 content::PAGE_TRANSITION_TYPED | | 43 content::PAGE_TRANSITION_TYPED | |
| 44 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)); | 44 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)); |
| 45 params.disposition = NEW_BACKGROUND_TAB; | 45 params.disposition = NEW_BACKGROUND_TAB; |
| 46 chrome::Navigate(¶ms); | 46 chrome::Navigate(¶ms); |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 class GPUCrashTest : public InProcessBrowserTest { | 51 class WebGLInfobarTest : public InProcessBrowserTest { |
| 52 protected: | 52 protected: |
| 53 virtual void SetUpCommandLine(CommandLine* command_line) { | 53 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 54 // GPU tests require gpu acceleration. | 54 // GPU tests require gpu acceleration. |
| 55 // We do not care which GL backend is used. | 55 // We do not care which GL backend is used. |
| 56 command_line->AppendSwitchASCII(switches::kUseGL, "any"); | 56 command_line->AppendSwitchASCII(switches::kUseGL, "any"); |
| 57 } | 57 } |
| 58 virtual void SetUpInProcessBrowserTestFixture() { | 58 virtual void SetUpInProcessBrowserTestFixture() { |
| 59 FilePath test_dir; | 59 FilePath test_dir; |
| 60 ASSERT_TRUE(PathService::Get(content::DIR_TEST_DATA, &test_dir)); | 60 ASSERT_TRUE(PathService::Get(content::DIR_TEST_DATA, &test_dir)); |
| 61 gpu_test_dir_ = test_dir.AppendASCII("gpu"); | 61 gpu_test_dir_ = test_dir.AppendASCII("gpu"); |
| 62 } | 62 } |
| 63 FilePath gpu_test_dir_; | 63 FilePath gpu_test_dir_; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 IN_PROC_BROWSER_TEST_F(GPUCrashTest, Kill) { | 66 IN_PROC_BROWSER_TEST_F(WebGLInfobarTest, ContextLossRaisesInfobar) { |
| 67 // crbug.com/162982, flaky on Mac Retina Release. | 67 // crbug.com/162982, flaky on Mac Retina Release. |
| 68 if (GPUTestBotConfig::CurrentConfigMatches("MAC NVIDIA 0x0fd5 RELEASE")) | 68 if (GPUTestBotConfig::CurrentConfigMatches("MAC NVIDIA 0x0fd5 RELEASE")) |
| 69 return; | 69 return; |
| 70 | 70 |
| 71 content::DOMMessageQueue message_queue; | |
| 72 | |
| 73 content::GpuDataManager::GetInstance()-> | |
| 74 DisableDomainBlockingFor3DAPIsForTesting(); | |
| 75 | |
| 76 // Load page and wait for it to load. | 71 // Load page and wait for it to load. |
| 77 content::WindowedNotificationObserver observer( | 72 content::WindowedNotificationObserver observer( |
| 78 content::NOTIFICATION_LOAD_STOP, | 73 content::NOTIFICATION_LOAD_STOP, |
| 79 content::NotificationService::AllSources()); | 74 content::NotificationService::AllSources()); |
| 80 ui_test_utils::NavigateToURL( | 75 ui_test_utils::NavigateToURL( |
| 81 browser(), | 76 browser(), |
| 82 content::GetFileUrlWithQuery( | 77 content::GetFileUrlWithQuery( |
| 83 gpu_test_dir_.AppendASCII("webgl.html"), "query=kill")); | 78 gpu_test_dir_.AppendASCII("webgl.html"), "query=kill")); |
| 84 observer.Wait(); | 79 observer.Wait(); |
| 85 | 80 |
| 86 SimulateGPUCrash(browser()); | |
| 87 | |
| 88 std::string m; | |
| 89 ASSERT_TRUE(message_queue.WaitForMessage(&m)); | |
| 90 EXPECT_EQ("\"SUCCESS\"", m); | |
| 91 } | |
| 92 | |
| 93 IN_PROC_BROWSER_TEST_F(GPUCrashTest, ContextLossRaisesInfobar) { | |
| 94 // crbug.com/162982, flaky on Mac Retina Release. | |
| 95 if (GPUTestBotConfig::CurrentConfigMatches("MAC NVIDIA 0x0fd5 RELEASE")) | |
| 96 return; | |
| 97 | |
| 98 // Load page and wait for it to load. | |
| 99 content::WindowedNotificationObserver observer( | |
| 100 content::NOTIFICATION_LOAD_STOP, | |
| 101 content::NotificationService::AllSources()); | |
| 102 ui_test_utils::NavigateToURL( | |
| 103 browser(), | |
| 104 content::GetFileUrlWithQuery( | |
| 105 gpu_test_dir_.AppendASCII("webgl.html"), "query=kill")); | |
| 106 observer.Wait(); | |
| 107 | |
| 108 content::WindowedNotificationObserver infobar_added( | 81 content::WindowedNotificationObserver infobar_added( |
| 109 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 82 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
| 110 content::NotificationService::AllSources()); | 83 content::NotificationService::AllSources()); |
| 111 SimulateGPUCrash(browser()); | 84 SimulateGPUCrash(browser()); |
| 112 infobar_added.Wait(); | 85 infobar_added.Wait(); |
| 113 EXPECT_EQ(1u, | 86 EXPECT_EQ(1u, |
| 114 InfoBarService::FromWebContents( | 87 InfoBarService::FromWebContents( |
| 115 chrome::GetActiveWebContents(browser()))->GetInfoBarCount()); | 88 chrome::GetActiveWebContents(browser()))->GetInfoBarCount()); |
| 116 } | 89 } |
| 117 | 90 |
| 118 IN_PROC_BROWSER_TEST_F(GPUCrashTest, ContextLossInfobarReload) { | 91 IN_PROC_BROWSER_TEST_F(WebGLInfobarTest, ContextLossInfobarReload) { |
| 119 // crbug.com/162982, flaky on Mac Retina Release. | 92 // crbug.com/162982, flaky on Mac Retina Release. |
| 120 if (GPUTestBotConfig::CurrentConfigMatches("MAC NVIDIA 0x0fd5 RELEASE")) | 93 if (GPUTestBotConfig::CurrentConfigMatches("MAC NVIDIA 0x0fd5 RELEASE")) |
| 121 return; | 94 return; |
| 122 | 95 |
| 123 content::DOMMessageQueue message_queue; | 96 content::DOMMessageQueue message_queue; |
| 124 | 97 |
| 125 // Load page and wait for it to load. | 98 // Load page and wait for it to load. |
| 126 content::WindowedNotificationObserver observer( | 99 content::WindowedNotificationObserver observer( |
| 127 content::NOTIFICATION_LOAD_STOP, | 100 content::NOTIFICATION_LOAD_STOP, |
| 128 content::NotificationService::AllSources()); | 101 content::NotificationService::AllSources()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 157 // The page should reload and another message sent to the | 130 // The page should reload and another message sent to the |
| 158 // DomAutomationController. | 131 // DomAutomationController. |
| 159 m = ""; | 132 m = ""; |
| 160 ASSERT_TRUE(message_queue.WaitForMessage(&m)); | 133 ASSERT_TRUE(message_queue.WaitForMessage(&m)); |
| 161 EXPECT_EQ("\"LOADED\"", m); | 134 EXPECT_EQ("\"LOADED\"", m); |
| 162 } | 135 } |
| 163 | 136 |
| 164 // There isn't any point in adding a test which calls Accept() on the | 137 // There isn't any point in adding a test which calls Accept() on the |
| 165 // ThreeDAPIInfoBarDelegate; doing so doesn't remove the infobar, and | 138 // ThreeDAPIInfoBarDelegate; doing so doesn't remove the infobar, and |
| 166 // there's no concrete event that could be observed in response. | 139 // there's no concrete event that could be observed in response. |
| 167 | |
| 168 IN_PROC_BROWSER_TEST_F(GPUCrashTest, WebkitLoseContext) { | |
| 169 content::DOMMessageQueue message_queue; | |
| 170 | |
| 171 ui_test_utils::NavigateToURL( | |
| 172 browser(), | |
| 173 content::GetFileUrlWithQuery( | |
| 174 gpu_test_dir_.AppendASCII("webgl.html"), | |
| 175 "query=WEBGL_lose_context")); | |
| 176 | |
| 177 std::string m; | |
| 178 ASSERT_TRUE(message_queue.WaitForMessage(&m)); | |
| 179 EXPECT_EQ("\"SUCCESS\"", m); | |
| 180 } | |
| OLD | NEW |