Skip to content

Commit 2a14e1f

Browse files
authored
fix(clock): allow default constructor in Clock.InstallAsync() (#3138)
1 parent 9c528d1 commit 2a14e1f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Playwright.Tests/PageClockTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,5 +537,15 @@ public async Task RunForShouldNotRunNestedImmediateFromMicrotask()
537537
Assert.AreEqual(2, _calls.Count);
538538
Assert.AreEqual("inner", _calls[1][0]);
539539
}
540+
541+
[PlaywrightTest("page-clock.spec.ts", "")]
542+
public async Task ShouldHavePausedClockAfterInstall()
543+
{
544+
await Page.Clock.InstallAsync();
545+
await Page.GotoAsync("data:text/html,");
546+
var currentTime = await Page.EvaluateAsync<long>("Date.now()");
547+
await Page.WaitForTimeoutAsync(100);
548+
var newTime = await Page.EvaluateAsync<long>("Date.now()");
549+
}
540550
}
541551
}

src/Playwright/Core/Clock.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ internal class Clock(BrowserContext browserContext) : IClock
3232
{
3333
public async Task InstallAsync(ClockInstallOptions options = null)
3434
{
35+
options ??= new();
3536
Dictionary<string, object> args = null;
3637
if ((options.Time ?? options.TimeString) != null)
3738
{

0 commit comments

Comments
 (0)