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

Add tests for body property handling in Request constructor #4612

Merged
merged 3 commits into from
Jan 27, 2017
Merged

Add tests for body property handling in Request constructor #4612

merged 3 commits into from
Jan 27, 2017

Conversation

yutakahirano
Copy link
Contributor

This change is for whatwg/fetch#425 and whatwg/fetch#458.

@wpt-pr-bot
Copy link
Collaborator

Notifying @jdm and @youennf. (Learn how reviewing works.)

@jdm
Copy link
Contributor

jdm commented Jan 24, 2017

These new tests look good to me. I'm not going to merge them until someone else says that they're testing the cases we care about for the fetch PRs mentioned in the original comment.

@yutakahirano
Copy link
Contributor Author

cc: @annevk

assert_true(bodyRequest.bodyUsed , "bodyUsed is true when request is disturbed");
assert_equals(bodyRequest.body, originalBody, "body should not change");
assert_not_equals(originalBody, undefined, "body should not be undefined");
assert_not_equals(originalBody, null, "body should not be null");
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a test here about what it should be? Either instanceof/typeof or some such?

And perhaps we should also have a test where the initial request does not have a body?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, I found that I forgot to expose body property on Request. I'll make another fetch spec PR...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anyway, I added some assertions.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe just add that to the existing PR? Then we can use these tests for both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will do.

Copy link
Member

Choose a reason for hiding this comment

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

Never mind, what you did is fine.

assert_false(bodyRequest.bodyUsed , "bodyUsed is false when request is not disturbed");
var requestFromRequest = new Request(bodyRequest);
assert_true(bodyRequest.bodyUsed , "bodyUsed is true when request is disturbed");
assert_equals(bodyRequest.body, originalBody, "body should not change");
assert_not_equals(originalBody, undefined, "body should not be undefined");
assert_not_equals(originalBody, null, "body should not be null");
}, "Input request used for creating new request became disturbed");
Copy link
Member

Choose a reason for hiding this comment

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

This test is basically duplicated no as a promise_test, no? Maybe it's better to just remove it? Or am I missing something subtle?

Copy link
Member

Choose a reason for hiding this comment

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

Oh wait, the difference is that the promise_test passes a body. Disregard the above comment please.

@annevk annevk merged commit a13d74a into web-platform-tests:master Jan 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants