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

Promise doesn't handle then-able result #260

Closed
RuralHunter opened this issue Oct 28, 2020 · 6 comments
Closed

Promise doesn't handle then-able result #260

RuralHunter opened this issue Oct 28, 2020 · 6 comments
Assignees

Comments

@RuralHunter
Copy link
Contributor

In real browser(Chrome), if the resolve function returns a then-able object(having then function), Promise.then handles it. But htmlunit fails to do so. Test case:

           var thenable={
                then: function(onFulfill, onReject) { onFulfill('fulfilled!'); },
                value: 'aaa'
            };
            var p = Promise.resolve(1);
            var p1=p.then(function(value) {
                //console.log(value);
                return thenable;
            });
            p1.then(function(value) {
                console.log(value);
            });

chrome outputs 'fulfilled!' but htmlunit outputs the thenable object.

@rbri
Copy link
Member

rbri commented Oct 28, 2020

Hi Rural,
any chance to make a bunch of test cases as PR for this?

@rbri
Copy link
Member

rbri commented Oct 28, 2020

Maybe you can take com.gargoylesoftware.htmlunit.javascript.host.PromiseTest.resolveThenables() as starting point

@RuralHunter
Copy link
Contributor Author

Ok, I will try.

RuralHunter added a commit to RuralHunter/htmlunit that referenced this issue Oct 29, 2020
@RuralHunter
Copy link
Contributor Author

PR created.

@rbri
Copy link
Member

rbri commented Oct 29, 2020

Hi @RuralHunter,

hopefully i have fixed your case. Please check the tests i wrote and feel free to add more test cases if you think there is something missing.
Will make a new snapshot as soon as the CI build is green.

@rbri rbri self-assigned this Oct 29, 2020
@rbri rbri added this to Waiting for Feedback in HtmlUnit - RBRi Oct 29, 2020
@rbri
Copy link
Member

rbri commented Oct 30, 2020

Have added on more test.

Will close this - please open a new one if you have more problems. Will work on you other issues later.
Thanks for the contribution.

@rbri rbri closed this as completed Oct 30, 2020
@rbri rbri removed this from Waiting for Feedback in HtmlUnit - RBRi Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants