tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit dd1af534d51e5a4baf0c40ffddd2356b989e6be8
parent 8db459c9b185cd1efaac47226b599edd1c9c510b
Author: agoloman <agoloman@mozilla.com>
Date:   Thu,  8 Jan 2026 12:26:07 +0200

Revert "Bug 2008920 - Make browser chrome mochitests log the task name as the subtest and log the assertion failure stacks in the stack field of structured messages, r=ahal." for breaking structured logging format.

This reverts commit b86f417f85ae296faf2510a33ee5d890f3cc4492.

Diffstat:
Mtesting/mochitest/browser-harness.xhtml | 20+++++++-------------
Mtesting/mochitest/browser-test.js | 33++++++---------------------------
2 files changed, 13 insertions(+), 40 deletions(-)

diff --git a/testing/mochitest/browser-harness.xhtml b/testing/mochitest/browser-harness.xhtml @@ -146,21 +146,11 @@ return; } - // Use task name as subtest if available - let subtest = this.scope?.SimpleTest?._currentTaskName || null; - - // Combine assertion name with exception details if present - let message = result.name; - if (result.msg) { - message += " - " + result.msg; - } - this.dumper.structuredLogger.testStatus(this.path, - subtest, + result.name, result.status, result.expected, - message, - result.stack || null); + result.msg); let markerName = "TEST-"; if (result.pass) { markerName += result.todo ? "KNOWN-FAIL" : "PASS"; @@ -168,7 +158,11 @@ else { markerName += "UNEXPECTED-" + result.status; } - ChromeUtils.addProfilerMarker(markerName, {category: "Test"}, message); + let markerText = result.name; + if (result.msg) { + markerText += " - " + result.msg; + } + ChromeUtils.addProfilerMarker(markerName, {category: "Test"}, markerText); }, setDuration: function setDuration(duration) { diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js @@ -1284,8 +1284,6 @@ Tester.prototype = { let desc = isSetup ? "setup" : "test"; currentScope.SimpleTest.info(`Entering ${desc} ${task.name}`); let startTimestamp = ChromeUtils.now(); - currentScope.SimpleTest._currentTaskName = task.name; - let controller = new AbortController(); currentScope.__signal = controller.signal; if (isSetup) { @@ -1314,7 +1312,7 @@ Tester.prototype = { } currentTest.addResult( new testResult({ - name: `Uncaught exception in ${desc}`, + name: `Uncaught exception in ${desc} ${task.name}`, pass: currentScope.SimpleTest.isExpectingUncaughtException(), ex, stack: typeof ex == "object" && "stack" in ex ? ex.stack : null, @@ -1330,10 +1328,9 @@ Tester.prototype = { ChromeUtils.addProfilerMarker( isSetup ? "setup-task" : "task", { category: "Test", startTime: startTimestamp }, - task.name || undefined + task.name.replace(/^bound /, "") || undefined ); currentScope.SimpleTest.info(`Leaving ${desc} ${task.name}`); - currentScope.SimpleTest._currentTaskName = null; }, async _runTaskBasedTest(currentTest) { @@ -1707,23 +1704,8 @@ function testResult({ name, pass, todo, ex, stack, allowFailure }) { if (ex) { if (typeof ex == "object" && "fileName" in ex) { - // Only add "at fileName:lineNumber" if stack doesn't start with same location - let stackMatchesExLocation = false; - - if (stack instanceof Ci.nsIStackFrame) { - stackMatchesExLocation = - stack.filename == ex.fileName && stack.lineNumber == ex.lineNumber; - } else if (typeof stack === "string") { - // For string stacks, format is: functionName@fileName:lineNumber:columnNumber - // Check if first line contains fileName:lineNumber - let firstLine = stack.split("\n")[0]; - let expectedLocation = ex.fileName + ":" + ex.lineNumber; - stackMatchesExLocation = firstLine.includes(expectedLocation); - } - - if (!stackMatchesExLocation) { - this.msg += "at " + ex.fileName + ":" + ex.lineNumber + " - "; - } + // we have an exception - print filename and linenumber information + this.msg += "at " + ex.fileName + ":" + ex.lineNumber + " - "; } if ( @@ -1740,8 +1722,8 @@ function testResult({ name, pass, todo, ex, stack, allowFailure }) { } } - // Store stack separately instead of appending to msg if (stack) { + this.msg += "\nStack trace:\n"; let normalized; if (stack instanceof Ci.nsIStackFrame) { let frames = []; @@ -1757,7 +1739,7 @@ function testResult({ name, pass, todo, ex, stack, allowFailure }) { } else { normalized = "" + stack; } - this.stack = normalized; + this.msg += normalized; } if (gConfig.debugOnFailure) { @@ -2015,10 +1997,7 @@ function testScope(aTester, aTest, expected) { } function decorateTaskFn(fn) { - let originalName = fn.name; fn = fn.bind(this); - // Restore original name to avoid "bound " prefix in task name - Object.defineProperty(fn, "name", { value: originalName }); fn.skip = (val = true) => (fn.__skipMe = val); fn.only = () => (this.__runOnlyThisTask = fn); return fn;