Skip to content

Commit

Permalink
Do not log in test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed May 23, 2017
1 parent bf2d429 commit 01e978b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/service/batched-xhr-impl.js
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {Xhr, xhrServiceForTesting} from './xhr-impl';
import {Xhr} from './xhr-impl';
import {getService, registerServiceBuilder} from '../service';
import {map} from '../utils/object';
import {removeFragment} from '../url';
Expand Down Expand Up @@ -92,7 +92,6 @@ export class BatchedXhr extends Xhr {
* @return {!BatchedXhr}
*/
export function batchedXhrServiceForTesting(window) {
xhrServiceForTesting(window);
installBatchedXhrService(window);
return getService(window, 'batched-xhr');
}
Expand Down
20 changes: 8 additions & 12 deletions src/service/xhr-impl.js
Expand Up @@ -25,6 +25,7 @@ import {isArray, isObject, isFormData} from '../types';
import {utf8EncodeSync} from '../utils/bytes';
import {ampdocServiceFor} from '../ampdoc';
import {viewerForDoc} from '../services';
import {getMode} from '../mode';


/**
Expand Down Expand Up @@ -97,12 +98,14 @@ export class Xhr {
/** @const {!Window} */
this.win = win;

const ampdocService = ampdocServiceFor(win);

/** @private @const {?./ampdoc-impl.AmpDoc} */
this.ampdocSingle_ = ampdocService.isSingleDoc() ?
ampdocService.getAmpDoc() :
null;
this.ampdocSingle_ = null;
if (!getMode().test) {
const ampdocService = ampdocServiceFor(win);
this.ampdocSingle_ = ampdocService.isSingleDoc() ?
ampdocService.getAmpDoc() :
null;
}
}

/**
Expand Down Expand Up @@ -593,13 +596,6 @@ export class FetchResponseHeaders {
* @return {!Xhr}
*/
export function xhrServiceForTesting(window) {
registerServiceBuilder(window, 'ampdoc', function() {
return {
isSingleDoc() {
return false;
},
};
});
installXhrService(window);
return getService(window, 'xhr');
}
Expand Down
7 changes: 4 additions & 3 deletions test/functional/web-worker/test-amp-worker.js
Expand Up @@ -19,7 +19,8 @@ import {
invokeWebWorker,
ampWorkerForTesting,
} from '../../../src/web-worker/amp-worker';
import {xhrServiceForTesting} from '../../../src/service/xhr-impl';
import {installXhrService} from '../../../src/service/xhr-impl';
import {xhrFor} from '../../../src/services';
import * as sinon from 'sinon';

describe('invokeWebWorker', () => {
Expand All @@ -46,8 +47,8 @@ describe('invokeWebWorker', () => {
};

// Stub xhr.fetchText() to return a resolved promise.
const xhr = xhrServiceForTesting(fakeWin);
sandbox.stub(xhr, 'fetchText', () => Promise.resolve());
installXhrService(fakeWin);
sandbox.stub(xhrFor(fakeWin), 'fetchText', () => Promise.resolve());

const ampWorker = ampWorkerForTesting(fakeWin);
workerReadyPromise = ampWorker.fetchPromiseForTesting();
Expand Down

0 comments on commit 01e978b

Please sign in to comment.