| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 // persisted. crbug.com/502057 | 388 // persisted. crbug.com/502057 |
| 389 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | 389 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
| 390 DISABLED_CheckFilePermissionNotGranted) { | 390 DISABLED_CheckFilePermissionNotGranted) { |
| 391 // This case should succeed because a normal page URL is used. | 391 // This case should succeed because a normal page URL is used. |
| 392 std::string script_result; | 392 std::string script_result; |
| 393 | 393 |
| 394 NotificationPermissionContext* permission_context = | 394 NotificationPermissionContext* permission_context = |
| 395 NotificationPermissionContextFactory::GetForProfile(browser()->profile()); | 395 NotificationPermissionContextFactory::GetForProfile(browser()->profile()); |
| 396 ASSERT_TRUE(permission_context); | 396 ASSERT_TRUE(permission_context); |
| 397 | 397 |
| 398 const url::Origin origin(TestPageUrl()); |
| 398 EXPECT_EQ(CONTENT_SETTING_ASK, | 399 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 399 permission_context->GetPermissionStatus(TestPageUrl(), | 400 permission_context->GetPermissionStatus(origin, origin)); |
| 400 TestPageUrl())); | |
| 401 | 401 |
| 402 RequestAndAcceptPermission(); | 402 RequestAndAcceptPermission(); |
| 403 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 403 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 404 permission_context->GetPermissionStatus(TestPageUrl(), | 404 permission_context->GetPermissionStatus(origin, origin)); |
| 405 TestPageUrl())); | |
| 406 | 405 |
| 407 // This case should fail because a file URL is used. | 406 // This case should fail because a file URL is used. |
| 408 base::FilePath dir_source_root; | 407 base::FilePath dir_source_root; |
| 409 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &dir_source_root)); | 408 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &dir_source_root)); |
| 410 base::FilePath full_file_path = | 409 base::FilePath full_file_path = |
| 411 dir_source_root.Append(server_root()).AppendASCII(kTestFileName); | 410 dir_source_root.Append(server_root()).AppendASCII(kTestFileName); |
| 412 GURL file_url(net::FilePathToFileURL(full_file_path)); | 411 const GURL file_url(net::FilePathToFileURL(full_file_path)); |
| 412 const url::Origin file_origin(file_url); |
| 413 | 413 |
| 414 ui_test_utils::NavigateToURL(browser(), file_url); | 414 ui_test_utils::NavigateToURL(browser(), file_url); |
| 415 | 415 |
| 416 EXPECT_EQ(CONTENT_SETTING_ASK, | 416 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 417 permission_context->GetPermissionStatus(file_url, file_url)); | 417 permission_context->GetPermissionStatus(file_origin, file_origin)); |
| 418 | 418 |
| 419 RequestAndAcceptPermission(); | 419 RequestAndAcceptPermission(); |
| 420 EXPECT_EQ(CONTENT_SETTING_ASK, | 420 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 421 permission_context->GetPermissionStatus(file_url, file_url)) | 421 permission_context->GetPermissionStatus(file_origin, file_origin)) |
| 422 << "If this test fails, you may have fixed a bug preventing file origins " | 422 << "If this test fails, you may have fixed a bug preventing file origins " |
| 423 << "from sending their origin from Blink; if so you need to update the " | 423 << "from sending their origin from Blink; if so you need to update the " |
| 424 << "display function for notification origins to show the file path."; | 424 << "display function for notification origins to show the file path."; |
| 425 } | 425 } |
| 426 | 426 |
| 427 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | 427 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
| 428 DataUrlAsNotificationImage) { | 428 DataUrlAsNotificationImage) { |
| 429 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); | 429 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); |
| 430 | 430 |
| 431 std::string script_result; | 431 std::string script_result; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 EXPECT_EQ("actionTitle2", base::UTF16ToUTF8(notification.buttons()[1].title)); | 478 EXPECT_EQ("actionTitle2", base::UTF16ToUTF8(notification.buttons()[1].title)); |
| 479 | 479 |
| 480 notification.delegate()->ButtonClick(0); | 480 notification.delegate()->ButtonClick(0); |
| 481 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); | 481 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); |
| 482 EXPECT_EQ("action_button_click actionId1", script_result); | 482 EXPECT_EQ("action_button_click actionId1", script_result); |
| 483 | 483 |
| 484 notification.delegate()->ButtonClick(1); | 484 notification.delegate()->ButtonClick(1); |
| 485 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); | 485 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); |
| 486 EXPECT_EQ("action_button_click actionId2", script_result); | 486 EXPECT_EQ("action_button_click actionId2", script_result); |
| 487 } | 487 } |
| OLD | NEW |