From e1ad6294bfd989ffe588d54b2239270bb4098680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 1 Aug 2024 17:12:48 +0000 Subject: [PATCH] Bug 1910698 - Remove nsIScriptError.sourceLine. r=smaug,devtools-reviewers,webdriver-reviewers,necko-reviewers,nchevobbe,kershaw,jdescottes,credential-management-reviewers,dimi Afaict the source lines are not exposed anywhere in the UI. Differential Revision: https://phabricator.services.mozilla.com/D218115 --- browser/base/content/browser-addons.js | 1 - .../browser-fullScreenAndPointerLock.js | 1 - browser/modules/PermissionUI.sys.mjs | 1 - caps/nsScriptSecurityManager.cpp | 7 +- chrome/nsChromeRegistry.cpp | 6 +- .../test/browser/browser_console.js | 1 - .../test/node/fixtures/stubs/cssMessage.js | 6 +- .../test/node/fixtures/stubs/pageError.js | 34 +----- .../server/actors/resources/css-messages.js | 12 --- .../server/actors/resources/error-messages.js | 11 -- .../server/actors/targets/window-global.js | 1 - .../server/actors/utils/custom-formatters.js | 3 +- devtools/server/actors/webconsole.js | 12 --- .../tests/browser_resources_error_messages.js | 18 ---- docshell/base/nsDocShell.cpp | 8 +- dom/base/ChromeUtils.cpp | 7 +- dom/base/DOMException.cpp | 2 +- dom/base/DOMException.h | 2 +- dom/base/EventSource.cpp | 6 +- dom/base/PostMessageEvent.cpp | 16 +-- dom/base/SourceLocation.cpp | 14 +-- dom/base/SourceLocation.h | 6 +- dom/base/nsContentUtils.cpp | 26 ++--- dom/base/nsContentUtils.h | 7 -- dom/base/nsFrameMessageManager.cpp | 13 ++- dom/bindings/Exceptions.cpp | 17 ++- dom/bindings/nsIScriptError.idl | 41 +++---- dom/bindings/nsScriptError.cpp | 102 ++++++++---------- dom/bindings/nsScriptError.h | 11 +- dom/console/Console.cpp | 9 +- dom/events/JSEventHandler.cpp | 5 +- dom/file/uri/BlobURLProtocolHandler.cpp | 7 +- dom/ipc/ContentChild.cpp | 33 +++--- dom/ipc/ContentChild.h | 10 +- dom/ipc/ContentParent.cpp | 46 ++++---- dom/ipc/ContentParent.h | 29 +++-- dom/ipc/PContent.ipdl | 4 +- dom/media/IdpSandbox.sys.mjs | 1 - dom/media/PeerConnection.sys.mjs | 1 - dom/media/webaudio/AudioWorkletNode.cpp | 8 +- dom/security/nsCSPUtils.cpp | 12 +-- dom/security/nsCSPUtils.h | 2 - dom/security/nsContentSecurityUtils.cpp | 7 +- dom/serviceworkers/test/console_monitor.js | 1 - dom/webidl/DOMException.webidl | 2 +- dom/webidl/ErrorEvent.webidl | 4 +- dom/webidl/EventHandler.webidl | 2 +- dom/websocket/WebSocket.cpp | 14 ++- dom/workers/WorkerDebugger.cpp | 8 +- dom/workers/WorkerDebugger.h | 4 +- dom/workers/WorkerError.cpp | 16 ++- dom/workers/WorkerError.h | 11 +- dom/workers/WorkerPrivate.cpp | 2 +- dom/workers/WorkerPrivate.h | 2 +- dom/workers/WorkerScope.cpp | 8 +- dom/workers/nsIWorkerDebugger.idl | 2 +- .../remoteworkers/RemoteWorkerChild.cpp | 2 +- .../remoteworkers/RemoteWorkerTypes.ipdlh | 5 +- image/RasterImage.cpp | 8 +- intl/l10n/rust/l10nregistry-ffi/src/env.rs | 13 ++- js/xpconnect/src/Sandbox.cpp | 4 +- js/xpconnect/src/XPCComponents.cpp | 29 ++--- js/xpconnect/src/XPCConvert.cpp | 6 +- js/xpconnect/src/XPCWrappedJSClass.cpp | 6 +- js/xpconnect/src/XPCWrappedNativeInfo.cpp | 3 +- js/xpconnect/src/nsXPConnect.cpp | 15 ++- js/xpconnect/src/xpcpublic.h | 3 +- js/xpconnect/wrappers/XrayWrapper.cpp | 4 +- layout/generic/nsImageMap.cpp | 6 +- layout/style/ErrorReporter.cpp | 20 ++-- layout/style/ErrorReporter.h | 4 +- layout/style/FontFaceSetImpl.cpp | 7 +- layout/style/GeckoBindings.cpp | 18 ++-- layout/style/GeckoBindings.h | 5 +- layout/style/test/test_bug413958.html | 10 +- netwerk/base/nsNetUtil.cpp | 4 +- netwerk/base/nsNetUtil.h | 2 +- netwerk/protocol/http/HttpBaseChannel.cpp | 6 +- netwerk/protocol/http/nsCORSListenerProxy.cpp | 14 ++- netwerk/protocol/http/nsHttpChannel.cpp | 6 +- parser/htmlparser/nsExpatDriver.cpp | 2 +- remote/cdp/test/browser/head.js | 1 - remote/shared/Realm.sys.mjs | 3 +- .../test/browser/browser_ConsoleListener.js | 1 - security/sandbox/linux/glue/SandboxCrash.cpp | 7 +- servo/ports/geckolib/error_reporter.rs | 4 - .../content/SpecialPowersChild.sys.mjs | 2 - .../cookiebanners/CookieBannerParent.sys.mjs | 5 +- .../extensions/ExtensionCommon.sys.mjs | 1 - .../extensions/ExtensionContent.sys.mjs | 1 - .../extensions/ExtensionPageChild.sys.mjs | 1 - .../glean/bindings/private/Common.cpp | 2 +- .../passwordmgr/InsecurePasswordUtils.sys.mjs | 1 - .../browser_insecurePasswordConsoleWarning.js | 2 +- .../telemetry/core/TelemetryCommon.cpp | 2 +- uriloader/preload/PreloaderBase.cpp | 10 +- xpcom/base/CycleCollectedJSRuntime.h | 2 +- xpcom/base/nsConsoleService.cpp | 11 +- xpcom/base/nsIException.idl | 5 +- xpcom/components/ManifestParser.cpp | 7 +- xpcom/ds/nsObserverService.cpp | 2 +- 101 files changed, 341 insertions(+), 573 deletions(-) diff --git a/browser/base/content/browser-addons.js b/browser/base/content/browser-addons.js index d071b231aa13..e81885a220e4 100644 --- a/browser/base/content/browser-addons.js +++ b/browser/base/content/browser-addons.js @@ -522,7 +522,6 @@ var gXPInstallObserver = { consoleMsg.initWithWindowID( message, gBrowser.currentURI.spec, - null, 0, 0, Ci.nsIScriptError.warningFlag, diff --git a/browser/base/content/browser-fullScreenAndPointerLock.js b/browser/base/content/browser-fullScreenAndPointerLock.js index c8794c760c17..a83d949499ab 100644 --- a/browser/base/content/browser-fullScreenAndPointerLock.js +++ b/browser/base/content/browser-fullScreenAndPointerLock.js @@ -464,7 +464,6 @@ var FullScreen = { consoleMsg.initWithWindowID( message, gBrowser.currentURI.spec, - null, 0, 0, Ci.nsIScriptError.warningFlag, diff --git a/browser/modules/PermissionUI.sys.mjs b/browser/modules/PermissionUI.sys.mjs index 8ef7bb232f37..8ed346e054bc 100644 --- a/browser/modules/PermissionUI.sys.mjs +++ b/browser/modules/PermissionUI.sys.mjs @@ -706,7 +706,6 @@ class SitePermsAddonInstallRequest extends PermissionPromptForRequest { scriptError.initWithWindowID( errorMessage, null, - null, 0, 0, 0, diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index b0dab054e2d3..292302df820d 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -1151,12 +1151,11 @@ nsresult nsScriptSecurityManager::ReportError(const char* aMessageTag, // using category of "SOP" so we can link to MDN if (aInnerWindowID != 0) { rv = error->InitWithWindowID( - message, u""_ns, u""_ns, 0, 0, nsIScriptError::errorFlag, "SOP"_ns, + message, ""_ns, 0, 0, nsIScriptError::errorFlag, "SOP"_ns, aInnerWindowID, true /* From chrome context */); } else { - rv = error->Init(message, u""_ns, u""_ns, 0, 0, nsIScriptError::errorFlag, - "SOP"_ns, aFromPrivateWindow, - true /* From chrome context */); + rv = error->Init(message, ""_ns, 0, 0, nsIScriptError::errorFlag, "SOP"_ns, + aFromPrivateWindow, true /* From chrome context */); } NS_ENSURE_SUCCESS(rv, rv); console->LogMessage(error); diff --git a/chrome/nsChromeRegistry.cpp b/chrome/nsChromeRegistry.cpp index 05f4d3dfe6dc..0821d572310c 100644 --- a/chrome/nsChromeRegistry.cpp +++ b/chrome/nsChromeRegistry.cpp @@ -75,9 +75,9 @@ void nsChromeRegistry::LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber, nsCString spec; if (aURL) aURL->GetSpec(spec); - rv = error->Init(NS_ConvertUTF8toUTF16(formatted.get()), - NS_ConvertUTF8toUTF16(spec), u""_ns, aLineNumber, 0, flags, - "chrome registration"_ns, false /* from private window */, + rv = error->Init(NS_ConvertUTF8toUTF16(formatted.get()), spec, aLineNumber, 0, + flags, "chrome registration"_ns, + false /* from private window */, true /* from chrome context */); if (NS_FAILED(rv)) return; diff --git a/devtools/client/webconsole/test/browser/browser_console.js b/devtools/client/webconsole/test/browser/browser_console.js index 131678415bcc..d5b39b65cbad 100644 --- a/devtools/client/webconsole/test/browser/browser_console.js +++ b/devtools/client/webconsole/test/browser/browser_console.js @@ -181,7 +181,6 @@ async function testMessages() { scriptErrorMessage.initWithWindowID( "Error from Services.console.logMessage", gBrowser.currentURI.prePath, - null, 0, 0, Ci.nsIScriptError.warningFlag, diff --git a/devtools/client/webconsole/test/node/fixtures/stubs/cssMessage.js b/devtools/client/webconsole/test/node/fixtures/stubs/cssMessage.js index 89a200839abe..475c97c884ce 100644 --- a/devtools/client/webconsole/test/node/fixtures/stubs/cssMessage.js +++ b/devtools/client/webconsole/test/node/fixtures/stubs/cssMessage.js @@ -23,7 +23,6 @@ rawPackets.set(`Unknown property ‘such-unknown-property’. Declaration dropp "errorMessage": "Unknown property ‘such-unknown-property’. Declaration dropped.", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-css-message.html", "sourceId": null, - "lineText": "", "lineNumber": 3, "columnNumber": 27, "category": "CSS Parser", @@ -38,8 +37,8 @@ rawPackets.set(`Unknown property ‘such-unknown-property’. Declaration dropp "chromeContext": false, "isForwardedFromContentProcess": false }, - "resourceType": "css-message", "cssSelectors": "p", + "resourceType": "css-message", "isAlreadyExistingResource": false }); @@ -48,7 +47,6 @@ rawPackets.set(`Error in parsing value for ‘padding-top’. Declaration dropp "errorMessage": "Error in parsing value for ‘padding-top’. Declaration dropped.", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/stub-generators/test-css-message.html", "sourceId": null, - "lineText": "", "lineNumber": 3, "columnNumber": 18, "category": "CSS Parser", @@ -63,8 +61,8 @@ rawPackets.set(`Error in parsing value for ‘padding-top’. Declaration dropp "chromeContext": false, "isForwardedFromContentProcess": false }, - "resourceType": "css-message", "cssSelectors": "p", + "resourceType": "css-message", "isAlreadyExistingResource": false }); diff --git a/devtools/client/webconsole/test/node/fixtures/stubs/pageError.js b/devtools/client/webconsole/test/node/fixtures/stubs/pageError.js index 8f8da9a521a9..cae806edef3e 100644 --- a/devtools/client/webconsole/test/node/fixtures/stubs/pageError.js +++ b/devtools/client/webconsole/test/node/fixtures/stubs/pageError.js @@ -25,7 +25,6 @@ rawPackets.set(`ReferenceError: asdf is not defined`, { "exceptionDocURL": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/Not_defined?utm_source=mozilla&utm_medium=firefox-console-errors&utm_campaign=default", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn0.child1/source22", - "lineText": "", "lineNumber": 3, "columnNumber": 5, "category": "content javascript", @@ -119,7 +118,6 @@ rawPackets.set(`SyntaxError: redeclaration of let a`, { "exceptionDocURL": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/Redeclared_parameter?utm_source=mozilla&utm_medium=firefox-console-errors&utm_campaign=default", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": null, - "lineText": " let a, a;", "lineNumber": 2, "columnNumber": 10, "category": "content javascript", @@ -204,12 +202,11 @@ rawPackets.set(`TypeError longString message`, { "length": 110007, "initial": "Error: Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Long error Lon" }, - "actorID": "server0.conn0.windowGlobal15032385537/longstractor23" + "actorID": "server0.conn0.process7//longstractor24" }, "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn0.child1/source23", - "lineText": "", "lineNumber": 1, "columnNumber": 7, "category": "content javascript", @@ -296,7 +293,6 @@ rawPackets.set(`throw string with URL`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn0.child2/source31", - "lineText": "", "lineNumber": 1, "columnNumber": 1, "category": "content javascript", @@ -354,7 +350,6 @@ rawPackets.set(`throw ""`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": null, - "lineText": "", "lineNumber": 1, "columnNumber": 1, "category": "content javascript", @@ -412,7 +407,6 @@ rawPackets.set(`throw "tomato"`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": null, - "lineText": "", "lineNumber": 1, "columnNumber": 1, "category": "content javascript", @@ -470,7 +464,6 @@ rawPackets.set(`throw false`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn4.child2/source31", - "lineText": "", "lineNumber": 1, "columnNumber": 1, "category": "content javascript", @@ -528,7 +521,6 @@ rawPackets.set(`throw 0`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn4.child2/source31", - "lineText": "", "lineNumber": 1, "columnNumber": 1, "category": "content javascript", @@ -586,7 +578,6 @@ rawPackets.set(`throw null`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn4.child2/source31", - "lineText": "", "lineNumber": 1, "columnNumber": 1, "category": "content javascript", @@ -646,7 +637,6 @@ rawPackets.set(`throw undefined`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn4.child2/source31", - "lineText": "", "lineNumber": 1, "columnNumber": 1, "category": "content javascript", @@ -706,7 +696,6 @@ rawPackets.set(`throw Symbol`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn4.child2/source27", - "lineText": "", "lineNumber": 1, "columnNumber": 7, "category": "content javascript", @@ -768,7 +757,6 @@ rawPackets.set(`throw Object`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn4.child2/source31", - "lineText": "", "lineNumber": 1, "columnNumber": 1, "category": "content javascript", @@ -850,7 +838,6 @@ rawPackets.set(`throw Error Object`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn4.child2/source41", - "lineText": "", "lineNumber": 1, "columnNumber": 7, "category": "content javascript", @@ -929,7 +916,6 @@ rawPackets.set(`throw Error Object with custom name`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn4.child2/source43", - "lineText": "", "lineNumber": 2, "columnNumber": 15, "category": "content javascript", @@ -1008,7 +994,6 @@ rawPackets.set(`throw Error Object with error cause`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn0.child4/source45", - "lineText": "", "lineNumber": 3, "columnNumber": 15, "category": "content javascript", @@ -1106,7 +1091,6 @@ rawPackets.set(`throw Error Object with cause chain`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn0.child4/source48", - "lineText": "", "lineNumber": 5, "columnNumber": 13, "category": "content javascript", @@ -1242,7 +1226,6 @@ rawPackets.set(`throw Error Object with cyclical cause chain`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn0.child4/source53", - "lineText": "", "lineNumber": 3, "columnNumber": 13, "category": "content javascript", @@ -1378,7 +1361,6 @@ rawPackets.set(`throw Error Object with falsy cause`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn0.child4/source58", - "lineText": "", "lineNumber": 1, "columnNumber": 7, "category": "content javascript", @@ -1460,7 +1442,6 @@ rawPackets.set(`throw Error Object with number cause`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn0.child4/source60", - "lineText": "", "lineNumber": 1, "columnNumber": 7, "category": "content javascript", @@ -1540,7 +1521,6 @@ rawPackets.set(`throw Error Object with string cause`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn0.child4/source62", - "lineText": "", "lineNumber": 1, "columnNumber": 7, "category": "content javascript", @@ -1620,7 +1600,6 @@ rawPackets.set(`throw Error Object with object cause`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn0.child4/source64", - "lineText": "", "lineNumber": 1, "columnNumber": 7, "category": "content javascript", @@ -1709,7 +1688,6 @@ rawPackets.set(`Promise reject ""`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": null, - "lineText": "", "lineNumber": 1, "columnNumber": 9, "category": "content javascript", @@ -1767,7 +1745,6 @@ rawPackets.set(`Promise reject "tomato"`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": null, - "lineText": "", "lineNumber": 1, "columnNumber": 9, "category": "content javascript", @@ -1825,7 +1802,6 @@ rawPackets.set(`Promise reject false`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": null, - "lineText": "", "lineNumber": 1, "columnNumber": 9, "category": "content javascript", @@ -1883,7 +1859,6 @@ rawPackets.set(`Promise reject 0`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": null, - "lineText": "", "lineNumber": 1, "columnNumber": 9, "category": "content javascript", @@ -1941,7 +1916,6 @@ rawPackets.set(`Promise reject null`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": null, - "lineText": "", "lineNumber": 1, "columnNumber": 9, "category": "content javascript", @@ -2001,7 +1975,6 @@ rawPackets.set(`Promise reject undefined`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": null, - "lineText": "", "lineNumber": 1, "columnNumber": 9, "category": "content javascript", @@ -2061,7 +2034,6 @@ rawPackets.set(`Promise reject Symbol`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": null, - "lineText": "", "lineNumber": 1, "columnNumber": 9, "category": "content javascript", @@ -2123,7 +2095,6 @@ rawPackets.set(`Promise reject Object`, { "errorMessageName": "JSMSG_UNCAUGHT_EXCEPTION", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": null, - "lineText": "", "lineNumber": 1, "columnNumber": 9, "category": "content javascript", @@ -2205,7 +2176,6 @@ rawPackets.set(`Promise reject Error Object`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn4.child2/source55", - "lineText": "", "lineNumber": 1, "columnNumber": 16, "category": "content javascript", @@ -2284,7 +2254,6 @@ rawPackets.set(`Promise reject Error Object with custom name`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn4.child2/source57", - "lineText": "", "lineNumber": 2, "columnNumber": 15, "category": "content javascript", @@ -2363,7 +2332,6 @@ rawPackets.set(`Promise reject Error Object with error cause`, { "errorMessageName": "", "sourceName": "https://example.com/browser/devtools/client/webconsole/test/browser/test-console-api.html", "sourceId": "server0.conn0.child4/source81", - "lineText": "", "lineNumber": 5, "columnNumber": 15, "category": "content javascript", diff --git a/devtools/server/actors/resources/css-messages.js b/devtools/server/actors/resources/css-messages.js index 5c8033b5a38d..730826ccea85 100644 --- a/devtools/server/actors/resources/css-messages.js +++ b/devtools/server/actors/resources/css-messages.js @@ -5,9 +5,6 @@ "use strict"; const nsIConsoleListenerWatcher = require("resource://devtools/server/actors/resources/utils/nsi-console-listener-watcher.js"); -const { - DevToolsServer, -} = require("resource://devtools/server/devtools-server.js"); const { createStringGrip, } = require("resource://devtools/server/actors/object/utils.js"); @@ -90,14 +87,6 @@ class CSSMessageWatcher extends nsIConsoleListenerWatcher { */ buildResource(targetActor, error) { const stack = this.prepareStackForRemote(targetActor, error.stack); - let lineText = error.sourceLine; - if ( - lineText && - lineText.length > DevToolsServer.LONG_STRING_INITIAL_LENGTH - ) { - lineText = lineText.substr(0, DevToolsServer.LONG_STRING_INITIAL_LENGTH); - } - const notesArray = this.prepareNotesForRemote(targetActor, error.notes); // If there is no location information in the error but we have a stack, @@ -114,7 +103,6 @@ class CSSMessageWatcher extends nsIConsoleListenerWatcher { errorMessage: createStringGrip(targetActor, error.errorMessage), sourceName, sourceId: getActorIdForInternalSourceId(targetActor, sourceId), - lineText, lineNumber, columnNumber, category: error.category, diff --git a/devtools/server/actors/resources/error-messages.js b/devtools/server/actors/resources/error-messages.js index 53a90b652a82..f6c69dec5ac5 100644 --- a/devtools/server/actors/resources/error-messages.js +++ b/devtools/server/actors/resources/error-messages.js @@ -5,9 +5,6 @@ "use strict"; const nsIConsoleListenerWatcher = require("resource://devtools/server/actors/resources/utils/nsi-console-listener-watcher.js"); -const { - DevToolsServer, -} = require("resource://devtools/server/devtools-server.js"); const ErrorDocs = require("resource://devtools/server/actors/errordocs.js"); const { createStringGrip, @@ -124,13 +121,6 @@ class ErrorMessageWatcher extends nsIConsoleListenerWatcher { */ buildResource(targetActor, error) { const stack = this.prepareStackForRemote(targetActor, error.stack); - let lineText = error.sourceLine; - if ( - lineText && - lineText.length > DevToolsServer.LONG_STRING_INITIAL_LENGTH - ) { - lineText = lineText.substr(0, DevToolsServer.LONG_STRING_INITIAL_LENGTH); - } const notesArray = this.prepareNotesForRemote(targetActor, error.notes); @@ -150,7 +140,6 @@ class ErrorMessageWatcher extends nsIConsoleListenerWatcher { exceptionDocURL: ErrorDocs.GetURL(error), sourceName, sourceId: getActorIdForInternalSourceId(targetActor, sourceId), - lineText, lineNumber, columnNumber, category: error.category, diff --git a/devtools/server/actors/targets/window-global.js b/devtools/server/actors/targets/window-global.js index 9e38e3cc50f3..437510091e05 100644 --- a/devtools/server/actors/targets/window-global.js +++ b/devtools/server/actors/targets/window-global.js @@ -993,7 +993,6 @@ class WindowGlobalTargetActor extends BaseTargetActor { scriptError.initWithWindowID( text, null, - null, 0, 0, flags, diff --git a/devtools/server/actors/utils/custom-formatters.js b/devtools/server/actors/utils/custom-formatters.js index f6d8cab797fc..f9354d8ac2a8 100644 --- a/devtools/server/actors/utils/custom-formatters.js +++ b/devtools/server/actors/utils/custom-formatters.js @@ -355,12 +355,11 @@ exports.customFormatterBody = customFormatterBody; function logCustomFormatterError(window, errorMsg, script) { const scriptErrorClass = Cc["@mozilla.org/scripterror;1"]; const scriptError = scriptErrorClass.createInstance(Ci.nsIScriptError); - const { url, source, startLine, startColumn } = script ?? {}; + const { url, startLine, startColumn } = script ?? {}; scriptError.initWithWindowID( `Custom formatter failed: ${errorMsg}`, url, - source, startLine, startColumn, Ci.nsIScriptError.errorFlag, diff --git a/devtools/server/actors/webconsole.js b/devtools/server/actors/webconsole.js index 3de636be9633..b08d90604e70 100644 --- a/devtools/server/actors/webconsole.js +++ b/devtools/server/actors/webconsole.js @@ -11,9 +11,6 @@ const { webconsoleSpec, } = require("resource://devtools/shared/specs/webconsole.js"); -const { - DevToolsServer, -} = require("resource://devtools/server/devtools-server.js"); const { ThreadActor } = require("resource://devtools/server/actors/thread.js"); const { ObjectActor } = require("resource://devtools/server/actors/object.js"); const { @@ -1414,14 +1411,6 @@ class WebConsoleActor extends Actor { */ preparePageErrorForRemote(pageError) { const stack = this.prepareStackForRemote(pageError.stack); - let lineText = pageError.sourceLine; - if ( - lineText && - lineText.length > DevToolsServer.LONG_STRING_INITIAL_LENGTH - ) { - lineText = lineText.substr(0, DevToolsServer.LONG_STRING_INITIAL_LENGTH); - } - let notesArray = null; const notes = pageError.notes; if (notes?.length) { @@ -1458,7 +1447,6 @@ class WebConsoleActor extends Actor { exceptionDocURL: ErrorDocs.GetURL(pageError), sourceName, sourceId: this.getActorIdForInternalSourceId(sourceId), - lineText, lineNumber, columnNumber, category: pageError.category, diff --git a/devtools/shared/commands/resource/tests/browser_resources_error_messages.js b/devtools/shared/commands/resource/tests/browser_resources_error_messages.js index 6f94266e4cac..800771ba79a9 100644 --- a/devtools/shared/commands/resource/tests/browser_resources_error_messages.js +++ b/devtools/shared/commands/resource/tests/browser_resources_error_messages.js @@ -223,7 +223,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: mdnUrl( @@ -256,7 +255,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: mdnUrl("docs/Web/JavaScript/Reference/Errors/Bad_radix"), @@ -287,7 +285,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: mdnUrl("docs/Web/JavaScript/Reference/Errors/Read-only"), @@ -318,7 +315,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: mdnUrl( @@ -351,7 +347,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: mdnUrl( @@ -391,7 +386,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: mdnUrl( @@ -431,7 +425,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: mdnUrl( @@ -465,7 +458,6 @@ const expectedPageErrors = new Map([ warning: true, info: false, sourceId: null, - lineText: "function a() { return; 1 + 1; }", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: mdnUrl( @@ -492,7 +484,6 @@ const expectedPageErrors = new Map([ warning: false, info: false, sourceId: null, - lineText: "{let a, a;}", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: mdnUrl( @@ -528,7 +519,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: undefined, @@ -559,7 +549,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: undefined, @@ -597,7 +586,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, exceptionDocURL: undefined, @@ -640,7 +628,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, innerWindowID: NUMBER_REGEX, @@ -685,7 +672,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, innerWindowID: NUMBER_REGEX, @@ -738,7 +724,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, innerWindowID: NUMBER_REGEX, @@ -776,7 +761,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, innerWindowID: NUMBER_REGEX, @@ -814,7 +798,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, innerWindowID: NUMBER_REGEX, @@ -850,7 +833,6 @@ const expectedPageErrors = new Map([ error: true, warning: false, info: false, - lineText: "", lineNumber: NUMBER_REGEX, columnNumber: NUMBER_REGEX, innerWindowID: NUMBER_REGEX, diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index e86d36adf7d1..c15a424a05d2 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -6342,10 +6342,12 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress, DisplayLoadError(aStatus, url, nullptr, aChannel); } } else if (skippedUnknownProtocolNavigation) { + nsAutoCString sanitized; nsTArray params; - if (NS_FAILED( - NS_GetSanitizedURIStringFromURI(url, *params.AppendElement()))) { - params.LastElement().AssignLiteral(u"(unknown uri)"); + if (NS_SUCCEEDED(NS_GetSanitizedURIStringFromURI(url, sanitized))) { + params.AppendElement(NS_ConvertUTF8toUTF16(sanitized)); + } else { + params.AppendElement(u"(unknown uri)"_ns); } nsContentUtils::ReportToConsole( nsIScriptError::warningFlag, "DOM"_ns, GetExtantDocument(), diff --git a/dom/base/ChromeUtils.cpp b/dom/base/ChromeUtils.cpp index ce3be98fb617..6833d2227f30 100644 --- a/dom/base/ChromeUtils.cpp +++ b/dom/base/ChromeUtils.cpp @@ -187,23 +187,22 @@ void ChromeUtils::ReleaseAssert(GlobalObject& aGlobal, bool aCondition, } // Extract the current stack from the JS runtime to embed in the crash reason. - nsAutoString filename; + nsAutoCString filename; uint32_t lineNo = 0; if (nsCOMPtr location = GetCurrentJSStack(1)) { location->GetFilename(aGlobal.Context(), filename); lineNo = location->GetLineNumber(aGlobal.Context()); } else { - filename.Assign(u""_ns); + filename.Assign(""_ns); } // Convert to utf-8 for adding as the MozCrashReason. - NS_ConvertUTF16toUTF8 filenameUtf8(filename); NS_ConvertUTF16toUTF8 messageUtf8(aMessage); // Actually crash. MOZ_CRASH_UNSAFE_PRINTF("Failed ChromeUtils.releaseAssert(\"%s\") @ %s:%u", - messageUtf8.get(), filenameUtf8.get(), lineNo); + messageUtf8.get(), filename.get(), lineNo); } /* static */ diff --git a/dom/base/DOMException.cpp b/dom/base/DOMException.cpp index d3e2fc42d3db..8bb60054a511 100644 --- a/dom/base/DOMException.cpp +++ b/dom/base/DOMException.cpp @@ -222,7 +222,7 @@ void Exception::GetName(nsAString& aName) { } } -void Exception::GetFilename(JSContext* aCx, nsAString& aFilename) { +void Exception::GetFilename(JSContext* aCx, nsACString& aFilename) { if (mLocation) { mLocation->GetFilename(aCx, aFilename); return; diff --git a/dom/base/DOMException.h b/dom/base/DOMException.h index c44cf904a04a..aff096bbc055 100644 --- a/dom/base/DOMException.h +++ b/dom/base/DOMException.h @@ -86,7 +86,7 @@ class Exception : public nsIException, public nsWrapperCache { CreateErrorMessage(name, aRetVal); } - void GetFilename(JSContext* aCx, nsAString& aFilename); + void GetFilename(JSContext* aCx, nsACString& aFilename); uint32_t SourceId(JSContext* aCx) const; diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp index aa3f675d19fb..d1d6bae8db85 100644 --- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -1292,9 +1292,9 @@ nsresult EventSourceImpl::PrintErrorOnConsole( NS_ENSURE_SUCCESS(rv, rv); rv = errObj->InitWithWindowID( - message, NS_ConvertUTF8toUTF16(mCallingLocation.FileName()), u""_ns, - mCallingLocation.mLine, mCallingLocation.mColumn, - nsIScriptError::errorFlag, "Event Source", mInnerWindowID); + message, mCallingLocation.FileName(), mCallingLocation.mLine, + mCallingLocation.mColumn, nsIScriptError::errorFlag, "Event Source", + mInnerWindowID); NS_ENSURE_SUCCESS(rv, rv); // print the error message directly to the JS console diff --git a/dom/base/PostMessageEvent.cpp b/dom/base/PostMessageEvent.cpp index f1ede5dc6f7e..952b9e93958d 100644 --- a/dom/base/PostMessageEvent.cpp +++ b/dom/base/PostMessageEvent.cpp @@ -138,18 +138,18 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP PostMessageEvent::Run() { NS_ENSURE_SUCCESS(rv, rv); if (mCallerWindowID == 0) { - rv = errorObject->Init( - errorText, NS_ConvertUTF8toUTF16(mScriptLocation.value()), u""_ns, - 0, 0, nsIScriptError::errorFlag, "DOM Window"_ns, - mIsFromPrivateWindow, mProvidedPrincipal->IsSystemPrincipal()); + rv = errorObject->Init(errorText, mScriptLocation.value(), 0, 0, + nsIScriptError::errorFlag, "DOM Window"_ns, + mIsFromPrivateWindow, + mProvidedPrincipal->IsSystemPrincipal()); } else if (callerURI) { - rv = errorObject->InitWithSourceURI(errorText, callerURI, u""_ns, 0, 0, + rv = errorObject->InitWithSourceURI(errorText, callerURI, 0, 0, nsIScriptError::errorFlag, "DOM Window"_ns, mCallerWindowID); } else { - rv = errorObject->InitWithWindowID( - errorText, NS_ConvertUTF8toUTF16(mScriptLocation.value()), u""_ns, - 0, 0, nsIScriptError::errorFlag, "DOM Window"_ns, mCallerWindowID); + rv = errorObject->InitWithWindowID(errorText, mScriptLocation.value(), + 0, 0, nsIScriptError::errorFlag, + "DOM Window"_ns, mCallerWindowID); } NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/base/SourceLocation.cpp b/dom/base/SourceLocation.cpp index 48b6337d64a5..0231639c16f0 100644 --- a/dom/base/SourceLocation.cpp +++ b/dom/base/SourceLocation.cpp @@ -14,18 +14,12 @@ SourceLocation::SourceLocation() = default; SourceLocation::~SourceLocation() = default; SourceLocation::SourceLocation(nsCString&& aResource, uint32_t aLine, - uint32_t aCol, nsCString&& aSourceLine) - : mResource(std::move(aResource)), - mLine(aLine), - mColumn(aCol), - mSourceLine(std::move(aSourceLine)) {} + uint32_t aCol) + : mResource(std::move(aResource)), mLine(aLine), mColumn(aCol) {} SourceLocation::SourceLocation(nsCOMPtr&& aResource, uint32_t aLine, - uint32_t aCol, nsCString&& aSourceLine) - : mResource(std::move(aResource)), - mLine(aLine), - mColumn(aCol), - mSourceLine(std::move(aSourceLine)) {} + uint32_t aCol) + : mResource(std::move(aResource)), mLine(aLine), mColumn(aCol) {} JSCallingLocation JSCallingLocation::Get() { return Get(nsContentUtils::GetCurrentJSContext()); diff --git a/dom/base/SourceLocation.h b/dom/base/SourceLocation.h index e23d417c63a4..ca78d55c35e2 100644 --- a/dom/base/SourceLocation.h +++ b/dom/base/SourceLocation.h @@ -20,13 +20,11 @@ struct SourceLocation { mozilla::Variant> mResource{VoidCString()}; uint32_t mLine = 0; uint32_t mColumn = 1; - nsCString mSourceLine; SourceLocation(); - explicit SourceLocation(nsCString&&, uint32_t aLine = 0, uint32_t aCol = 1, - nsCString&& aSourceLine = {}); + explicit SourceLocation(nsCString&&, uint32_t aLine = 0, uint32_t aCol = 1); explicit SourceLocation(nsCOMPtr&&, uint32_t aLine = 0, - uint32_t aCol = 1, nsCString&& aSourceLine = {}); + uint32_t aCol = 1); ~SourceLocation(); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index b3e4b04d4aaa..8518005d2938 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -4531,7 +4531,7 @@ void nsContentUtils::LogSimpleConsoleError(const nsAString& aErrorText, nsCOMPtr console = do_GetService(NS_CONSOLESERVICE_CONTRACTID); if (console && NS_SUCCEEDED(scriptError->Init( - aErrorText, u""_ns, u""_ns, 0, 0, aErrorFlags, aCategory, + aErrorText, ""_ns, 0, 0, aErrorFlags, aCategory, aFromPrivateWindow, aFromChromeContext))) { console->LogMessage(scriptError); } @@ -4591,17 +4591,15 @@ nsresult nsContentUtils::ReportToConsoleByWindowID( do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - NS_ConvertUTF8toUTF16 sourceLine(aLocation.mSourceLine); if (aLocation.mResource.is>()) { nsIURI* uri = aLocation.mResource.as>(); - rv = errorObject->InitWithSourceURI(aErrorText, uri, sourceLine, - aLocation.mLine, aLocation.mColumn, - aErrorFlags, aCategory, aInnerWindowID); + rv = errorObject->InitWithSourceURI(aErrorText, uri, aLocation.mLine, + aLocation.mColumn, aErrorFlags, + aCategory, aInnerWindowID); } else { rv = errorObject->InitWithWindowID( - aErrorText, NS_ConvertUTF8toUTF16(aLocation.mResource.as()), - sourceLine, aLocation.mLine, aLocation.mColumn, aErrorFlags, aCategory, - aInnerWindowID); + aErrorText, aLocation.mResource.as(), aLocation.mLine, + aLocation.mColumn, aErrorFlags, aCategory, aInnerWindowID); } NS_ENSURE_SUCCESS(rv, rv); @@ -11016,7 +11014,7 @@ bool nsContentUtils::IsOverridingWindowName(const nsAString& aName) { template static Result ExtractExceptionValues( - JSContext* aCx, JS::Handle aObj, nsAString& aSourceSpecOut, + JSContext* aCx, JS::Handle aObj, nsACString& aSourceSpecOut, uint32_t* aLineOut, uint32_t* aColumnOut, nsString& aMessageOut) { AssertStaticUnwrapOK(); RefPtr exn; @@ -11041,16 +11039,6 @@ static Result ExtractExceptionValues( void nsContentUtils::ExtractErrorValues( JSContext* aCx, JS::Handle aValue, nsACString& aSourceSpecOut, uint32_t* aLineOut, uint32_t* aColumnOut, nsString& aMessageOut) { - nsAutoString sourceSpec; - ExtractErrorValues(aCx, aValue, sourceSpec, aLineOut, aColumnOut, - aMessageOut); - CopyUTF16toUTF8(sourceSpec, aSourceSpecOut); -} - -/* static */ -void nsContentUtils::ExtractErrorValues( - JSContext* aCx, JS::Handle aValue, nsAString& aSourceSpecOut, - uint32_t* aLineOut, uint32_t* aColumnOut, nsString& aMessageOut) { MOZ_ASSERT(aLineOut); MOZ_ASSERT(aColumnOut); diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index f0e5c36019d9..b4b2244ddfbe 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -1386,13 +1386,6 @@ class nsContentUtils { static bool PrefetchPreloadEnabled(nsIDocShell* aDocShell); - static void ExtractErrorValues(JSContext* aCx, JS::Handle aValue, - nsAString& aSourceSpecOut, uint32_t* aLineOut, - uint32_t* aColumnOut, nsString& aMessageOut); - - // Variant on `ExtractErrorValues` with a `nsACString`. This - // method is provided for backwards compatibility. Prefer the - // faster method above for your code. static void ExtractErrorValues(JSContext* aCx, JS::Handle aValue, nsACString& aSourceSpecOut, uint32_t* aLineOut, uint32_t* aColumnOut, nsString& aMessageOut); diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index 03afb5ca1e7f..8b2177eddc7e 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -461,8 +461,8 @@ bool nsFrameMessageManager::GetParamsForMessage(JSContext* aCx, error->Init( u"Sending message that cannot be cloned. Are " "you trying to send an XPCOM object?"_ns, - NS_ConvertUTF8toUTF16(location.FileName()), u""_ns, location.mLine, - location.mColumn, nsIScriptError::warningFlag, "chrome javascript"_ns, + location.FileName(), location.mLine, location.mColumn, + nsIScriptError::warningFlag, "chrome javascript"_ns, false /* from private window */, true /* from chrome context */); console->LogMessage(error); } @@ -805,17 +805,16 @@ void nsFrameMessageManager::ReceiveMessage( data->Write(cx, rval, aError); if (NS_WARN_IF(aError.Failed())) { aRetVal->RemoveLastElement(); - nsString msg = - aMessage + nsLiteralString( - u": message reply cannot be cloned. Are " - "you trying to send an XPCOM object?"); + nsString msg = aMessage + + u": message reply cannot be cloned. Are " + "you trying to send an XPCOM object?"_ns; nsCOMPtr console( do_GetService(NS_CONSOLESERVICE_CONTRACTID)); if (console) { nsCOMPtr error( do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); - error->Init(msg, u""_ns, u""_ns, 0, 0, nsIScriptError::warningFlag, + error->Init(msg, ""_ns, 0, 0, nsIScriptError::warningFlag, "chrome javascript"_ns, false /* from private window */, true /* from chrome context */); console->LogMessage(error); diff --git a/dom/bindings/Exceptions.cpp b/dom/bindings/Exceptions.cpp index eceddee9cfdb..b6467f8c4afa 100644 --- a/dom/bindings/Exceptions.cpp +++ b/dom/bindings/Exceptions.cpp @@ -226,7 +226,7 @@ class JSStackFrame final : public nsIStackFrame, public xpc::JSStackFrameBase { nsCOMPtr mCaller; nsCOMPtr mAsyncCaller; - nsString mFilename; + nsCString mFilename; nsString mFunname; nsString mAsyncCause; int32_t mSourceId; @@ -383,12 +383,12 @@ static void GetValueIfNotCached( } NS_IMETHODIMP JSStackFrame::GetFilenameXPCOM(JSContext* aCx, - nsAString& aFilename) { + nsACString& aFilename) { GetFilename(aCx, aFilename); return NS_OK; } -void JSStackFrame::GetFilename(JSContext* aCx, nsAString& aFilename) { +void JSStackFrame::GetFilename(JSContext* aCx, nsACString& aFilename) { if (!mStack) { aFilename.Truncate(); return; @@ -404,7 +404,7 @@ void JSStackFrame::GetFilename(JSContext* aCx, nsAString& aFilename) { return; } - nsAutoJSString str; + nsAutoJSCString str; if (!str.init(aCx, filename)) { JS_ClearPendingException(aCx); aFilename.Truncate(); @@ -542,11 +542,6 @@ JSStackFrame::GetColumnNumberXPCOM(JSContext* aCx, int32_t* aColumnNumber) { return NS_OK; } -NS_IMETHODIMP JSStackFrame::GetSourceLine(nsACString& aSourceLine) { - aSourceLine.Truncate(); - return NS_OK; -} - NS_IMETHODIMP JSStackFrame::GetAsyncCauseXPCOM(JSContext* aCx, nsAString& aAsyncCause) { GetAsyncCause(aCx, aAsyncCause); @@ -717,7 +712,7 @@ JSStackFrame::ToStringXPCOM(JSContext* aCx, nsACString& _retval) { void JSStackFrame::ToString(JSContext* aCx, nsACString& _retval) { _retval.Truncate(); - nsString filename; + nsCString filename; GetFilename(aCx, filename); if (filename.IsEmpty()) { @@ -734,7 +729,7 @@ void JSStackFrame::ToString(JSContext* aCx, nsACString& _retval) { int32_t lineno = GetLineNumber(aCx); static const char format[] = "JS frame :: %s :: %s :: line %d"; - _retval.AppendPrintf(format, NS_ConvertUTF16toUTF8(filename).get(), + _retval.AppendPrintf(format, filename.get(), NS_ConvertUTF16toUTF8(funname).get(), lineno); } diff --git a/dom/bindings/nsIScriptError.idl b/dom/bindings/nsIScriptError.idl index b650de181c84..3d06970ad334 100644 --- a/dom/bindings/nsIScriptError.idl +++ b/dom/bindings/nsIScriptError.idl @@ -21,7 +21,7 @@ interface nsIURI; interface nsIScriptErrorNote : nsISupports { readonly attribute AString errorMessage; - readonly attribute AString sourceName; + readonly attribute ACString sourceName; /** * Unique identifier within the process for the script source this note is @@ -55,8 +55,7 @@ interface nsIScriptError : nsIConsoleMessage */ readonly attribute AString errorMessage; - readonly attribute AString sourceName; - readonly attribute AString sourceLine; + readonly attribute ACString sourceName; /** * Unique identifier within the process for the script source this error is @@ -129,8 +128,7 @@ interface nsIScriptError : nsIConsoleMessage attribute AString cssSelectors; void init(in AString message, - in AString sourceName, - in AString sourceLine, + in ACString sourceName, in uint32_t lineNumber, in uint32_t columnNumber, in uint32_t flags, @@ -151,8 +149,7 @@ interface nsIScriptError : nsIConsoleMessage * (e.g. https://USERNAME:****@example.com/some/path). */ void initWithWindowID(in AString message, - in AString sourceName, - in AString sourceLine, + in ACString sourceName, in uint32_t lineNumber, in uint32_t columnNumber, in uint32_t flags, @@ -165,8 +162,7 @@ interface nsIScriptError : nsIConsoleMessage * Please use it only if sourceName string is already sanitized. */ void initWithSanitizedSource(in AString message, - in AString sourceName, - in AString sourceLine, + in ACString sourceName, in uint32_t lineNumber, in uint32_t columnNumber, in uint32_t flags, @@ -178,7 +174,6 @@ interface nsIScriptError : nsIConsoleMessage */ void initWithSourceURI(in AString message, in nsIURI sourceURI, - in AString sourceLine, in uint32_t lineNumber, in uint32_t columnNumber, in uint32_t flags, @@ -191,23 +186,21 @@ interface nsIScriptError : nsIConsoleMessage %{C++ nsresult InitWithWindowID(const nsAString& message, - const nsAString& sourceName, - const nsAString& sourceLine, + const nsACString& sourceName, uint32_t lineNumber, uint32_t columnNumber, uint32_t flags, const nsACString& category, uint64_t aInnerWindowID) { - return InitWithWindowID(message, sourceName, sourceLine, lineNumber, + return InitWithWindowID(message, sourceName, lineNumber, columnNumber, flags, category, aInnerWindowID, false); } // These overloads allow passing a literal string for category. template nsresult InitWithWindowID(const nsAString& message, - const nsAString& sourceName, - const nsAString& sourceLine, + const nsACString& sourceName, uint32_t lineNumber, uint32_t columnNumber, uint32_t flags, @@ -216,21 +209,20 @@ interface nsIScriptError : nsIConsoleMessage bool aFromChromeContext = false) { nsDependentCString category(c, N - 1); - return InitWithWindowID(message, sourceName, sourceLine, lineNumber, + return InitWithWindowID(message, sourceName, lineNumber, columnNumber, flags, category, aInnerWindowID, aFromChromeContext); } nsresult InitWithSanitizedSource(const nsAString& message, - const nsAString& sourceName, - const nsAString& sourceLine, + const nsACString& sourceName, uint32_t lineNumber, uint32_t columnNumber, uint32_t flags, const nsACString& category, uint64_t aInnerWindowID) { - return InitWithSanitizedSource(message, sourceName, sourceLine, + return InitWithSanitizedSource(message, sourceName, lineNumber, columnNumber, flags, category, aInnerWindowID, false); @@ -238,8 +230,7 @@ interface nsIScriptError : nsIConsoleMessage template nsresult InitWithSanitizedSource(const nsAString& message, - const nsAString& sourceName, - const nsAString& sourceLine, + const nsACString& sourceName, uint32_t lineNumber, uint32_t columnNumber, uint32_t flags, @@ -248,7 +239,7 @@ interface nsIScriptError : nsIConsoleMessage bool aFromChromeContext = false) { nsDependentCString category(c, N - 1); - return InitWithSanitizedSource(message, sourceName, sourceLine, + return InitWithSanitizedSource(message, sourceName, lineNumber, columnNumber, flags, category, aInnerWindowID, aFromChromeContext); @@ -256,14 +247,13 @@ interface nsIScriptError : nsIConsoleMessage nsresult InitWithSourceURI(const nsAString& message, nsIURI* sourceURI, - const nsAString& sourceLine, uint32_t lineNumber, uint32_t columnNumber, uint32_t flags, const nsACString& category, uint64_t aInnerWindowID) { - return InitWithSourceURI(message, sourceURI, sourceLine, + return InitWithSourceURI(message, sourceURI, lineNumber, columnNumber, flags, category, aInnerWindowID, false); } @@ -271,7 +261,6 @@ interface nsIScriptError : nsIConsoleMessage template nsresult InitWithSourceURI(const nsAString& message, nsIURI* sourceURI, - const nsAString& sourceLine, uint32_t lineNumber, uint32_t columnNumber, uint32_t flags, @@ -280,7 +269,7 @@ interface nsIScriptError : nsIConsoleMessage bool aFromChromeContext = false) { nsDependentCString category(c, N - 1); - return InitWithSourceURI(message, sourceURI, sourceLine, + return InitWithSourceURI(message, sourceURI, lineNumber, columnNumber, flags, category, aInnerWindowID, aFromChromeContext); } diff --git a/dom/bindings/nsScriptError.cpp b/dom/bindings/nsScriptError.cpp index c44ccaf39f25..adc836bc69b9 100644 --- a/dom/bindings/nsScriptError.cpp +++ b/dom/bindings/nsScriptError.cpp @@ -97,7 +97,7 @@ nsScriptErrorBase::GetErrorMessage(nsAString& aResult) { } NS_IMETHODIMP -nsScriptErrorBase::GetSourceName(nsAString& aResult) { +nsScriptErrorBase::GetSourceName(nsACString& aResult) { aResult.Assign(mSourceName); return NS_OK; } @@ -120,12 +120,6 @@ nsScriptErrorBase::GetSourceId(uint32_t* result) { return NS_OK; } -NS_IMETHODIMP -nsScriptErrorBase::GetSourceLine(nsAString& aResult) { - aResult.Assign(mSourceLine); - return NS_OK; -} - NS_IMETHODIMP nsScriptErrorBase::GetLineNumber(uint32_t* result) { *result = mLineNumber; @@ -194,9 +188,11 @@ nsScriptErrorBase::SetErrorMessageName(const nsAString& aErrorMessageName) { return NS_OK; } -static void AssignSourceNameHelper(nsString& aSourceNameDest, - const nsAString& aSourceNameSrc) { - if (aSourceNameSrc.IsEmpty()) return; +static void AssignSourceNameHelper(nsCString& aSourceNameDest, + const nsACString& aSourceNameSrc) { + if (aSourceNameSrc.IsEmpty()) { + return; + } aSourceNameDest.Assign(aSourceNameSrc); @@ -209,7 +205,7 @@ static void AssignSourceNameHelper(nsString& aSourceNameDest, } static void AssignSourceNameHelper(nsIURI* aSourceURI, - nsString& aSourceNameDest) { + nsCString& aSourceNameDest) { if (!aSourceURI) return; if (NS_FAILED(NS_GetSanitizedURIStringFromURI(aSourceURI, aSourceNameDest))) { @@ -218,13 +214,12 @@ static void AssignSourceNameHelper(nsIURI* aSourceURI, } NS_IMETHODIMP -nsScriptErrorBase::Init(const nsAString& message, const nsAString& sourceName, - const nsAString& sourceLine, uint32_t lineNumber, - uint32_t columnNumber, uint32_t flags, - const nsACString& category, bool fromPrivateWindow, - bool fromChromeContext) { - InitializationHelper(message, sourceLine, lineNumber, columnNumber, flags, - category, 0 /* inner Window ID */, fromChromeContext); +nsScriptErrorBase::Init(const nsAString& message, const nsACString& sourceName, + uint32_t lineNumber, uint32_t columnNumber, + uint32_t flags, const nsACString& category, + bool fromPrivateWindow, bool fromChromeContext) { + InitializationHelper(message, lineNumber, columnNumber, flags, category, + 0 /* inner Window ID */, fromChromeContext); AssignSourceNameHelper(mSourceName, sourceName); mIsFromPrivateWindow = fromPrivateWindow; @@ -233,12 +228,11 @@ nsScriptErrorBase::Init(const nsAString& message, const nsAString& sourceName, } void nsScriptErrorBase::InitializationHelper( - const nsAString& message, const nsAString& sourceLine, uint32_t lineNumber, - uint32_t columnNumber, uint32_t flags, const nsACString& category, - uint64_t aInnerWindowID, bool aFromChromeContext) { + const nsAString& message, uint32_t lineNumber, uint32_t columnNumber, + uint32_t flags, const nsACString& category, uint64_t aInnerWindowID, + bool aFromChromeContext) { mMessage.Assign(message); mLineNumber = lineNumber; - mSourceLine.Assign(sourceLine); mColumnNumber = columnNumber; mFlags = flags; mCategory = category; @@ -249,14 +243,13 @@ void nsScriptErrorBase::InitializationHelper( NS_IMETHODIMP nsScriptErrorBase::InitWithWindowID(const nsAString& message, - const nsAString& sourceName, - const nsAString& sourceLine, + const nsACString& sourceName, uint32_t lineNumber, uint32_t columnNumber, uint32_t flags, const nsACString& category, uint64_t aInnerWindowID, bool aFromChromeContext) { - InitializationHelper(message, sourceLine, lineNumber, columnNumber, flags, - category, aInnerWindowID, aFromChromeContext); + InitializationHelper(message, lineNumber, columnNumber, flags, category, + aInnerWindowID, aFromChromeContext); AssignSourceNameHelper(mSourceName, sourceName); if (aInnerWindowID && NS_IsMainThread()) InitializeOnMainThread(); @@ -266,12 +259,11 @@ nsScriptErrorBase::InitWithWindowID(const nsAString& message, NS_IMETHODIMP nsScriptErrorBase::InitWithSanitizedSource( - const nsAString& message, const nsAString& sourceName, - const nsAString& sourceLine, uint32_t lineNumber, uint32_t columnNumber, - uint32_t flags, const nsACString& category, uint64_t aInnerWindowID, - bool aFromChromeContext) { - InitializationHelper(message, sourceLine, lineNumber, columnNumber, flags, - category, aInnerWindowID, aFromChromeContext); + const nsAString& message, const nsACString& sourceName, uint32_t lineNumber, + uint32_t columnNumber, uint32_t flags, const nsACString& category, + uint64_t aInnerWindowID, bool aFromChromeContext) { + InitializationHelper(message, lineNumber, columnNumber, flags, category, + aInnerWindowID, aFromChromeContext); mSourceName = sourceName; if (aInnerWindowID && NS_IsMainThread()) InitializeOnMainThread(); @@ -281,14 +273,13 @@ nsScriptErrorBase::InitWithSanitizedSource( NS_IMETHODIMP nsScriptErrorBase::InitWithSourceURI(const nsAString& message, - nsIURI* sourceURI, - const nsAString& sourceLine, - uint32_t lineNumber, uint32_t columnNumber, - uint32_t flags, const nsACString& category, + nsIURI* sourceURI, uint32_t lineNumber, + uint32_t columnNumber, uint32_t flags, + const nsACString& category, uint64_t aInnerWindowID, bool aFromChromeContext) { - InitializationHelper(message, sourceLine, lineNumber, columnNumber, flags, - category, aInnerWindowID, aFromChromeContext); + InitializationHelper(message, lineNumber, columnNumber, flags, category, + aInnerWindowID, aFromChromeContext); AssignSourceNameHelper(sourceURI, mSourceName); if (aInnerWindowID && NS_IsMainThread()) InitializeOnMainThread(); @@ -297,8 +288,7 @@ nsScriptErrorBase::InitWithSourceURI(const nsAString& message, } static nsresult ToStringHelper(const char* aSeverity, const nsString& aMessage, - const nsString& aSourceName, - const nsString* aSourceLine, + const nsCString& aSourceName, uint32_t aLineNumber, uint32_t aColumnNumber, nsACString& /*UTF8*/ aResult) { static const char format0[] = @@ -311,15 +301,15 @@ static nsresult ToStringHelper(const char* aSeverity, const nsString& aMessage, char* tempSourceName = nullptr; char* tempSourceLine = nullptr; - if (!aMessage.IsEmpty()) tempMessage = ToNewUTF8String(aMessage); - if (!aSourceName.IsEmpty()) + if (!aMessage.IsEmpty()) { + tempMessage = ToNewUTF8String(aMessage); + } + if (!aSourceName.IsEmpty()) { // Use at most 512 characters from mSourceName. - tempSourceName = ToNewUTF8String(StringHead(aSourceName, 512)); - if (aSourceLine && !aSourceLine->IsEmpty()) - // Use at most 512 characters from mSourceLine. - tempSourceLine = ToNewUTF8String(StringHead(*aSourceLine, 512)); + tempSourceName = ToNewCString(StringHead(aSourceName, 512)); + } - if (nullptr != tempSourceName && nullptr != tempSourceLine) { + if (tempSourceName && tempSourceLine) { temp = JS_smprintf(format0, aSeverity, tempMessage, tempSourceName, aLineNumber, aColumnNumber, tempSourceLine); } else if (!aSourceName.IsEmpty()) { @@ -329,9 +319,9 @@ static nsresult ToStringHelper(const char* aSeverity, const nsString& aMessage, temp = JS_smprintf(format2, aSeverity, tempMessage); } - if (nullptr != tempMessage) free(tempMessage); - if (nullptr != tempSourceName) free(tempSourceName); - if (nullptr != tempSourceLine) free(tempSourceLine); + if (tempMessage) free(tempMessage); + if (tempSourceName) free(tempSourceName); + if (tempSourceLine) free(tempSourceLine); if (!temp) return NS_ERROR_OUT_OF_MEMORY; @@ -347,8 +337,8 @@ nsScriptErrorBase::ToString(nsACString& /*UTF8*/ aResult) { const char* severity = !(mFlags & nsIScriptError::warningFlag) ? error : warning; - return ToStringHelper(severity, mMessage, mSourceName, &mSourceLine, - mLineNumber, mColumnNumber, aResult); + return ToStringHelper(severity, mMessage, mSourceName, mLineNumber, + mColumnNumber, aResult); } NS_IMETHODIMP @@ -472,7 +462,7 @@ nsScriptErrorNote::nsScriptErrorNote() nsScriptErrorNote::~nsScriptErrorNote() = default; void nsScriptErrorNote::Init(const nsAString& message, - const nsAString& sourceName, uint32_t sourceId, + const nsACString& sourceName, uint32_t sourceId, uint32_t lineNumber, uint32_t columnNumber) { mMessage.Assign(message); AssignSourceNameHelper(mSourceName, sourceName); @@ -489,7 +479,7 @@ nsScriptErrorNote::GetErrorMessage(nsAString& aResult) { } NS_IMETHODIMP -nsScriptErrorNote::GetSourceName(nsAString& aResult) { +nsScriptErrorNote::GetSourceName(nsACString& aResult) { aResult.Assign(mSourceName); return NS_OK; } @@ -514,8 +504,8 @@ nsScriptErrorNote::GetColumnNumber(uint32_t* result) { NS_IMETHODIMP nsScriptErrorNote::ToString(nsACString& /*UTF8*/ aResult) { - return ToStringHelper("JavaScript Note", mMessage, mSourceName, nullptr, - mLineNumber, mColumnNumber, aResult); + return ToStringHelper("JavaScript Note", mMessage, mSourceName, mLineNumber, + mColumnNumber, aResult); } NS_IMPL_ISUPPORTS(nsScriptErrorNote, nsIScriptErrorNote) diff --git a/dom/bindings/nsScriptError.h b/dom/bindings/nsScriptError.h index f00a859a5942..4a2818a1625a 100644 --- a/dom/bindings/nsScriptError.h +++ b/dom/bindings/nsScriptError.h @@ -28,16 +28,15 @@ class nsScriptErrorNote final : public nsIScriptErrorNote { NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSISCRIPTERRORNOTE - void Init(const nsAString& message, const nsAString& sourceName, + void Init(const nsAString& message, const nsACString& sourceName, uint32_t sourceId, uint32_t lineNumber, uint32_t columnNumber); private: virtual ~nsScriptErrorNote(); nsString mMessage; - nsString mSourceName; + nsCString mSourceName; nsString mCssSelectors; - nsString mSourceLine; uint32_t mSourceId; uint32_t mLineNumber; uint32_t mColumnNumber; @@ -62,8 +61,7 @@ class nsScriptErrorBase : public nsIScriptError { void InitializeOnMainThread(); - void InitializationHelper(const nsAString& message, - const nsAString& sourceLine, uint32_t lineNumber, + void InitializationHelper(const nsAString& message, uint32_t lineNumber, uint32_t columnNumber, uint32_t flags, const nsACString& category, uint64_t aInnerWindowID, bool aFromChromeContext); @@ -71,11 +69,10 @@ class nsScriptErrorBase : public nsIScriptError { nsCOMArray mNotes; nsString mMessage; nsString mMessageName; - nsString mSourceName; + nsCString mSourceName; nsString mCssSelectors; uint32_t mSourceId; uint32_t mLineNumber; - nsString mSourceLine; uint32_t mColumnNumber; uint32_t mFlags; nsCString mCategory; diff --git a/dom/console/Console.cpp b/dom/console/Console.cpp index db0f1eed674c..3b8c5663b4e5 100644 --- a/dom/console/Console.cpp +++ b/dom/console/Console.cpp @@ -1223,10 +1223,7 @@ void StackFrameToStackEntry(JSContext* aCx, nsIStackFrame* aStackFrame, ConsoleStackEntry& aStackEntry) { MOZ_ASSERT(aStackFrame); - nsAutoString filename; - aStackFrame->GetFilename(aCx, filename); - CopyUTF16toUTF8(filename, aStackEntry.mFilename); - + aStackFrame->GetFilename(aCx, aStackEntry.mFilename); aStackEntry.mSourceId = aStackFrame->GetSourceId(aCx); aStackEntry.mLineNumber = aStackFrame->GetLineNumber(aCx); aStackEntry.mColumnNumber = aStackFrame->GetColumnNumber(aCx); @@ -2747,10 +2744,10 @@ void Console::MaybeExecuteDumpFunction(JSContext* aCx, nsCOMPtr stack(aStack); while (stack) { - nsAutoString filename; + nsAutoCString filename; stack->GetFilename(aCx, filename); - message.Append(filename); + AppendUTF8toUTF16(filename, message); message.AppendLiteral(" "); message.AppendInt(stack->GetLineNumber(aCx)); diff --git a/dom/events/JSEventHandler.cpp b/dom/events/JSEventHandler.cpp index 8304ec658276..33cc08d4baef 100644 --- a/dom/events/JSEventHandler.cpp +++ b/dom/events/JSEventHandler.cpp @@ -116,9 +116,10 @@ nsresult JSEventHandler::HandleEvent(Event* aEvent) { if (mTypedHandler.Type() == TypedEventHandler::eOnError) { MOZ_ASSERT_IF(mEventName, mEventName == nsGkAtoms::onerror); - nsString errorMsg, file; + nsString errorMsg; + nsCString file; EventOrString msgOrEvent; - Optional fileName; + Optional fileName; Optional lineNumber; Optional columnNumber; Optional> error; diff --git a/dom/file/uri/BlobURLProtocolHandler.cpp b/dom/file/uri/BlobURLProtocolHandler.cpp index 9c27ece1d18a..f15be19e7ef5 100644 --- a/dom/file/uri/BlobURLProtocolHandler.cpp +++ b/dom/file/uri/BlobURLProtocolHandler.cpp @@ -316,13 +316,12 @@ class BlobURLsReporter final : public nsIMemoryReporter { JSContext* cx = frame ? nsContentUtils::GetCurrentJSContext() : nullptr; while (frame) { - nsString fileNameUTF16; - frame->GetFilename(cx, fileNameUTF16); + nsCString fileName; + frame->GetFilename(cx, fileName); int32_t lineNumber = frame->GetLineNumber(cx); - if (!fileNameUTF16.IsEmpty()) { - NS_ConvertUTF16toUTF8 fileName(fileNameUTF16); + if (!fileName.IsEmpty()) { stack += "js("; if (!origin.IsEmpty()) { // Make the file name root-relative for conciseness if possible. diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 648464d7163c..9e3506f22495 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -487,7 +487,8 @@ NS_IMPL_ISUPPORTS(ConsoleListener, nsIConsoleListener) // errors in particular share the memory for long lines with // repeated errors, but the IPC communication we're about to do // will break that sharing, so we better truncate now. -static void TruncateString(nsAString& aString) { +template +static void TruncateString(nsTSubstring& aString) { if (aString.Length() > 1000) { aString.Truncate(1000); } @@ -501,7 +502,8 @@ ConsoleListener::Observe(nsIConsoleMessage* aMessage) { nsCOMPtr scriptError = do_QueryInterface(aMessage); if (scriptError) { - nsAutoString msg, sourceName, sourceLine; + nsAutoString msg; + nsAutoCString sourceName; nsCString category; uint32_t lineNum, colNum, flags; bool fromPrivateWindow, fromChromeContext; @@ -512,9 +514,6 @@ ConsoleListener::Observe(nsIConsoleMessage* aMessage) { rv = scriptError->GetSourceName(sourceName); NS_ENSURE_SUCCESS(rv, rv); TruncateString(sourceName); - rv = scriptError->GetSourceLine(sourceLine); - NS_ENSURE_SUCCESS(rv, rv); - TruncateString(sourceLine); rv = scriptError->GetCategory(getter_Copies(category)); NS_ENSURE_SUCCESS(rv, rv); @@ -559,15 +558,15 @@ ConsoleListener::Observe(nsIConsoleMessage* aMessage) { return NS_ERROR_FAILURE; } - mChild->SendScriptErrorWithStack( - msg, sourceName, sourceLine, lineNum, colNum, flags, category, - fromPrivateWindow, fromChromeContext, cloned); + mChild->SendScriptErrorWithStack(msg, sourceName, lineNum, colNum, + flags, category, fromPrivateWindow, + fromChromeContext, cloned); return NS_OK; } } - mChild->SendScriptError(msg, sourceName, sourceLine, lineNum, colNum, flags, - category, fromPrivateWindow, 0, fromChromeContext); + mChild->SendScriptError(msg, sourceName, lineNum, colNum, flags, category, + fromPrivateWindow, 0, fromChromeContext); return NS_OK; } @@ -4234,11 +4233,11 @@ mozilla::ipc::IPCResult ContentChild::RecvDiscardWindowContext( } mozilla::ipc::IPCResult ContentChild::RecvScriptError( - const nsString& aMessage, const nsString& aSourceName, - const nsString& aSourceLine, const uint32_t& aLineNumber, - const uint32_t& aColNumber, const uint32_t& aFlags, - const nsCString& aCategory, const bool& aFromPrivateWindow, - const uint64_t& aInnerWindowId, const bool& aFromChromeContext) { + const nsString& aMessage, const nsCString& aSourceName, + const uint32_t& aLineNumber, const uint32_t& aColNumber, + const uint32_t& aFlags, const nsCString& aCategory, + const bool& aFromPrivateWindow, const uint64_t& aInnerWindowId, + const bool& aFromChromeContext) { nsresult rv = NS_OK; nsCOMPtr consoleService = do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv); @@ -4249,8 +4248,8 @@ mozilla::ipc::IPCResult ContentChild::RecvScriptError( NS_ENSURE_TRUE(scriptError, IPC_FAIL(this, "Failed to construct nsIScriptError")); - scriptError->InitWithWindowID(aMessage, aSourceName, aSourceLine, aLineNumber, - aColNumber, aFlags, aCategory, aInnerWindowId, + scriptError->InitWithWindowID(aMessage, aSourceName, aLineNumber, aColNumber, + aFlags, aCategory, aInnerWindowId, aFromChromeContext); rv = consoleService->LogMessage(scriptError); NS_ENSURE_SUCCESS(rv, IPC_FAIL(this, "Failed to log script error")); diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index aa0c0f149f79..b42375c761fa 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -709,11 +709,11 @@ class ContentChild final : public PContentChild, uint64_t aContextId, DiscardWindowContextResolver&& aResolve); mozilla::ipc::IPCResult RecvScriptError( - const nsString& aMessage, const nsString& aSourceName, - const nsString& aSourceLine, const uint32_t& aLineNumber, - const uint32_t& aColNumber, const uint32_t& aFlags, - const nsCString& aCategory, const bool& aFromPrivateWindow, - const uint64_t& aInnerWindowId, const bool& aFromChromeContext); + const nsString& aMessage, const nsCString& aSourceName, + const uint32_t& aLineNumber, const uint32_t& aColNumber, + const uint32_t& aFlags, const nsCString& aCategory, + const bool& aFromPrivateWindow, const uint64_t& aInnerWindowId, + const bool& aFromChromeContext); mozilla::ipc::IPCResult RecvReportFrameTimingData( const LoadInfoArgs& loadInfoArgs, const nsString& entryName, diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 20d4f6151cf5..12b3882c25b4 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -4837,33 +4837,33 @@ mozilla::ipc::IPCResult ContentParent::RecvReportFrameTimingData( } mozilla::ipc::IPCResult ContentParent::RecvScriptError( - const nsAString& aMessage, const nsAString& aSourceName, - const nsAString& aSourceLine, const uint32_t& aLineNumber, - const uint32_t& aColNumber, const uint32_t& aFlags, - const nsACString& aCategory, const bool& aIsFromPrivateWindow, - const uint64_t& aInnerWindowId, const bool& aIsFromChromeContext) { - return RecvScriptErrorInternal(aMessage, aSourceName, aSourceLine, - aLineNumber, aColNumber, aFlags, aCategory, - aIsFromPrivateWindow, aIsFromChromeContext); + const nsAString& aMessage, const nsACString& aSourceName, + const uint32_t& aLineNumber, const uint32_t& aColNumber, + const uint32_t& aFlags, const nsACString& aCategory, + const bool& aIsFromPrivateWindow, const uint64_t& aInnerWindowId, + const bool& aIsFromChromeContext) { + return RecvScriptErrorInternal(aMessage, aSourceName, aLineNumber, aColNumber, + aFlags, aCategory, aIsFromPrivateWindow, + aIsFromChromeContext); } mozilla::ipc::IPCResult ContentParent::RecvScriptErrorWithStack( - const nsAString& aMessage, const nsAString& aSourceName, - const nsAString& aSourceLine, const uint32_t& aLineNumber, - const uint32_t& aColNumber, const uint32_t& aFlags, - const nsACString& aCategory, const bool& aIsFromPrivateWindow, - const bool& aIsFromChromeContext, const ClonedMessageData& aStack) { - return RecvScriptErrorInternal( - aMessage, aSourceName, aSourceLine, aLineNumber, aColNumber, aFlags, - aCategory, aIsFromPrivateWindow, aIsFromChromeContext, &aStack); + const nsAString& aMessage, const nsACString& aSourceName, + const uint32_t& aLineNumber, const uint32_t& aColNumber, + const uint32_t& aFlags, const nsACString& aCategory, + const bool& aIsFromPrivateWindow, const bool& aIsFromChromeContext, + const ClonedMessageData& aStack) { + return RecvScriptErrorInternal(aMessage, aSourceName, aLineNumber, aColNumber, + aFlags, aCategory, aIsFromPrivateWindow, + aIsFromChromeContext, &aStack); } mozilla::ipc::IPCResult ContentParent::RecvScriptErrorInternal( - const nsAString& aMessage, const nsAString& aSourceName, - const nsAString& aSourceLine, const uint32_t& aLineNumber, - const uint32_t& aColNumber, const uint32_t& aFlags, - const nsACString& aCategory, const bool& aIsFromPrivateWindow, - const bool& aIsFromChromeContext, const ClonedMessageData* aStack) { + const nsAString& aMessage, const nsACString& aSourceName, + const uint32_t& aLineNumber, const uint32_t& aColNumber, + const uint32_t& aFlags, const nsACString& aCategory, + const bool& aIsFromPrivateWindow, const bool& aIsFromChromeContext, + const ClonedMessageData* aStack) { nsresult rv; nsCOMPtr consoleService = do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv); @@ -4903,8 +4903,8 @@ mozilla::ipc::IPCResult ContentParent::RecvScriptErrorInternal( msg = new nsScriptError(); } - rv = msg->Init(aMessage, aSourceName, aSourceLine, aLineNumber, aColNumber, - aFlags, aCategory, aIsFromPrivateWindow, aIsFromChromeContext); + rv = msg->Init(aMessage, aSourceName, aLineNumber, aColNumber, aFlags, + aCategory, aIsFromPrivateWindow, aIsFromChromeContext); if (NS_FAILED(rv)) return IPC_OK(); msg->SetIsForwardedFromContentProcess(true); diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 5e6ed71561c1..25881972a613 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -1029,30 +1029,29 @@ class ContentParent final : public PContentParent, mozilla::ipc::IPCResult RecvConsoleMessage(const nsAString& aMessage); mozilla::ipc::IPCResult RecvScriptError( - const nsAString& aMessage, const nsAString& aSourceName, - const nsAString& aSourceLine, const uint32_t& aLineNumber, - const uint32_t& aColNumber, const uint32_t& aFlags, - const nsACString& aCategory, const bool& aIsFromPrivateWindow, - const uint64_t& aInnerWindowId, const bool& aIsFromChromeContext); + const nsAString& aMessage, const nsACString& aSourceName, + const uint32_t& aLineNumber, const uint32_t& aColNumber, + const uint32_t& aFlags, const nsACString& aCategory, + const bool& aIsFromPrivateWindow, const uint64_t& aInnerWindowId, + const bool& aIsFromChromeContext); mozilla::ipc::IPCResult RecvReportFrameTimingData( const LoadInfoArgs& loadInfoArgs, const nsAString& entryName, const nsAString& initiatorType, UniquePtr&& aData); mozilla::ipc::IPCResult RecvScriptErrorWithStack( - const nsAString& aMessage, const nsAString& aSourceName, - const nsAString& aSourceLine, const uint32_t& aLineNumber, - const uint32_t& aColNumber, const uint32_t& aFlags, - const nsACString& aCategory, const bool& aIsFromPrivateWindow, - const bool& aIsFromChromeContext, const ClonedMessageData& aStack); + const nsAString& aMessage, const nsACString& aSourceName, + const uint32_t& aLineNumber, const uint32_t& aColNumber, + const uint32_t& aFlags, const nsACString& aCategory, + const bool& aIsFromPrivateWindow, const bool& aIsFromChromeContext, + const ClonedMessageData& aStack); private: mozilla::ipc::IPCResult RecvScriptErrorInternal( - const nsAString& aMessage, const nsAString& aSourceName, - const nsAString& aSourceLine, const uint32_t& aLineNumber, - const uint32_t& aColNumber, const uint32_t& aFlags, - const nsACString& aCategory, const bool& aIsFromPrivateWindow, - const bool& aIsFromChromeContext, + const nsAString& aMessage, const nsACString& aSourceName, + const uint32_t& aLineNumber, const uint32_t& aColNumber, + const uint32_t& aFlags, const nsACString& aCategory, + const bool& aIsFromPrivateWindow, const bool& aIsFromChromeContext, const ClonedMessageData* aStack = nullptr); public: diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index edd17e84d7f4..42f80c1fa06d 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -1206,7 +1206,7 @@ parent: async SetGeolocationHigherAccuracy(bool enable); async ConsoleMessage(nsString message); - async ScriptErrorWithStack(nsString message, nsString sourceName, nsString sourceLine, + async ScriptErrorWithStack(nsString message, nsCString sourceName, uint32_t lineNumber, uint32_t colNumber, uint32_t flags, nsCString category, bool isFromPrivateWindow, bool isFromChromeContext, ClonedMessageData stack); @@ -1828,7 +1828,7 @@ parent: [LazySend] async CleanupPendingLoadState(uint64_t aLoadIdentifier); both: - async ScriptError(nsString message, nsString sourceName, nsString sourceLine, + async ScriptError(nsString message, nsCString sourceName, uint32_t lineNumber, uint32_t colNumber, uint32_t flags, nsCString category, bool isFromPrivateWindow, uint64_t innerWindowId, bool isFromChromeContext); diff --git a/dom/media/IdpSandbox.sys.mjs b/dom/media/IdpSandbox.sys.mjs index c8735c223de9..de26ca77bee4 100644 --- a/dom/media/IdpSandbox.sys.mjs +++ b/dom/media/IdpSandbox.sys.mjs @@ -260,7 +260,6 @@ IdpSandbox.prototype = { scriptError.initWithWindowID( e.message, e.fileName, - null, e.lineNumber, e.columnNumber, Ci.nsIScriptError.errorFlag, diff --git a/dom/media/PeerConnection.sys.mjs b/dom/media/PeerConnection.sys.mjs index 0aaf5cca8c42..ed7481d15228 100644 --- a/dom/media/PeerConnection.sys.mjs +++ b/dom/media/PeerConnection.sys.mjs @@ -30,7 +30,6 @@ function logWebRTCMsg(msg, file, line, flag, win) { scriptError.initWithWindowID( `WebRTC: ${msg}`, file, - null, line, 0, flag, diff --git a/dom/media/webaudio/AudioWorkletNode.cpp b/dom/media/webaudio/AudioWorkletNode.cpp index 76a3185f2c32..1b215a42245c 100644 --- a/dom/media/webaudio/AudioWorkletNode.cpp +++ b/dom/media/webaudio/AudioWorkletNode.cpp @@ -52,7 +52,7 @@ struct ProcessorErrorDetails { unsigned mLineno; // Column number in UTF-16 code units (1-origin). unsigned mColno; - nsString mFilename; + nsCString mFilename; nsString mMessage; }; @@ -231,11 +231,7 @@ void WorkletNodeEngine::SendProcessorError(AudioNodeTrack* aTrack, } ProcessorErrorDetails details; - - CopyUTF8toUTF16( - mozilla::MakeStringSpan(jsReport.report()->filename.c_str()), - details.mFilename); - + details.mFilename.Assign(jsReport.report()->filename.c_str()); xpc::ErrorReport::ErrorReportToMessageString(jsReport.report(), details.mMessage); details.mLineno = jsReport.report()->lineno; diff --git a/dom/security/nsCSPUtils.cpp b/dom/security/nsCSPUtils.cpp index 6f087ff67bf0..ff2e907c0d8f 100644 --- a/dom/security/nsCSPUtils.cpp +++ b/dom/security/nsCSPUtils.cpp @@ -230,13 +230,13 @@ void CSP_LogMessage(const nsAString& aMessage, const nsACString& aSourceName, nsresult rv; if (aInnerWindowID > 0) { - rv = error->InitWithWindowID(cspMsg, NS_ConvertUTF8toUTF16(aSourceName), - aSourceLine, aLineNumber, aColumnNumber, - aFlags, category, aInnerWindowID); + rv = + error->InitWithWindowID(cspMsg, aSourceName, aLineNumber, aColumnNumber, + aFlags, category, aInnerWindowID); } else { - rv = error->Init(cspMsg, NS_ConvertUTF8toUTF16(aSourceName), aSourceLine, - aLineNumber, aColumnNumber, aFlags, category, - aFromPrivateWindow, true /* from chrome context */); + rv = error->Init(cspMsg, aSourceName, aLineNumber, aColumnNumber, aFlags, + category, aFromPrivateWindow, + true /* from chrome context */); } if (NS_FAILED(rv)) { return; diff --git a/dom/security/nsCSPUtils.h b/dom/security/nsCSPUtils.h index eb2b7f3ffbd9..3241883fe867 100644 --- a/dom/security/nsCSPUtils.h +++ b/dom/security/nsCSPUtils.h @@ -11,11 +11,9 @@ #include "nsIContentSecurityPolicy.h" #include "nsILoadInfo.h" #include "nsIURI.h" -#include "nsLiteralString.h" #include "nsString.h" #include "nsTArray.h" #include "nsUnicharUtils.h" -#include "mozilla/Logging.h" class nsIChannel; diff --git a/dom/security/nsContentSecurityUtils.cpp b/dom/security/nsContentSecurityUtils.cpp index 3cf9aea7cb3a..fa6b15ed6ffa 100644 --- a/dom/security/nsContentSecurityUtils.cpp +++ b/dom/security/nsContentSecurityUtils.cpp @@ -794,10 +794,9 @@ void nsContentSecurityUtils::NotifyEvalUsage(bool aIsSystemPrincipal, return; } - rv = error->InitWithWindowID(message, fileNameA, u""_ns, aLineNumber, - aColumnNumber, nsIScriptError::errorFlag, - "BrowserEvalUsage", aWindowID, - true /* From chrome context */); + rv = error->InitWithWindowID(message, aFileName, aLineNumber, aColumnNumber, + nsIScriptError::errorFlag, "BrowserEvalUsage", + aWindowID, true /* From chrome context */); if (NS_FAILED(rv)) { return; } diff --git a/dom/serviceworkers/test/console_monitor.js b/dom/serviceworkers/test/console_monitor.js index 099feb646df1..30aa5c2cc317 100644 --- a/dom/serviceworkers/test/console_monitor.js +++ b/dom/serviceworkers/test/console_monitor.js @@ -18,7 +18,6 @@ ConsoleListener.prototype = { cssSelectors: aMsg.cssSelectors, errorMessage: aMsg.errorMessage, sourceName: aMsg.sourceName, - sourceLine: aMsg.sourceLine, lineNumber: aMsg.lineNumber, columnNumber: aMsg.columnNumber, category: aMsg.category, diff --git a/dom/webidl/DOMException.webidl b/dom/webidl/DOMException.webidl index 44f93a4a1a81..cd3d22ead214 100644 --- a/dom/webidl/DOMException.webidl +++ b/dom/webidl/DOMException.webidl @@ -28,7 +28,7 @@ interface mixin ExceptionMembers // etc. // null indicates "no data" - readonly attribute DOMString filename; + readonly attribute UTF8String filename; // Valid line numbers begin at '1'. '0' indicates unknown. readonly attribute unsigned long lineNumber; // Valid column numbers begin at 0. diff --git a/dom/webidl/ErrorEvent.webidl b/dom/webidl/ErrorEvent.webidl index 7ff6faf72078..7ca78abd1029 100644 --- a/dom/webidl/ErrorEvent.webidl +++ b/dom/webidl/ErrorEvent.webidl @@ -13,7 +13,7 @@ interface ErrorEvent : Event constructor(DOMString type, optional ErrorEventInit eventInitDict = {}); readonly attribute DOMString message; - readonly attribute DOMString filename; + readonly attribute UTF8String filename; readonly attribute unsigned long lineno; readonly attribute unsigned long colno; readonly attribute any error; @@ -22,7 +22,7 @@ interface ErrorEvent : Event dictionary ErrorEventInit : EventInit { DOMString message = ""; - DOMString filename = ""; + UTF8String filename = ""; unsigned long lineno = 0; unsigned long colno = 0; any error; diff --git a/dom/webidl/EventHandler.webidl b/dom/webidl/EventHandler.webidl index fb949f5cf2e4..f669e69cc969 100644 --- a/dom/webidl/EventHandler.webidl +++ b/dom/webidl/EventHandler.webidl @@ -19,7 +19,7 @@ callback OnBeforeUnloadEventHandlerNonNull = DOMString? (Event event); typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnloadEventHandler; [LegacyTreatNonObjectAsNull] -callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long column, optional any error); +callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, optional UTF8String source, optional unsigned long lineno, optional unsigned long column, optional any error); typedef OnErrorEventHandlerNonNull? OnErrorEventHandler; interface mixin GlobalEventHandlers { diff --git a/dom/websocket/WebSocket.cpp b/dom/websocket/WebSocket.cpp index b9577b03c750..c71e9e49193b 100644 --- a/dom/websocket/WebSocket.cpp +++ b/dom/websocket/WebSocket.cpp @@ -420,15 +420,13 @@ void WebSocketImpl::PrintErrorOnConsole(const char* aBundleURI, NS_ENSURE_SUCCESS_VOID(rv); if (mInnerWindowID) { - rv = errorObject->InitWithWindowID( - message, NS_ConvertUTF8toUTF16(mScriptFile), u""_ns, mScriptLine, - mScriptColumn, nsIScriptError::errorFlag, "Web Socket"_ns, - mInnerWindowID); + rv = errorObject->InitWithWindowID(message, mScriptFile, mScriptLine, + mScriptColumn, nsIScriptError::errorFlag, + "Web Socket"_ns, mInnerWindowID); } else { - rv = - errorObject->Init(message, NS_ConvertUTF8toUTF16(mScriptFile), u""_ns, - mScriptLine, mScriptColumn, nsIScriptError::errorFlag, - "Web Socket"_ns, mPrivateBrowsing, mIsChromeContext); + rv = errorObject->Init(message, mScriptFile, mScriptLine, mScriptColumn, + nsIScriptError::errorFlag, "Web Socket"_ns, + mPrivateBrowsing, mIsChromeContext); } NS_ENSURE_SUCCESS_VOID(rv); diff --git a/dom/workers/WorkerDebugger.cpp b/dom/workers/WorkerDebugger.cpp index b43b03bb49a4..7ba8cce99391 100644 --- a/dom/workers/WorkerDebugger.cpp +++ b/dom/workers/WorkerDebugger.cpp @@ -146,13 +146,13 @@ class WorkerDebugger::PostDebuggerMessageRunnable final : public Runnable { class WorkerDebugger::ReportDebuggerErrorRunnable final : public Runnable { WorkerDebugger* mDebugger; - nsString mFilename; + nsCString mFilename; uint32_t mLineno; nsString mMessage; public: ReportDebuggerErrorRunnable(WorkerDebugger* aDebugger, - const nsAString& aFilename, uint32_t aLineno, + const nsACString& aFilename, uint32_t aLineno, const nsAString& aMessage) : Runnable("ReportDebuggerErrorRunnable"), mDebugger(aDebugger), @@ -461,7 +461,7 @@ void WorkerDebugger::PostMessageToDebuggerOnMainThread( } } -void WorkerDebugger::ReportErrorToDebugger(const nsAString& aFilename, +void WorkerDebugger::ReportErrorToDebugger(const nsACString& aFilename, uint32_t aLineno, const nsAString& aMessage) { mWorkerPrivate->AssertIsOnWorkerThread(); @@ -475,7 +475,7 @@ void WorkerDebugger::ReportErrorToDebugger(const nsAString& aFilename, } void WorkerDebugger::ReportErrorToDebuggerOnMainThread( - const nsAString& aFilename, uint32_t aLineno, const nsAString& aMessage) { + const nsACString& aFilename, uint32_t aLineno, const nsAString& aMessage) { AssertIsOnMainThread(); for (const auto& listener : mListeners.Clone()) { diff --git a/dom/workers/WorkerDebugger.h b/dom/workers/WorkerDebugger.h index 3be7ef4203f6..625162856977 100644 --- a/dom/workers/WorkerDebugger.h +++ b/dom/workers/WorkerDebugger.h @@ -39,7 +39,7 @@ class WorkerDebugger : public nsIWorkerDebugger { void PostMessageToDebugger(const nsAString& aMessage); - void ReportErrorToDebugger(const nsAString& aFilename, uint32_t aLineno, + void ReportErrorToDebugger(const nsACString& aFilename, uint32_t aLineno, const nsAString& aMessage); private: @@ -47,7 +47,7 @@ class WorkerDebugger : public nsIWorkerDebugger { void PostMessageToDebuggerOnMainThread(const nsAString& aMessage); - void ReportErrorToDebuggerOnMainThread(const nsAString& aFilename, + void ReportErrorToDebuggerOnMainThread(const nsACString& aFilename, uint32_t aLineno, const nsAString& aMessage); diff --git a/dom/workers/WorkerError.cpp b/dom/workers/WorkerError.cpp index 4fe9b237fec1..73fd61b04f28 100644 --- a/dom/workers/WorkerError.cpp +++ b/dom/workers/WorkerError.cpp @@ -201,7 +201,7 @@ class ReportGenericErrorRunnable final : public WorkerParentDebuggeeRunnable { } // namespace void WorkerErrorBase::AssignErrorBase(JSErrorBase* aReport) { - CopyUTF8toUTF16(MakeStringSpan(aReport->filename.c_str()), mFilename); + mFilename.Assign(aReport->filename.c_str()); mLineNumber = aReport->lineno; mColumnNumber = aReport->column.oneOriginValue(); mErrorNumber = aReport->errorNumber; @@ -218,8 +218,6 @@ WorkerErrorReport::WorkerErrorReport() void WorkerErrorReport::AssignErrorReport(JSErrorReport* aReport) { WorkerErrorBase::AssignErrorBase(aReport); xpc::ErrorReport::ErrorReportToMessageString(aReport, mMessage); - - mLine.Assign(aReport->linebuf(), aReport->linebufLength()); mIsWarning = aReport->isWarning(); MOZ_ASSERT(aReport->exnType >= JSEXN_FIRST && aReport->exnType < JSEXN_LIMIT); mExnType = JSExnType(aReport->exnType); @@ -371,7 +369,7 @@ void WorkerErrorReport::LogErrorToConsole(JSContext* aCx, ErrorData errorData( aReport.mIsWarning, aReport.mLineNumber, aReport.mColumnNumber, - aReport.mMessage, aReport.mFilename, aReport.mLine, + aReport.mMessage, aReport.mFilename, TransformIntoNewArray(aReport.mNotes, [](const WorkerErrorNote& note) { return ErrorDataNote(note.mLineNumber, note.mColumnNumber, note.mMessage, note.mFilename); @@ -396,9 +394,8 @@ void WorkerErrorReport::LogErrorToConsole(const ErrorData& aReport, uint32_t flags = aReport.isWarning() ? nsIScriptError::warningFlag : nsIScriptError::errorFlag; if (NS_FAILED(scriptError->nsIScriptError::InitWithWindowID( - aReport.message(), aReport.filename(), aReport.line(), - aReport.lineNumber(), aReport.columnNumber(), flags, category, - aInnerWindowId))) { + aReport.message(), aReport.filename(), aReport.lineNumber(), + aReport.columnNumber(), flags, category, aInnerWindowId))) { NS_WARNING("Failed to init script error!"); scriptError = nullptr; } @@ -429,16 +426,15 @@ void WorkerErrorReport::LogErrorToConsole(const ErrorData& aReport, } NS_ConvertUTF16toUTF8 msg(aReport.message()); - NS_ConvertUTF16toUTF8 filename(aReport.filename()); static const char kErrorString[] = "JS error in Web Worker: %s [%s:%u]"; #ifdef ANDROID __android_log_print(ANDROID_LOG_INFO, "Gecko", kErrorString, msg.get(), - filename.get(), aReport.lineNumber()); + aReport.filename().get(), aReport.lineNumber()); #endif - fprintf(stderr, kErrorString, msg.get(), filename.get(), + fprintf(stderr, kErrorString, msg.get(), aReport.filename().get(), aReport.lineNumber()); fflush(stderr); } diff --git a/dom/workers/WorkerError.h b/dom/workers/WorkerError.h index 43600fbf1ad1..bc1ac911b311 100644 --- a/dom/workers/WorkerError.h +++ b/dom/workers/WorkerError.h @@ -21,14 +21,14 @@ class ErrorData; class WorkerErrorBase { public: nsString mMessage; - nsString mFilename; + nsCString mFilename; // Line number (1-origin). - uint32_t mLineNumber; + uint32_t mLineNumber = 0; // Column number in UTF-16 code units (1-origin). - uint32_t mColumnNumber; - uint32_t mErrorNumber; + uint32_t mColumnNumber = 0; + uint32_t mErrorNumber = 0; - WorkerErrorBase() : mLineNumber(0), mColumnNumber(0), mErrorNumber(0) {} + WorkerErrorBase() = default; void AssignErrorBase(JSErrorBase* aReport); }; @@ -42,7 +42,6 @@ class WorkerPrivate; class WorkerErrorReport : public WorkerErrorBase, public SerializedStackHolder { public: - nsString mLine; bool mIsWarning; JSExnType mExnType; bool mMutedError; diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 660c5bddaf14..008e64626c1e 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -5188,7 +5188,7 @@ void WorkerPrivate::SetDebuggerImmediate(dom::Function& aHandler, } } -void WorkerPrivate::ReportErrorToDebugger(const nsAString& aFilename, +void WorkerPrivate::ReportErrorToDebugger(const nsACString& aFilename, uint32_t aLineno, const nsAString& aMessage) { mDebugger->ReportErrorToDebugger(aFilename, aLineno, aMessage); diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index 732cacfa8fd7..da25a495a893 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -406,7 +406,7 @@ class WorkerPrivate final void SetDebuggerImmediate(Function& aHandler, ErrorResult& aRv); - void ReportErrorToDebugger(const nsAString& aFilename, uint32_t aLineno, + void ReportErrorToDebugger(const nsACString& aFilename, uint32_t aLineno, const nsAString& aMessage); bool NotifyInternal(WorkerStatus aStatus); diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index c7ed66563346..22b6a5a63377 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -1344,11 +1344,9 @@ void WorkerDebuggerGlobalScope::SetImmediate(Function& aHandler, void WorkerDebuggerGlobalScope::ReportError(JSContext* aCx, const nsAString& aMessage) { - JS::AutoFilename chars; - uint32_t lineno = 0; - JS::DescribeScriptedCaller(aCx, &chars, &lineno); - nsString filename(NS_ConvertUTF8toUTF16(chars.get())); - mWorkerPrivate->ReportErrorToDebugger(filename, lineno, aMessage); + auto caller = JSCallingLocation::Get(aCx); + mWorkerPrivate->ReportErrorToDebugger(caller.FileName(), caller.mLine, + aMessage); } void WorkerDebuggerGlobalScope::RetrieveConsoleEvents( diff --git a/dom/workers/nsIWorkerDebugger.idl b/dom/workers/nsIWorkerDebugger.idl index 573e7027b0bc..2d492f4e7e37 100644 --- a/dom/workers/nsIWorkerDebugger.idl +++ b/dom/workers/nsIWorkerDebugger.idl @@ -12,7 +12,7 @@ interface nsIWorkerDebuggerListener : nsISupports { void onClose(); - void onError(in AString filename, in unsigned long lineno, + void onError(in ACString filename, in unsigned long lineno, in AString message); void onMessage(in AString message); diff --git a/dom/workers/remoteworkers/RemoteWorkerChild.cpp b/dom/workers/remoteworkers/RemoteWorkerChild.cpp index a04ea5ec1bc4..60826ac5ee3c 100644 --- a/dom/workers/remoteworkers/RemoteWorkerChild.cpp +++ b/dom/workers/remoteworkers/RemoteWorkerChild.cpp @@ -593,7 +593,7 @@ void RemoteWorkerChild::ErrorPropagationOnMainThread( if (aIsErrorEvent) { ErrorData data( aReport->mIsWarning, aReport->mLineNumber, aReport->mColumnNumber, - aReport->mMessage, aReport->mFilename, aReport->mLine, + aReport->mMessage, aReport->mFilename, TransformIntoNewArray(aReport->mNotes, [](const WorkerErrorNote& note) { return ErrorDataNote(note.mLineNumber, note.mColumnNumber, note.mMessage, note.mFilename); diff --git a/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh b/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh index 08fb5700feb0..4c58f39681c3 100644 --- a/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh +++ b/dom/workers/remoteworkers/RemoteWorkerTypes.ipdlh @@ -102,7 +102,7 @@ struct ErrorDataNote { uint32_t lineNumber; uint32_t columnNumber; nsString message; - nsString filename; + nsCString filename; }; struct ErrorData { @@ -110,8 +110,7 @@ struct ErrorData { uint32_t lineNumber; uint32_t columnNumber; nsString message; - nsString filename; - nsString line; + nsCString filename; ErrorDataNote[] notes; }; diff --git a/image/RasterImage.cpp b/image/RasterImage.cpp index 862226ca36aa..f8608d86cfe7 100644 --- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -1729,15 +1729,13 @@ void RasterImage::ReportDecoderError() { if (consoleService && errorObject) { nsAutoString msg(u"Image corrupt or truncated."_ns); - nsAutoString src; + nsAutoCString src; if (GetURI()) { - nsAutoCString uri; - if (!GetSpecTruncatedTo1k(uri)) { + if (!GetSpecTruncatedTo1k(src)) { msg += u" URI in this note truncated due to length."_ns; } - CopyUTF8toUTF16(uri, src); } - if (NS_SUCCEEDED(errorObject->InitWithWindowID(msg, src, u""_ns, 0, 0, + if (NS_SUCCEEDED(errorObject->InitWithWindowID(msg, src, 0, 0, nsIScriptError::errorFlag, "Image", InnerWindowID()))) { consoleService->LogMessage(errorObject); diff --git a/intl/l10n/rust/l10nregistry-ffi/src/env.rs b/intl/l10n/rust/l10nregistry-ffi/src/env.rs index 7a77af21767a..10645b233abe 100644 --- a/intl/l10n/rust/l10nregistry-ffi/src/env.rs +++ b/intl/l10n/rust/l10nregistry-ffi/src/env.rs @@ -11,7 +11,7 @@ use l10nregistry::{ }; use log::warn; use nserror::{nsresult, NS_ERROR_NOT_AVAILABLE}; -use nsstring::{nsCStr, nsString}; +use nsstring::{nsCStr, nsCString, nsString}; use std::fmt::{self, Write}; use unic_langid::LanguageIdentifier; use xpcom::interfaces; @@ -55,7 +55,7 @@ impl ErrorReporter for GeckoEnvironment { &error.to_string(), false, true, - Some(nsString::from(&resource_id.value)), + Some(nsCString::from(&resource_id.value)), loc.map_or((0, 0), |(l, c)| (l as u32, c as u32)), interfaces::nsIScriptError::errorFlag as u32, ), @@ -95,7 +95,7 @@ fn log_simple_console_error( error: &impl fmt::Display, from_private_window: bool, from_chrome_context: bool, - path: Option, + path: Option, pos: (u32, u32), error_flags: u32, ) -> Result<(), nsresult> { @@ -115,10 +115,9 @@ fn log_simple_console_error( script_error .Init( &*error_str, - &*path.unwrap_or(nsString::new()), /* aSourceName */ - &*nsString::new(), /* aSourceLine */ - pos.0, /* aLineNumber */ - pos.1, /* aColNumber */ + &*path.unwrap_or_else(nsCString::new), /* aSourceName */ + pos.0, /* aLineNumber */ + pos.1, /* aColNumber */ error_flags, &*category, from_private_window, diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index 290992a9ae8e..31220f17de32 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -2010,12 +2010,12 @@ static nsresult AssembleSandboxMemoryReporterName(JSContext* cx, // Append the caller's location information. if (frame) { - nsString location; + nsAutoCString location; frame->GetFilename(cx, location); int32_t lineNumber = frame->GetLineNumber(cx); sandboxName.AppendLiteral(" (from: "); - sandboxName.Append(NS_ConvertUTF16toUTF8(location)); + sandboxName.Append(location); sandboxName.Append(':'); sandboxName.AppendInt(lineNumber); sandboxName.Append(')'); diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 9ee9f53630f0..a729e0908b8d 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -1348,7 +1348,7 @@ nsXPCComponents_Utils::ReportError(HandleValue error, HandleValue stack, } } - nsString fileName; + nsCString fileName; uint32_t lineNo = 0; if (!scripterr) { @@ -1374,7 +1374,7 @@ nsXPCComponents_Utils::ReportError(HandleValue error, HandleValue stack, } RootedString source(cx); - nsAutoJSString str; + nsAutoJSCString str; if (GetSavedFrameSource(cx, principals, stackObj, &source) == SavedFrameResult::Ok && str.init(cx, source)) { @@ -1409,22 +1409,14 @@ nsXPCComponents_Utils::ReportError(HandleValue error, HandleValue stack, JSErrorReport* err = errorObj ? JS_ErrorFromException(cx, errorObj) : nullptr; if (err) { // It's a proper JS Error - nsAutoString fileUni; - CopyUTF8toUTF16(mozilla::MakeStringSpan(err->filename.c_str()), fileUni); - - const char16_t* linebuf = err->linebuf(); uint32_t flags = err->isWarning() ? nsIScriptError::warningFlag : nsIScriptError::errorFlag; - nsresult rv = scripterr->InitWithWindowID( err->message() ? NS_ConvertUTF8toUTF16(err->message().c_str()) : EmptyString(), - fileUni, - linebuf ? nsDependentString(linebuf, err->linebufLength()) - : EmptyString(), + nsDependentCString(err->filename ? err->filename.c_str() : ""), err->lineno, err->column.oneOriginValue(), flags, - "XPConnect JavaScript", innerWindowID, - innerWindowID == 0 ? true : false); + "XPConnect JavaScript", innerWindowID, innerWindowID == 0); NS_ENSURE_SUCCESS(rv, NS_OK); console->LogMessage(scripterr); @@ -1442,9 +1434,9 @@ nsXPCComponents_Utils::ReportError(HandleValue error, HandleValue stack, return NS_OK; } - nsresult rv = scripterr->InitWithWindowID( - msg, fileName, u""_ns, lineNo, 0, 0, "XPConnect JavaScript", - innerWindowID, innerWindowID == 0 ? true : false); + nsresult rv = scripterr->InitWithWindowID(msg, fileName, lineNo, 0, 0, + "XPConnect JavaScript", + innerWindowID, innerWindowID == 0); NS_ENSURE_SUCCESS(rv, NS_OK); console->LogMessage(scripterr); @@ -1471,11 +1463,8 @@ nsXPCComponents_Utils::EvalInSandbox( filename.Assign(filenameArg); } else { // Get the current source info. - nsCOMPtr frame = dom::GetCurrentJSStack(); - if (frame) { - nsString frameFile; - frame->GetFilename(cx, frameFile); - CopyUTF16toUTF8(frameFile, filename); + if (nsCOMPtr frame = dom::GetCurrentJSStack()) { + frame->GetFilename(cx, filename); lineNo = frame->GetLineNumber(cx); } } diff --git a/js/xpconnect/src/XPCConvert.cpp b/js/xpconnect/src/XPCConvert.cpp index 0118b54da4ec..2de3ce92eaa7 100644 --- a/js/xpconnect/src/XPCConvert.cpp +++ b/js/xpconnect/src/XPCConvert.cpp @@ -1123,15 +1123,13 @@ static nsresult JSErrorToXPCException(JSContext* cx, const char* toStringResult, bestMessage.AssignLiteral("JavaScript Error"); } - const char16_t* linebuf = report->linebuf(); uint32_t flags = report->isWarning() ? nsIScriptError::warningFlag : nsIScriptError::errorFlag; data = new nsScriptError(); data->nsIScriptError::InitWithWindowID( - bestMessage, NS_ConvertUTF8toUTF16(report->filename.c_str()), - linebuf ? nsDependentString(linebuf, report->linebufLength()) - : EmptyString(), + bestMessage, + nsDependentCString(report->filename ? report->filename.c_str() : ""), report->lineno, report->column.oneOriginValue(), flags, "XPConnect JavaScript"_ns, nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx)); diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappedJSClass.cpp index b29d05de771e..9cfbe60f4220 100644 --- a/js/xpconnect/src/XPCWrappedJSClass.cpp +++ b/js/xpconnect/src/XPCWrappedJSClass.cpp @@ -645,7 +645,7 @@ nsresult nsXPCWrappedJS::CheckForException(XPCCallContext& ccx, // try to get filename, lineno from the first // stack frame location. int32_t lineNumber = 0; - nsString sourceName; + nsAutoCString sourceName; nsCOMPtr location = xpc_exception->GetLocation(); if (location) { @@ -657,8 +657,8 @@ nsresult nsXPCWrappedJS::CheckForException(XPCCallContext& ccx, } nsresult rv = scriptError->InitWithWindowID( - NS_ConvertUTF8toUTF16(newMessage), sourceName, u""_ns, - lineNumber, 0, 0, "XPConnect JavaScript", + NS_ConvertUTF8toUTF16(newMessage), sourceName, lineNumber, 0, 0, + "XPConnect JavaScript", nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx)); if (NS_FAILED(rv)) { scriptError = nullptr; diff --git a/js/xpconnect/src/XPCWrappedNativeInfo.cpp b/js/xpconnect/src/XPCWrappedNativeInfo.cpp index a832616a657d..b64ac53d2e19 100644 --- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp +++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp @@ -202,8 +202,7 @@ already_AddRefed XPCNativeInterface::NewInstance( auto location = JSCallingLocation::Get(cx); nsCOMPtr error( do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); - error->Init(NS_ConvertUTF8toUTF16(errorMsg), - NS_ConvertUTF8toUTF16(location.FileName()), u""_ns, + error->Init(NS_ConvertUTF8toUTF16(errorMsg), location.FileName(), location.mLine, location.mColumn, nsIScriptError::warningFlag, "chrome javascript"_ns, false /* from private window */, true /* from chrome context */); diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index 5b98e8cad5f9..4d190207aba1 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -189,8 +189,7 @@ void xpc::ErrorBase::Init(JSErrorBase* aReport) { if (!aReport->filename) { mFileName.SetIsVoid(true); } else { - CopyUTF8toUTF16(mozilla::MakeStringSpan(aReport->filename.c_str()), - mFileName); + mFileName.Assign(aReport->filename.c_str()); } mSourceId = aReport->sourceId; @@ -220,8 +219,6 @@ void xpc::ErrorReport::Init(JSErrorReport* aReport, const char* aToStringResult, mErrorMsg.AssignLiteral(""); } - mSourceLine.Assign(aReport->linebuf(), aReport->linebufLength()); - if (aReport->errorMessageName) { mErrorMsgName.AssignASCII(aReport->errorMessageName); } else { @@ -263,7 +260,7 @@ void xpc::ErrorReport::Init(JSContext* aCx, mozilla::dom::Exception* aException, static LazyLogModule gJSDiagnostics("JSDiagnostics"); void xpc::ErrorBase::AppendErrorDetailsTo(nsCString& error) { - AppendUTF16toUTF8(mFileName, error); + error = mFileName; error.AppendLiteral(", line "); error.AppendInt(mLineNumber, 10); error.AppendLiteral(": "); @@ -324,8 +321,8 @@ void xpc::ErrorReport::LogToConsoleWithStack( LogToStderr(); MOZ_LOG(gJSDiagnostics, IsWarning() ? LogLevel::Warning : LogLevel::Error, - ("file %s, line %u\n%s", NS_ConvertUTF16toUTF8(mFileName).get(), - mLineNumber, NS_ConvertUTF16toUTF8(mErrorMsg).get())); + ("file %s, line %u\n%s", mFileName.get(), mLineNumber, + NS_ConvertUTF16toUTF8(mErrorMsg).get())); // Log to the console. We do this last so that we can simply return if // there's no console service without affecting the other reporting @@ -341,8 +338,8 @@ void xpc::ErrorReport::LogToConsoleWithStack( uint32_t flags = mIsWarning ? nsIScriptError::warningFlag : nsIScriptError::errorFlag; nsresult rv = errorObject->InitWithWindowID( - mErrorMsg, mFileName, mSourceLine, mLineNumber, mColumn, flags, mCategory, - mWindowID, mCategory.Equals("chrome javascript"_ns)); + mErrorMsg, mFileName, mLineNumber, mColumn, flags, mCategory, mWindowID, + mCategory.Equals("chrome javascript"_ns)); NS_ENSURE_SUCCESS_VOID(rv); rv = errorObject->InitSourceId(mSourceId); diff --git a/js/xpconnect/src/xpcpublic.h b/js/xpconnect/src/xpcpublic.h index 4efc0a77bae3..d757fb934201 100644 --- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -720,7 +720,7 @@ void InitGlobalObjectOptions(JS::RealmOptions& aOptions, class ErrorBase { public: nsString mErrorMsg; - nsString mFileName; + nsCString mFileName; uint32_t mSourceId; // Line number (1-origin). uint32_t mLineNumber; @@ -755,7 +755,6 @@ class ErrorReport : public ErrorBase { nsTArray mNotes; nsCString mCategory; - nsString mSourceLine; nsString mErrorMsgName; uint64_t mWindowID; bool mIsWarning; diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 48696cd12db0..80e7719c6304 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -270,9 +270,9 @@ bool ReportWrapperDenial(JSContext* cx, HandleId id, WrapperDenialType type, "access from a given global object will be reported.", NS_LossyConvertUTF16toASCII(propertyName).get()); } - nsString filenameStr(NS_ConvertASCIItoUTF16(filename.get())); nsresult rv = errorObject->InitWithWindowID( - NS_ConvertASCIItoUTF16(errorMessage.ref()), filenameStr, u""_ns, line, + NS_ConvertASCIItoUTF16(errorMessage.ref()), + nsDependentCString(filename.get() ? filename.get() : ""), line, column.oneOriginValue(), nsIScriptError::warningFlag, "XPConnect", windowId); NS_ENSURE_SUCCESS(rv, true); diff --git a/layout/generic/nsImageMap.cpp b/layout/generic/nsImageMap.cpp index 69221d4e97c9..e6c5cfd15760 100644 --- a/layout/generic/nsImageMap.cpp +++ b/layout/generic/nsImageMap.cpp @@ -74,11 +74,7 @@ static void logMessage(nsIContent* aContent, const nsAString& aCoordsSpec, int32_t aFlags, const char* aMessageName) { nsContentUtils::ReportToConsole( aFlags, "Layout: ImageMap"_ns, aContent->OwnerDoc(), - nsContentUtils::eLAYOUT_PROPERTIES, aMessageName, - nsTArray(), /* params */ - SourceLocation(aContent->OwnerDoc()->GetDocumentURI(), 0, 1, - NS_ConvertUTF16toUTF8(u"coords=\""_ns + aCoordsSpec + - u"\""_ns))); /* source line */ + nsContentUtils::eLAYOUT_PROPERTIES, aMessageName); } void Area::ParseCoords(const nsAString& aSpec) { diff --git a/layout/style/ErrorReporter.cpp b/layout/style/ErrorReporter.cpp index 6335c695acca..a819aa63077a 100644 --- a/layout/style/ErrorReporter.cpp +++ b/layout/style/ErrorReporter.cpp @@ -37,7 +37,7 @@ class ShortTermURISpecCache : public Runnable { ShortTermURISpecCache() : Runnable("ShortTermURISpecCache"), mPending(false) {} - nsString const& GetSpec(nsIURI* aURI) { + nsCString const& GetSpec(nsIURI* aURI) { if (mURI != aURI) { mURI = aURI; @@ -62,7 +62,7 @@ class ShortTermURISpecCache : public Runnable { private: nsCOMPtr mURI; - nsString mSpec; + nsCString mSpec; bool mPending; }; @@ -200,17 +200,9 @@ bool ErrorReporter::ShouldReportErrors(const StyleSheet* aSheet, return false; } -void ErrorReporter::OutputError(const nsACString& aSourceLine, - const nsACString& aSelectors, +void ErrorReporter::OutputError(const nsACString& aSelectors, uint32_t aLineNumber, uint32_t aColNumber, nsIURI* aURI) { - nsAutoString errorLine; - // This could be a really long string for minified CSS; just leave it empty - // if we OOM. - if (!AppendUTF8toUTF16(aSourceLine, errorLine, fallible)) { - errorLine.Truncate(); - } - nsAutoString selectors; if (!AppendUTF8toUTF16(aSelectors, selectors, fallible)) { selectors.Truncate(); @@ -220,7 +212,7 @@ void ErrorReporter::OutputError(const nsACString& aSourceLine, return; } - nsAutoString fileName; + nsAutoCString fileName; if (aURI) { if (!sSpecCache) { sSpecCache = new ShortTermURISpecCache; @@ -239,8 +231,8 @@ void ErrorReporter::OutputError(const nsACString& aSourceLine, // It is safe to used InitWithSanitizedSource because fileName is // an already anonymized uri spec. rv = errorObject->InitWithSanitizedSource( - mError, fileName, errorLine, aLineNumber, aColNumber, - nsIScriptError::warningFlag, "CSS Parser", mInnerWindowId); + mError, fileName, aLineNumber, aColNumber, nsIScriptError::warningFlag, + "CSS Parser", mInnerWindowId); if (NS_SUCCEEDED(rv)) { errorObject->SetCssSelectors(selectors); diff --git a/layout/style/ErrorReporter.h b/layout/style/ErrorReporter.h index 3f24cf089fed..e1e21c823461 100644 --- a/layout/style/ErrorReporter.h +++ b/layout/style/ErrorReporter.h @@ -42,8 +42,8 @@ class MOZ_STACK_CLASS ErrorReporter final { static bool ShouldReportErrors(const StyleSheet*, const Loader*); static uint64_t FindInnerWindowId(const StyleSheet*, const Loader*); - void OutputError(const nsACString& aSource, const nsACString& aSelectors, - uint32_t aLineNumber, uint32_t aColNumber, nsIURI* aURI); + void OutputError(const nsACString& aSelectors, uint32_t aLineNumber, + uint32_t aColNumber, nsIURI* aURI); void ClearError(); // In all overloads of ReportUnexpected, aMessage is a stringbundle diff --git a/layout/style/FontFaceSetImpl.cpp b/layout/style/FontFaceSetImpl.cpp index e1b4c4190fe1..eec5095338ef 100644 --- a/layout/style/FontFaceSetImpl.cpp +++ b/layout/style/FontFaceSetImpl.cpp @@ -637,12 +637,10 @@ nsresult FontFaceSetImpl::LogMessage(gfxUserFontEntry* aUserFontEntry, // try to give the user an indication of where the rule came from StyleLockedFontFaceRule* rule = FindRuleForUserFontEntry(aUserFontEntry); - nsString href; - nsAutoCString text; + nsAutoCString href; uint32_t line = 0; uint32_t column = 0; if (rule) { - Servo_FontFaceRule_GetCssText(rule, &text); Servo_FontFaceRule_GetSourceLocation(rule, &line, &column); // FIXME We need to figure out an approach to get the style sheet // of this raw rule. See bug 1450903. @@ -666,8 +664,7 @@ nsresult FontFaceSetImpl::LogMessage(gfxUserFontEntry* aUserFontEntry, NS_ENSURE_SUCCESS(rv, rv); rv = scriptError->InitWithWindowID(NS_ConvertUTF8toUTF16(message), - href, // file - NS_ConvertUTF8toUTF16(text), // src line + href, // file line, column, aFlags, // flags "CSS Loader", // category (make separate?) diff --git a/layout/style/GeckoBindings.cpp b/layout/style/GeckoBindings.cpp index b6d1c4fb94d0..7ed493b8fedf 100644 --- a/layout/style/GeckoBindings.cpp +++ b/layout/style/GeckoBindings.cpp @@ -1515,12 +1515,14 @@ bool Gecko_ErrorReportingEnabled(const StyleSheet* aSheet, return true; } -void Gecko_ReportUnexpectedCSSError( - const uint64_t aWindowId, nsIURI* aURI, const char* message, - const char* param, uint32_t paramLen, const char* prefix, - const char* prefixParam, uint32_t prefixParamLen, const char* suffix, - const char* source, uint32_t sourceLen, const char* selectors, - uint32_t selectorsLen, uint32_t lineNumber, uint32_t colNumber) { +void Gecko_ReportUnexpectedCSSError(const uint64_t aWindowId, nsIURI* aURI, + const char* message, const char* param, + uint32_t paramLen, const char* prefix, + const char* prefixParam, + uint32_t prefixParamLen, const char* suffix, + const char* selectors, + uint32_t selectorsLen, uint32_t lineNumber, + uint32_t colNumber) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); ErrorReporter reporter(aWindowId); @@ -1548,10 +1550,8 @@ void Gecko_ReportUnexpectedCSSError( if (suffix) { reporter.ReportUnexpected(suffix); } - nsDependentCSubstring sourceValue(source, sourceLen); nsDependentCSubstring selectorsValue(selectors, selectorsLen); - reporter.OutputError(sourceValue, selectorsValue, lineNumber + 1, colNumber, - aURI); + reporter.OutputError(selectorsValue, lineNumber + 1, colNumber, aURI); } void Gecko_ContentList_AppendAll(nsSimpleContentList* aList, diff --git a/layout/style/GeckoBindings.h b/layout/style/GeckoBindings.h index d273793fc8d9..c18d38d8ad2f 100644 --- a/layout/style/GeckoBindings.h +++ b/layout/style/GeckoBindings.h @@ -536,9 +536,8 @@ bool Gecko_ErrorReportingEnabled(const mozilla::StyleSheet* sheet, void Gecko_ReportUnexpectedCSSError( uint64_t windowId, nsIURI* uri, const char* message, const char* param, uint32_t paramLen, const char* prefix, const char* prefixParam, - uint32_t prefixParamLen, const char* suffix, const char* source, - uint32_t sourceLen, const char* selectors, uint32_t selectorsLen, - uint32_t lineNumber, uint32_t colNumber); + uint32_t prefixParamLen, const char* suffix, const char* selectors, + uint32_t selectorsLen, uint32_t lineNumber, uint32_t colNumber); // DOM APIs. void Gecko_ContentList_AppendAll(nsSimpleContentList* aContentList, diff --git a/layout/style/test/test_bug413958.html b/layout/style/test/test_bug413958.html index 0b48e3aa68a8..f8e3a41aaf7a 100644 --- a/layout/style/test/test_bug413958.html +++ b/layout/style/test/test_bug413958.html @@ -43,15 +43,15 @@ var tests = [ ]; var results = [ [ { errorMessage: /Unknown property \u2018nosuchprop\u2019/, - lineNumber: 1, columnNumber: 16, sourceLine: "", cssSelectors: "#s1" }, + lineNumber: 1, columnNumber: 16, cssSelectors: "#s1" }, { errorMessage: /Unknown property \u2018nosuchprop\u2019/, - lineNumber: 2, columnNumber: 16, sourceLine: "", cssSelectors: "#s2" }, + lineNumber: 2, columnNumber: 16, cssSelectors: "#s2" }, { errorMessage: /Ruleset ignored due to bad selector/, - lineNumber: 2, columnNumber: 41, sourceLine: "", cssSelectors: "" } ], + lineNumber: 2, columnNumber: 41, cssSelectors: "" } ], [ { errorMessage: /parsing value for \u2018width\u2019/, - lineNumber: 1, columnNumber: 7, sourceLine: "", cssSelectors: "" } ], + lineNumber: 1, columnNumber: 7, cssSelectors: "" } ], [ { errorMessage: /parsing value for \u2018width\u2019/, - lineNumber: 1, columnNumber: 1, sourceLine: "", cssSelectors: "" } ], + lineNumber: 1, columnNumber: 1, cssSelectors: "" } ], ]; var curTest = -1; diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index 3f0af205ee97..5f5fd2e6c6aa 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -2066,7 +2066,7 @@ nsresult NS_NewURI(nsIURI** aURI, const nsACString& aSpec, } nsresult NS_GetSanitizedURIStringFromURI(nsIURI* aUri, - nsAString& aSanitizedSpec) { + nsACString& aSanitizedSpec) { aSanitizedSpec.Truncate(); nsCOMPtr safeUri = do_QueryInterface(aUri); @@ -2079,7 +2079,7 @@ nsresult NS_GetSanitizedURIStringFromURI(nsIURI* aUri, } if (NS_SUCCEEDED(rv)) { - aSanitizedSpec.Assign(NS_ConvertUTF8toUTF16(cSpec)); + aSanitizedSpec.Assign(cSpec); } return rv; } diff --git a/netwerk/base/nsNetUtil.h b/netwerk/base/nsNetUtil.h index f46612e57152..a3dd047cd3cf 100644 --- a/netwerk/base/nsNetUtil.h +++ b/netwerk/base/nsNetUtil.h @@ -137,7 +137,7 @@ nsresult NS_GetURIWithNewRef(nsIURI* aInput, const nsACString& aRef, nsresult NS_GetURIWithoutRef(nsIURI* aInput, nsIURI** aOutput); nsresult NS_GetSanitizedURIStringFromURI(nsIURI* aUri, - nsAString& aSanitizedSpec); + nsACString& aSanitizedSpec); /* * How to create a new Channel, using NS_NewChannel, diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 8c568e12f8ba..8b951dcf8c1c 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -3703,9 +3703,9 @@ nsresult HttpBaseChannel::AddSecurityMessage( NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); - error->InitWithSourceURI( - errorText, mURI, u""_ns, 0, 0, nsIScriptError::warningFlag, - NS_ConvertUTF16toUTF8(aMessageCategory), innerWindowID); + error->InitWithSourceURI(errorText, mURI, 0, 0, nsIScriptError::warningFlag, + NS_ConvertUTF16toUTF8(aMessageCategory), + innerWindowID); console->LogMessage(error); diff --git a/netwerk/protocol/http/nsCORSListenerProxy.cpp b/netwerk/protocol/http/nsCORSListenerProxy.cpp index 0afcce0c7f15..63bff70724f2 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -1742,18 +1742,16 @@ void nsCORSListenerProxy::LogBlockedCORSRequest( // the error to the browser console. if (aInnerWindowID > 0) { rv = scriptError->InitWithSanitizedSource(aMessage, - u""_ns, // sourceName - u""_ns, // sourceLine - 0, // lineNumber - 0, // columnNumber + ""_ns, // sourceName + 0, // lineNumber + 0, // columnNumber errorFlag, aCategory, aInnerWindowID); } else { rv = scriptError->Init(aMessage, - u""_ns, // sourceName - u""_ns, // sourceLine - 0, // lineNumber - 0, // columnNumber + ""_ns, // sourceName + 0, // lineNumber + 0, // columnNumber errorFlag, aCategory, aPrivateBrowsing, aFromChromeContext); // From chrome context } diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 2400e6d7bd9a..7600ed94ca29 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -8038,9 +8038,9 @@ nsresult nsHttpChannel::LogConsoleError(const char* aTag) { nsCOMPtr error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); NS_ENSURE_TRUE(error, NS_ERROR_OUT_OF_MEMORY); - rv = error->InitWithSourceURI(errorText, mURI, u""_ns, 0, 0, - nsIScriptError::errorFlag, - "Invalid HTTP Status Lines"_ns, innerWindowID); + rv = + error->InitWithSourceURI(errorText, mURI, 0, 0, nsIScriptError::errorFlag, + "Invalid HTTP Status Lines"_ns, innerWindowID); NS_ENSURE_SUCCESS(rv, rv); console->LogMessage(error); return NS_OK; diff --git a/parser/htmlparser/nsExpatDriver.cpp b/parser/htmlparser/nsExpatDriver.cpp index 7cdaedba942b..0719ea9c5893 100644 --- a/parser/htmlparser/nsExpatDriver.cpp +++ b/parser/htmlparser/nsExpatDriver.cpp @@ -1139,7 +1139,7 @@ nsresult nsExpatDriver::HandleError() { nsresult rv = NS_ERROR_FAILURE; if (serr) { rv = serr->InitWithSourceURI( - errorText, mURIs.SafeElementAt(0), mLastLine, + errorText, mURIs.SafeElementAt(0), lineNumber.unverified_safe_because(RLBOX_SAFE_PRINT), colNumber.unverified_safe_because(RLBOX_SAFE_PRINT), nsIScriptError::errorFlag, "malformed-xml", mInnerWindowID); diff --git a/remote/cdp/test/browser/head.js b/remote/cdp/test/browser/head.js index acf2216194e2..89dabe1642a1 100644 --- a/remote/cdp/test/browser/head.js +++ b/remote/cdp/test/browser/head.js @@ -440,7 +440,6 @@ async function throwScriptError(options = {}) { scriptError.initWithWindowID( options.text, options.sourceName || "sourceName", - null, options.lineNumber || 0, options.columnNumber || 0, flag, diff --git a/remote/shared/Realm.sys.mjs b/remote/shared/Realm.sys.mjs index 5bf4a2fa3a01..69cef79f3242 100644 --- a/remote/shared/Realm.sys.mjs +++ b/remote/shared/Realm.sys.mjs @@ -362,7 +362,7 @@ export class WindowRealm extends Realm { * The JavaScript stack trace. */ reportError(message, stack) { - const { column, line, source: sourceLine } = stack; + const { column, line } = stack; const scriptErrorClass = Cc["@mozilla.org/scripterror;1"]; const scriptError = scriptErrorClass.createInstance(Ci.nsIScriptError); @@ -370,7 +370,6 @@ export class WindowRealm extends Realm { scriptError.initWithWindowID( message, this.#window.document.baseURI, - sourceLine, line, column, Ci.nsIScriptError.errorFlag, diff --git a/remote/shared/listeners/test/browser/browser_ConsoleListener.js b/remote/shared/listeners/test/browser/browser_ConsoleListener.js index 656f05d068b4..2fdbd6feee0d 100644 --- a/remote/shared/listeners/test/browser/browser_ConsoleListener.js +++ b/remote/shared/listeners/test/browser/browser_ConsoleListener.js @@ -81,7 +81,6 @@ function logConsoleMessage(options = {}) { scriptError.initWithWindowID( _options.message, _options.sourceName || "sourceName", - null, _options.lineNumber || 0, _options.columnNumber || 0, levelToFlags[level], diff --git a/security/sandbox/linux/glue/SandboxCrash.cpp b/security/sandbox/linux/glue/SandboxCrash.cpp index 3a9222c076d9..843a025a26f7 100644 --- a/security/sandbox/linux/glue/SandboxCrash.cpp +++ b/security/sandbox/linux/glue/SandboxCrash.cpp @@ -48,7 +48,8 @@ static void SandboxLogJSStack(void) { // using or something. JSContext* cx = frame ? nsContentUtils::GetCurrentJSContext() : nullptr; for (int i = 0; frame != nullptr; ++i) { - nsAutoString fileName, funName; + nsAutoCString fileName; + nsAutoString funName; int32_t lineNumber; // Don't stop unwinding if an attribute can't be read. @@ -62,9 +63,7 @@ static void SandboxLogJSStack(void) { SANDBOX_LOG("JS frame %d: %s %s line %d", i, funName.IsVoid() ? "(anonymous)" : NS_ConvertUTF16toUTF8(funName).get(), - fileName.IsVoid() ? "(no file)" - : NS_ConvertUTF16toUTF8(fileName).get(), - lineNumber); + fileName.IsVoid() ? "(no file)" : fileName.get(), lineNumber); } frame = frame->GetCaller(cx); diff --git a/servo/ports/geckolib/error_reporter.rs b/servo/ports/geckolib/error_reporter.rs index 78facf33712e..3115684ff0fe 100644 --- a/servo/ports/geckolib/error_reporter.rs +++ b/servo/ports/geckolib/error_reporter.rs @@ -476,8 +476,6 @@ impl ErrorReporter { let pre_param = pre_param.map(|p| p.into_str()); let param_ptr = param.as_ref().map_or(ptr::null(), |p| p.as_ptr()); let pre_param_ptr = pre_param.as_ref().map_or(ptr::null(), |p| p.as_ptr()); - // The CSS source text is unused and will be removed in bug 1381188. - let source = ""; unsafe { bindings::Gecko_ReportUnexpectedCSSError( self.window_id, @@ -489,8 +487,6 @@ impl ErrorReporter { pre_param_ptr as *const _, pre_param.as_ref().map_or(0, |p| p.len()) as u32, suffix as *const _, - source.as_ptr() as *const _, - source.len() as u32, selector_list_ptr, desugared_selector_list .as_ref() diff --git a/testing/specialpowers/content/SpecialPowersChild.sys.mjs b/testing/specialpowers/content/SpecialPowersChild.sys.mjs index ef81af911cd9..66534e6f4ab0 100644 --- a/testing/specialpowers/content/SpecialPowersChild.sys.mjs +++ b/testing/specialpowers/content/SpecialPowersChild.sys.mjs @@ -75,7 +75,6 @@ SPConsoleListener.prototype = { errorMessage: null, cssSelectors: null, sourceName: null, - sourceLine: null, lineNumber: null, columnNumber: null, category: null, @@ -88,7 +87,6 @@ SPConsoleListener.prototype = { m.errorMessage = msg.errorMessage; m.cssSelectors = msg.cssSelectors; m.sourceName = msg.sourceName; - m.sourceLine = msg.sourceLine; m.lineNumber = msg.lineNumber; m.columnNumber = msg.columnNumber; m.category = msg.category; diff --git a/toolkit/components/cookiebanners/CookieBannerParent.sys.mjs b/toolkit/components/cookiebanners/CookieBannerParent.sys.mjs index 445b2ea31a6f..705cf3eee9a4 100644 --- a/toolkit/components/cookiebanners/CookieBannerParent.sys.mjs +++ b/toolkit/components/cookiebanners/CookieBannerParent.sys.mjs @@ -111,9 +111,8 @@ export class CookieBannerParent extends JSWindowActorParent { consoleMsg.initWithWindowID( message.value, this.manager.documentURI?.spec, - null, - null, - null, + 0, + 0, Ci.nsIScriptError.warningFlag, "cookiebannerhandling", this.manager?.innerWindowId diff --git a/toolkit/components/extensions/ExtensionCommon.sys.mjs b/toolkit/components/extensions/ExtensionCommon.sys.mjs index bf7eef0f0ef2..366330cb15a3 100644 --- a/toolkit/components/extensions/ExtensionCommon.sys.mjs +++ b/toolkit/components/extensions/ExtensionCommon.sys.mjs @@ -748,7 +748,6 @@ export class BaseContext { new ScriptError( message, fileName, - null, lineNumber, columnNumber, Ci.nsIScriptError.errorFlag, diff --git a/toolkit/components/extensions/ExtensionContent.sys.mjs b/toolkit/components/extensions/ExtensionContent.sys.mjs index 84027af4dcc5..54a381e43c89 100644 --- a/toolkit/components/extensions/ExtensionContent.sys.mjs +++ b/toolkit/components/extensions/ExtensionContent.sys.mjs @@ -730,7 +730,6 @@ class Script { new ScriptError( error.toString(), error.fileName, - null, error.lineNumber, error.columnNumber, Ci.nsIScriptError.errorFlag, diff --git a/toolkit/components/extensions/ExtensionPageChild.sys.mjs b/toolkit/components/extensions/ExtensionPageChild.sys.mjs index f0ac5ed22949..2561ffc2e795 100644 --- a/toolkit/components/extensions/ExtensionPageChild.sys.mjs +++ b/toolkit/components/extensions/ExtensionPageChild.sys.mjs @@ -48,7 +48,6 @@ const initializeBackgroundPage = context => { consoleMsg.initWithWindowID( text, filename, - null, lineNumber, columnNumber, Ci.nsIScriptError.warningFlag, diff --git a/toolkit/components/glean/bindings/private/Common.cpp b/toolkit/components/glean/bindings/private/Common.cpp index f84c39c05d93..d64104f1645b 100644 --- a/toolkit/components/glean/bindings/private/Common.cpp +++ b/toolkit/components/glean/bindings/private/Common.cpp @@ -25,7 +25,7 @@ void LogToBrowserConsole(uint32_t aLogLevel, const nsAString& aMsg) { } nsCOMPtr error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); - error->Init(aMsg, u""_ns, u""_ns, 0, 0, aLogLevel, "chrome javascript"_ns, + error->Init(aMsg, ""_ns, 0, 0, aLogLevel, "chrome javascript"_ns, false /* from private window */, true /* from chrome context */); console->LogMessage(error); } diff --git a/toolkit/components/passwordmgr/InsecurePasswordUtils.sys.mjs b/toolkit/components/passwordmgr/InsecurePasswordUtils.sys.mjs index 5d1bb2bf1958..73319d7df94c 100644 --- a/toolkit/components/passwordmgr/InsecurePasswordUtils.sys.mjs +++ b/toolkit/components/passwordmgr/InsecurePasswordUtils.sys.mjs @@ -52,7 +52,6 @@ export const InsecurePasswordUtils = { domDoc.location.href, 0, 0, - 0, flag, category, windowId diff --git a/toolkit/components/passwordmgr/test/browser/browser_insecurePasswordConsoleWarning.js b/toolkit/components/passwordmgr/test/browser/browser_insecurePasswordConsoleWarning.js index 68d566325866..5116bc923568 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_insecurePasswordConsoleWarning.js +++ b/toolkit/components/passwordmgr/test/browser/browser_insecurePasswordConsoleWarning.js @@ -86,7 +86,7 @@ add_task(async function testInsecurePasswordWarning() { let promiseConsoleMessages = new Promise(resolve => { warningPatternHandler = function (warning, originMessage) { Assert.ok(warning, "Handling a warning pattern"); - let fullMessage = `[${warning.msg} {file: "${testURL}" line: 0 column: 0 source: "0"}]`; + let fullMessage = `[${warning.msg} {file: "${testURL}" line: 0}]`; Assert.equal( originMessage, fullMessage, diff --git a/toolkit/components/telemetry/core/TelemetryCommon.cpp b/toolkit/components/telemetry/core/TelemetryCommon.cpp index 278763eaff3b..a52d8e0a649d 100644 --- a/toolkit/components/telemetry/core/TelemetryCommon.cpp +++ b/toolkit/components/telemetry/core/TelemetryCommon.cpp @@ -127,7 +127,7 @@ void LogToBrowserConsole(uint32_t aLogLevel, const nsAString& aMsg) { } nsCOMPtr error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); - error->Init(aMsg, u""_ns, u""_ns, 0, 0, aLogLevel, "chrome javascript"_ns, + error->Init(aMsg, ""_ns, 0, 0, aLogLevel, "chrome javascript"_ns, false /* from private window */, true /* from chrome context */); console->LogMessage(error); } diff --git a/uriloader/preload/PreloaderBase.cpp b/uriloader/preload/PreloaderBase.cpp index 2c3d4fb60bee..e8b2889cf6a6 100644 --- a/uriloader/preload/PreloaderBase.cpp +++ b/uriloader/preload/PreloaderBase.cpp @@ -373,12 +373,12 @@ NS_IMETHODIMP PreloaderBase::UsageTimer::Notify(nsITimer* aTimer) { return NS_OK; } - nsString spec; + nsAutoCString spec; NS_GetSanitizedURIStringFromURI(uri, spec); - nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "DOM"_ns, - mDocument, nsContentUtils::eDOM_PROPERTIES, - "UnusedLinkPreloadPending", - nsTArray({std::move(spec)})); + nsContentUtils::ReportToConsole( + nsIScriptError::warningFlag, "DOM"_ns, mDocument, + nsContentUtils::eDOM_PROPERTIES, "UnusedLinkPreloadPending", + nsTArray({NS_ConvertUTF8toUTF16(spec)})); return NS_OK; } diff --git a/xpcom/base/CycleCollectedJSRuntime.h b/xpcom/base/CycleCollectedJSRuntime.h index 78c3ec831d97..40e41385c840 100644 --- a/xpcom/base/CycleCollectedJSRuntime.h +++ b/xpcom/base/CycleCollectedJSRuntime.h @@ -502,7 +502,7 @@ class CycleCollectedJSRuntime { // complicated garbage-collection scenarios, e.g. a JSContext being killed // while we still hold onto an exception thrown from it. struct ErrorDetails { - nsString mFilename; + nsCString mFilename; nsString mMessage; nsString mStack; JSExnType mType; diff --git a/xpcom/base/nsConsoleService.cpp b/xpcom/base/nsConsoleService.cpp index e6b17a6571ba..06045176e40b 100644 --- a/xpcom/base/nsConsoleService.cpp +++ b/xpcom/base/nsConsoleService.cpp @@ -191,7 +191,8 @@ nsresult nsConsoleService::MaybeForwardScriptError(nsIConsoleMessage* aMessage, return NS_ERROR_FAILURE; } - nsAutoString msg, sourceName, sourceLine; + nsAutoString msg; + nsAutoCString sourceName; nsCString category; uint32_t lineNum, colNum, flags; uint64_t innerWindowId; @@ -201,8 +202,6 @@ nsresult nsConsoleService::MaybeForwardScriptError(nsIConsoleMessage* aMessage, NS_ENSURE_SUCCESS(rv, rv); rv = scriptError->GetSourceName(sourceName); NS_ENSURE_SUCCESS(rv, rv); - rv = scriptError->GetSourceLine(sourceLine); - NS_ENSURE_SUCCESS(rv, rv); rv = scriptError->GetCategory(getter_Copies(category)); NS_ENSURE_SUCCESS(rv, rv); @@ -219,9 +218,9 @@ nsresult nsConsoleService::MaybeForwardScriptError(nsIConsoleMessage* aMessage, rv = scriptError->GetInnerWindowID(&innerWindowId); NS_ENSURE_SUCCESS(rv, rv); - *sent = contentParent->SendScriptError( - msg, sourceName, sourceLine, lineNum, colNum, flags, category, - fromPrivateWindow, innerWindowId, fromChromeContext); + *sent = contentParent->SendScriptError(msg, sourceName, lineNum, colNum, + flags, category, fromPrivateWindow, + innerWindowId, fromChromeContext); return NS_OK; } diff --git a/xpcom/base/nsIException.idl b/xpcom/base/nsIException.idl index 7f529e1c087d..3a54f9839d02 100644 --- a/xpcom/base/nsIException.idl +++ b/xpcom/base/nsIException.idl @@ -15,7 +15,7 @@ native StackFrameRef(already_AddRefed); interface nsIStackFrame : nsISupports { [implicit_jscontext, binaryname(FilenameXPCOM)] - readonly attribute AString filename; + readonly attribute AUTF8String filename; [implicit_jscontext, binaryname(NameXPCOM)] readonly attribute AString name; // Unique identifier of the script source for the frame, or zero. @@ -26,7 +26,6 @@ interface nsIStackFrame : nsISupports readonly attribute int32_t lineNumber; [implicit_jscontext, binaryname(ColumnNumberXPCOM)] readonly attribute int32_t columnNumber; - readonly attribute AUTF8String sourceLine; [implicit_jscontext, binaryname(AsyncCauseXPCOM)] readonly attribute AString asyncCause; [implicit_jscontext, binaryname(AsyncCallerXPCOM)] @@ -49,7 +48,7 @@ interface nsIStackFrame : nsISupports // Infallible things to be called from C++. [notxpcom, nostdcall] - void getFilename(in JSContext aCx, out AString aFilename); + void getFilename(in JSContext aCx, out AUTF8String aFilename); [notxpcom, nostdcall] void getName(in JSContext aCx, out AString aName); [notxpcom, nostdcall] diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp index 88ee06d78db6..7af4865220f7 100644 --- a/xpcom/components/ManifestParser.cpp +++ b/xpcom/components/ManifestParser.cpp @@ -153,10 +153,9 @@ void LogMessageWithContext(FileLocation& aFile, uint32_t aLineNumber, } nsresult rv = error->Init( - NS_ConvertUTF8toUTF16(formatted.get()), NS_ConvertUTF8toUTF16(file), - u""_ns, aLineNumber, 0, nsIScriptError::warningFlag, - "chrome registration"_ns, false /* from private window */, - true /* from chrome context */); + NS_ConvertUTF8toUTF16(formatted.get()), file, aLineNumber, 0, + nsIScriptError::warningFlag, "chrome registration"_ns, + false /* from private window */, true /* from chrome context */); if (NS_FAILED(rv)) { return; } diff --git a/xpcom/ds/nsObserverService.cpp b/xpcom/ds/nsObserverService.cpp index 882d86747437..286c4c08e7d6 100644 --- a/xpcom/ds/nsObserverService.cpp +++ b/xpcom/ds/nsObserverService.cpp @@ -193,7 +193,7 @@ nsresult nsObserverService::FilterHttpOnTopics(const char* aTopic) { nsCOMPtr error( do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); error->Init(u"http-on-* observers only work in the parent process"_ns, - u""_ns, u""_ns, 0, 0, nsIScriptError::warningFlag, + ""_ns, 0, 0, nsIScriptError::warningFlag, "chrome javascript"_ns, false /* from private window */, true /* from chrome context */); console->LogMessage(error);