зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1721525 - Replace Cu.reportError with log warnings for Contile r=mythmon
Differential Revision: https://phabricator.services.mozilla.com/D122285
This commit is contained in:
Родитель
5ada5065e3
Коммит
00f5f2fce4
|
@ -74,6 +74,13 @@ ChromeUtils.defineModuleGetter(
|
|||
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "log", () => {
|
||||
const { Logger } = ChromeUtils.import(
|
||||
"resource://messaging-system/lib/Logger.jsm"
|
||||
);
|
||||
return new Logger("TopSitesFeed");
|
||||
});
|
||||
|
||||
const DEFAULT_SITES_PREF = "default.sites";
|
||||
const SHOWN_ON_NEWTAB_PREF = "feeds.topsites";
|
||||
const DEFAULT_TOP_SITES = [];
|
||||
|
@ -171,7 +178,7 @@ class ContileIntegration {
|
|||
let url = Services.prefs.getStringPref(CONTILE_ENDPOINT_PREF);
|
||||
const response = await fetch(url, { credentials: "omit" });
|
||||
if (!response.ok) {
|
||||
Cu.reportError(
|
||||
log.warn(
|
||||
`Contile endpoint returned unexpected status: ${response.status}`
|
||||
);
|
||||
}
|
||||
|
@ -188,7 +195,7 @@ class ContileIntegration {
|
|||
let { tiles } = body;
|
||||
tiles = this._filterBlockedSponsors(tiles);
|
||||
if (tiles.length > MAX_NUM_SPONSORED) {
|
||||
Cu.reportError(
|
||||
log.warn(
|
||||
`Contile provided more links than permitted. (${tiles.length} received, limit is ${MAX_NUM_SPONSORED})`
|
||||
);
|
||||
tiles.length = MAX_NUM_SPONSORED;
|
||||
|
@ -197,9 +204,7 @@ class ContileIntegration {
|
|||
return true;
|
||||
}
|
||||
} catch (error) {
|
||||
Cu.reportError(
|
||||
`Failed to fetch data from Contile server: ${error.message}`
|
||||
);
|
||||
log.warn(`Failed to fetch data from Contile server: ${error.message}`);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -160,13 +160,15 @@ describe("Top Sites Feed", () => {
|
|||
}
|
||||
|
||||
describe("#constructor", () => {
|
||||
it("should defineLazyGetter for _currentSearchHostname", () => {
|
||||
assert.calledOnce(global.XPCOMUtils.defineLazyGetter);
|
||||
assert.calledWith(
|
||||
global.XPCOMUtils.defineLazyGetter,
|
||||
feed,
|
||||
"_currentSearchHostname",
|
||||
sinon.match.func
|
||||
it("should defineLazyGetter for log and _currentSearchHostname", () => {
|
||||
assert.calledTwice(global.XPCOMUtils.defineLazyGetter);
|
||||
|
||||
let spyCall = global.XPCOMUtils.defineLazyGetter.getCall(0);
|
||||
assert.ok(spyCall.calledWith(sinon.match.any, "log", sinon.match.func));
|
||||
|
||||
spyCall = global.XPCOMUtils.defineLazyGetter.getCall(1);
|
||||
assert.ok(
|
||||
spyCall.calledWith(feed, "_currentSearchHostname", sinon.match.func)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -66,6 +66,14 @@ class JSWindowActorChild {
|
|||
}
|
||||
}
|
||||
|
||||
class Logger {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
warn() {}
|
||||
}
|
||||
|
||||
const TEST_GLOBAL = {
|
||||
JSWindowActorParent,
|
||||
JSWindowActorChild,
|
||||
|
@ -509,6 +517,7 @@ const TEST_GLOBAL = {
|
|||
gUUIDGenerator: {
|
||||
generateUUID: () => "{foo-123-foo}",
|
||||
},
|
||||
Logger,
|
||||
};
|
||||
TEST_GLOBAL.NimbusFeatures.pocketNewtab = TEST_GLOBAL.NimbusFeatures.newtab;
|
||||
overrider.set(TEST_GLOBAL);
|
||||
|
|
Загрузка…
Ссылка в новой задаче