forked from cefsharp/CefSharp
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Async JavascriptBinding - Add support for returning Task
Rewrite MethodRunnerQueue to use Func instead of task as it simplified debugging, for the old code path rather than running the Tasks sync we just execute the fun For the new code path the Func is executed, if the Result is a generic Task we wait for it's completion If the task is not generic then we return immediately This is only enabled when CefSharpSettings.ConcurrentTaskExecution = true; Additional tests will be required before this is production ready
- Loading branch information
Showing
6 changed files
with
114 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,55 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | ||
<html> | ||
<head> | ||
<title>Binding Test</title> | ||
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.4.1.css"> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<script src="https://code.jquery.com/qunit/qunit-2.4.1.js"></script> | ||
|
||
<script type="text/javascript"> | ||
<head> | ||
<title>Binding Test</title> | ||
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.4.1.css"> | ||
</head> | ||
<body> | ||
<div> | ||
These tests require CefSharpSettings.ConcurrentTaskExecution = true; | ||
Which by default is set to false | ||
</div> | ||
|
||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<script src="https://code.jquery.com/qunit/qunit-2.4.1.js"></script> | ||
|
||
<script type="text/javascript"> | ||
(async () => | ||
{ | ||
await CefSharp.BindObjectAsync("boundAsync", "bound"); | ||
await CefSharp.BindObjectAsync("boundAsync"); | ||
|
||
QUnit.test( "Struct Test:", function( assert ) | ||
QUnit.test("ReturnTaskStringAsync:", function (assert) | ||
{ | ||
var asyncCallback = assert.async(); | ||
|
||
//Returns a Struct | ||
boundAsync.returnObject('CefSharp Struct Test').then(function (actualResult) | ||
boundAsync.returnTaskStringAsync().then(function (actualResult) | ||
{ | ||
const expectedResult = 'CefSharp Struct Test'; | ||
const expectedResult = 'ReturnTaskStringAsync'; | ||
|
||
assert.equal(expectedResult, actualResult.Value, "Return class " + expectedResult); | ||
assert.equal(expectedResult, actualResult, "Return string " + expectedResult); | ||
|
||
asyncCallback(); | ||
}); | ||
}); | ||
}); | ||
|
||
QUnit.test( "Class Test:", function( assert ) | ||
QUnit.test("VoidReturnAsync Test:", function (assert) | ||
{ | ||
var asyncCallback = assert.async(); | ||
|
||
//Returns a class | ||
boundAsync.returnClass('CefSharp Class Test').then(function (actualResult) | ||
boundAsync.voidReturnAsync().then(function (actualResult) | ||
{ | ||
const expectedResult = 'CefSharp Class Test'; | ||
const expectedResult = null; | ||
|
||
assert.equal(expectedResult, actualResult.Value, "Return class " + expectedResult); | ||
assert.equal(expectedResult, actualResult, "Return null"); | ||
|
||
asyncCallback(); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
})(); | ||
</script> | ||
</script> | ||
|
||
</body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters