Bug 1806503 - Automatically replace Cu.reportError with console.error (browser/actors, browser/base). r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D165068
This commit is contained in:
Mark Banner 2022-12-27 10:08:58 +00:00
Родитель 7a685d54d2
Коммит 3a07fcf436
33 изменённых файлов: 99 добавлений и 97 удалений

Просмотреть файл

@ -208,8 +208,6 @@ module.exports = {
// Bug 877389 - Gradually migrate from Cu.reportError to console.error.
// Report as warnings where it is not yet passing.
files: [
"browser/actors/**",
"browser/base/content/**",
"browser/components/Browser*.*",
"browser/components/**",
"browser/extensions/report-site-issue/**",

Просмотреть файл

@ -56,7 +56,7 @@ export class AboutReaderChild extends JSWindowActorChild {
gUrlsToDocTitle.set(this.document.URL, this.document.title);
this._articlePromise = lazy.ReaderMode.parseDocument(
this.document
).catch(Cu.reportError);
).catch(console.error);
// Get the article data and cache it in the parent process. The reader mode
// page will retrieve it when it has loaded.

Просмотреть файл

@ -83,7 +83,7 @@ export class AboutReaderParent extends JSWindowActorParent {
try {
listener.receiveMessage(message);
} catch (e) {
Cu.reportError(e);
console.error(e);
}
}
}
@ -171,8 +171,9 @@ export class AboutReaderParent extends JSWindowActorParent {
this.callListeners(message);
return result;
} catch (ex) {
Cu.reportError(
"Error requesting favicon URL for about:reader content: " + ex
console.error(
"Error requesting favicon URL for about:reader content: ",
ex
);
}
@ -332,7 +333,7 @@ export class AboutReaderParent extends JSWindowActorParent {
// Pass up the error so we can navigate the browser in question to the new URL:
throw e;
}
Cu.reportError("Error downloading and parsing document: " + e);
console.error("Error downloading and parsing document: ", e);
return null;
});
}

Просмотреть файл

@ -153,7 +153,7 @@ export class ClickHandlerParent extends JSWindowActorParent {
listener.onContentClick(browser, data);
} catch (ex) {
Cu.reportError(ex);
console.error(ex);
}
}
}

Просмотреть файл

