Skip to content

Commit a697edb

Browse files
committed
Add BooleanLocalValue
1 parent 76183eb commit a697edb

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

dotnet/src/webdriver/BiDi/Modules/Script/LocalValue.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace OpenQA.Selenium.BiDi.Modules.Script;
2727
[JsonDerivedType(typeof(StringLocalValue), "string")]
2828
[JsonDerivedType(typeof(NullLocalValue), "null")]
2929
[JsonDerivedType(typeof(UndefinedLocalValue), "undefined")]
30+
[JsonDerivedType(typeof(BooleanLocalValue), "boolean")]
3031
[JsonDerivedType(typeof(ChannelLocalValue), "channel")]
3132
[JsonDerivedType(typeof(ArrayLocalValue), "array")]
3233
[JsonDerivedType(typeof(DateLocalValue), "date")]
@@ -84,6 +85,8 @@ public record NullLocalValue : PrimitiveProtocolLocalValue;
8485

8586
public record UndefinedLocalValue : PrimitiveProtocolLocalValue;
8687

88+
public record BooleanLocalValue(bool Value) : PrimitiveProtocolLocalValue;
89+
8790
public record ChannelLocalValue(ChannelLocalValue.ChannelProperties Value) : LocalValue
8891
{
8992
// TODO: Revise why we need it

dotnet/test/common/BiDi/Script/CallFunctionLocalValueTest.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@ await context.Script.CallFunctionAsync($$"""
5656
}, Throws.Nothing);
5757
}
5858

59+
[Test]
60+
public void CanCallFunctionWithArgumentBoolean()
61+
{
62+
var arg = new BooleanLocalValue(true);
63+
Assert.That(async () =>
64+
{
65+
await context.Script.CallFunctionAsync($$"""
66+
(arg) => {
67+
if (arg !== true) {
68+
throw new Error("Assert failed: " + arg);
69+
}
70+
}
71+
""", false, new() { Arguments = [arg] });
72+
}, Throws.Nothing);
73+
}
74+
5975
[Test]
6076
public void CanCallFunctionWithArgumentEmptyString()
6177
{

0 commit comments

Comments
 (0)