Index: third_party/WebKit/Source/web/tests/scheduler/ThrottlingTest.cpp |
diff --git a/third_party/WebKit/Source/web/tests/scheduler/ThrottlingTest.cpp b/third_party/WebKit/Source/web/tests/scheduler/ThrottlingTest.cpp |
index cdb41a92783e04ebbe2d414263d6fa3cd481e907..f3aede4f9308b64b2d890aad7b77ded880326b42 100644 |
--- a/third_party/WebKit/Source/web/tests/scheduler/ThrottlingTest.cpp |
+++ b/third_party/WebKit/Source/web/tests/scheduler/ThrottlingTest.cpp |
@@ -66,4 +66,35 @@ TEST_F(DisableBackgroundThrottlingIsRespectedTest, |
"called f", "called f")); |
} |
+class BackgroundRendererThrottlingTest : public SimTest {}; |
+ |
+TEST_F(BackgroundRendererThrottlingTest, BackgroundRenderersAreThrottled) { |
+ SimRequest main_resource("https://example.com/", "text/html"); |
+ |
+ LoadURL("https://example.com/"); |
+ |
+ main_resource.Complete( |
+ "(<script>" |
+ " function f(repetitions) {" |
+ " if (repetitions == 0) return;" |
+ " console.log('called f');" |
+ " setTimeout(f, 10, repetitions - 1);" |
+ " }" |
+ " setTimeout(f, 10, 3);" |
+ "</script>)"); |
+ |
+ Platform::Current() |
+ ->CurrentThread() |
+ ->Scheduler() |
+ ->GetRendererSchedulerForTest() |
+ ->OnRendererBackgrounded(); |
+ |
+ // Make sure that we run a task once a second. |
+ for (int i = 0; i < 3; ++i) { |
+ testing::RunDelayedTasks(1000); |
+ EXPECT_THAT(ConsoleMessages(), ElementsAre("called f")); |
+ ConsoleMessages().clear(); |
+ } |
+} |
+ |
} // namespace blink |