| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "chrome/common/chrome_switches.h" | 6 #include "chrome/common/chrome_switches.h" |
| 7 #include "chrome/test/automation/browser_proxy.h" | 7 #include "chrome/test/automation/browser_proxy.h" |
| 8 #include "chrome/test/automation/tab_proxy.h" | 8 #include "chrome/test/automation/tab_proxy.h" |
| 9 #include "chrome/test/ui/ui_test.h" | 9 #include "chrome/test/ui/ui_test.h" |
| 10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 const wchar_t kDocRoot[] = L"chrome/test/data"; | 22 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 23 scoped_refptr<HTTPTestServer> server = | 23 scoped_refptr<HTTPTestServer> server = |
| 24 HTTPTestServer::CreateServer(kDocRoot, NULL); | 24 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 25 ASSERT_TRUE(server.get() != NULL); | 25 ASSERT_TRUE(server.get() != NULL); |
| 26 | 26 |
| 27 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 27 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 28 ASSERT_TRUE(browser.get()); | 28 ASSERT_TRUE(browser.get()); |
| 29 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); | 29 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); |
| 30 ASSERT_TRUE(tab.get()); | 30 ASSERT_TRUE(tab.get()); |
| 31 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 31 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 32 tab->NavigateToURL(server->TestServerPageW( | 32 tab->NavigateToURL(server->TestServerPage( |
| 33 L"files/notifications/notifications_request_function.html"))); | 33 "files/notifications/notifications_request_function.html"))); |
| 34 WaitUntilTabCount(1); | 34 WaitUntilTabCount(1); |
| 35 | 35 |
| 36 // Request permission by calling request() while eval'ing an inline script; | 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. | 37 // That's considered a user gesture to webkit, and should produce an infobar. |
| 38 bool result; | 38 bool result; |
| 39 ASSERT_TRUE(tab->ExecuteAndExtractBool( | 39 ASSERT_TRUE(tab->ExecuteAndExtractBool( |
| 40 L"", | 40 L"", |
| 41 L"window.domAutomationController.send(request());", | 41 L"window.domAutomationController.send(request());", |
| 42 &result)); | 42 &result)); |
| 43 EXPECT_TRUE(result); | 43 EXPECT_TRUE(result); |
| 44 | 44 |
| 45 EXPECT_TRUE(tab->WaitForInfoBarCount(1, action_max_timeout_ms())); | 45 EXPECT_TRUE(tab->WaitForInfoBarCount(1, action_max_timeout_ms())); |
| 46 } | 46 } |
| 47 | 47 |
| 48 TEST_F(NotificationsPermissionTest, TestNoUserGestureInfobar) { | 48 TEST_F(NotificationsPermissionTest, TestNoUserGestureInfobar) { |
| 49 const wchar_t kDocRoot[] = L"chrome/test/data"; | 49 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 50 scoped_refptr<HTTPTestServer> server = | 50 scoped_refptr<HTTPTestServer> server = |
| 51 HTTPTestServer::CreateServer(kDocRoot, NULL); | 51 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 52 ASSERT_TRUE(server.get() != NULL); | 52 ASSERT_TRUE(server.get() != NULL); |
| 53 | 53 |
| 54 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 54 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 55 ASSERT_TRUE(browser.get()); | 55 ASSERT_TRUE(browser.get()); |
| 56 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); | 56 scoped_refptr<TabProxy> tab(browser->GetActiveTab()); |
| 57 ASSERT_TRUE(tab.get()); | 57 ASSERT_TRUE(tab.get()); |
| 58 | 58 |
| 59 // Load a page which just does a request; no user gesture should result | 59 // Load a page which just does a request; no user gesture should result |
| 60 // in no infobar. | 60 // in no infobar. |
| 61 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 61 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 62 tab->NavigateToURL(server->TestServerPageW( | 62 tab->NavigateToURL(server->TestServerPage( |
| 63 L"files/notifications/notifications_request_inline.html"))); | 63 "files/notifications/notifications_request_inline.html"))); |
| 64 WaitUntilTabCount(1); | 64 WaitUntilTabCount(1); |
| 65 | 65 |
| 66 int info_bar_count; | 66 int info_bar_count; |
| 67 ASSERT_TRUE(tab->GetInfoBarCount(&info_bar_count)); | 67 ASSERT_TRUE(tab->GetInfoBarCount(&info_bar_count)); |
| 68 EXPECT_EQ(0, info_bar_count); | 68 EXPECT_EQ(0, info_bar_count); |
| 69 } | 69 } |
| OLD | NEW |