@ -336,7 +336,7 @@ export let ContentSearch = {
fieldname: browserData.controller.formHistoryParam,
value: entry.value,
source: entry.engineName,
}).catch(err => Cu.reportError("Error adding form history entry: " + err));
}).catch(err => console.error("Error adding form history entry: ", err));
return true;
},
@ -380,7 +380,7 @@ export let ContentSearch = {
try {
await this["_on" + event.type](event);
} catch (err) {
Cu.reportError(err);
console.error(err);
} finally {
this._currentEventPromise = null;

Просмотреть файл

@ -277,7 +277,7 @@ export class ContextMenuChild extends JSWindowActorChild {
let imageName = url.substr(url.lastIndexOf("/") + 1);
return Promise.resolve({ failed: false, dataURL, imageName });
} catch (e) {
Cu.reportError(e);
console.error(e);
}
}

Просмотреть файл

@ -112,8 +112,9 @@ export class DecoderDoctorParent extends JSWindowActorParent {
try {
parsedData = JSON.parse(aMessage.data);
} catch (ex) {
Cu.reportError(
"Malformed Decoder Doctor message with data: " + aMessage.data
console.error(
"Malformed Decoder Doctor message with data: ",
aMessage.data
);
return;
}
@ -190,7 +191,7 @@ export class DecoderDoctorParent extends JSWindowActorParent {
}
}
} else if (!decodeIssue) {
Cu.reportError(
console.error(
"Malformed Decoder Doctor unsolved message with no formats nor decode issue"
);
return;

Просмотреть файл

@ -106,7 +106,7 @@ export class EncryptedMediaChild extends JSWindowActorChild {
try {
parsedData = JSON.parse(aData);
} catch (ex) {
Cu.reportError("Malformed EME video message with data: " + aData);
console.error("Malformed EME video message with data: ", aData);
return;
}
const { status } = parsedData;

Просмотреть файл

@ -73,7 +73,7 @@ export class EncryptedMediaParent extends JSWindowActorParent {
try {
parsedData = JSON.parse(aMessage.data);
} catch (ex) {
Cu.reportError("Malformed EME video message with data: " + aMessage.data);
console.error("Malformed EME video message with data: ", aMessage.data);
return;
}
let { status, keySystem } = parsedData;
@ -129,7 +129,7 @@ export class EncryptedMediaParent extends JSWindowActorParent {
// about it.
return;
default:
Cu.reportError(
console.error(
new Error(
"Unknown message ('" +
status +

Просмотреть файл

@ -124,7 +124,7 @@ class LinkHandlerParent extends JSWindowActorParent {
try {
iconURI = Services.io.newURI(iconURL);
} catch (ex) {
Cu.reportError(ex);
console.error(ex);
return;
}
if (iconURI.scheme != "data") {
@ -149,7 +149,7 @@ class LinkHandlerParent extends JSWindowActorParent {
iconURI
);
} catch (ex) {
Cu.reportError(ex);
console.error(ex);
}
}

Просмотреть файл

@ -46,7 +46,7 @@ const PluginManager = {
!propertyBag.hasKey("pluginDumpID") ||
!propertyBag.hasKey("pluginName")
) {
Cu.reportError("PluginManager can not read plugin information.");
console.error("PluginManager can not read plugin information.");
return;
}
@ -85,7 +85,7 @@ const PluginManager = {
submitCrashReport(pluginCrashID, keyVals = {}) {
let report = this.getCrashReport(pluginCrashID);
if (!report) {
Cu.reportError(
console.error(
`Could not find plugin dump IDs for ${JSON.stringify(pluginCrashID)}.` +
`It is possible that a report was already submitted.`
);
@ -119,8 +119,9 @@ class PluginParent extends JSWindowActorParent {
break;
default:
Cu.reportError(
"PluginParent did not expect to handle message " + msg.name
console.error(
"PluginParent did not expect to handle message ",
msg.name
);
break;
}

Просмотреть файл

@ -238,7 +238,7 @@ class PromptParent extends JSWindowActorParent {
return promise;
} catch (ex) {
Cu.reportError(ex);
console.error(ex);
onPromptClose(true);
}

Просмотреть файл

@ -79,7 +79,7 @@ class WebRTCParent extends JSWindowActorParent {
return false;
}
} catch (err) {
Cu.reportError(`error in PeerConnection blocker: ${err.message}`);
console.error(`error in PeerConnection blocker: ${err.message}`);
}
}
return true;
@ -1017,7 +1017,7 @@ function prompt(aActor, aBrowser, aRequest) {
// No preview for you.
return;
}
Cu.reportError(
console.error(
`error in preview: ${err.message} ${err.constraint}`
);
}

Просмотреть файл

@ -382,7 +382,7 @@ var FullScreen = {
*/
shiftMacToolbarDown(shiftSize) {
if (typeof shiftSize !== "number") {
Cu.reportError("Tried to shift the toolbar by a non-numeric distance.");
console.error("Tried to shift the toolbar by a non-numeric distance.");
return;
}

Просмотреть файл

@ -382,7 +382,7 @@ var FullZoom = {
try {
browser.sendMessageToActor(name, {}, "Pdfjs");
} catch (ex) {
Cu.reportError(ex);
console.error(ex);
}
},

Просмотреть файл

@ -346,7 +346,7 @@ var BrowserPageActions = {
PanelMultiView.openPopup(panelNode, anchorNode, {
position: "bottomright topright",
triggerEvent: event,
}).catch(Cu.reportError);
}).catch(console.error);
},
_makeActivatedActionPanelForAction(action) {
@ -923,7 +923,7 @@ var BrowserPageActions = {
PanelMultiView.openPopup(this.panelNode, this.mainButtonNode, {
position: "bottomright topright",
triggerEvent: event,
}).catch(Cu.reportError);
}).catch(console.error);
},
/**

Просмотреть файл

@ -100,14 +100,14 @@ var StarUI = {
if (removeBookmarksOnPopupHidden && guidsForRemoval) {
if (this._isNewBookmark) {
PlacesTransactions.undo().catch(Cu.reportError);
PlacesTransactions.undo().catch(console.error);
break;
}
// Remove all bookmarks for the bookmark's url, this also removes
// the tags for the url.
PlacesTransactions.Remove(guidsForRemoval)
.transact()
.catch(Cu.reportError);
.catch(console.error);
} else if (this._isNewBookmark) {
this.showConfirmation();
}
@ -303,7 +303,7 @@ var StarUI = {
let canvas = PageThumbs.createCanvas(window);
PageThumbs.captureToCanvas(gBrowser.selectedBrowser, canvas).catch(e =>
Cu.reportError(e)
console.error(e)
);
document.mozSetImageElement("editBookmarkPanelImageCanvas", canvas);
},
@ -465,7 +465,7 @@ var PlacesCommandHook = {
info.title = info.title || url.href;
charset = browser.characterSet;
} catch (e) {
Cu.reportError(e);
console.error(e);
}
if (showEditUI) {
@ -479,7 +479,7 @@ var PlacesCommandHook = {
if (charset) {
PlacesUIUtils.setCharsetForPage(url, charset, window).catch(
Cu.reportError
console.error
);
}
}
@ -1767,7 +1767,7 @@ var BookmarkingUI = {
PlacesUtils.bookmarks
.fetch({ url: this._uri }, b => guids.add(b.guid), { concurrent: true })
.catch(Cu.reportError)
.catch(console.error)
.then(() => {
if (pendingUpdate != this._pendingUpdate) {
return;
@ -1799,8 +1799,9 @@ var BookmarkingUI = {
);
this._hasBookmarksObserver = true;
} catch (ex) {
Cu.reportError(
"BookmarkingUI failed adding a bookmarks observer: " + ex
console.error(
"BookmarkingUI failed adding a bookmarks observer: ",
ex
);
}
}

Просмотреть файл

@ -449,7 +449,7 @@ var gIdentityHandler = {
removeCertException() {
if (!this._uriHasHost) {
Cu.reportError(
console.error(
"Trying to revoke a cert exception on a URI without a host?"
);
return;
@ -626,9 +626,9 @@ var gIdentityHandler = {
);
return principal.isOriginPotentiallyTrustworthy;
} catch (error) {
Cu.reportError(
"Error while computing isPotentiallyTrustWorthy for pdf viewer page: " +
error
console.error(
"Error while computing isPotentiallyTrustWorthy for pdf viewer page: ",
error
);
return false;
}
@ -1209,7 +1209,7 @@ var gIdentityHandler = {
PanelMultiView.openPopup(this._identityPopup, this._identityIconBox, {
position: "bottomleft topleft",
triggerEvent: event,
}).catch(Cu.reportError);
}).catch(console.error);
},
onPopupShown(event) {

Просмотреть файл

@ -247,7 +247,7 @@ var gPermissionPanel = {
PanelMultiView.openPopup(this._permissionPopup, this._popupAnchor, {
position: this._popupPosition,
triggerEvent: event,
}).catch(Cu.reportError);
}).catch(console.error);
},
/**
@ -855,7 +855,7 @@ var gPermissionPanel = {
}
let lastAccess = new Date(lastAccessStr);
if (isNaN(lastAccess)) {
Cu.reportError("Invalid timestamp for last geolocation access");
console.error("Invalid timestamp for last geolocation access");
return;
}

Просмотреть файл

@ -611,7 +611,7 @@ let ThirdPartyCookies = new (class ThirdPartyCookies extends ProtectionCategory
case Ci.nsICookieService.BEHAVIOR_LIMIT_FOREIGN:
return "cookiesfromunvisitedsitesblocked";
default:
Cu.reportError(
console.error(
`Error: Unknown cookieBehavior pref observed: ${this.behaviorPref}`
);
// fall through
@ -684,7 +684,7 @@ let ThirdPartyCookies = new (class ThirdPartyCookies extends ProtectionCategory
label = "contentBlocking.cookies.blockingTrackers3.label";
break;
default:
Cu.reportError(
console.error(
`Error: Unknown cookieBehavior pref observed: ${this.behaviorPref}`
);
break;
@ -781,7 +781,7 @@ let ThirdPartyCookies = new (class ThirdPartyCookies extends ProtectionCategory
: "protections.blocking.cookies.trackers.title";
break;
default:
Cu.reportError(
console.error(
`Error: Unknown cookieBehavior pref when updating subview: ${this.behaviorPref}`
);
break;
@ -2361,7 +2361,7 @@ var gProtectionsHandler = {
position: "bottomleft topleft",
triggerEvent: event,
}
).catch(Cu.reportError);
).catch(console.error);
},
showSiteNotWorkingView() {
@ -2487,7 +2487,7 @@ var gProtectionsHandler = {
.then(response => {
this._protectionsPopupSendReportButton.disabled = false;
if (!response.ok) {
Cu.reportError(
console.error(
`Content Blocking report to ${reportEndpoint} failed with status ${response.status}`
);
this._protectionsPopupSiteNotWorkingReportError.hidden = false;
@ -2499,7 +2499,7 @@ var gProtectionsHandler = {
);
}
})
.catch(Cu.reportError);
.catch(console.error);
},
onSendReportClicked() {

Просмотреть файл

@ -73,7 +73,7 @@ this.SyncedTabsPanelList = class SyncedTabsPanelList {
}
// force a background sync.
SyncedTabs.syncTabs().catch(ex => {
Cu.reportError(ex);
console.error(ex);
});
this.deck.toggleAttribute("syncingtabs", true);
// show the current list - it will be updated by our observer.
@ -99,7 +99,7 @@ this.SyncedTabsPanelList = class SyncedTabsPanelList {
return this.__showSyncedTabs(paginationInfo);
},
e => {
Cu.reportError(e);
console.error(e);
}
);
}
@ -176,7 +176,7 @@ this.SyncedTabsPanelList = class SyncedTabsPanelList {
this.tabsList.appendChild(fragment);
})
.catch(err => {
Cu.reportError(err);
console.error(err);
})
.then(() => {
// an observer for tests.
@ -574,7 +574,7 @@ var gSync = {
observe(subject, topic, data) {
if (!this._initialized) {
Cu.reportError("browser-sync observer called after unload: " + topic);
console.error("browser-sync observer called after unload: ", topic);
return;
}
switch (topic) {

Просмотреть файл

@ -435,7 +435,7 @@ XPCOMUtils.defineLazyGetter(this, "PopupNotifications", () => {
{ shouldSuppress }
);
} catch (ex) {
Cu.reportError(ex);
console.error(ex);
return null;
}
});
@ -1847,7 +1847,7 @@ var gBrowserInit = {
try {
gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, tabToAdopt);
} catch (e) {
Cu.reportError(e);
console.error(e);
}
// Clear the reference to the tab once its adoption has been completed.
@ -1966,7 +1966,7 @@ var gBrowserInit = {
BookmarkingUI.init();
BrowserSearch.delayedStartupInit();
gProtectionsHandler.init();
HomePage.delayedStartup().catch(Cu.reportError);
HomePage.delayedStartup().catch(console.error);
let safeMode = document.getElementById("helpSafeMode");
if (Services.appinfo.inSafeMode) {
@ -2352,7 +2352,7 @@ var gBrowserInit = {
triggeringRemoteType,
});
} catch (e) {
Cu.reportError(e);
console.error(e);
}
window.focus();
@ -2440,7 +2440,7 @@ var gBrowserInit = {
}
Services.telemetry.setEventRecordingEnabled("downloads", true);
} catch (ex) {
Cu.reportError(ex);
console.error(ex);
}
},
{ timeout: 10000 }
@ -3151,7 +3151,7 @@ function loadURI(
allowInheritPrincipal,
});
} catch (e) {
Cu.reportError(e);
console.error(e);
}
}
@ -3732,7 +3732,7 @@ function openHomeDialog(aURL) {
);
if (pressedVal == 0) {
HomePage.set(aURL).catch(Cu.reportError);
HomePage.set(aURL).catch(console.error);
}
}
@ -4420,7 +4420,7 @@ const BrowserSearch = {
this._updateURLBarPlaceholderFromDefaultEngine(
PrivateBrowsingUtils.isWindowPrivate(window),
false
).catch(Cu.reportError);
).catch(console.error);
},
};
@ -6243,7 +6243,7 @@ nsBrowserAccess.prototype = {
openURI(aURI, aOpenWindowInfo, aWhere, aFlags, aTriggeringPrincipal, aCsp) {
if (!aURI) {
Cu.reportError("openURI should only be called with a valid URI");
console.error("openURI should only be called with a valid URI");
throw Components.Exception("", Cr.NS_ERROR_FAILURE);
}
return this.getContentWindowOrOpenURI(
@ -6270,7 +6270,7 @@ nsBrowserAccess.prototype = {
var isExternal = !!(aFlags & Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
if (aOpenWindowInfo && isExternal) {
Cu.reportError(
console.error(
"nsBrowserAccess.openURI did not expect aOpenWindowInfo to be " +
"passed if the context is OPEN_EXTERNAL."
);
@ -6360,7 +6360,7 @@ nsBrowserAccess.prototype = {
// context for a newly opened window is ready.
browsingContext = null;
} catch (ex) {
Cu.reportError(ex);
console.error(ex);
}
break;
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB: {
@ -7272,7 +7272,7 @@ function middleMousePaste(event) {
} catch (ex) {
// Things may go wrong when adding url to session history,
// but don't let that interfere with the loading of the url.
Cu.reportError(ex);
console.error(ex);
}
if (
@ -8977,7 +8977,7 @@ var MousePosTracker = {
try {
this._callListener(listener);
} catch (e) {
Cu.reportError(e);
console.error(e);
}
});
},
@ -9176,7 +9176,7 @@ var PanicButtonNotifier = {
let anchor = widget.anchor.icon;
popup.openPopup(anchor, popup.getAttribute("position"));
} catch (ex) {
Cu.reportError(ex);
console.error(ex);
}
},
close() {
@ -9799,7 +9799,7 @@ var gDialogBox = {
try {
await this._open(uri, args);
} catch (ex) {
Cu.reportError(ex);
console.error(ex);
} finally {
let dialog = document.getElementById("window-modal-dialog");
if (dialog.open) {

Просмотреть файл

@ -2287,14 +2287,14 @@ class nsContextMenu {
}
bookmarkThisPage() {
window.top.PlacesCommandHook.bookmarkPage().catch(Cu.reportError);
window.top.PlacesCommandHook.bookmarkPage().catch(console.error);
}
bookmarkLink() {
window.top.PlacesCommandHook.bookmarkLink(
this.linkURL,
this.linkTextStr
).catch(Cu.reportError);
).catch(console.error);
}
addBookmarkForFrame() {
@ -2302,7 +2302,7 @@ class nsContextMenu {
this.actor.getFrameTitle(this.targetIdentifier).then(title => {
window.top.PlacesCommandHook.bookmarkLink(uri.spec, title).catch(
Cu.reportError
console.error
);
});
}

Просмотреть файл

@ -131,12 +131,12 @@ var gSanitizePromptDialog = {
range,
};
Sanitizer.sanitize(null, options)
.catch(Cu.reportError)
.catch(console.error)
.then(() => window.close())
.catch(Cu.reportError);
.catch(console.error);
event.preventDefault();
} catch (er) {
Cu.reportError("Exception during sanitize: " + er);
console.error("Exception during sanitize: ", er);
}
},

Просмотреть файл

@ -501,12 +501,12 @@
// since we can update the image during the dnd.
PageThumbs.captureToCanvas(browser, canvas)
.then(captureListener)
.catch(e => Cu.reportError(e));
.catch(e => console.error(e));
} else {
// For the non e10s case we can just use PageThumbs
// sync, so let's use the canvas for setDragImage.
PageThumbs.captureToCanvas(browser, canvas).catch(e =>
Cu.reportError(e)
console.error(e)
);
dragImageOffset = dragImageOffset * scale;
}

Просмотреть файл

@ -927,7 +927,7 @@
}
} catch (e) {
// don't inhibit other listeners
Cu.reportError(e);
console.error(e);
}
}
}
@ -1018,7 +1018,7 @@
description: aDescription,
previewImageURL: aPreviewImage,
};
PlacesUtils.history.update(pageInfo).catch(Cu.reportError);
PlacesUtils.history.update(pageInfo).catch(console.error);
}
},
@ -2837,8 +2837,8 @@
}
}
} catch (e) {
Cu.reportError("Failed to create tab");
Cu.reportError(e);
console.error("Failed to create tab");
console.error(e);
t.remove();
if (t.linkedBrowser) {
this._tabFilters.delete(t);
@ -2922,7 +2922,7 @@
triggeringRemoteType,
});
} catch (ex) {
Cu.reportError(ex);
console.error(ex);
}
}
}
@ -3627,7 +3627,7 @@
}
}
} catch (e) {
Cu.reportError(e);
console.error(e);
}
return false;
},
@ -3721,7 +3721,7 @@
this.removeTab(lastToClose, aParams);
}
} catch (e) {
Cu.reportError(e);
console.error(e);
}
this._clearMultiSelectionLocked = false;
@ -4619,12 +4619,12 @@
addProgressListener(aListener) {
if (arguments.length != 1) {
Cu.reportError(
console.error(
"gBrowser.addProgressListener was " +
"called with a second argument, " +
"which is not supported. See bug " +
"608628. Call stack: " +
new Error().stack
"608628. Call stack: ",
new Error().stack
);
}
@ -5183,7 +5183,7 @@
this.selectedTab = selectedTabs.at(-1);
}
} catch (e) {
Cu.reportError(e);
console.error(e);
}
this._clearMultiSelectionLocked = false;

Просмотреть файл

@ -171,7 +171,7 @@ async function setDownloadDir() {
try {
await IOUtils.remove(tmpDir, { recursive: true });
} catch (e) {
Cu.reportError(e);
console.error(e);
}
Services.prefs.clearUserPref("browser.download.folderList");
Services.prefs.clearUserPref("browser.download.dir");

Просмотреть файл

@ -27,7 +27,7 @@ add_setup(async function() {
try {
await IOUtils.remove(tmpDir, { recursive: true });
} catch (e) {
Cu.reportError(e);
console.error(e);
}
Services.prefs.clearUserPref("browser.download.folderList");
Services.prefs.clearUserPref("browser.download.dir");

Просмотреть файл

@ -30,7 +30,7 @@ add_task(async function allowOnionMixedContent() {
const tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
TEST_URL
).catch(Cu.reportError);
).catch(console.error);
const browser = gBrowser.getBrowserForTab(tab);
await assertMixedContentBlockingState(browser, {

Просмотреть файл

@ -389,7 +389,7 @@ function chromeFileExists(aURI) {
} catch (e) {
if (e.result != Cr.NS_ERROR_FILE_NOT_FOUND) {
dump("Checking " + aURI + ": " + e + "\n");
Cu.reportError(e);
console.error(e);
}
}
return available > 0;

Просмотреть файл

@ -76,7 +76,7 @@ var FullZoomHelper = {
resolve(value);
},
handleError(error) {
Cu.reportError(error);
console.error(error);
},
});
});
@ -179,7 +179,7 @@ var FullZoomHelper = {
failAndContinue: function failAndContinue(func) {
return function(err) {
Cu.reportError(err);
console.error(err);
ok(false, err);
func();
};

Просмотреть файл

@ -329,7 +329,7 @@ function openLinkIn(url, where, params) {
);
} else {
if (!aInitiatingDoc) {
Cu.reportError(
console.error(
"openUILink/openLinkIn was called with " +
"where == 'save' but without initiatingDoc. See bug 814264."
);

Просмотреть файл

@ -68,7 +68,7 @@ function updateIndicatorState() {
break;
default:
if (ssi) {
Cu.reportError(`Unknown showScreenSharingIndicator: ${ssi}`);
console.error(`Unknown showScreenSharingIndicator: ${ssi}`);
}
ssL10nId = "";
}