Skip to content

Commit

Permalink
Backed out changeset 0f3b01e74838 (bug 1642556) for failures on test_…
Browse files Browse the repository at this point in the history
…errorhandler_filelog.js. CLOSED TREE
  • Loading branch information
ncsoregi committed Jun 30, 2020
1 parent f8f21f2 commit c0c732c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 85 deletions.
1 change: 0 additions & 1 deletion browser/base/content/browser-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,6 @@ var gSync = {
let action = PageActions.actionForID("sendToDevice");
showBrowserPageActionFeedback(action);
}
fxAccounts.flushLogFile();
});
};
const onSendAllCommand = event => {
Expand Down
25 changes: 0 additions & 25 deletions browser/base/content/test/sync/browser_contextmenu_sendtab.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,6 @@ add_task(async function setup() {
is(gBrowser.visibleTabs.length, 2, "there are two visible tabs");
});

add_task(async function test_sendTabToDevice_callsFlushLogFile() {
const sandbox = setupSendTabMocks({ fxaDevices });
updateTabContextMenu(testTab);
await openTabContextMenu("context_sendTabToDevice");
let promiseObserved = promiseObserver("service:log-manager:flush-log-file");
document
.getElementById("context_sendTabToDevicePopupMenu")
.querySelector("menuitem")
.click();

await promiseObserved;
await hideTabContextMenu();
sandbox.restore();
});

add_task(async function test_tab_contextmenu() {
const sandbox = setupSendTabMocks({ fxaDevices });
let expectation = sandbox
Expand Down Expand Up @@ -255,13 +240,3 @@ async function hideTabContextMenu() {
contextMenu.hidePopup();
await awaitPopupHidden;
}

function promiseObserver(topic) {
return new Promise(resolve => {
let obs = (aSubject, aTopic, aData) => {
Services.obs.removeObserver(obs, aTopic);
resolve(aSubject);
};
Services.obs.addObserver(obs, topic);
});
}
15 changes: 0 additions & 15 deletions services/fxaccounts/FxAccounts.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const {
SERVER_ERRNO_TO_ERROR,
log,
logPII,
logManager,
} = ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js");

ChromeUtils.defineModuleGetter(
Expand Down Expand Up @@ -774,20 +773,6 @@ class FxAccounts {
return this._internal.whenVerified(data);
});
}

/**
* Generate a log file for the FxA action that just completed
* and refresh the input & output streams.
*/
async flushLogFile() {
const logType = await logManager.resetFileLog();
if (logType == logManager.ERROR_LOG_WRITTEN) {
Cu.reportError(
"FxA encountered an error - see about:sync-log for the log file."
);
}
Services.obs.notifyObservers(null, "service:log-manager:flush-log-file");
}
}

var FxAccountsInternal = function() {};
Expand Down
21 changes: 0 additions & 21 deletions services/fxaccounts/FxAccountsCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);
const { Log } = ChromeUtils.import("resource://gre/modules/Log.jsm");
const { LogManager } = ChromeUtils.import(
"resource://services-common/logmanager.js"
);

// loglevel should be one of "Fatal", "Error", "Warn", "Info", "Config",
// "Debug", "Trace" or "All". If none is specified, "Debug" will be used by
Expand All @@ -32,21 +26,6 @@ XPCOMUtils.defineLazyGetter(exports, "log", function() {
return log;
});

XPCOMUtils.defineLazyGetter(exports, "logManager", function() {
let logs = [
"Sync",
"Services.Common",
"FirefoxAccounts",
"Hawk",
"browserwindow.syncui",
"BookmarkSyncUtils",
"addons.xpi",
];

// for legacy reasons, the log manager still thinks it's part of sync
return new LogManager(new Preferences("services.sync."), logs, "sync");
});

// A boolean to indicate if personally identifiable information (or anything
// else sensitive, such as credentials) should be logged.
XPCOMUtils.defineLazyGetter(exports, "logPII", function() {
Expand Down
17 changes: 0 additions & 17 deletions services/fxaccounts/tests/xpcshell/test_accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1980,23 +1980,6 @@ add_task(async function test_deriveKeys() {
);
});

add_task(async function test_flushLogFile() {
_("Tests flushLogFile");
let account = await MakeFxAccounts();
let promiseObserved = new Promise(res => {
log.info("Adding flush-log-file observer.");
Services.obs.addObserver(function onFlushLogFile() {
Services.obs.removeObserver(
onFlushLogFile,
"service:log-manager:flush-log-file"
);
res();
}, "service:log-manager:flush-log-file");
});
account.flushLogFile();
await promiseObserved;
});

/*
* End of tests.
* Utility functions follow.
Expand Down
24 changes: 18 additions & 6 deletions services/sync/modules/policies.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const {
kSyncMasterPasswordLocked,
} = ChromeUtils.import("resource://services-sync/constants.js");
const { Svc, Utils } = ChromeUtils.import("resource://services-sync/util.js");
const { logManager } = ChromeUtils.import(
"resource://gre/modules/FxAccountsCommon.js"
const { LogManager } = ChromeUtils.import(
"resource://services-common/logmanager.js"
);
const { Async } = ChromeUtils.import("resource://services-common/async.js");
const { CommonUtils } = ChromeUtils.import(
Expand Down Expand Up @@ -866,6 +866,18 @@ ErrorHandler.prototype = {
// And allow our specific log to have a custom level via a pref.
this._log = Log.repository.getLogger("Sync.ErrorHandler");
this._log.manageLevelFromPref("services.sync.log.logger.service.main");

let logs = [
"Sync",
"Services.Common",
"FirefoxAccounts",
"Hawk",
"browserwindow.syncui",
"BookmarkSyncUtils",
"addons.xpi",
];

this._logManager = new LogManager(Svc.Prefs, logs, "sync");
},

observe(subject, topic, data) {
Expand Down Expand Up @@ -950,7 +962,7 @@ ErrorHandler.prototype = {
// although for privacy reasons we also delete all logs (but we allow
// a preference to avoid this to help with debugging.)
if (!Svc.Prefs.get("log.keepLogsOnReset", false)) {
return logManager.removeAllLogs().then(() => {
return this._logManager.removeAllLogs().then(() => {
Svc.Obs.notify("weave:service:remove-file-log");
});
}
Expand Down Expand Up @@ -988,11 +1000,11 @@ ErrorHandler.prototype = {
*/
async resetFileLog() {
// If we're writing an error log, dump extensions that may be causing problems.
if (logManager.sawError) {
if (this._logManager.sawError) {
await this._dumpAddons();
}
const logType = await logManager.resetFileLog();
if (logType == logManager.ERROR_LOG_WRITTEN) {
const logType = await this._logManager.resetFileLog();
if (logType == this._logManager.ERROR_LOG_WRITTEN) {
Cu.reportError(
"Sync encountered an error - see about:sync-log for the log file."
);
Expand Down

0 comments on commit c0c732c

Please sign in to comment.