| 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/infobars/infobar_tab_helper.h" |
| 8 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| 10 #include "chrome/browser/ui/browser_navigator.h" | 11 #include "chrome/browser/ui/browser_navigator.h" |
| 12 #include "chrome/browser/ui/browser_tabstrip.h" |
| 13 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
| 12 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "chrome/test/base/test_launcher_utils.h" | 18 #include "chrome/test/base/test_launcher_utils.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 20 #include "content/public/browser/gpu_data_manager.h" |
| 17 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 19 #include "content/public/common/content_paths.h" | 23 #include "content/public/common/content_paths.h" |
| 20 #include "content/public/common/page_transition_types.h" | 24 #include "content/public/common/page_transition_types.h" |
| 21 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "ui/gl/gl_implementation.h" | 27 #include "ui/gl/gl_implementation.h" |
| 24 | 28 |
| 25 namespace { | 29 namespace { |
| 26 | 30 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 53 FilePath test_dir; | 57 FilePath test_dir; |
| 54 ASSERT_TRUE(PathService::Get(content::DIR_TEST_DATA, &test_dir)); | 58 ASSERT_TRUE(PathService::Get(content::DIR_TEST_DATA, &test_dir)); |
| 55 gpu_test_dir_ = test_dir.AppendASCII("gpu"); | 59 gpu_test_dir_ = test_dir.AppendASCII("gpu"); |
| 56 } | 60 } |
| 57 FilePath gpu_test_dir_; | 61 FilePath gpu_test_dir_; |
| 58 }; | 62 }; |
| 59 | 63 |
| 60 IN_PROC_BROWSER_TEST_F(GPUCrashTest, Kill) { | 64 IN_PROC_BROWSER_TEST_F(GPUCrashTest, Kill) { |
| 61 content::DOMMessageQueue message_queue; | 65 content::DOMMessageQueue message_queue; |
| 62 | 66 |
| 67 content::GpuDataManager::GetInstance()-> |
| 68 DisableDomainBlockingFor3DAPIsForTesting(); |
| 69 |
| 63 // Load page and wait for it to load. | 70 // Load page and wait for it to load. |
| 64 content::WindowedNotificationObserver observer( | 71 content::WindowedNotificationObserver observer( |
| 65 content::NOTIFICATION_LOAD_STOP, | 72 content::NOTIFICATION_LOAD_STOP, |
| 66 content::NotificationService::AllSources()); | 73 content::NotificationService::AllSources()); |
| 67 ui_test_utils::NavigateToURL( | 74 ui_test_utils::NavigateToURL( |
| 68 browser(), | 75 browser(), |
| 69 content::GetFileUrlWithQuery( | 76 content::GetFileUrlWithQuery( |
| 70 gpu_test_dir_.AppendASCII("webgl.html"), "query=kill")); | 77 gpu_test_dir_.AppendASCII("webgl.html"), "query=kill")); |
| 71 observer.Wait(); | 78 observer.Wait(); |
| 72 | 79 |
| 73 SimulateGPUCrash(browser()); | 80 SimulateGPUCrash(browser()); |
| 74 | 81 |
| 75 std::string m; | 82 std::string m; |
| 76 ASSERT_TRUE(message_queue.WaitForMessage(&m)); | 83 ASSERT_TRUE(message_queue.WaitForMessage(&m)); |
| 77 EXPECT_EQ("\"SUCCESS\"", m); | 84 EXPECT_EQ("\"SUCCESS\"", m); |
| 78 } | 85 } |
| 79 | 86 |
| 87 IN_PROC_BROWSER_TEST_F(GPUCrashTest, ContextLossRaisesInfobar) { |
| 88 // Load page and wait for it to load. |
| 89 content::WindowedNotificationObserver observer( |
| 90 content::NOTIFICATION_LOAD_STOP, |
| 91 content::NotificationService::AllSources()); |
| 92 ui_test_utils::NavigateToURL( |
| 93 browser(), |
| 94 content::GetFileUrlWithQuery( |
| 95 gpu_test_dir_.AppendASCII("webgl.html"), "query=kill")); |
| 96 observer.Wait(); |
| 97 |
| 98 content::WindowedNotificationObserver infobar_added( |
| 99 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
| 100 content::NotificationService::AllSources()); |
| 101 SimulateGPUCrash(browser()); |
| 102 infobar_added.Wait(); |
| 103 EXPECT_EQ(1u, |
| 104 InfoBarTabHelper::FromWebContents( |
| 105 chrome::GetActiveWebContents(browser()))->GetInfoBarCount()); |
| 106 } |
| 80 | 107 |
| 81 IN_PROC_BROWSER_TEST_F(GPUCrashTest, WebkitLoseContext) { | 108 IN_PROC_BROWSER_TEST_F(GPUCrashTest, WebkitLoseContext) { |
| 82 content::DOMMessageQueue message_queue; | 109 content::DOMMessageQueue message_queue; |
| 83 | 110 |
| 84 ui_test_utils::NavigateToURL( | 111 ui_test_utils::NavigateToURL( |
| 85 browser(), | 112 browser(), |
| 86 content::GetFileUrlWithQuery( | 113 content::GetFileUrlWithQuery( |
| 87 gpu_test_dir_.AppendASCII("webgl.html"), | 114 gpu_test_dir_.AppendASCII("webgl.html"), |
| 88 "query=WEBGL_lose_context")); | 115 "query=WEBGL_lose_context")); |
| 89 | 116 |
| 90 std::string m; | 117 std::string m; |
| 91 ASSERT_TRUE(message_queue.WaitForMessage(&m)); | 118 ASSERT_TRUE(message_queue.WaitForMessage(&m)); |
| 92 EXPECT_EQ("\"SUCCESS\"", m); | 119 EXPECT_EQ("\"SUCCESS\"", m); |
| 93 } | 120 } |
| OLD | NEW |