Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: chrome/browser/cookie_modal_dialog_uitest.cc

Issue 3299020: Remove vestigial cookie/web app permissions prompting UI now that the async U... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/net/url_request_mock_http_job.h"
6 #include "chrome/test/automation/tab_proxy.h"
7 #include "chrome/test/ui/ui_test.h"
8
9 class CookieModalDialogTest : public UITest {
10 public:
11 void RunBasicTest(MessageBoxFlags::DialogButton button_to_press,
12 const std::wstring& expected_title) {
13 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
14 ASSERT_TRUE(browser);
15
16 ASSERT_TRUE(browser->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES,
17 CONTENT_SETTING_ASK));
18
19 GURL url(URLRequestMockHTTPJob::GetMockUrl(
20 FilePath(FILE_PATH_LITERAL("cookie2.html"))));
21
22 scoped_refptr<TabProxy> tab_proxy(GetActiveTab());
23 ASSERT_TRUE(tab_proxy);
24
25 int64 last_navigation_time;
26 ASSERT_TRUE(tab_proxy->GetLastNavigationTime(&last_navigation_time));
27 ASSERT_TRUE(tab_proxy->NavigateToURLAsync(url));
28
29 // cookie2.html sets a cookie and then reads back the cookie within onload,
30 // which means that the navigation will not complete until the cookie
31 // prompt is dismissed.
32
33 bool modal_dialog_showing = false;
34 MessageBoxFlags::DialogButton available_buttons;
35 ASSERT_TRUE(automation()->WaitForAppModalDialog());
36 ASSERT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing,
37 &available_buttons));
38 ASSERT_TRUE(modal_dialog_showing);
39 ASSERT_NE((button_to_press & available_buttons), 0);
40 ASSERT_TRUE(automation()->ClickAppModalDialogButton(button_to_press));
41
42 // Now, the cookie prompt is dismissed, and we can wait for the navigation
43 // to complete. Before returning from onload, the test updates the title.
44 // We can therefore be sure that upon return from WaitForNavigation that
45 // the title has been updated with the final test result.
46
47 ASSERT_TRUE(tab_proxy->WaitForNavigation(last_navigation_time));
48
49 std::wstring title;
50 ASSERT_TRUE(tab_proxy->GetTabTitle(&title));
51
52 EXPECT_EQ(expected_title, title);
53 }
54 };
55
56 // TODO(port): Enable these once the cookie dialogs are fully implemented.
57 #if defined(OS_WIN)
58 TEST_F(CookieModalDialogTest, AllowCookies) {
59 RunBasicTest(MessageBoxFlags::DIALOGBUTTON_OK, L"cookie allowed");
60 }
61
62 TEST_F(CookieModalDialogTest, BlockCookies) {
63 RunBasicTest(MessageBoxFlags::DIALOGBUTTON_CANCEL, L"cookie blocked");
64 }
65 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698