Skip to content

fix(http):fix jsonp callbackname is undefined #14270

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

Closed
wants to merge 2 commits into from

Conversation

doxiaodong
Copy link

fix #14267

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@doxiaodong doxiaodong force-pushed the jsonp branch 2 times, most recently from b670a34 to 471a8e6 Compare February 3, 2017 09:14
@googlebot
Copy link

CLAs look good, thanks!

@DzmitryShylovich
Copy link
Contributor

need to add a test to ensure that callback is actually executed to prevent such situations in the future

@doxiaodong
Copy link
Author

I update the callback name test, it can be any function name.

@@ -32,17 +30,13 @@ export class BrowserJsonp {

nextRequestID(): string { return `__req${_nextRequestId++}`; }

requestCallback(id: string): string { return `${JSONP_HOME}${id}_finished`; }
requestCallback(id: string): string { return _getJsonpCallbackName(id); }
Copy link
Contributor

Choose a reason for hiding this comment

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

revert

@@ -70,10 +70,11 @@ export function main() {
expect(instance).toBeAnInstanceOf(JSONPConnection);
});

it('callback name should not contain dots', () => {
it('callback name should be a function name', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

as we saw testing callback name doesn't actually verify anything.
Need a test for Uncaught ReferenceError: __ng_jsonp____req0_finished is not defined arror

Copy link
Author

Choose a reason for hiding this comment

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

this callback name can be any validate function name, and I think it's enough. What to cause __ng_jsonp____req0_finished is not defined is the error of the data https://github.com/angular/angular/blob/master/modules/playground/src/jsonp/people.json#L2

@alxhub alxhub self-requested a review February 10, 2017 20:20
@DzmitryShylovich
Copy link
Contributor

DzmitryShylovich commented Feb 10, 2017

@alxhub this pr will add callbacks to the global namespace (window). It may be very unexpected :)
@mhevery said he will revert 9e5617e (commit that introduced the bug)
and it's already fixed in 4.0 so I don't think you should merge this

@alxhub
Copy link
Member

alxhub commented Feb 10, 2017

I actually think it's okay, and the behavior is correct.

The callbacks are only there while the request is in progress, and some APIs have issues with dots in the callback names.

@DzmitryShylovich
Copy link
Contributor

ok :)

@doxiaodong
Copy link
Author

so, If I need to resolve the conflicts?

@doxiaodong
Copy link
Author

how about this?

@DzmitryShylovich
Copy link
Contributor

@doxiaodong it will be fixed in the new http module in 4.0
so I think you can close this

@splincode
Copy link
Contributor

@doxiaodong What is the status of the task? @angular/http is deprecated, please closed PR

@doxiaodong
Copy link
Author

ok

@doxiaodong doxiaodong closed this Mar 1, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
6 participants