mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-03 23:12:42 +00:00
ca905157f7
Issue #4276
46 lines
1.6 KiB
HTML
46 lines
1.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<title>Binding Test Single</title>
|
|
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.10.0.css">
|
|
</head>
|
|
<body>
|
|
<div id="qunit"></div>
|
|
<div id="qunit-fixture"></div>
|
|
<script src="https://code.jquery.com/qunit/qunit-2.10.0.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
QUnit.module('BindingTestSingle', (hooks) =>
|
|
{
|
|
hooks.before(async () =>
|
|
{
|
|
await CefSharp.BindObjectAsync("boundAsync");
|
|
});
|
|
|
|
QUnit.test("Pass callback(promise) that is conditionally invoked:", async (assert) =>
|
|
{
|
|
let callback = function (msg)
|
|
{
|
|
return new Promise((resolve, reject) =>
|
|
{
|
|
setTimeout(() =>
|
|
{
|
|
resolve(msg);
|
|
}, 300);
|
|
});
|
|
};
|
|
|
|
const expectedResult = "Callback has not been invoked";
|
|
const actualResult = await boundAsync.javascriptOptionalCallbackEvalPromise(false, expectedResult, callback);
|
|
assert.equal(expectedResult, actualResult, "Echo response after promise execution");
|
|
|
|
const expectedSecondResult = "Callback has been invoked";
|
|
const actualSecondResult = await boundAsync.javascriptOptionalCallbackEvalPromise(true, expectedSecondResult, callback);
|
|
assert.equal(expectedSecondResult, actualSecondResult, "Echo response after promise execution");
|
|
});
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|