fix(http): remove dots from jsonp callback name (#13219)
PR Close #13219
This commit is contained in:
parent
bc1320d926
commit
9e5617e41e
|
@ -32,23 +32,23 @@ export class BrowserJsonp {
|
||||||
|
|
||||||
nextRequestID(): string { return `__req${_nextRequestId++}`; }
|
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();
|
const connections = _getJsonpConnections();
|
||||||
connections[id] = connection;
|
connections[id] = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeConnection(id: string) {
|
removeConnection(id: string): void {
|
||||||
const connections = _getJsonpConnections();
|
const connections = _getJsonpConnections();
|
||||||
connections[id] = null;
|
connections[id] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach the <script> element to the DOM
|
// 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
|
// Remove <script> element from the DOM
|
||||||
cleanup(node: any) {
|
cleanup(node: any): void {
|
||||||
if (node.parentNode) {
|
if (node.parentNode) {
|
||||||
node.parentNode.removeChild(<Node>(node));
|
node.parentNode.removeChild(<Node>(node));
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,11 @@ export function main() {
|
||||||
expect(instance).toBeAnInstanceOf(JSONPConnection);
|
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', () => {
|
describe('JSONPConnection', () => {
|
||||||
it('should use the injected BaseResponseOptions to create the response',
|
it('should use the injected BaseResponseOptions to create the response',
|
||||||
|
|
Loading…
Reference in New Issue