From dfc3bdb42a208da0570d3ae86d790f45b21fda3f Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Tue, 20 Dec 2022 07:43:44 +0000 Subject: [PATCH] Bug 1806500 - Automatically replace Cu.reportError with console.error (uriloader dom). r=smaug Differential Revision: https://phabricator.services.mozilla.com/D165067 --- .eslintrc.js | 10 ---------- dom/base/DOMRequestHelper.jsm | 4 ++-- dom/console/ConsoleAPIStorage.jsm | 4 ++-- dom/push/PushComponents.sys.mjs | 10 +++++----- dom/push/PushServiceHttp2.sys.mjs | 4 ++-- dom/push/test/mockpushserviceparent.js | 10 +++++----- dom/push/test/xpcshell/head.js | 4 ++-- dom/serviceworkers/test/browser_download.js | 4 ++-- dom/system/NetworkGeolocationProvider.jsm | 2 +- dom/tests/browser/browser_hasbeforeunload.js | 2 +- uriloader/exthandler/ExtHandlerService.sys.mjs | 8 ++++---- .../mochitest/HelperAppLauncherDialog_chromeScript.js | 2 +- .../mochitest/browser_shows_where_to_save_dialog.js | 2 +- uriloader/exthandler/tests/mochitest/head.js | 4 ++-- 14 files changed, 30 insertions(+), 40 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8c1d510a3796..7f258e0d4f6b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -217,17 +217,7 @@ module.exports = { "browser/modules/**", "browser/themes/BuiltInThemes.sys.mjs", "devtools/**", - "dom/base/DOMRequestHelper.*", - "dom/console/ConsoleAPIStorage.*", - "dom/push/PushComponents.sys.mjs", - "dom/push/PushServiceHttp2.sys.mjs", - "dom/push/test/mockpushserviceparent.js", - "dom/push/test/xpcshell/head.js", - "dom/serviceworkers/test/browser_download.js", - "dom/system/NetworkGeolocationProvider.*", - "dom/tests/browser/browser_hasbeforeunload.js", "toolkit/**", - "uriloader/exthandler/**", ], rules: { "mozilla/no-cu-reportError": "off", diff --git a/dom/base/DOMRequestHelper.jsm b/dom/base/DOMRequestHelper.jsm index 5bb0e39d731c..21411a2d39ae 100644 --- a/dom/base/DOMRequestHelper.jsm +++ b/dom/base/DOMRequestHelper.jsm @@ -270,7 +270,7 @@ DOMRequestIpcHelper.prototype = { createRequest() { // If we don't have a valid window object, throw. if (!this._window) { - Cu.reportError( + console.error( "DOMRequestHelper trying to create a DOMRequest without a valid window, failing." ); throw Components.Exception("", Cr.NS_ERROR_FAILURE); @@ -286,7 +286,7 @@ DOMRequestIpcHelper.prototype = { createPromise(aPromiseInit) { // If we don't have a valid window object, throw. if (!this._window) { - Cu.reportError( + console.error( "DOMRequestHelper trying to create a Promise without a valid window, failing." ); throw Components.Exception("", Cr.NS_ERROR_FAILURE); diff --git a/dom/console/ConsoleAPIStorage.jsm b/dom/console/ConsoleAPIStorage.jsm index e3b44e883a09..6c5b649901b5 100644 --- a/dom/console/ConsoleAPIStorage.jsm +++ b/dom/console/ConsoleAPIStorage.jsm @@ -135,7 +135,7 @@ ConsoleAPIStorageService.prototype = { if (index != -1) { _logEventListeners.splice(index, 1); } else { - Cu.reportError( + console.error( "Attempted to remove a log event listener that does not exist." ); } @@ -173,7 +173,7 @@ ConsoleAPIStorageService.prototype = { } } catch (e) { // A failing listener should not prevent from calling other listeners. - Cu.reportError(e); + console.error(e); } } }, diff --git a/dom/push/PushComponents.sys.mjs b/dom/push/PushComponents.sys.mjs index 53772d423ef3..6c98f85ecb8b 100644 --- a/dom/push/PushComponents.sys.mjs +++ b/dom/push/PushComponents.sys.mjs @@ -154,7 +154,7 @@ Object.assign(PushServiceParent.prototype, { this._deliverSubscriptionError(callback, error); } ) - .catch(Cu.reportError); + .catch(console.error); }, unsubscribe(scope, principal, callback) { @@ -169,7 +169,7 @@ Object.assign(PushServiceParent.prototype, { callback.onUnsubscribe(Cr.NS_ERROR_FAILURE, false); } ) - .catch(Cu.reportError); + .catch(console.error); }, getSubscription(scope, principal, callback) { @@ -184,7 +184,7 @@ Object.assign(PushServiceParent.prototype, { this._deliverSubscriptionError(callback, error); } ) - .catch(Cu.reportError); + .catch(console.error); }, clearForDomain(domain, callback) { @@ -199,7 +199,7 @@ Object.assign(PushServiceParent.prototype, { callback.onClear(Cr.NS_ERROR_FAILURE); } ) - .catch(Cu.reportError); + .catch(console.error); }, // nsIPushQuotaManager methods @@ -250,7 +250,7 @@ Object.assign(PushServiceParent.prototype, { }); } ) - .catch(Cu.reportError); + .catch(console.error); }, ensureReady() { diff --git a/dom/push/PushServiceHttp2.sys.mjs b/dom/push/PushServiceHttp2.sys.mjs index 837c3333bcee..29c7a36b92a0 100644 --- a/dom/push/PushServiceHttp2.sys.mjs +++ b/dom/push/PushServiceHttp2.sys.mjs @@ -735,14 +735,14 @@ export var PushServiceHttp2 = { if (this._mainPushService) { this._mainPushService .updateRegistrationAndNotifyApp(aSubscriptionUri, recordNew) - .catch(Cu.reportError); + .catch(console.error); } }, error => { if (this._mainPushService) { this._mainPushService .dropRegistrationAndNotifyApp(aSubscriptionUri) - .catch(Cu.reportError); + .catch(console.error); } } ) diff --git a/dom/push/test/mockpushserviceparent.js b/dom/push/test/mockpushserviceparent.js index d787d009f5fb..13bcadeb8b85 100644 --- a/dom/push/test/mockpushserviceparent.js +++ b/dom/push/test/mockpushserviceparent.js @@ -18,7 +18,7 @@ function waterfall(...callbacks) { }), Promise.resolve() ) - .catch(Cu.reportError); + .catch(console.error); } /** @@ -97,7 +97,7 @@ addMessageListener("socket-teardown", function(msg) { sendAsyncMessage("socket-server-teardown"); }) .catch(error => { - Cu.reportError(`Error restoring service backend: ${error}`); + console.error(`Error restoring service backend: ${error}`); }); }); @@ -132,7 +132,7 @@ var MockService = { handleResponse(response) { if (!this.resolvers.has(response.id)) { - Cu.reportError(`Unexpected response for request ${response.id}`); + console.error(`Unexpected response for request ${response.id}`); return; } let resolver = this.resolvers.get(response.id); @@ -182,7 +182,7 @@ addMessageListener("service-replace", function() { sendAsyncMessage("service-replaced"); }) .catch(error => { - Cu.reportError(`Error replacing service: ${error}`); + console.error(`Error replacing service: ${error}`); }); }); @@ -192,7 +192,7 @@ addMessageListener("service-restore", function() { sendAsyncMessage("service-restored"); }) .catch(error => { - Cu.reportError(`Error restoring service: ${error}`); + console.error(`Error restoring service: ${error}`); }); }); diff --git a/dom/push/test/xpcshell/head.js b/dom/push/test/xpcshell/head.js index e232d97b6c4b..6752281971e7 100644 --- a/dom/push/test/xpcshell/head.js +++ b/dom/push/test/xpcshell/head.js @@ -62,7 +62,7 @@ Services.obs.addObserver(function observe(subject, topic, data) { try { thread.processNextEvent(true); } catch (e) { - Cu.reportError(e); + console.error(e); } } }, "profile-change-net-teardown"); @@ -99,7 +99,7 @@ function waterfall(...callbacks) { }), Promise.resolve() ) - .catch(Cu.reportError); + .catch(console.error); } /** diff --git a/dom/serviceworkers/test/browser_download.js b/dom/serviceworkers/test/browser_download.js index 3a495a9ecc4b..271f217012cd 100644 --- a/dom/serviceworkers/test/browser_download.js +++ b/dom/serviceworkers/test/browser_download.js @@ -73,8 +73,8 @@ function test() { ok(file.exists(), "download completed"); is(file.fileSize, 33, "downloaded file has correct size"); file.remove(false); - downloadList.remove(aDownload).catch(Cu.reportError); - downloadList.removeView(downloadListener).catch(Cu.reportError); + downloadList.remove(aDownload).catch(console.error); + downloadList.removeView(downloadListener).catch(console.error); gBrowser.removeTab(tab); Services.ww.unregisterNotification(windowObserver); diff --git a/dom/system/NetworkGeolocationProvider.jsm b/dom/system/NetworkGeolocationProvider.jsm index 4111428681dc..b20765227a2b 100644 --- a/dom/system/NetworkGeolocationProvider.jsm +++ b/dom/system/NetworkGeolocationProvider.jsm @@ -472,7 +472,7 @@ NetworkGeolocationProvider.prototype = { ); } catch (err) { LOG("Location request hit error: " + err.name); - Cu.reportError(err); + console.error(err); if (err.name == "AbortError") { this.onStatus(true, "xhr-timeout"); } else { diff --git a/dom/tests/browser/browser_hasbeforeunload.js b/dom/tests/browser/browser_hasbeforeunload.js index cd930edf2790..f804e7424889 100644 --- a/dom/tests/browser/browser_hasbeforeunload.js +++ b/dom/tests/browser/browser_hasbeforeunload.js @@ -315,7 +315,7 @@ function controlFrameAt(browser, frameDepth, command) { break; } } - }).catch(Cu.reportError); + }).catch(console.error); } /** diff --git a/uriloader/exthandler/ExtHandlerService.sys.mjs b/uriloader/exthandler/ExtHandlerService.sys.mjs index ddd1573fedc7..e7e5c2f0b577 100644 --- a/uriloader/exthandler/ExtHandlerService.sys.mjs +++ b/uriloader/exthandler/ExtHandlerService.sys.mjs @@ -124,7 +124,7 @@ HandlerService.prototype = { this._store.saveSoon(); } } catch (ex) { - Cu.reportError(ex); + console.error(ex); } }, @@ -300,7 +300,7 @@ HandlerService.prototype = { try { kMigrations[migration](); } catch (ex) { - Cu.reportError(ex); + console.error(ex); } } @@ -316,7 +316,7 @@ HandlerService.prototype = { } this.__store = null; this.__storeInitialized = false; - })().catch(Cu.reportError); + })().catch(console.error); }, // nsIObserver @@ -348,7 +348,7 @@ HandlerService.prototype = { this._ensureStoreInitialized(); } }) - .catch(Cu.reportError); + .catch(console.error); } }, diff --git a/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js b/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js index f08cbd9ffa5a..41fac13402f4 100644 --- a/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js +++ b/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js @@ -94,7 +94,7 @@ addMessageListener("unregister", async function() { await dl.refresh(); if (dl.target.exists || dl.target.partFileExists) { dump("Finalizing download.\n"); - await dl.finalize(true).catch(Cu.reportError); + await dl.finalize(true).catch(console.error); } } await list.removeFinished(); diff --git a/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js b/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js index 8c7f7c732fb7..0052ee394c58 100644 --- a/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js +++ b/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js @@ -273,7 +273,7 @@ async function setupFilePickerDirectory() { try { await IOUtils.remove(saveDir.path, { recursive: true }); } catch (e) { - Cu.reportError(e); + console.error(e); } }); diff --git a/uriloader/exthandler/tests/mochitest/head.js b/uriloader/exthandler/tests/mochitest/head.js index e853825ed236..5168fd31ca41 100644 --- a/uriloader/exthandler/tests/mochitest/head.js +++ b/uriloader/exthandler/tests/mochitest/head.js @@ -123,7 +123,7 @@ async function openHelperAppDialog(launcher) { false, "Trying to show unknownContentType.xhtml failed with exception: " + ex ); - Cu.reportError(ex); + console.error(ex); } let dlg = await helperAppDialogShownPromise; @@ -293,7 +293,7 @@ async function setDownloadDir() { try { await IOUtils.remove(tmpDir, { recursive: true }); } catch (e) { - Cu.reportError(e); + console.error(e); } }); Services.prefs.setIntPref("browser.download.folderList", 2);