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