|
167 | 167 | ReturnValues["invokeAsyncThrowsSerializingCircularStructure"] = $"Failure: {ex.Message}";
|
168 | 168 | }
|
169 | 169 |
|
170 |
| - try |
171 |
| - { |
172 |
| - var undefinedJsObjectReference = await JSRuntime.InvokeAsync<IJSObjectReference>("returnUndefined"); |
173 |
| - ReturnValues["invokeAsyncThrowsUndefinedJSObjectReference"] = undefinedJsObjectReference is null ? "Failure: null" : "Failure: not null"; |
174 |
| - } |
175 |
| - catch (JSException) |
176 |
| - { |
177 |
| - ReturnValues["invokeAsyncThrowsUndefinedJSObjectReference"] = "Success"; |
178 |
| - } |
179 |
| - catch (Exception ex) |
180 |
| - { |
181 |
| - ReturnValues["invokeAsyncThrowsUndefinedJSObjectReference"] = $"Failure: {ex.Message}"; |
182 |
| - } |
183 |
| - |
184 |
| - try |
185 |
| - { |
186 |
| - var nullJsObjectReference = await JSRuntime.InvokeAsync<IJSObjectReference>("returnNull"); |
187 |
| - ReturnValues["invokeAsyncThrowsNullJSObjectReference"] = nullJsObjectReference is null ? "Failure: null" : "Failure: not null"; |
188 |
| - } |
189 |
| - catch (JSException) |
190 |
| - { |
191 |
| - ReturnValues["invokeAsyncThrowsNullJSObjectReference"] = "Success"; |
192 |
| - } |
193 |
| - catch (Exception ex) |
194 |
| - { |
195 |
| - ReturnValues["invokeAsyncThrowsNullJSObjectReference"] = $"Failure: {ex.Message}"; |
196 |
| - } |
197 | 170 |
|
198 | 171 | var jsObjectReference = await JSRuntime.InvokeAsync<IJSObjectReference>("returnJSObjectReference");
|
199 | 172 | ReturnValues["jsObjectReference.identity"] = await jsObjectReference.InvokeAsync<string>("identity", "Invoked from JSObjectReference");
|
|
308 | 281 | FunctionReferenceTests();
|
309 | 282 | }
|
310 | 283 |
|
| 284 | + await JSObjectReferenceAsyncTests(); |
| 285 | + |
| 286 | + if (shouldSupportSyncInterop) |
| 287 | + { |
| 288 | + JSObjectReferenceTests(); |
| 289 | + } |
| 290 | + |
311 | 291 | Invocations = invocations;
|
312 | 292 | DoneWithInterop = true;
|
313 | 293 | }
|
|
394 | 374 | ReturnValues["invokeThrowsSerializingCircularStructure"] = $"Failure: {ex.Message}";
|
395 | 375 | }
|
396 | 376 |
|
397 |
| - try |
398 |
| - { |
399 |
| - var undefinedJsObjectReference = inProcRuntime.Invoke<IJSObjectReference>("returnUndefined"); |
400 |
| - ReturnValues["invokeThrowsUndefinedJSObjectReference"] = undefinedJsObjectReference is null ? "Failure: null" : "Failure: not null"; |
401 |
| - } |
402 |
| - catch (JSException) |
403 |
| - { |
404 |
| - ReturnValues["invokeThrowsUndefinedJSObjectReference"] = "Success"; |
405 |
| - } |
406 |
| - catch (Exception ex) |
407 |
| - { |
408 |
| - ReturnValues["invokeThrowsUndefinedJSObjectReference"] = $"Failure: {ex.Message}"; |
409 |
| - } |
410 |
| - |
411 |
| - try |
412 |
| - { |
413 |
| - var nullJsObjectReference = inProcRuntime.Invoke<IJSObjectReference>("returnNull"); |
414 |
| - ReturnValues["invokeThrowsNullJSObjectReference"] = nullJsObjectReference is null ? "Failure: null" : "Failure: not null"; |
415 |
| - } |
416 |
| - catch (JSException) |
417 |
| - { |
418 |
| - ReturnValues["invokeThrowsNullJSObjectReference"] = "Success"; |
419 |
| - } |
420 |
| - catch (Exception ex) |
421 |
| - { |
422 |
| - ReturnValues["invokeThrowsNullJSObjectReference"] = $"Failure: {ex.Message}"; |
423 |
| - } |
424 |
| - |
425 | 377 | var jsInProcObjectReference = inProcRuntime.Invoke<IJSInProcessObjectReference>("returnJSObjectReference");
|
426 | 378 | ReturnValues["jsInProcessObjectReference.identity"] = jsInProcObjectReference.Invoke<string>("identity", "Invoked from JSInProcessObjectReference");
|
427 | 379 |
|
|
626 | 578 | ReturnValues["changeFunctionViaObjectReference"] = testClassRef.Invoke<int>("getTextLength").ToString();
|
627 | 579 | }
|
628 | 580 |
|
| 581 | + private async Task JSObjectReferenceAsyncTests() |
| 582 | + { |
| 583 | + try |
| 584 | + { |
| 585 | + var undefinedJsObjectReference = await JSRuntime.InvokeAsync<IJSObjectReference>("jsInteropTests.returnUndefined"); |
| 586 | + ReturnValues["invokeAsyncUndefinedJSObjectReference"] = undefinedJsObjectReference is null ? "Success" : $"Failure: not null (type: {undefinedJsObjectReference.GetType().FullName})"; |
| 587 | + } |
| 588 | + catch (JSException ex) |
| 589 | + { |
| 590 | + ReturnValues["invokeAsyncUndefinedJSObjectReference"] = $"Failure: {ex.Message}"; |
| 591 | + } |
| 592 | + catch (Exception ex) |
| 593 | + { |
| 594 | + ReturnValues["invokeAsyncUndefinedJSObjectReference"] = $"Failure: {ex.Message}"; |
| 595 | + } |
| 596 | + |
| 597 | + try |
| 598 | + { |
| 599 | + var nullJsObjectReference = await JSRuntime.InvokeAsync<IJSObjectReference>("jsInteropTests.returnNull"); |
| 600 | + ReturnValues["invokeAsyncNullJSObjectReference"] = nullJsObjectReference is null ? "Success" : $"Failure: not null (type: {nullJsObjectReference.GetType().FullName})"; |
| 601 | + } |
| 602 | + catch (JSException ex) |
| 603 | + { |
| 604 | + ReturnValues["invokeAsyncNullJSObjectReference"] = $"Failure: {ex.Message}"; |
| 605 | + } |
| 606 | + catch (Exception ex) |
| 607 | + { |
| 608 | + ReturnValues["invokeAsyncNullJSObjectReference"] = $"Failure: {ex.Message}"; |
| 609 | + } |
| 610 | + |
| 611 | + try |
| 612 | + { |
| 613 | + var nullVariableJsObjectReference = await JSRuntime.GetValueAsync<IJSObjectReference>("jsInteropTests.testObject.nullProperty"); |
| 614 | + ReturnValues["invokeAsyncNullFromVariableJSObjectReference"] = nullVariableJsObjectReference is null ? "Success" : $"Failure: not null (type: {nullVariableJsObjectReference.GetType().FullName})"; |
| 615 | + } |
| 616 | + catch (JSException ex) |
| 617 | + { |
| 618 | + ReturnValues["invokeAsyncNullFromVariableJSObjectReference"] = $"Failure: {ex.Message}"; |
| 619 | + } |
| 620 | + catch (Exception ex) |
| 621 | + { |
| 622 | + ReturnValues["invokeAsyncNullFromVariableJSObjectReference"] = $"Failure: {ex.Message}"; |
| 623 | + } |
| 624 | + |
| 625 | + try |
| 626 | + { |
| 627 | + await JSRuntime.GetValueAsync<IJSObjectReference>("nonexistend"); |
| 628 | + } |
| 629 | + catch (JSException) |
| 630 | + { |
| 631 | + ReturnValues["invokeAsyncNonExistentJSObjectReference"] = "Success"; |
| 632 | + } |
| 633 | + catch (Exception ex) |
| 634 | + { |
| 635 | + ReturnValues["invokeAsyncNonExistentJSObjectReference"] = $"Failure: {ex.Message}"; |
| 636 | + } |
| 637 | + } |
| 638 | + |
| 639 | + private void JSObjectReferenceTests() |
| 640 | + { |
| 641 | + var inProcRuntime = ((IJSInProcessRuntime)JSRuntime); |
| 642 | + |
| 643 | + try |
| 644 | + { |
| 645 | + var undefinedJsObjectReference = inProcRuntime.Invoke<IJSObjectReference>("returnUndefined"); |
| 646 | + ReturnValues["invokeUndefinedJSObjectReference"] = undefinedJsObjectReference is null ? "Success" : $"Failure: not null (type: {undefinedJsObjectReference.GetType().FullName})"; |
| 647 | + } |
| 648 | + catch (JSException ex) |
| 649 | + { |
| 650 | + ReturnValues["invokeUndefinedJSObjectReference"] = $"Failure: {ex.Message}"; |
| 651 | + } |
| 652 | + catch (Exception ex) |
| 653 | + { |
| 654 | + ReturnValues["invokeUndefinedJSObjectReference"] = $"Failure: {ex.Message}"; |
| 655 | + } |
| 656 | + |
| 657 | + try |
| 658 | + { |
| 659 | + var nullJsObjectReference = inProcRuntime.Invoke<IJSObjectReference>("returnNull"); |
| 660 | + ReturnValues["invokeNullJSObjectReference"] = nullJsObjectReference is null ? "Success" : $"Failure: not null (type: {nullJsObjectReference.GetType().FullName})"; |
| 661 | + } |
| 662 | + catch (JSException ex) |
| 663 | + { |
| 664 | + ReturnValues["invokeNullJSObjectReference"] = $"Failure: {ex.Message}"; |
| 665 | + } |
| 666 | + catch (Exception ex) |
| 667 | + { |
| 668 | + ReturnValues["invokeNullJSObjectReference"] = $"Failure: {ex.Message}"; |
| 669 | + } |
| 670 | + |
| 671 | + try |
| 672 | + { |
| 673 | + var nullVariableJsObjectReference = inProcRuntime.GetValue<IJSObjectReference>("jsInteropTests.testObject.nullProperty"); |
| 674 | + ReturnValues["invokeNullFromVariableJSObjectReference"] = nullVariableJsObjectReference is null ? "Success" : $"Failure: not null (type: {nullVariableJsObjectReference.GetType().FullName})"; |
| 675 | + } |
| 676 | + catch (JSException ex) |
| 677 | + { |
| 678 | + ReturnValues["invokeNullFromVariableJSObjectReference"] = $"Failure: {ex.Message}"; |
| 679 | + } |
| 680 | + catch (Exception ex) |
| 681 | + { |
| 682 | + ReturnValues["invokeNullFromVariableJSObjectReference"] = $"Failure: {ex.Message}"; |
| 683 | + } |
| 684 | + |
| 685 | + try |
| 686 | + { |
| 687 | + inProcRuntime.GetValue<IJSObjectReference>("nonexistend"); |
| 688 | + } |
| 689 | + catch (JSException) |
| 690 | + { |
| 691 | + ReturnValues["invokeNonExistentJSObjectReference"] = "Success"; |
| 692 | + } |
| 693 | + catch (Exception ex) |
| 694 | + { |
| 695 | + ReturnValues["invokeNonExistentJSObjectReference"] = $"Failure: {ex.Message}"; |
| 696 | + } |
| 697 | + } |
| 698 | + |
629 | 699 | public class PassDotNetObjectByRefArgs
|
630 | 700 | {
|
631 | 701 | public string StringValue { get; set; }
|
|
0 commit comments