1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/command_line.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/infobars/confirm_infobar_delegate.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/test_launcher_utils.h"
#include "chrome/test/base/test_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/page_transition_types.h"
#include "content/public/test/browser_test_utils.h"
#include "gpu/config/gpu_test_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_implementation.h"
namespace {
void SimulateGPUCrash(Browser* browser) {
// None of the ui_test_utils entry points supports what we need to
// do here: navigate with the PAGE_TRANSITION_FROM_ADDRESS_BAR flag,
// without waiting for the navigation. It would be painful to change
// either of the NavigateToURL entry points to support these two
// constraints, so we use chrome::Navigate directly.
chrome::NavigateParams params(
browser,
GURL(content::kChromeUIGpuCrashURL),
static_cast<content::PageTransition>(
content::PAGE_TRANSITION_TYPED |
content::PAGE_TRANSITION_FROM_ADDRESS_BAR));
params.disposition = NEW_BACKGROUND_TAB;
chrome::Navigate(¶ms);
}
} // namespace
class WebGLInfoBarTest : public InProcessBrowserTest {
protected:
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
base::FilePath test_dir;
ASSERT_TRUE(PathService::Get(content::DIR_TEST_DATA, &test_dir));
gpu_test_dir_ = test_dir.AppendASCII("gpu");
}
base::FilePath gpu_test_dir_;
};
// This test is flaky on Mac. http://crbug.com/324555
#if defined(OS_MACOSX)
#define MAYBE_ContextLossRaisesInfoBar DISABLED_ContextLossRaisesInfoBar
#else
#define MAYBE_ContextLossRaisesInfoBar ContextLossRaisesInfoBar
#endif
IN_PROC_BROWSER_TEST_F(WebGLInfoBarTest, MAYBE_ContextLossRaisesInfoBar) {
#undef MAYBE_ContextLossRaisesInfoBard
#if defined(OS_WIN) && defined(USE_ASH)
// Disable this test in Metro+Ash for now (http://crbug.com/262796).
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
return;
#endif
if (gpu::GPUTestBotConfig::CurrentConfigMatches("XP"))
return;
// Load page and wait for it to load.
content::WindowedNotificationObserver observer(
content::NOTIFICATION_LOAD_STOP,
content::NotificationService::AllSources());
ui_test_utils::NavigateToURL(
browser(),
content::GetFileUrlWithQuery(
gpu_test_dir_.AppendASCII("webgl.html"), "query=kill"));
observer.Wait();
content::WindowedNotificationObserver infobar_added(
chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
content::NotificationService::AllSources());
SimulateGPUCrash(browser());
infobar_added.Wait();
EXPECT_EQ(1u,
InfoBarService::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents())->
infobar_count());
}
// This test is flaky on Mac. http://crbug.com/324555
#if defined(OS_MACOSX)
#define MAYBE_ContextLossInfoBarReload DISABLED_ContextLossInfoBarReload
#else
#define MAYBE_ContextLossInfoBarReload ContextLossInfoBarReload
#endif
IN_PROC_BROWSER_TEST_F(WebGLInfoBarTest, MAYBE_ContextLossInfoBarReload) {
#undef MAYBE_ContextLossInfoBarReload
#if defined(OS_WIN) && defined(USE_ASH)
// Disable this test in Metro+Ash for now (http://crbug.com/262796).
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
return;
#endif
if (gpu::GPUTestBotConfig::CurrentConfigMatches("XP"))
return;
content::DOMMessageQueue message_queue;
// Load page and wait for it to load.
content::WindowedNotificationObserver observer(
content::NOTIFICATION_LOAD_STOP,
content::NotificationService::AllSources());
ui_test_utils::NavigateToURL(
browser(),
content::GetFileUrlWithQuery(
gpu_test_dir_.AppendASCII("webgl.html"),
"query=kill_after_notification"));
observer.Wait();
std::string m;
ASSERT_TRUE(message_queue.WaitForMessage(&m));
EXPECT_EQ("\"LOADED\"", m);
message_queue.ClearQueue();
content::WindowedNotificationObserver infobar_added(
chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
content::NotificationService::AllSources());
SimulateGPUCrash(browser());
infobar_added.Wait();
InfoBarService* infobar_service = InfoBarService::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents());
ASSERT_EQ(1u, infobar_service->infobar_count());
InfoBarDelegate* delegate = infobar_service->infobar_at(0);
ASSERT_TRUE(delegate->AsThreeDAPIInfoBarDelegate());
delegate->AsConfirmInfoBarDelegate()->Cancel();
// The page should reload and another message sent to the
// DomAutomationController.
m.clear();
ASSERT_TRUE(message_queue.WaitForMessage(&m));
EXPECT_EQ("\"LOADED\"", m);
}
// There isn't any point in adding a test which calls Accept() on the
// ThreeDAPIInfoBarDelegate; doing so doesn't remove the infobar, and
// there's no concrete event that could be observed in response.
|