summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-13 22:04:58 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-13 22:04:58 +0000
commit4440a58b8f7658021f9badf5d5e142fc61f288c6 (patch)
tree9ba043ce2dc73dbc36cdfb2e5d8c9e23343bdf0d /chrome/browser/notifications
parent5ccaa41d72d5241e76bad7f16c3e0147d990584b (diff)
downloadchromium_src-4440a58b8f7658021f9badf5d5e142fc61f288c6.zip
chromium_src-4440a58b8f7658021f9badf5d5e142fc61f288c6.tar.gz
chromium_src-4440a58b8f7658021f9badf5d5e142fc61f288c6.tar.bz2
Notifications permission infobar should only be shown in response to a user gesture, not arbitrary script.
Experimental fix for UI test, so checking in flaky at first to see if I have it... BUG=27215 TEST=included Committed as r31839... and reverted. Review URL: http://codereview.chromium.org/387011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications')
-rwxr-xr-xchrome/browser/notifications/notifications_uitest.cc65
1 files changed, 65 insertions, 0 deletions
diff --git a/chrome/browser/notifications/notifications_uitest.cc b/chrome/browser/notifications/notifications_uitest.cc
new file mode 100755
index 0000000..9fa61ff
--- /dev/null
+++ b/chrome/browser/notifications/notifications_uitest.cc
@@ -0,0 +1,65 @@
+// Copyright (c) 2006-2009 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/file_path.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/automation/browser_proxy.h"
+#include "chrome/test/automation/tab_proxy.h"
+#include "chrome/test/ui/ui_test.h"
+#include "net/base/net_util.h"
+#include "net/url_request/url_request_unittest.h"
+
+class NotificationsPermissionTest : public UITest {
+ public:
+ NotificationsPermissionTest() {
+ launch_arguments_.AppendSwitch(switches::kEnableDesktopNotifications);
+ dom_automation_enabled_ = true;
+ show_window_ = true;
+ }
+};
+
+#if defined(OS_WIN)
+TEST_F(NotificationsPermissionTest, FLAKY_TestUserGestureInfobar) {
+ const wchar_t kDocRoot[] = L"chrome/test/data";
+ scoped_refptr<HTTPTestServer> server =
+ HTTPTestServer::CreateServer(kDocRoot, NULL);
+ ASSERT_TRUE(server.get() != NULL);
+
+ scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ scoped_refptr<TabProxy> tab(browser->GetActiveTab());
+ tab->NavigateToURL(server->TestServerPageW(
+ L"files/notifications/notifications_request_function.html"));
+ WaitUntilTabCount(1);
+
+ // Request permission by calling request() while eval'ing an inline script;
+ // That's considered a user gesture to webkit, and should produce an infobar.
+ bool result;
+ tab->ExecuteAndExtractBool(L"",
+ L"window.domAutomationController.send(request());",
+ &result);
+ EXPECT_TRUE(result);
+
+ EXPECT_TRUE(tab->WaitForInfoBarCount(1, action_max_timeout_ms()));
+}
+
+TEST_F(NotificationsPermissionTest, TestNoUserGestureInfobar) {
+ const wchar_t kDocRoot[] = L"chrome/test/data";
+ scoped_refptr<HTTPTestServer> server =
+ HTTPTestServer::CreateServer(kDocRoot, NULL);
+ ASSERT_TRUE(server.get() != NULL);
+
+ scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ scoped_refptr<TabProxy> tab(browser->GetActiveTab());
+
+ // Load a page which just does a request; no user gesture should result
+ // in no infobar.
+ tab->NavigateToURL(server->TestServerPageW(
+ L"files/notifications/notifications_request_inline.html"));
+ WaitUntilTabCount(1);
+
+ int info_bar_count;
+ tab->GetInfoBarCount(&info_bar_count);
+ EXPECT_EQ(0, info_bar_count);
+}
+#endif // OS_WIN