fix(http): remove dots from jsonp callback name (#13219)

PR Close #13219
This commit is contained in:
Dzmitry Shylovich 2016-12-03 21:42:38 +03:00 committed by Miško Hevery
parent bc1320d926
commit 9e5617e41e
2 changed files with 10 additions and 5 deletions

View File

@ -32,23 +32,23 @@ export class BrowserJsonp {
nextRequestID(): string { return `__req${_nextRequestId++}`; }
requestCallback(id: string): string { return `${JSONP_HOME}.${id}.finished`; }
requestCallback(id: string): string { return `${JSONP_HOME}${id}_finished`; }
exposeConnection(id: string, connection: any) {
exposeConnection(id: string, connection: any): void {
const connections = _getJsonpConnections();
connections[id] = connection;
}
removeConnection(id: string) {
removeConnection(id: string): void {
const connections = _getJsonpConnections();
connections[id] = null;
}
// Attach the <script> element to the DOM
send(node: any) { document.body.appendChild(<Node>(node)); }
send(node: any): void { document.body.appendChild(<Node>(node)); }
// Remove <script> element from the DOM
cleanup(node: any) {
cleanup(node: any): void {
if (node.parentNode) {
node.parentNode.removeChild(<Node>(node));
}

View File

@ -70,6 +70,11 @@ export function main() {
expect(instance).toBeAnInstanceOf(JSONPConnection);
});
it('callback name should not contain dots', () => {
const domJsonp = new MockBrowserJsonp();
const callback: string = domJsonp.requestCallback(domJsonp.nextRequestID());
expect(callback.indexOf('.') === -1).toBeTruthy();
});
describe('JSONPConnection', () => {
it('should use the injected BaseResponseOptions to create the response',