Index: content/browser/service_worker/foreign_fetch_request_handler_unittest.cc |
diff --git a/content/browser/service_worker/foreign_fetch_request_handler_unittest.cc b/content/browser/service_worker/foreign_fetch_request_handler_unittest.cc |
index cdf3bc48a5fadb166da6f4c30b85660ee1629112..5f6382b7aeea986d137b3e5f6f534f18002be66b 100644 |
--- a/content/browser/service_worker/foreign_fetch_request_handler_unittest.cc |
+++ b/content/browser/service_worker/foreign_fetch_request_handler_unittest.cc |
@@ -6,6 +6,7 @@ |
#include "base/memory/ptr_util.h" |
#include "base/run_loop.h" |
+#include "base/test/simple_test_clock.h" |
#include "base/test/simple_test_tick_clock.h" |
#include "content/browser/browser_thread_impl.h" |
#include "content/browser/service_worker/embedded_worker_test_helper.h" |
@@ -50,6 +51,10 @@ int kMockProviderId = 1; |
const char* kValidUrl = "https://valid.example.com/foo/bar"; |
+// This timestamp is set to a time after the expiry timestamp of the expired |
+// tokens in this test, but before the expiry timestamp of the valid ones. |
+double kNowTimestamp = 1500000000; |
+ |
void EmptyCallback() {} |
} // namespace |
@@ -79,6 +84,12 @@ class ForeignFetchRequestHandlerTest : public testing::Test { |
kVersionId, context()->AsWeakPtr()); |
version_->set_foreign_fetch_scopes({kScope}); |
+ // Fix the time for testing to kNowTimestamp |
+ std::unique_ptr<base::SimpleTestClock> clock = |
+ base::MakeUnique<base::SimpleTestClock>(); |
+ clock->SetNow(base::Time::FromDoubleT(kNowTimestamp)); |
+ version_->SetClockForTesting(std::move(clock)); |
+ |
context()->storage()->LazyInitialize(base::Bind(&EmptyCallback)); |
base::RunLoop().RunUntilIdle(); |