Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser] enable JsImportTaskTypes test #88728

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1505,16 +1505,20 @@ public async Task JsImportSleep()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/77334")]
public async Task JsImportTaskTypes()
{
object a = new object();
Exception e = new Exception();
JSObject j = JSHost.GlobalThis;
Assert.Equal("test", await JavaScriptTestHelper.echopromise_String("test"));
Assert.Same(a, await JavaScriptTestHelper.echopromise_Object(a));
Assert.Same(e, await JavaScriptTestHelper.echopromise_Exception(e));
Assert.Same(j, await JavaScriptTestHelper.echopromise_JSObject(j));
for(int i=0;i<100;i++)
{
object a = new object();
Exception e = new Exception();
JSObject j = JSHost.GlobalThis;
Assert.Equal("test", await JavaScriptTestHelper.echopromise_String("test"));
Assert.Same(a, await JavaScriptTestHelper.echopromise_Object(a));
Assert.Same(e, await JavaScriptTestHelper.echopromise_Exception(e));
Assert.Same(j, await JavaScriptTestHelper.echopromise_JSObject(j));
GC.Collect();
await Task.Delay(10);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious. Is an explicit GC.Collect needed if we have a delay here, that should effectively yield?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this will yield to browser main loop, which I hope would give it a chance to run JS GC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delay(1) will also work (only 0 completes immediately) I think Task.Yield() should work as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW: on V8 the setTimeout value is always ignored.

}
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ export function invokeStructClassRecords(arg1) {
}

export function echopromise(arg1) {
if (globalThis.gc) {
//console.log('globalThis.gc');
globalThis.gc();
}
return new Promise(resolve => setTimeout(() => resolve(arg1), 0));
}

Expand Down
Loading