| 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 // persisted. crbug.com/502057 | 397 // persisted. crbug.com/502057 |
| 398 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | 398 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
| 399 DISABLED_CheckFilePermissionNotGranted) { | 399 DISABLED_CheckFilePermissionNotGranted) { |
| 400 // This case should succeed because a normal page URL is used. | 400 // This case should succeed because a normal page URL is used. |
| 401 std::string script_result; | 401 std::string script_result; |
| 402 | 402 |
| 403 NotificationPermissionContext* permission_context = | 403 NotificationPermissionContext* permission_context = |
| 404 NotificationPermissionContextFactory::GetForProfile(browser()->profile()); | 404 NotificationPermissionContextFactory::GetForProfile(browser()->profile()); |
| 405 ASSERT_TRUE(permission_context); | 405 ASSERT_TRUE(permission_context); |
| 406 | 406 |
| 407 const url::Origin origin(TestPageUrl()); |
| 407 EXPECT_EQ(CONTENT_SETTING_ASK, | 408 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 408 permission_context->GetPermissionStatus(TestPageUrl(), | 409 permission_context->GetPermissionStatus(origin, origin)); |
| 409 TestPageUrl())); | |
| 410 | 410 |
| 411 RequestAndAcceptPermission(); | 411 RequestAndAcceptPermission(); |
| 412 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 412 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 413 permission_context->GetPermissionStatus(TestPageUrl(), | 413 permission_context->GetPermissionStatus(origin, origin)); |
| 414 TestPageUrl())); | |
| 415 | 414 |
| 416 // This case should fail because a file URL is used. | 415 // This case should fail because a file URL is used. |
| 417 base::FilePath dir_source_root; | 416 base::FilePath dir_source_root; |
| 418 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &dir_source_root)); | 417 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &dir_source_root)); |
| 419 base::FilePath full_file_path = | 418 base::FilePath full_file_path = |
| 420 dir_source_root.Append(server_root()).AppendASCII(kTestFileName); | 419 dir_source_root.Append(server_root()).AppendASCII(kTestFileName); |
| 421 GURL file_url(net::FilePathToFileURL(full_file_path)); | 420 const GURL file_url(net::FilePathToFileURL(full_file_path)); |
| 421 const url::Origin file_origin(file_url); |
| 422 | 422 |
| 423 ui_test_utils::NavigateToURL(browser(), file_url); | 423 ui_test_utils::NavigateToURL(browser(), file_url); |
| 424 | 424 |
| 425 EXPECT_EQ(CONTENT_SETTING_ASK, | 425 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 426 permission_context->GetPermissionStatus(file_url, file_url)); | 426 permission_context->GetPermissionStatus(file_origin, file_origin)); |
| 427 | 427 |
| 428 RequestAndAcceptPermission(); | 428 RequestAndAcceptPermission(); |
| 429 EXPECT_EQ(CONTENT_SETTING_ASK, | 429 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 430 permission_context->GetPermissionStatus(file_url, file_url)) | 430 permission_context->GetPermissionStatus(file_origin, file_origin)) |
| 431 << "If this test fails, you may have fixed a bug preventing file origins " | 431 << "If this test fails, you may have fixed a bug preventing file origins " |
| 432 << "from sending their origin from Blink; if so you need to update the " | 432 << "from sending their origin from Blink; if so you need to update the " |
| 433 << "display function for notification origins to show the file path."; | 433 << "display function for notification origins to show the file path."; |
| 434 } | 434 } |
| 435 | 435 |
| 436 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | 436 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
| 437 DataUrlAsNotificationImage) { | 437 DataUrlAsNotificationImage) { |
| 438 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); | 438 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); |
| 439 | 439 |
| 440 std::string script_result; | 440 std::string script_result; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 EXPECT_EQ("actionTitle2", base::UTF16ToUTF8(notification.buttons()[1].title)); | 487 EXPECT_EQ("actionTitle2", base::UTF16ToUTF8(notification.buttons()[1].title)); |
| 488 | 488 |
| 489 notification.delegate()->ButtonClick(0); | 489 notification.delegate()->ButtonClick(0); |
| 490 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); | 490 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); |
| 491 EXPECT_EQ("action_button_click actionId1", script_result); | 491 EXPECT_EQ("action_button_click actionId1", script_result); |
| 492 | 492 |
| 493 notification.delegate()->ButtonClick(1); | 493 notification.delegate()->ButtonClick(1); |
| 494 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); | 494 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); |
| 495 EXPECT_EQ("action_button_click actionId2", script_result); | 495 EXPECT_EQ("action_button_click actionId2", script_result); |
| 496 } | 496 } |
| OLD | NEW |