| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/browser/notifications/notification_interactive_uitest_support.h
" | 5 #include "chrome/browser/notifications/notification_interactive_uitest_support.h
" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 10 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 10 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 ui_test_utils::NavigateToURL(browser, GetTestPageURL()); | 233 ui_test_utils::NavigateToURL(browser, GetTestPageURL()); |
| 234 PermissionRequestObserver observer(web_contents); | 234 PermissionRequestObserver observer(web_contents); |
| 235 std::string result; | 235 std::string result; |
| 236 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 236 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 237 web_contents, "requestPermissionAndRespond();", &result)); | 237 web_contents, "requestPermissionAndRespond();", &result)); |
| 238 EXPECT_EQ("requested", result); | 238 EXPECT_EQ("requested", result); |
| 239 observer.Wait(); | 239 observer.Wait(); |
| 240 return observer.request_shown(); | 240 return observer.request_shown(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 std::string NotificationsTest::QueryPermissionStatus(Browser* browser) { |
| 244 std::string result; |
| 245 content::WebContents* web_contents = GetActiveWebContents(browser); |
| 246 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 247 web_contents, "queryPermissionStatus();", &result)); |
| 248 return result; |
| 249 } |
| 250 |
| 243 bool NotificationsTest::CancelNotification(const char* notification_id, | 251 bool NotificationsTest::CancelNotification(const char* notification_id, |
| 244 Browser* browser) { | 252 Browser* browser) { |
| 245 std::string script = | 253 std::string script = |
| 246 base::StringPrintf("cancelNotification('%s');", notification_id); | 254 base::StringPrintf("cancelNotification('%s');", notification_id); |
| 247 | 255 |
| 248 MessageCenterChangeObserver observer; | 256 MessageCenterChangeObserver observer; |
| 249 std::string result; | 257 std::string result; |
| 250 bool success = content::ExecuteScriptAndExtractString( | 258 bool success = content::ExecuteScriptAndExtractString( |
| 251 GetActiveWebContents(browser), script, &result); | 259 GetActiveWebContents(browser), script, &result); |
| 252 if (!success || result != "1") | 260 if (!success || result != "1") |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 294 |
| 287 GURL NotificationsTest::GetTestPageURL() const { | 295 GURL NotificationsTest::GetTestPageURL() const { |
| 288 return GetTestPageURLForFile("notification_tester.html"); | 296 return GetTestPageURLForFile("notification_tester.html"); |
| 289 } | 297 } |
| 290 | 298 |
| 291 content::WebContents* NotificationsTest::GetActiveWebContents( | 299 content::WebContents* NotificationsTest::GetActiveWebContents( |
| 292 Browser* browser) { | 300 Browser* browser) { |
| 293 return browser->tab_strip_model()->GetActiveWebContents(); | 301 return browser->tab_strip_model()->GetActiveWebContents(); |
| 294 } | 302 } |
| 295 | 303 |
| 304 void NotificationsTest::EnablePermissionsEmbargo() { |
| 305 feature_list_.InitWithFeatures({features::kBlockPromptsIfDismissedOften, |
| 306 features::kBlockPromptsIfIgnoredOften}, |
| 307 {}); |
| 308 } |
| 309 |
| 296 void NotificationsTest::EnableFullscreenNotifications() { | 310 void NotificationsTest::EnableFullscreenNotifications() { |
| 297 feature_list_.InitWithFeatures( | 311 feature_list_.InitWithFeatures( |
| 298 {features::kPreferHtmlOverPlugins, | 312 {features::kPreferHtmlOverPlugins, |
| 299 features::kAllowFullscreenWebNotificationsFeature}, | 313 features::kAllowFullscreenWebNotificationsFeature}, |
| 300 {}); | 314 {}); |
| 301 } | 315 } |
| 302 | 316 |
| 303 void NotificationsTest::DisableFullscreenNotifications() { | 317 void NotificationsTest::DisableFullscreenNotifications() { |
| 304 feature_list_.InitWithFeatures( | 318 feature_list_.InitWithFeatures( |
| 305 {features::kPreferHtmlOverPlugins}, | 319 {features::kPreferHtmlOverPlugins}, |
| 306 {features::kAllowFullscreenWebNotificationsFeature}); | 320 {features::kAllowFullscreenWebNotificationsFeature}); |
| 307 } | 321 } |
| 308 | 322 |
| 309 void NotificationsTest::DropOriginPreference(const GURL& origin) { | 323 void NotificationsTest::DropOriginPreference(const GURL& origin) { |
| 310 DesktopNotificationProfileUtil::ClearSetting(browser()->profile(), origin); | 324 DesktopNotificationProfileUtil::ClearSetting(browser()->profile(), origin); |
| 311 } | 325 } |
| OLD | NEW |