Skip to content

Commit c97fd75

Browse files
authored
Merge aca4164 into d4a9e20
2 parents d4a9e20 + aca4164 commit c97fd75

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

CefSharp.BrowserSubprocess.Core/Serialization/V8Serialization.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,13 @@ namespace CefSharp
5959
else if (obj->IsArray())
6060
{
6161
int arrLength = obj->GetArrayLength();
62-
std::vector<CefString> keys;
6362
auto array = CefListValue::Create();
64-
if (arrLength > 0 && obj->GetKeys(keys))
63+
if (arrLength > 0)
6564
{
6665
for (int i = 0; i < arrLength; i++)
6766
{
68-
SerializeV8Object(obj->GetValue(keys[i]), array, i, callbackRegistry, seen);
67+
SerializeV8Object(obj->GetValue(i), array, i, callbackRegistry, seen);
6968
}
70-
7169
}
7270

7371
list->SetList(index, array);

CefSharp.Test/JavascriptBinding/IntegrationTestFacts.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,5 +230,28 @@ public async Task CanCallCefSharpBindObjectAsyncWithoutParams()
230230
Assert.Equal(JavascriptObjectRepository.AllObjects, evt.Arguments.ObjectName);
231231
}
232232
}
233+
234+
[Fact]
235+
public async Task CanSerializePartiallyEmptyArrays()
236+
{
237+
using (var browser = new ChromiumWebBrowser(CefExample.HelloWorldUrl))
238+
{
239+
var testCases = new[]
240+
{
241+
("[1,2,,5]", new object[] { 1, 2, null, 5 }),
242+
("[1,2,,]", new object[] { 1, 2, null }),
243+
("[,2,3]", new object[] { null, 2, 3 }),
244+
("[,2,,3,,4,,,,5,,,]", new object[] {null, 2, null, 3, null, 4, null, null, null, 5, null, null })
245+
};
246+
await browser.LoadUrlAsync();
247+
foreach (var testCase in testCases)
248+
{
249+
var result = await browser.EvaluateScriptAsync(testCase.Item1);
250+
251+
Assert.True(result.Success);
252+
Assert.Equal(testCase.Item2, result.Result);
253+
}
254+
}
255+
}
233256
}
234257
}

0 commit comments

Comments
 (0)