Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 | 155 |
| 156 void PlatformNotificationServiceBrowserTest::TearDown() { | 156 void PlatformNotificationServiceBrowserTest::TearDown() { |
| 157 service()->SetNotificationDisplayServiceForTesting(nullptr); | 157 service()->SetNotificationDisplayServiceForTesting(nullptr); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void PlatformNotificationServiceBrowserTest:: | 160 void PlatformNotificationServiceBrowserTest:: |
| 161 GrantNotificationPermissionForTest() const { | 161 GrantNotificationPermissionForTest() const { |
| 162 GURL origin = TestPageUrl().GetOrigin(); | 162 GURL origin = TestPageUrl().GetOrigin(); |
| 163 | 163 |
| 164 DesktopNotificationProfileUtil::GrantPermission(browser()->profile(), origin); | 164 DesktopNotificationProfileUtil::GrantPermission(browser()->profile(), origin); |
| 165 ASSERT_EQ(blink::mojom::PermissionStatus::GRANTED, | 165 ASSERT_EQ(CONTENT_SETTING_ALLOW, |
| 166 PermissionManager::Get(browser()->profile()) | 166 PermissionManager::Get(browser()->profile()) |
| 167 ->GetPermissionStatus(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 167 ->GetPermissionStatus(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 168 origin, origin)); | 168 origin, origin)); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void PlatformNotificationServiceBrowserTest::NavigateToTestPage( | 171 void PlatformNotificationServiceBrowserTest::NavigateToTestPage( |
| 172 const std::string& path) const { | 172 const std::string& path) const { |
| 173 ui_test_utils::NavigateToURL(browser(), https_server_->GetURL(path)); | 173 ui_test_utils::NavigateToURL(browser(), https_server_->GetURL(path)); |
| 174 } | 174 } |
| 175 | 175 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 // TODO(felt): This DCHECKs when bubbles are enabled, when the file_url is | 462 // TODO(felt): This DCHECKs when bubbles are enabled, when the file_url is |
| 463 // persisted. crbug.com/502057 | 463 // persisted. crbug.com/502057 |
| 464 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | 464 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
| 465 DISABLED_CheckFilePermissionNotGranted) { | 465 DISABLED_CheckFilePermissionNotGranted) { |
| 466 // This case should succeed because a normal page URL is used. | 466 // This case should succeed because a normal page URL is used. |
| 467 std::string script_result; | 467 std::string script_result; |
| 468 | 468 |
| 469 PermissionManager* permission_manager = | 469 PermissionManager* permission_manager = |
| 470 PermissionManager::Get(browser()->profile()); | 470 PermissionManager::Get(browser()->profile()); |
| 471 | 471 |
| 472 EXPECT_EQ(blink::mojom::PermissionStatus::ASK, | 472 EXPECT_EQ( |
| 473 permission_manager->GetPermissionStatus( | 473 CONTENT_SETTING_ASK, |
| 474 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, TestPageUrl(), | 474 permission_manager->GetPermissionStatus( |
| 475 TestPageUrl())); | 475 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, TestPageUrl(), TestPageUrl())); |
| 476 | 476 |
| 477 RequestAndAcceptPermission(); | 477 RequestAndAcceptPermission(); |
| 478 EXPECT_EQ(blink::mojom::PermissionStatus::GRANTED, | 478 EXPECT_EQ( |
| 479 permission_manager->GetPermissionStatus( | 479 CONTENT_SETTING_ASK, |
|
raymes
2017/02/28 01:37:34
CONTENT_SETTING_ALLOW
Timothy Loh
2017/02/28 04:02:46
Fixed
| |
| 480 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, TestPageUrl(), | 480 permission_manager->GetPermissionStatus( |
| 481 TestPageUrl())); | 481 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, TestPageUrl(), TestPageUrl())); |
| 482 | 482 |
| 483 // This case should fail because a file URL is used. | 483 // This case should fail because a file URL is used. |
| 484 base::FilePath dir_source_root; | 484 base::FilePath dir_source_root; |
| 485 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &dir_source_root)); | 485 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &dir_source_root)); |
| 486 base::FilePath full_file_path = | 486 base::FilePath full_file_path = |
| 487 dir_source_root.Append(server_root()).AppendASCII(kTestFileName); | 487 dir_source_root.Append(server_root()).AppendASCII(kTestFileName); |
| 488 GURL file_url(net::FilePathToFileURL(full_file_path)); | 488 GURL file_url(net::FilePathToFileURL(full_file_path)); |
| 489 | 489 |
| 490 ui_test_utils::NavigateToURL(browser(), file_url); | 490 ui_test_utils::NavigateToURL(browser(), file_url); |
| 491 | 491 |
| 492 EXPECT_EQ(blink::mojom::PermissionStatus::ASK, | 492 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 493 permission_manager->GetPermissionStatus( | 493 permission_manager->GetPermissionStatus( |
| 494 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, file_url, file_url)); | 494 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, file_url, file_url)); |
| 495 | 495 |
| 496 RequestAndAcceptPermission(); | 496 RequestAndAcceptPermission(); |
| 497 EXPECT_EQ(blink::mojom::PermissionStatus::ASK, | 497 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 498 permission_manager->GetPermissionStatus( | 498 permission_manager->GetPermissionStatus( |
| 499 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, file_url, file_url)) | 499 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, file_url, file_url)) |
| 500 << "If this test fails, you may have fixed a bug preventing file origins " | 500 << "If this test fails, you may have fixed a bug preventing file origins " |
| 501 << "from sending their origin from Blink; if so you need to update the " | 501 << "from sending their origin from Blink; if so you need to update the " |
| 502 << "display function for notification origins to show the file path."; | 502 << "display function for notification origins to show the file path."; |
| 503 } | 503 } |
| 504 | 504 |
| 505 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | 505 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
| 506 DataUrlAsNotificationImage) { | 506 DataUrlAsNotificationImage) { |
| 507 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); | 507 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 781 RunScript("DisplayPersistentAllOptionsNotification()", &script_result)); | 781 RunScript("DisplayPersistentAllOptionsNotification()", &script_result)); |
| 782 EXPECT_EQ("ok", script_result); | 782 EXPECT_EQ("ok", script_result); |
| 783 | 783 |
| 784 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); | 784 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); |
| 785 const Notification& notification = ui_manager()->GetNotificationAt(0); | 785 const Notification& notification = ui_manager()->GetNotificationAt(0); |
| 786 | 786 |
| 787 // Since the kNotificationContentImage kill switch has disabled images, the | 787 // Since the kNotificationContentImage kill switch has disabled images, the |
| 788 // notification should be shown without an image. | 788 // notification should be shown without an image. |
| 789 EXPECT_TRUE(notification.image().IsEmpty()); | 789 EXPECT_TRUE(notification.image().IsEmpty()); |
| 790 } | 790 } |
| OLD | NEW |