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 3 // found in the LICENSE file. 4 5 #include "base/path_service.h" 6 #include "content/browser/gpu/gpu_data_manager_impl.h" 7 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 8 #include "content/public/browser/notification_service.h" 9 #include "content/public/browser/notification_types.h" 10 #include "content/public/common/content_paths.h" 11 #include "content/public/test/browser_test_utils.h" 12 #include "content/public/test/test_utils.h" 13 #include "content/shell/shell.h" 14 #include "content/test/content_browser_test.h" 15 #include "content/test/content_browser_test_utils.h" 16 17 namespace content { 18 class GpuCrashTest : public ContentBrowserTest { 19 protected: 20 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 21 base::FilePath test_dir; 22 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &test_dir)); 23 gpu_test_dir_ = test_dir.AppendASCII("gpu"); 24 } 25 base::FilePath gpu_test_dir_; 26 }; 27 28 #if defined(OS_LINUX) && !defined(NDEBUG) 29 // http://crbug.com/254724 30 #define IF_NOT_DEBUG_LINUX(x) DISABLED_ ## x 31 #else 32 #define IF_NOT_DEBUG_LINUX(x) x 33 #endif 34 35 IN_PROC_BROWSER_TEST_F(GpuCrashTest, IF_NOT_DEBUG_LINUX(MANUAL_Kill)) { 36 DOMMessageQueue message_queue; 37 38 content::GpuDataManagerImpl::GetInstance()-> 39 DisableDomainBlockingFor3DAPIsForTesting(); 40 41 // Load page and wait for it to load. 42 content::WindowedNotificationObserver observer( 43 content::NOTIFICATION_LOAD_STOP, 44 content::NotificationService::AllSources()); 45 NavigateToURL( 46 shell(), 47 GetFileUrlWithQuery( 48 gpu_test_dir_.AppendASCII("webgl.html"), "query=kill")); 49 observer.Wait(); 50 51 GpuProcessHostUIShim* host = 52 GpuProcessHostUIShim::GetOneInstance(); 53 ASSERT_TRUE(host); 54 host->SimulateCrash(); 55 56 std::string m; 57 ASSERT_TRUE(message_queue.WaitForMessage(&m)); 58 EXPECT_EQ("\"SUCCESS\"", m); 59 } 60 61 IN_PROC_BROWSER_TEST_F(GpuCrashTest, 62 IF_NOT_DEBUG_LINUX(MANUAL_WebkitLoseContext)) { 63 DOMMessageQueue message_queue; 64 65 NavigateToURL( 66 shell(), 67 GetFileUrlWithQuery( 68 gpu_test_dir_.AppendASCII("webgl.html"), 69 "query=WEBGL_lose_context")); 70 71 std::string m; 72 ASSERT_TRUE(message_queue.WaitForMessage(&m)); 73 EXPECT_EQ("\"SUCCESS\"", m); 74 } 75 76 } // namespace content 77