Support JS invocations that return undefined
This commit is contained in:
parent
d1069e2d1e
commit
fe6105a902
|
|
@ -37,7 +37,7 @@ namespace MonoSanityClient
|
||||||
return $".NET got exception: {result}";
|
return $".NET got exception: {result}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $".NET received: {result}";
|
return $".NET received: {(result ?? "(NULL)")}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace Microsoft.Blazor.Browser
|
||||||
{
|
{
|
||||||
public Renderer()
|
public Renderer()
|
||||||
{
|
{
|
||||||
WebAssembly.Runtime.EvaluateJavaScript("console.log('Renderer'), 'done'");
|
WebAssembly.Runtime.EvaluateJavaScript("console.log('Renderer')");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,26 @@ namespace Microsoft.Blazor.E2ETest.Tests
|
||||||
Assert.Contains("at triggerJsException", result);
|
Assert.Contains("at triggerJsException", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CanEvaluateJsExpressionThatResultsInNull()
|
||||||
|
{
|
||||||
|
Navigate("/", noReload: true);
|
||||||
|
SetValue(Browser, "callJsEvalExpression", "null");
|
||||||
|
Browser.FindElement(By.CssSelector("#callJs button")).Click();
|
||||||
|
var result = GetValue(Browser, "callJsResult");
|
||||||
|
Assert.Equal(".NET received: (NULL)", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CanEvaluateJsExpressionThatResultsInUndefined()
|
||||||
|
{
|
||||||
|
Navigate("/", noReload: true);
|
||||||
|
SetValue(Browser, "callJsEvalExpression", "console.log('Not returning anything')");
|
||||||
|
Browser.FindElement(By.CssSelector("#callJs button")).Click();
|
||||||
|
var result = GetValue(Browser, "callJsResult");
|
||||||
|
Assert.Equal(".NET received: (NULL)", result);
|
||||||
|
}
|
||||||
|
|
||||||
private static string GetValue(IWebDriver webDriver, string elementId)
|
private static string GetValue(IWebDriver webDriver, string elementId)
|
||||||
{
|
{
|
||||||
var element = webDriver.FindElement(By.Id(elementId));
|
var element = webDriver.FindElement(By.Id(elementId));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue