| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT)); | 737 ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT)); |
| 738 WatchPositionAndObservePermissionRequest(true); | 738 WatchPositionAndObservePermissionRequest(true); |
| 739 | 739 |
| 740 // TODO(mvanouwerkerk): Can't close a window you did not open. Maybe this was | 740 // TODO(mvanouwerkerk): Can't close a window you did not open. Maybe this was |
| 741 // valid when the test was written, but now it just prints "Scripts may close | 741 // valid when the test was written, but now it just prints "Scripts may close |
| 742 // only the windows that were opened by it." | 742 // only the windows that were opened by it." |
| 743 std::string script = "window.domAutomationController.send(window.close())"; | 743 std::string script = "window.domAutomationController.send(window.close())"; |
| 744 ASSERT_TRUE(content::ExecuteScript( | 744 ASSERT_TRUE(content::ExecuteScript( |
| 745 current_browser()->tab_strip_model()->GetActiveWebContents(), script)); | 745 current_browser()->tab_strip_model()->GetActiveWebContents(), script)); |
| 746 } | 746 } |
| 747 | |
| 748 IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, LastUsageUpdated) { | |
| 749 ASSERT_NO_FATAL_FAILURE(Initialize(INITIALIZATION_DEFAULT)); | |
| 750 base::SimpleTestClock* clock_ = new base::SimpleTestClock(); | |
| 751 GetHostContentSettingsMap()->SetPrefClockForTesting( | |
| 752 std::unique_ptr<base::Clock>(clock_)); | |
| 753 clock_->SetNow(base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(10)); | |
| 754 | |
| 755 // Setting the permission should trigger the last usage. | |
| 756 GetHostContentSettingsMap()->SetContentSettingDefaultScope( | |
| 757 current_url(), current_url(), CONTENT_SETTINGS_TYPE_GEOLOCATION, | |
| 758 std::string(), CONTENT_SETTING_ALLOW); | |
| 759 | |
| 760 // Permission has been used at the starting time. | |
| 761 EXPECT_EQ(GetHostContentSettingsMap()->GetLastUsage( | |
| 762 current_url().GetOrigin(), | |
| 763 current_url().GetOrigin(), | |
| 764 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 10); | |
| 765 | |
| 766 clock_->Advance(base::TimeDelta::FromSeconds(3)); | |
| 767 | |
| 768 // Calling watchPosition should trigger the last usage update. | |
| 769 WatchPositionAndObservePermissionRequest(false); | |
| 770 ExpectPosition(fake_latitude(), fake_longitude()); | |
| 771 | |
| 772 // Last usage has been updated. | |
| 773 EXPECT_EQ(GetHostContentSettingsMap()->GetLastUsage( | |
| 774 current_url().GetOrigin(), | |
| 775 current_url().GetOrigin(), | |
| 776 CONTENT_SETTINGS_TYPE_GEOLOCATION).ToDoubleT(), 13); | |
| 777 } | |
| OLD | NEW |