Skip to content

Commit

Permalink
Add EvaluateScriptAsyncTests.ShouldTimeout test
Browse files Browse the repository at this point in the history
Follow up to #4654
  • Loading branch information
amaitland committed Dec 16, 2023
1 parent 56c9f3c commit ed1763e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions CefSharp.Test/Javascript/EvaluateScriptAsyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,18 @@ public async Task CanEvaluateScriptAsyncWithEncodedStringArguments()
output.WriteLine("{0} passes {1}", test, javascriptResponse.Result);
}
}

[Theory]
[InlineData("(async () => { function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }; await sleep(2000); return true; })();")]
public async Task ShouldTimeout(string script)
{
AssertInitialLoadComplete();

var exception = await Assert.ThrowsAsync<TaskCanceledException>(
async () => await Browser.EvaluateScriptAsync(script, timeout: TimeSpan.FromMilliseconds(100)));

Assert.NotNull(exception);
Assert.IsType<TaskCanceledException>(exception);
}
}
}

0 comments on commit ed1763e

Please sign in to comment.