Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: third_party/WebKit/Source/web/tests/scheduler/ThrottlingTest.cpp

Issue 2896603002: [scheduler] Move task alignment into WakeUpBudgetPool. (Closed)
Patch Set: no iostream Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698