diff --git a/packages/firestore/src/platform/browser/webchannel_connection.ts b/packages/firestore/src/platform/browser/webchannel_connection.ts index c7eeec0f7f1..7939b789b6f 100644 --- a/packages/firestore/src/platform/browser/webchannel_connection.ts +++ b/packages/firestore/src/platform/browser/webchannel_connection.ts @@ -23,6 +23,7 @@ import { WebChannelError, WebChannelOptions, FetchXmlHttpFactory, + Integer, XhrIo, getStatEventTarget, EventTarget, @@ -95,12 +96,25 @@ export class WebChannelConnection extends RestConnection { break; case ErrorCode.HTTP_ERROR: const status = xhr.getStatus(); + + const integer1 = new Integer([1, 2, 3], 1); + const integer2 = new Integer([3, 2, 1], 1); + const integer3 = integer1.add(integer2); + const integer4 = integer3.multiply(integer2); + const integer5 = integer4.modulo(integer3); + const val1 = integer5.compare(integer4); + const val2 = integer5.toString(); + const val3 = integer5.getBits(1234); + const val4 = Integer.fromNumber(4321).toNumber(); + const val5 = Integer.fromString(rpcName).toNumber(); + logDebug( LOG_TAG, `RPC '${rpcName}' ${streamId} failed with status:`, status, 'response text:', - xhr.getResponseText() + xhr.getResponseText(), + `${val1}${val2}${val3}${val4}${val5}` ); if (status > 0) { let response = xhr.getResponseJson(); diff --git a/packages/webchannel-wrapper/src/index.d.ts b/packages/webchannel-wrapper/src/index.d.ts index 4a1f45f1d70..abddec83f06 100644 --- a/packages/webchannel-wrapper/src/index.d.ts +++ b/packages/webchannel-wrapper/src/index.d.ts @@ -136,3 +136,19 @@ export function getStatEventTarget(): EventTarget; export class FetchXmlHttpFactory { constructor(options: {}); } + +// See https://google.github.io/closure-library/api/goog.math.Integer.html +// Unit test are written in +// packages/firestore/test/unit/core/webchannel_wrapper.test.ts +export class Integer { + constructor(bits: Array, sign: number); + add(other: Integer): Integer; + multiply(other: Integer): Integer; + modulo(other: Integer): Integer; + compare(other: Integer): number; + toNumber(): number; + toString(opt_radix?: number): string; + getBits(index: number): number; + static fromNumber(value: number): Integer; + static fromString(str: string, opt_radix?: number): Integer; +} diff --git a/packages/webchannel-wrapper/src/index.js b/packages/webchannel-wrapper/src/index.js index c51f7d68ba3..0e70ab64438 100644 --- a/packages/webchannel-wrapper/src/index.js +++ b/packages/webchannel-wrapper/src/index.js @@ -78,6 +78,17 @@ goog.net.XhrIo.prototype['send'] = goog.net.XhrIo.prototype.send; goog.net.XhrIo.prototype['setWithCredentials'] = goog.net.XhrIo.prototype.setWithCredentials; +goog.require('goog.math.Integer'); +goog.math.Integer.prototype['add'] = goog.math.Integer.prototype.add; +goog.math.Integer.prototype['multiply'] = goog.math.Integer.prototype.multiply; +goog.math.Integer.prototype['modulo'] = goog.math.Integer.prototype.modulo; +goog.math.Integer.prototype['compare'] = goog.math.Integer.prototype.compare; +goog.math.Integer.prototype['toNumber'] = goog.math.Integer.prototype.toNumber; +goog.math.Integer.prototype['toString'] = goog.math.Integer.prototype.toString; +goog.math.Integer.prototype['getBits'] = goog.math.Integer.prototype.getBits; +goog.math.Integer['fromNumber'] = goog.math.Integer.fromNumber; +goog.math.Integer['fromString'] = goog.math.Integer.fromString; + module['exports']['createWebChannelTransport'] = goog.net.createWebChannelTransport; module['exports']['getStatEventTarget'] = @@ -89,3 +100,4 @@ module['exports']['Stat'] = goog.labs.net.webChannel.requestStats.Stat; module['exports']['FetchXmlHttpFactory'] = goog.net.FetchXmlHttpFactory; module['exports']['WebChannel'] = goog.net.WebChannel; module['exports']['XhrIo'] = goog.net.XhrIo; +module['exports']['Integer'] = goog.math.Integer;