File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,8 @@ public void CanInvokeInteropMethods()
107107 [ "invokeNewWithClassConstructorAsync.dataProperty" ] = "abraka" ,
108108 [ "invokeNewWithClassConstructorAsync.function" ] = "6" ,
109109 [ "invokeNewWithNonConstructorAsync" ] = "Success" ,
110+ // Function reference tests
111+ [ "changeFunctionViaObjectReferenceAsync" ] = "42"
110112 } ;
111113
112114 var expectedSyncValues = new Dictionary < string , string >
@@ -171,6 +173,8 @@ public void CanInvokeInteropMethods()
171173 [ "invokeNewWithClassConstructor.dataProperty" ] = "abraka" ,
172174 [ "invokeNewWithClassConstructor.function" ] = "6" ,
173175 [ "invokeNewWithNonConstructor" ] = "Success" ,
176+ // Function reference tests
177+ [ "changeFunctionViaObjectReference" ] = "42"
174178 } ;
175179
176180 // Include the sync assertions only when running under WebAssembly
Original file line number Diff line number Diff line change 301301 InvokeNewTests ();
302302 }
303303
304+ await FunctionReferenceAsyncTests ();
305+
306+ if (shouldSupportSyncInterop )
307+ {
308+ FunctionReferenceTests ();
309+ }
310+
304311 Invocations = invocations ;
305312 DoneWithInterop = true ;
306313 }
601608 }
602609 }
603610
611+ private async Task FunctionReferenceAsyncTests ()
612+ {
613+ var funcRef = await JSRuntime .GetValueAsync <IJSObjectReference >(" jsInteropTests.nonConstructorFunction" );
614+ var testClassRef = await JSRuntime .InvokeNewAsync (" jsInteropTests.TestClass" , " abraka" );
615+ await testClassRef .SetValueAsync (" getTextLength" , funcRef );
616+ ReturnValues [" changeFunctionViaObjectReferenceAsync" ] = (await testClassRef .InvokeAsync <int >(" getTextLength" )).ToString ();
617+ }
618+
619+ private void FunctionReferenceTests ()
620+ {
621+ var inProcRuntime = ((IJSInProcessRuntime )JSRuntime );
622+
623+ var funcRef = inProcRuntime .GetValue <IJSObjectReference >(" jsInteropTests.nonConstructorFunction" );
624+ var testClassRef = inProcRuntime .InvokeNew (" jsInteropTests.TestClass" , " abraka" );
625+ testClassRef .SetValue (" getTextLength" , funcRef );
626+ ReturnValues [" changeFunctionViaObjectReference" ] = testClassRef .Invoke <int >(" getTextLength" ).ToString ();
627+ }
628+
604629 public class PassDotNetObjectByRefArgs
605630 {
606631 public string StringValue { get ; set ; }
You can’t perform that action at this time.
0 commit comments