OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/common/chrome_switches.h" | 5 #include "chrome/common/chrome_switches.h" |
6 #include "chrome/test/automation/browser_proxy.h" | 6 #include "chrome/test/automation/browser_proxy.h" |
7 #include "chrome/test/automation/tab_proxy.h" | 7 #include "chrome/test/automation/tab_proxy.h" |
8 #include "chrome/test/ui/ui_test.h" | 8 #include "chrome/test/ui/ui_test.h" |
9 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
10 #include "net/test/test_server.h" | 10 #include "net/test/test_server.h" |
11 | 11 |
12 class NotificationsPermissionTest : public UITest { | 12 class NotificationsPermissionTest : public UITest { |
13 public: | 13 public: |
14 NotificationsPermissionTest() { | 14 NotificationsPermissionTest() { |
15 dom_automation_enabled_ = true; | 15 dom_automation_enabled_ = true; |
16 show_window_ = true; | 16 show_window_ = true; |
17 } | 17 } |
18 }; | 18 }; |
19 | 19 |
20 TEST_F(NotificationsPermissionTest, TestUserGestureInfobar) { | 20 // Flaky, http://crbug.com/62311. |
| 21 TEST_F(NotificationsPermissionTest, FLAKY_TestUserGestureInfobar) { |
21 net::TestServer test_server(net::TestServer::TYPE_HTTP, | 22 net::TestServer test_server(net::TestServer::TYPE_HTTP, |
22 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 23 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
23 ASSERT_TRUE(test_server.Start()); | 24 ASSERT_TRUE(test_server.Start()); |
24 | 25 |
25 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 26 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
26 ASSERT_TRUE(browser.get()); | 27 ASSERT_TRUE(browser.get()); |
27 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); | 28 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); |
28 ASSERT_TRUE(tab.get()); | 29 ASSERT_TRUE(tab.get()); |
29 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 30 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
30 tab->NavigateToURL(test_server.GetURL( | 31 tab->NavigateToURL(test_server.GetURL( |
31 "files/notifications/notifications_request_function.html"))); | 32 "files/notifications/notifications_request_function.html"))); |
32 WaitUntilTabCount(1); | 33 WaitUntilTabCount(1); |
33 | 34 |
34 // Request permission by calling request() while eval'ing an inline script; | 35 // Request permission by calling request() while eval'ing an inline script; |
35 // That's considered a user gesture to webkit, and should produce an infobar. | 36 // That's considered a user gesture to webkit, and should produce an infobar. |
36 bool result; | 37 bool result; |
37 ASSERT_TRUE(tab->ExecuteAndExtractBool( | 38 ASSERT_TRUE(tab->ExecuteAndExtractBool( |
38 L"", | 39 L"", |
39 L"window.domAutomationController.send(request());", | 40 L"window.domAutomationController.send(request());", |
40 &result)); | 41 &result)); |
41 EXPECT_TRUE(result); | 42 EXPECT_TRUE(result); |
42 | 43 |
43 EXPECT_TRUE(tab->WaitForInfoBarCount(1)); | 44 EXPECT_TRUE(tab->WaitForInfoBarCount(1)); |
44 } | 45 } |
45 | 46 |
46 TEST_F(NotificationsPermissionTest, TestNoUserGestureInfobar) { | 47 // Flaky, http://crbug.com/62311. |
| 48 TEST_F(NotificationsPermissionTest, FLAKY_TestNoUserGestureInfobar) { |
47 net::TestServer test_server(net::TestServer::TYPE_HTTP, | 49 net::TestServer test_server(net::TestServer::TYPE_HTTP, |
48 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); | 50 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
49 ASSERT_TRUE(test_server.Start()); | 51 ASSERT_TRUE(test_server.Start()); |
50 | 52 |
51 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 53 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
52 ASSERT_TRUE(browser.get()); | 54 ASSERT_TRUE(browser.get()); |
53 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); | 55 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); |
54 ASSERT_TRUE(tab.get()); | 56 ASSERT_TRUE(tab.get()); |
55 | 57 |
56 // Load a page which just does a request; no user gesture should result | 58 // Load a page which just does a request; no user gesture should result |
57 // in no infobar. | 59 // in no infobar. |
58 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 60 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
59 tab->NavigateToURL(test_server.GetURL( | 61 tab->NavigateToURL(test_server.GetURL( |
60 "files/notifications/notifications_request_inline.html"))); | 62 "files/notifications/notifications_request_inline.html"))); |
61 WaitUntilTabCount(1); | 63 WaitUntilTabCount(1); |
62 | 64 |
63 int info_bar_count; | 65 int info_bar_count; |
64 ASSERT_TRUE(tab->GetInfoBarCount(&info_bar_count)); | 66 ASSERT_TRUE(tab->GetInfoBarCount(&info_bar_count)); |
65 EXPECT_EQ(0, info_bar_count); | 67 EXPECT_EQ(0, info_bar_count); |
66 } | 68 } |
OLD | NEW |