Skip to content

Commit ed1763e

Browse files
committed
Add EvaluateScriptAsyncTests.ShouldTimeout test
Follow up to #4654
1 parent 56c9f3c commit ed1763e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

CefSharp.Test/Javascript/EvaluateScriptAsyncTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,5 +252,18 @@ public async Task CanEvaluateScriptAsyncWithEncodedStringArguments()
252252
output.WriteLine("{0} passes {1}", test, javascriptResponse.Result);
253253
}
254254
}
255+
256+
[Theory]
257+
[InlineData("(async () => { function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }; await sleep(2000); return true; })();")]
258+
public async Task ShouldTimeout(string script)
259+
{
260+
AssertInitialLoadComplete();
261+
262+
var exception = await Assert.ThrowsAsync<TaskCanceledException>(
263+
async () => await Browser.EvaluateScriptAsync(script, timeout: TimeSpan.FromMilliseconds(100)));
264+
265+
Assert.NotNull(exception);
266+
Assert.IsType<TaskCanceledException>(exception);
267+
}
255268
}
256269
}

0 commit comments

Comments
 (0)