From 705aa818698f7480c765717bb50c8dd6486f1376 Mon Sep 17 00:00:00 2001 From: Natalia Csoregi Date: Wed, 22 Nov 2023 14:01:55 +0200 Subject: [PATCH] Backed out 14 changesets (bug 1865005, bug 1864168, bug 1864155, bug 1862814, bug 1862693) for causing bustage on nsRFPService.cpp. CLOSED TREE Backed out changeset a4f3e7625abf (bug 1865005) Backed out changeset ab38141e470b (bug 1862814) Backed out changeset a679b50dc4a9 (bug 1862814) Backed out changeset e340886ce62a (bug 1862814) Backed out changeset 1378502e64b0 (bug 1862814) Backed out changeset 8ee94e5e79c2 (bug 1862814) Backed out changeset 6d4ef1cdfabb (bug 1864168) Backed out changeset 2c30c4d757fc (bug 1864168) Backed out changeset d4db9576559b (bug 1864168) Backed out changeset 8ffec0d83028 (bug 1864168) Backed out changeset fa77d852b494 (bug 1864168) Backed out changeset f6646771a26a (bug 1864168) Backed out changeset 7bd0ff6986df (bug 1864155) Backed out changeset 39867b503289 (bug 1862693) --- caps/nsScriptSecurityManager.cpp | 2 +- .../client/debugger/src/utils/location.js | 4 +- .../browser_webconsole_csp_violation.js | 6 +- ...ser_webconsole_custom_formatters_errors.js | 2 +- .../debugger-api/debugger.script/index.rst | 14 +-- .../docs/user/debugger-api/debugger/index.rst | 2 + .../actors/inspector/event-collector.js | 7 +- devtools/server/actors/inspector/node.js | 7 +- devtools/server/actors/object/previewers.js | 6 +- devtools/server/actors/source.js | 42 ++----- devtools/server/actors/thread.js | 5 - devtools/server/actors/tracer.js | 16 +-- .../server/actors/utils/sources-manager.js | 6 +- devtools/startup/DevToolsStartup.sys.mjs | 8 +- .../browser/browser_command_line_urls.js | 2 +- dom/base/EventSource.cpp | 2 +- dom/base/TimeoutHandler.h | 2 +- dom/base/nsContentUtils.h | 4 +- dom/base/nsFrameMessageManager.cpp | 2 +- dom/base/nsJSUtils.cpp | 4 +- dom/base/nsStyledElement.cpp | 2 +- dom/bindings/BindingUtils.cpp | 2 +- dom/events/EventListenerManager.cpp | 2 +- dom/html/HTMLFormElement.cpp | 2 +- dom/html/HTMLScriptElement.cpp | 6 +- dom/jsurl/nsJSProtocolHandler.cpp | 2 +- dom/media/webaudio/WebAudioUtils.cpp | 2 +- dom/reporting/tests/common_deprecated.js | 6 +- dom/reporting/tests/iframe_delivering.html | 2 +- dom/script/ScriptLoadContext.h | 3 +- dom/script/ScriptLoader.cpp | 33 +++-- dom/script/nsIScriptElement.h | 7 +- dom/security/CSPEvalChecker.cpp | 4 +- dom/security/DOMSecurityMonitor.cpp | 2 +- dom/security/nsCSPContext.cpp | 14 +-- dom/security/nsCSPParser.cpp | 2 +- dom/security/nsContentSecurityUtils.cpp | 4 +- dom/security/nsMixedContentBlocker.cpp | 2 +- dom/security/test/unit/test_csp_reports.js | 16 +-- dom/serviceworkers/ServiceWorkerEvents.cpp | 6 +- dom/smil/SMILCSSValueType.cpp | 4 +- dom/svg/SVGScriptElement.cpp | 6 +- dom/system/IOUtils.cpp | 2 +- dom/websocket/WebSocket.cpp | 12 +- dom/workers/RuntimeService.cpp | 2 +- dom/xml/nsXMLContentSink.cpp | 10 +- dom/xml/nsXMLContentSink.h | 1 - js/public/ColumnNumber.h | 33 +++-- js/public/CompileOptions.h | 2 +- js/src/builtin/ReflectParse.cpp | 4 +- js/src/builtin/TestingUtility.cpp | 6 +- js/src/debugger/Object.cpp | 6 +- js/src/debugger/Script.cpp | 35 ++++-- js/src/debugger/Source.cpp | 2 +- js/src/doc/Debugger/Debugger.Script.md | 113 +++++++++--------- js/src/doc/Debugger/Debugger.Source.md | 4 +- js/src/doc/Debugger/Debugger.md | 6 + js/src/frontend/Stencil.cpp | 4 +- js/src/jit-test/lib/assert-offset-columns.js | 4 +- .../tests/basic/getBacktrace-invalid.js | 2 +- .../class/default-constructor-position.js | 2 +- .../debug/Frame-onPop-source-location.js | 2 +- .../tests/debug/Object-createSource.js | 4 +- .../debug/Script-getPossibleBreakpoints-02.js | 28 ++--- .../debug/Script-getPossibleBreakpoints.js | 2 +- .../tests/debug/Script-startColumn.js | 28 ++--- js/src/jit-test/tests/debug/Source-reparse.js | 6 +- .../debug/Source-startLine-startColumn.js | 2 +- .../tests/debug/onExceptionUnwind-16.js | 4 +- .../tests/debug/onExceptionUnwind-17.js | 4 +- .../tests/debug/onExceptionUnwind-18.js | 4 +- .../fields/field-initializer-position.js | 4 +- .../tests/modules/export-declaration.js | 4 +- .../tests/modules/import-declaration.js | 4 +- js/src/jit-test/tests/parser/bug-1161312.js | 2 +- js/src/jit-test/tests/parser/bug-975484.js | 8 +- js/src/jit-test/tests/parser/columnNumber.js | 8 +- .../tests/parser/script-source-extent.js | 4 +- .../tests/profiler/interpreter-stacks.js | 2 +- js/src/jit/BaselineBailouts.cpp | 20 ++-- js/src/jit/BaselineCacheIRCompiler.cpp | 2 +- js/src/jit/BaselineCodeGen.cpp | 8 +- js/src/jit/BaselineDebugModeOSR.cpp | 4 +- js/src/jit/BaselineIC.cpp | 7 +- js/src/jit/BytecodeAnalysis.cpp | 4 +- js/src/jit/CacheIRHealth.cpp | 7 +- js/src/jit/CacheIRSpewer.cpp | 2 +- js/src/jit/CodeGenerator.cpp | 4 +- js/src/jit/InterpreterEntryTrampoline.cpp | 2 +- js/src/jit/Ion.cpp | 16 +-- js/src/jit/JitScript.cpp | 2 +- js/src/jit/JitcodeMap.cpp | 4 +- js/src/jit/PerfSpewer.cpp | 6 +- js/src/jit/TrialInlining.cpp | 4 +- js/src/jit/WarpOracle.cpp | 10 +- js/src/jit/WarpSnapshot.cpp | 2 +- js/src/jit/shared/CodeGenerator-shared.cpp | 6 +- .../non262/reflect-parse/computedPropNames.js | 2 +- js/src/tests/non262/reflect-parse/location.js | 14 +-- .../non262/reflect-parse/templateStrings.js | 14 +-- .../syntax/column-numbers-in-long-lines.js | 96 +++++++-------- js/src/util/DumpFunctions.cpp | 3 +- js/src/util/StructuredSpewer.cpp | 4 +- js/src/vm/BytecodeUtil.cpp | 2 +- js/src/vm/GeckoProfiler.cpp | 2 +- js/src/vm/JSScript.cpp | 10 +- js/xpconnect/src/XPCWrappedNativeInfo.cpp | 2 +- js/xpconnect/wrappers/XrayWrapper.cpp | 4 +- netwerk/base/nsNetUtil.cpp | 2 +- parser/html/nsHtml5TreeBuilderCppSupplement.h | 10 +- parser/html/nsHtml5TreeOperation.cpp | 4 +- parser/htmlparser/nsIExpatSink.idl | 3 +- testing/modules/CoverageUtils.sys.mjs | 3 +- .../blockeduri-eval.html | 2 +- .../blockeduri-inline.html | 2 +- ...ck-cross-origin-image-from-script.sub.html | 2 +- ...iolation-block-cross-origin-image.sub.html | 2 +- ...violation-block-image-from-script.sub.html | 2 +- ...curitypolicyviolation-block-image.sub.html | 2 +- .../source-file-blob-scheme.html | 2 +- .../source-file-data-scheme.html | 2 +- .../securitypolicyviolation/targeting.html | 8 +- .../antitracking/ContentBlockingNotifier.cpp | 4 +- tools/profiler/core/ProfileBuffer.cpp | 2 +- 124 files changed, 452 insertions(+), 505 deletions(-) diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 842b41811e8d..b245c3761c64 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -555,7 +555,7 @@ bool nsScriptSecurityManager::ContentSecurityPolicyPermitsJSAction( csp->LogViolationDetails(violationType, nullptr, // triggering element cspEventListener, fileName, scriptSample, lineNum, - columnNum.oneOriginValue(), u""_ns, u""_ns); + columnNum.zeroOriginValue(), u""_ns, u""_ns); } return evalOK; diff --git a/devtools/client/debugger/src/utils/location.js b/devtools/client/debugger/src/utils/location.js index 00c63f860400..f780eec3c531 100644 --- a/devtools/client/debugger/src/utils/location.js +++ b/devtools/client/debugger/src/utils/location.js @@ -27,10 +27,10 @@ export function createLocation({ sourceActor, sourceActorId: sourceActor?.id, - // `line` and `column` are 1-based. + // `line` is 1-based while `column` is 0-based. // This data is mostly coming from and driven by // JSScript::lineno and JSScript::column - // https://searchfox.org/mozilla-central/rev/90dce6b0223b4dc17bb10f1125b44f70951585f9/js/src/vm/JSScript.h#1545-1548 + // https://searchfox.org/mozilla-central/rev/d81e60336d9f498ad3985491dc17c2b77969ade4/js/src/vm/JSScript.h#1544-1547 line, column, }; diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_csp_violation.js b/devtools/client/webconsole/test/browser/browser_webconsole_csp_violation.js index 3eb4decd8241..5a8c7cbf2b21 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_csp_violation.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_csp_violation.js @@ -39,7 +39,7 @@ add_task(async function () { `Content-Security-Policy: The page’s settings blocked` + ` the loading of a resource at inline (“style-src”).`; const VIOLATION_LOCATION_HTML = "test-csp-violation-inline.html:18:1"; - const VIOLATION_LOCATION_JS = "test-csp-violation-inline.html:14:25"; + const VIOLATION_LOCATION_JS = "test-csp-violation-inline.html:14:24"; await navigateTo(TEST_VIOLATION); // Triggering the Violation via HTML let msg = await waitFor(() => findErrorMessage(hud, CSP_VIOLATION)); @@ -70,7 +70,7 @@ add_task(async function () { "https://example.com/browser/devtools/client/webconsole/" + "test/browser/test-csp-violation-base-uri.html"; const CSP_VIOLATION = `Content-Security-Policy: The page’s settings blocked the loading of a resource at https://evil.com/ (“base-uri”).`; - const VIOLATION_LOCATION = "test-csp-violation-base-uri.html:15:25"; + const VIOLATION_LOCATION = "test-csp-violation-base-uri.html:15:24"; await navigateTo(TEST_VIOLATION); let msg = await waitFor(() => findErrorMessage(hud, CSP_VIOLATION)); ok(msg, "Base-URI validation was Printed"); @@ -95,7 +95,7 @@ add_task(async function () { "https://example.com/browser/devtools/client/webconsole/" + "test/browser/test-csp-violation-form-action.html"; const CSP_VIOLATION = `Content-Security-Policy: The page’s settings blocked the loading of a resource at https://evil.com/evil.com (“form-action”).`; - const VIOLATION_LOCATION = "test-csp-violation-form-action.html:14:40"; + const VIOLATION_LOCATION = "test-csp-violation-form-action.html:14:39"; await navigateTo(TEST_VIOLATION); const msg = await waitFor(() => findErrorMessage(hud, CSP_VIOLATION)); diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_custom_formatters_errors.js b/devtools/client/webconsole/test/browser/browser_webconsole_custom_formatters_errors.js index f769338a19c7..6f8477e306c9 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_custom_formatters_errors.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_custom_formatters_errors.js @@ -47,7 +47,7 @@ async function testHeaderNotReturningJsonMl(hud) { info(`Test for "header" not returning JsonML`); await testCustomFormatting(hud, { messageText: `Custom formatter failed: devtoolsFormatters[1].header should return an array, got number`, - source: "test-console-custom-formatters-errors.html:19:19", + source: "test-console-custom-formatters-errors.html:19:18", }); } diff --git a/devtools/docs/user/debugger-api/debugger.script/index.rst b/devtools/docs/user/debugger-api/debugger.script/index.rst index 5652868696d0..7df26208af90 100644 --- a/devtools/docs/user/debugger-api/debugger.script/index.rst +++ b/devtools/docs/user/debugger-api/debugger.script/index.rst @@ -174,7 +174,7 @@ The functions described below may only be called with a ``this`` value referring The elements of the array are objects, each of which describes a single entry point, and contains the following properties: - lineNumber: the line number for which offset is an entry point - - columnNumber: the 1-based column number for which offset is an entry point + - columnNumber: the column number for which offset is an entry point - offset: the bytecode instruction offset of the entry point @@ -191,10 +191,10 @@ The functions described below may only be called with a ``this`` value referring .. code-block:: javascript - [{ lineNumber: 0, columnNumber: 1, offset: 0 }, - { lineNumber: 1, columnNumber: 6, offset: 5 }, - { lineNumber: 1, columnNumber: 11, offset: 20 }, - { lineNumber: 3, columnNumber: 5, offset: 10 }] + [{ lineNumber: 0, columnNumber: 0, offset: 0 }, + { lineNumber: 1, columnNumber: 5, offset: 5 }, + { lineNumber: 1, columnNumber: 10, offset: 20 }, + { lineNumber: 3, columnNumber: 4, offset: 10 }] **If the instance refers to WebAssembly code**, throw a ``TypeError``. @@ -205,7 +205,7 @@ The functions described below may only be called with a ``this`` value referring **If the instance refers to a JSScript**, return an object describing the source code location responsible for the bytecode at *offset* in this script. The object has the following properties: - lineNumber: the line number for which offset is an entry point - - columnNumber: the 1-based column number for which offset is an entry point + - columnNumber: the column number for which offset is an entry point - isEntryPoint: true if the offset is a column entry point, as would be reported by getAllColumnOffsets(); otherwise false. @@ -213,7 +213,7 @@ The functions described below may only be called with a ``this`` value referring **If the instance refers to a JSScript**, return ``null`` or an array which contains information about the coverage of all opcodes. The elements of the array are objects, each of which describes a single opcode, and contains the following properties: - lineNumber: the line number of the current opcode. - - columnNumber: the 1-based column number of the current opcode. + - columnNumber: the column number of the current opcode. - offset: the bytecode instruction offset of the current opcode. - count: the number of times the current opcode got executed. diff --git a/devtools/docs/user/debugger-api/debugger/index.rst b/devtools/docs/user/debugger-api/debugger/index.rst index 87647602bd45..b26716a78af4 100644 --- a/devtools/docs/user/debugger-api/debugger/index.rst +++ b/devtools/docs/user/debugger-api/debugger/index.rst @@ -238,6 +238,8 @@ The functions described below may only be called with a ``this`` value referring The script’s ``source`` property must be equal to this value. ``line`` The script must at least partially cover the given source line. If this property is present, the ``url`` property must be present as well. + ``column`` + The script must include given column on the line given by the ``line`` property. If this property is present, the ``url`` and ``line`` properties must both be present as well. ``innermost`` If this property is present and true, the script must be the innermost script covering the given source location; scripts of enclosing code are omitted. ``global`` diff --git a/devtools/server/actors/inspector/event-collector.js b/devtools/server/actors/inspector/event-collector.js index 4ee8dc388fe5..1801c23f92bd 100644 --- a/devtools/server/actors/inspector/event-collector.js +++ b/devtools/server/actors/inspector/event-collector.js @@ -968,13 +968,8 @@ class EventCollector { if (script) { const scriptSource = script.source.text; - // NOTE: Debugger.Script.prototype.startColumn is 1-based. - // Convert to 0-based, while keeping the wasm's column (1) as is. - // (bug 1863878) - const columnBase = script.format === "wasm" ? 0 : 1; - line = script.startLine; - column = script.startColumn - columnBase; + column = script.startColumn; url = script.url; const actor = this.targetActor.sourcesManager.getOrCreateSourceActor( script.source diff --git a/devtools/server/actors/inspector/node.js b/devtools/server/actors/inspector/node.js index 294e3e956418..0f664cb0b9b6 100644 --- a/devtools/server/actors/inspector/node.js +++ b/devtools/server/actors/inspector/node.js @@ -506,15 +506,10 @@ class NodeActor extends Actor { return undefined; } - // NOTE: Debugger.Script.prototype.startColumn is 1-based. - // Convert to 0-based, while keeping the wasm's column (1) as is. - // (bug 1863878) - const columnBase = customElementDO.script.format === "wasm" ? 0 : 1; - return { url: customElementDO.script.url, line: customElementDO.script.startLine, - column: customElementDO.script.startColumn - columnBase, + column: customElementDO.script.startColumn, }; } diff --git a/devtools/server/actors/object/previewers.js b/devtools/server/actors/object/previewers.js index 1edae149c92e..8e428c2ca0c0 100644 --- a/devtools/server/actors/object/previewers.js +++ b/devtools/server/actors/object/previewers.js @@ -156,14 +156,10 @@ const previewers = { grip.isGenerator = obj.isGeneratorFunction; if (obj.script) { - // NOTE: Debugger.Script.prototype.startColumn is 1-based. - // Convert to 0-based, while keeping the wasm's column (1) as is. - // (bug 1863878) - const columnBase = obj.script.format === "wasm" ? 0 : 1; grip.location = { url: obj.script.url, line: obj.script.startLine, - column: obj.script.startColumn - columnBase, + column: obj.script.startColumn, }; } diff --git a/devtools/server/actors/source.js b/devtools/server/actors/source.js index ff08bcb4c220..a90b78958e8d 100644 --- a/devtools/server/actors/source.js +++ b/devtools/server/actors/source.js @@ -193,11 +193,6 @@ class SourceActor extends Actor { introductionType = "scriptElement"; } - // NOTE: Debugger.Source.prototype.startColumn is 1-based. - // Convert to 0-based, while keeping the wasm's column (1) as is. - // (bug 1863878) - const columnBase = source.introductionType === "wasm" ? 0 : 1; - return { actor: this.actorID, extensionName: this.extensionName, @@ -211,7 +206,7 @@ class SourceActor extends Actor { introductionType, isInlineSource: this._isInlineSource, sourceStartLine: source.startLine, - sourceStartColumn: source.startColumn - columnBase, + sourceStartColumn: source.startColumn, sourceLength: source.text?.length, }; } @@ -416,15 +411,10 @@ class SourceActor extends Actor { return false; } - // NOTE: Debugger.Script.prototype.startColumn is 1-based. - // Convert to 0-based, while keeping the wasm's column (1) as is. - // (bug 1863878) - const columnBase = script.format === "wasm" ? 0 : 1; if ( script.startLine > endLine || script.startLine + lineCount <= startLine || - (script.startLine == endLine && - script.startColumn - columnBase > endColumn) + (script.startLine == endLine && script.startColumn > endColumn) ) { return false; } @@ -432,7 +422,7 @@ class SourceActor extends Actor { if ( lineCount == 1 && script.startLine == startLine && - script.startColumn - columnBase + script.sourceLength <= startColumn + script.startColumn + script.sourceLength <= startColumn ) { return false; } @@ -479,25 +469,20 @@ class SourceActor extends Actor { end: { line: endLine = Infinity, column: endColumn = Infinity } = {}, } = query || {}; - // NOTE: Debugger.Script.prototype.startColumn is 1-based. - // Convert to 0-based, while keeping the wasm's column (1) as is. - // (bug 1863878) - const columnBase = script.format === "wasm" ? 0 : 1; - const offsets = script.getPossibleBreakpoints(); for (const { lineNumber, columnNumber } of offsets) { if ( lineNumber < startLine || - (lineNumber === startLine && columnNumber - columnBase < startColumn) || + (lineNumber === startLine && columnNumber < startColumn) || lineNumber > endLine || - (lineNumber === endLine && columnNumber - columnBase >= endColumn) + (lineNumber === endLine && columnNumber >= endColumn) ) { continue; } positions.push({ line: lineNumber, - column: columnNumber - columnBase, + column: columnNumber, }); } } @@ -625,11 +610,6 @@ class SourceActor extends Actor { script => !actor.hasScript(script) ); - // NOTE: Debugger.Script.prototype.getPossibleBreakpoints returns - // columnNumber in 1-based. - // The following code uses columnNumber only for comparing against - // other columnNumber, and we don't need to convert to 0-based. - // This is a line breakpoint, so we add a breakpoint on the first // breakpoint on the line. const lineMatches = []; @@ -664,19 +644,13 @@ class SourceActor extends Actor { ); for (const script of scripts) { - // NOTE: getPossibleBreakpoints's minColumn/maxColumn parameters are - // 1-based. - // Convert to 1-based, while keeping the wasm's column (1) as is. - // (bug 1863878) - const columnBase = script.format === "wasm" ? 0 : 1; - // Check to see if the script contains a breakpoint position at // this line and column. const possibleBreakpoint = script .getPossibleBreakpoints({ line, - minColumn: column + columnBase, - maxColumn: column + columnBase + 1, + minColumn: column, + maxColumn: column + 1, }) .pop(); diff --git a/devtools/server/actors/thread.js b/devtools/server/actors/thread.js index d33b3e5eb270..9af1d9b540bd 100644 --- a/devtools/server/actors/thread.js +++ b/devtools/server/actors/thread.js @@ -2254,11 +2254,7 @@ class ThreadActor extends Actor { ...content.substring(0, scriptStartOffset).matchAll("\n"), ]; const startLine = 1 + allLineBreaks.length; - // NOTE: Debugger.Source.prototype.startColumn is 1-based. - // Create 1-based column here for the following comparison, - // and also the createSource call below. const startColumn = - 1 + scriptStartOffset - (allLineBreaks.length ? allLineBreaks.at(-1).index - 1 : 0); @@ -2274,7 +2270,6 @@ class ThreadActor extends Actor { try { const global = this.dbg.getDebuggees()[0]; - // NOTE: Debugger.Object.prototype.createSource takes 1-based column. this._addSource( global.createSource({ text, diff --git a/devtools/server/actors/tracer.js b/devtools/server/actors/tracer.js index a6b685257ff0..9b805c2b6eff 100644 --- a/devtools/server/actors/tracer.js +++ b/devtools/server/actors/tracer.js @@ -149,20 +149,8 @@ class TracerActor extends Actor { const { lineNumber, columnNumber } = script.getOffsetMetadata(frame.offset); const url = script.source.url; - // NOTE: Debugger.Script.prototype.getOffsetMetadata returns - // columnNumber in 1-based. - // Convert to 0-based, while keeping the wasm's column (1) as is. - // (bug 1863878) - const columnBase = script.format === "wasm" ? 0 : 1; - // Ignore blackboxed sources - if ( - this.sourcesManager.isBlackBoxed( - url, - lineNumber, - columnNumber - columnBase - ) - ) { + if (this.sourcesManager.isBlackBoxed(url, lineNumber, columnNumber)) { return false; } @@ -197,7 +185,7 @@ class TracerActor extends Actor { this.throttledConsoleMessages.push({ filename: url, lineNumber, - columnNumber: columnNumber - columnBase, + columnNumber, arguments: args, styles: CONSOLE_ARGS_STYLES, level: "logTrace", diff --git a/devtools/server/actors/utils/sources-manager.js b/devtools/server/actors/utils/sources-manager.js index b80da69bfa8c..7b8e4690f30c 100644 --- a/devtools/server/actors/utils/sources-manager.js +++ b/devtools/server/actors/utils/sources-manager.js @@ -228,14 +228,10 @@ class SourcesManager extends EventEmitter { */ getScriptOffsetLocation(script, offset) { const { lineNumber, columnNumber } = script.getOffsetMetadata(offset); - // NOTE: Debugger.Source.prototype.startColumn is 1-based. - // Convert to 0-based, while keeping the wasm's column (1) as is. - // (bug 1863878) - const columnBase = script.format === "wasm" ? 0 : 1; return new SourceLocation( this.createSourceActor(script.source), lineNumber, - columnNumber - columnBase + columnNumber ); } diff --git a/devtools/startup/DevToolsStartup.sys.mjs b/devtools/startup/DevToolsStartup.sys.mjs index f7d3d804cb74..a58da06a8ad8 100644 --- a/devtools/startup/DevToolsStartup.sys.mjs +++ b/devtools/startup/DevToolsStartup.sys.mjs @@ -442,14 +442,8 @@ DevToolsStartup.prototype = { } } - // line and column are supposed to be 1-based. const { url, line, column } = match.groups; - // Debugger internal uses 0-based column number. - // NOTE: Non-debugger view-source doesn't use column number. - const columnOneBased = parseInt(column || 0, 10); - const columnZeroBased = columnOneBased > 0 ? columnOneBased - 1 : 0; - // If for any reason the final url is invalid, ignore it try { Services.io.newURI(url); @@ -487,7 +481,7 @@ DevToolsStartup.prototype = { toolbox.viewSourceInDebugger( url, parseInt(line, 10), - columnZeroBased, + parseInt(column || 0, 10), null, "CommandLine" ); diff --git a/devtools/startup/tests/browser/browser_command_line_urls.js b/devtools/startup/tests/browser/browser_command_line_urls.js index 4494d635c672..76687054bcda 100644 --- a/devtools/startup/tests/browser/browser_command_line_urls.js +++ b/devtools/startup/tests/browser/browser_command_line_urls.js @@ -121,7 +121,7 @@ add_task(async function openingWithDevToolsAndKnownSource() { }); is(selectedLocation.source.url, URL_ROOT + "command-line.js"); is(selectedLocation.line, 5); - is(selectedLocation.column, 1); + is(selectedLocation.column, 2); info("Open another URL with only a line"); const url2 = URL_ROOT + "command-line.js:6"; diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp index b9666e87c7b5..0f80aa50d097 100644 --- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -378,7 +378,7 @@ EventSourceImpl::EventSourceImpl(EventSource* aEventSource, mIsShutDown(false), mSharedData(SharedData{aEventSource}, "EventSourceImpl::mSharedData"), mScriptLine(0), - mScriptColumn(1), + mScriptColumn(0), mInnerWindowID(0), mCookieJarSettings(aCookieJarSettings), mTargetThread(NS_GetCurrentThread()) { diff --git a/dom/base/TimeoutHandler.h b/dom/base/TimeoutHandler.h index f8dd350af603..ce659d762377 100644 --- a/dom/base/TimeoutHandler.h +++ b/dom/base/TimeoutHandler.h @@ -37,7 +37,7 @@ class TimeoutHandler : public nsISupports { virtual void MarkForCC() {} protected: - TimeoutHandler() : mFileName(""), mLineNo(0), mColumn(1) {} + TimeoutHandler() : mFileName(""), mLineNo(0), mColumn(0) {} explicit TimeoutHandler(JSContext* aCx); virtual ~TimeoutHandler() = default; diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index cd6a504c1913..9f7e0963087c 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -1177,7 +1177,7 @@ class nsContentUtils { contains the error (may be empty). * @param [aLineNumber=0] (Optional) Line number within resource containing error. - * @param [aColumnNumber=1] (Optional) Column number within resource + * @param [aColumnNumber=0] (Optional) Column number within resource containing error. If aURI is null, then aDocument->GetDocumentURI() is used. * @param [aLocationMode] (Optional) Specifies the behavior if @@ -1187,7 +1187,7 @@ class nsContentUtils { const nsAString& aErrorText, uint32_t aErrorFlags, const nsACString& aCategory, uint64_t aInnerWindowID, nsIURI* aURI = nullptr, const nsString& aSourceLine = u""_ns, - uint32_t aLineNumber = 0, uint32_t aColumnNumber = 1, + uint32_t aLineNumber = 0, uint32_t aColumnNumber = 0, MissingErrorLocationMode aLocationMode = eUSE_CALLING_LOCATION); /** diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index da275095b192..fdf6b4775b56 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -456,7 +456,7 @@ bool nsFrameMessageManager::GetParamsForMessage(JSContext* aCx, do_GetService(NS_CONSOLESERVICE_CONTRACTID)); if (console) { nsAutoString filename; - uint32_t lineno = 0, column = 1; + uint32_t lineno = 0, column = 0; nsJSUtils::GetCallingLocation(aCx, filename, &lineno, &column); nsCOMPtr error( do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp index cf8037cd5800..bb280d9a15ae 100644 --- a/dom/base/nsJSUtils.cpp +++ b/dom/base/nsJSUtils.cpp @@ -56,7 +56,7 @@ bool nsJSUtils::GetCallingLocation(JSContext* aContext, nsACString& aFilename, return false; } if (aColumn) { - *aColumn = column.oneOriginValue(); + *aColumn = column.zeroOriginValue(); } return aFilename.Assign(filename.get(), fallible); @@ -70,7 +70,7 @@ bool nsJSUtils::GetCallingLocation(JSContext* aContext, nsAString& aFilename, return false; } if (aColumn) { - *aColumn = column.oneOriginValue(); + *aColumn = column.zeroOriginValue(); } return aFilename.Assign(NS_ConvertUTF8toUTF16(filename.get()), fallible); diff --git a/dom/base/nsStyledElement.cpp b/dom/base/nsStyledElement.cpp index 921ccea0043c..0ea8086a490b 100644 --- a/dom/base/nsStyledElement.cpp +++ b/dom/base/nsStyledElement.cpp @@ -181,7 +181,7 @@ void nsStyledElement::ParseStyleAttribute(const nsAString& aValue, if (!isNativeAnon && !nsStyleUtil::CSPAllowsInlineStyle(this, doc, aMaybeScriptedPrincipal, 0, - 1, aValue, nullptr)) + 0, aValue, nullptr)) return; if (aForceInDataDoc || !doc->IsLoadedAsData() || GetExistingStyle() || diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 98f22b93e038..6bc0b3eb9178 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -4237,7 +4237,7 @@ void MaybeReportDeprecation(const GlobalObject& aGlobal, Nullable lineNumber; Nullable columnNumber; uint32_t line = 0; - uint32_t column = 1; + uint32_t column = 0; if (nsJSUtils::GetCallingLocation(aGlobal.Context(), fileName, &line, &column)) { lineNumber.SetValue(line); diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index de2b37b6280b..93b109574475 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -1046,7 +1046,7 @@ nsresult EventListenerManager::SetEventHandler(nsAtom* aName, true, // aParserCreated (true because attribute event handler) aElement, nullptr, // nsICSPEventListener - aBody, lineNum, columnNum.oneOriginValue(), &allowsInlineScript); + aBody, lineNum, columnNum.zeroOriginValue(), &allowsInlineScript); NS_ENSURE_SUCCESS(rv, rv); // return early if CSP wants us to block inline scripts diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index af2283736601..d10bb910783e 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -1694,7 +1694,7 @@ nsresult HTMLFormElement::GetActionURL(nsIURI** aActionURL, u""_ns, // aSourceFile u""_ns, // aScriptSample 0, // aLineNumber - 1, // aColumnNumber + 0, // aColumnNumber nsIScriptError::warningFlag, "upgradeInsecureRequest"_ns, document->InnerWindowID(), !!document->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId); diff --git a/dom/html/HTMLScriptElement.cpp b/dom/html/HTMLScriptElement.cpp index 5e5abfa5fec6..8d568e0022a3 100644 --- a/dom/html/HTMLScriptElement.cpp +++ b/dom/html/HTMLScriptElement.cpp @@ -184,8 +184,7 @@ void HTMLScriptElement::FreezeExecutionAttrs(const Document* aOwnerDoc) { nsContentUtils::ReportToConsole( nsIScriptError::warningFlag, "HTML"_ns, OwnerDoc(), nsContentUtils::eDOM_PROPERTIES, "ScriptSourceInvalidUri", params, - nullptr, u""_ns, GetScriptLineNumber(), - GetScriptColumnNumber().oneOriginValue()); + nullptr, u""_ns, GetScriptLineNumber(), GetScriptColumnNumber()); } } else { AutoTArray params = {u"src"_ns}; @@ -193,8 +192,7 @@ void HTMLScriptElement::FreezeExecutionAttrs(const Document* aOwnerDoc) { nsContentUtils::ReportToConsole( nsIScriptError::warningFlag, "HTML"_ns, OwnerDoc(), nsContentUtils::eDOM_PROPERTIES, "ScriptSourceEmpty", params, nullptr, - u""_ns, GetScriptLineNumber(), - GetScriptColumnNumber().oneOriginValue()); + u""_ns, GetScriptLineNumber(), GetScriptColumnNumber()); } // At this point mUri will be null for invalid URLs. diff --git a/dom/jsurl/nsJSProtocolHandler.cpp b/dom/jsurl/nsJSProtocolHandler.cpp index 770548668bf1..bb16adbf9443 100644 --- a/dom/jsurl/nsJSProtocolHandler.cpp +++ b/dom/jsurl/nsJSProtocolHandler.cpp @@ -161,7 +161,7 @@ static bool AllowedByCSP(nsIContentSecurityPolicy* aCSP, nullptr, // nsICSPEventListener NS_ConvertASCIItoUTF16(aJavaScriptURL), // aContent 0, // aLineNumber - 1, // aColumnNumber + 0, // aColumnNumber &allowsInlineScript); return (NS_SUCCEEDED(rv) && allowsInlineScript); diff --git a/dom/media/webaudio/WebAudioUtils.cpp b/dom/media/webaudio/WebAudioUtils.cpp index a1338650e0b4..78edc2947e5a 100644 --- a/dom/media/webaudio/WebAudioUtils.cpp +++ b/dom/media/webaudio/WebAudioUtils.cpp @@ -81,7 +81,7 @@ void WebAudioUtils::LogToDeveloperConsole(uint64_t aWindowID, } nsAutoString spec; - uint32_t aLineNumber = 0, aColumnNumber = 1; + uint32_t aLineNumber = 0, aColumnNumber = 0; JSContext* cx = nsContentUtils::GetCurrentJSContext(); if (cx) { nsJSUtils::GetCallingLocation(cx, spec, &aLineNumber, &aColumnNumber); diff --git a/dom/reporting/tests/common_deprecated.js b/dom/reporting/tests/common_deprecated.js index 8f8415fcf34d..8af37331b24d 100644 --- a/dom/reporting/tests/common_deprecated.js +++ b/dom/reporting/tests/common_deprecated.js @@ -35,7 +35,7 @@ function test_deprecatedInterface() { "We have a sourceFile" ); is(report.body.lineNumber, 48, "We have a lineNumber"); - is(report.body.columnNumber, 24, "We have a columnNumber"); + is(report.body.columnNumber, 23, "We have a columnNumber"); obs.disconnect(); resolve(); @@ -87,7 +87,7 @@ function test_deprecatedMethod() { "We have a sourceFile" ); is(report.body.lineNumber, 100, "We have a lineNumber"); - is(report.body.columnNumber, 22, "We have a columnNumber"); + is(report.body.columnNumber, 21, "We have a columnNumber"); obs.disconnect(); resolve(); @@ -168,7 +168,7 @@ function test_deprecatedAttribute() { "We have a sourceFile" ); is(report.body.lineNumber, 181, "We have a lineNumber"); - is(report.body.columnNumber, 8, "We have a columnNumber"); + is(report.body.columnNumber, 7, "We have a columnNumber"); obs.disconnect(); resolve(); diff --git a/dom/reporting/tests/iframe_delivering.html b/dom/reporting/tests/iframe_delivering.html index e8c5e9e3a487..c77ff50b9c19 100644 --- a/dom/reporting/tests/iframe_delivering.html +++ b/dom/reporting/tests/iframe_delivering.html @@ -60,7 +60,7 @@ function runTests(extraParams = "") { is(report.body.body.message, "TestingDeprecatedInterface is a testing-only interface and this is its testing deprecation message.", "We have a report.body.message"); is(report.body.body.sourceFile, "https://example.org/tests/dom/reporting/tests/iframe_delivering.html", "report.body.sourceFile"); is(report.body.body.lineNumber, 40, "report.body.lineNumber"); - is(report.body.body.columnNumber, 5, "report.body.columnNumber"); + is(report.body.body.columnNumber, 4, "report.body.columnNumber"); }); } diff --git a/dom/script/ScriptLoadContext.h b/dom/script/ScriptLoadContext.h index 74f7c6fe4ffd..0a8cfd2b979e 100644 --- a/dom/script/ScriptLoadContext.h +++ b/dom/script/ScriptLoadContext.h @@ -8,7 +8,6 @@ #define mozilla_dom_ScriptLoadContext_h #include "js/AllocPolicy.h" -#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin #include "js/CompileOptions.h" // JS::OwningCompileOptions #include "js/experimental/JSStencil.h" // JS::FrontendContext, JS::Stencil, JS::InstantiationStorage #include "js/RootingAPI.h" @@ -235,7 +234,7 @@ class ScriptLoadContext : public JS::loader::LoadContextBase, RefPtr mCompileOrDecodeTask; uint32_t mLineNo; - JS::ColumnNumberOneOrigin mColumnNo; + uint32_t mColumnNo; // Set on scripts and top level modules. bool mIsPreload; diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index cf2bfa0ea393..63cf31bd9d63 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -919,8 +919,8 @@ static bool CSPAllowsInlineScript(nsIScriptElement* aElement, nsIContentSecurityPolicy::SCRIPT_SRC_ELEM_DIRECTIVE, false /* aHasUnsafeHash */, aNonce, parserCreated, element, nullptr /* nsICSPEventListener */, u""_ns, - aElement->GetScriptLineNumber(), - aElement->GetScriptColumnNumber().oneOriginValue(), &allowInlineScript); + aElement->GetScriptLineNumber(), aElement->GetScriptColumnNumber(), + &allowInlineScript); return NS_SUCCEEDED(rv) && allowInlineScript; } @@ -2331,7 +2331,8 @@ nsresult ScriptLoader::FillCompileOptionsForRequest( if (aRequest->GetScriptLoadContext()->mIsInline && aRequest->GetScriptLoadContext()->GetParserCreated() == FROM_PARSER_NETWORK) { - aOptions->setColumn(aRequest->GetScriptLoadContext()->mColumnNo); + aOptions->setColumn(JS::ColumnNumberOneOrigin::fromZeroOrigin( + aRequest->GetScriptLoadContext()->mColumnNo)); } aOptions->setIsRunOnce(true); aOptions->setNoScriptRval(true); @@ -3415,15 +3416,12 @@ void ScriptLoader::ReportErrorToConsole(ScriptLoadRequest* aRequest, nsIScriptElement* element = aRequest->GetScriptLoadContext()->GetScriptElement(); uint32_t lineNo = element ? element->GetScriptLineNumber() : 0; - JS::ColumnNumberOneOrigin columnNo; - if (element) { - columnNo = element->GetScriptColumnNumber(); - } + uint32_t columnNo = element ? element->GetScriptColumnNumber() : 0; - nsContentUtils::ReportToConsole( - nsIScriptError::warningFlag, "Script Loader"_ns, mDocument, - nsContentUtils::eDOM_PROPERTIES, message, params, nullptr, u""_ns, lineNo, - columnNo.oneOriginValue()); + nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, + "Script Loader"_ns, mDocument, + nsContentUtils::eDOM_PROPERTIES, message, + params, nullptr, u""_ns, lineNo, columnNo); } void ScriptLoader::ReportWarningToConsole( @@ -3432,14 +3430,11 @@ void ScriptLoader::ReportWarningToConsole( nsIScriptElement* element = aRequest->GetScriptLoadContext()->GetScriptElement(); uint32_t lineNo = element ? element->GetScriptLineNumber() : 0; - JS::ColumnNumberOneOrigin columnNo; - if (element) { - columnNo = element->GetScriptColumnNumber(); - } - nsContentUtils::ReportToConsole( - nsIScriptError::warningFlag, "Script Loader"_ns, mDocument, - nsContentUtils::eDOM_PROPERTIES, aMessageName, aParams, nullptr, u""_ns, - lineNo, columnNo.oneOriginValue()); + uint32_t columnNo = element ? element->GetScriptColumnNumber() : 0; + nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, + "Script Loader"_ns, mDocument, + nsContentUtils::eDOM_PROPERTIES, aMessageName, + aParams, nullptr, u""_ns, lineNo, columnNo); } void ScriptLoader::ReportPreloadErrorsToConsole(ScriptLoadRequest* aRequest) { diff --git a/dom/script/nsIScriptElement.h b/dom/script/nsIScriptElement.h index 8601dbd18292..0201658a962b 100644 --- a/dom/script/nsIScriptElement.h +++ b/dom/script/nsIScriptElement.h @@ -7,7 +7,6 @@ #ifndef nsIScriptElement_h___ #define nsIScriptElement_h___ -#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin #include "js/loader/ScriptKind.h" #include "mozilla/AlreadyAddRefed.h" #include "mozilla/Assertions.h" @@ -159,11 +158,11 @@ class nsIScriptElement : public nsIScriptLoaderObserver { uint32_t GetScriptLineNumber() { return mLineNumber; } - void SetScriptColumnNumber(JS::ColumnNumberOneOrigin aColumnNumber) { + void SetScriptColumnNumber(uint32_t aColumnNumber) { mColumnNumber = aColumnNumber; } - JS::ColumnNumberOneOrigin GetScriptColumnNumber() { return mColumnNumber; } + uint32_t GetScriptColumnNumber() { return mColumnNumber; } void SetIsMalformed() { mMalformed = true; } @@ -300,7 +299,7 @@ class nsIScriptElement : public nsIScriptLoaderObserver { /** * The start column number of the script. */ - JS::ColumnNumberOneOrigin mColumnNumber; + uint32_t mColumnNumber; /** * The "already started" flag per HTML5. diff --git a/dom/security/CSPEvalChecker.cpp b/dom/security/CSPEvalChecker.cpp index 71fa4397ed9b..8b46b96cd300 100644 --- a/dom/security/CSPEvalChecker.cpp +++ b/dom/security/CSPEvalChecker.cpp @@ -131,7 +131,7 @@ nsresult CSPEvalChecker::CheckForWindow(JSContext* aCx, // Get the calling location. uint32_t lineNum = 0; - uint32_t columnNum = 1; + uint32_t columnNum = 0; nsAutoString fileNameString; if (!nsJSUtils::GetCallingLocation(aCx, fileNameString, &lineNum, &columnNum)) { @@ -164,7 +164,7 @@ nsresult CSPEvalChecker::CheckForWorker(JSContext* aCx, // Get the calling location. uint32_t lineNum = 0; - uint32_t columnNum = 1; + uint32_t columnNum = 0; nsAutoString fileNameString; if (!nsJSUtils::GetCallingLocation(aCx, fileNameString, &lineNum, &columnNum)) { diff --git a/dom/security/DOMSecurityMonitor.cpp b/dom/security/DOMSecurityMonitor.cpp index 2ec4998b0b31..bbe0f2aeb640 100644 --- a/dom/security/DOMSecurityMonitor.cpp +++ b/dom/security/DOMSecurityMonitor.cpp @@ -36,7 +36,7 @@ void DOMSecurityMonitor::AuditParsingOfHTMLXMLFragments( // originating from JS code. nsAutoString filename; uint32_t lineNum = 0; - uint32_t columnNum = 1; + uint32_t columnNum = 0; JSContext* cx = nsContentUtils::GetCurrentJSContext(); if (!cx || !nsJSUtils::GetCallingLocation(cx, filename, &lineNum, &columnNum)) { diff --git a/dom/security/nsCSPContext.cpp b/dom/security/nsCSPContext.cpp index 1175ae16860d..e4c8cedeaf31 100644 --- a/dom/security/nsCSPContext.cpp +++ b/dom/security/nsCSPContext.cpp @@ -210,13 +210,13 @@ bool nsCSPContext::permitsInternal( // nonce, and will incorrectly fail the unit tests. if (aSendViolationReports) { uint32_t lineNumber = 0; - uint32_t columnNumber = 1; + uint32_t columnNumber = 0; nsAutoString spec; JSContext* cx = nsContentUtils::GetCurrentJSContext(); if (cx) { nsJSUtils::GetCallingLocation(cx, spec, &lineNumber, &columnNumber); - // If GetCallingLocation fails linenumber & columnNumber are set to - // (0, 1) anyway so we can skip checking if that is the case. + // If GetCallingLocation fails linenumber & columnNumber are set to 0 + // anyway so we can skip checking if that is the case. } AsyncReportViolation( aTriggeringElement, aCSPEventListener, @@ -732,13 +732,13 @@ nsCSPContext::GetAllowsNavigateTo(nsIURI* aURI, bool aIsFormSubmission, // Lines numbers and source file for the violation report uint32_t lineNumber = 0; - uint32_t columnNumber = 1; + uint32_t columnNumber = 0; nsAutoCString spec; JSContext* cx = nsContentUtils::GetCurrentJSContext(); if (cx) { nsJSUtils::GetCallingLocation(cx, spec, &lineNumber, &columnNumber); - // If GetCallingLocation fails linenumber & columnNumber are set to - // (0, 1) anyway so we can skip checking if that is the case. + // If GetCallingLocation fails linenumber & columnNumber are set to 0 + // anyway so we can skip checking if that is the case. } // Report the violation @@ -1848,7 +1848,7 @@ nsCSPContext::GetCSPSandboxFlags(uint32_t* aOutSandboxFlags) { NS_ConvertUTF16toUTF8(policy).get())); AutoTArray params = {policy}; - logToConsole("ignoringReportOnlyDirective", params, u""_ns, u""_ns, 0, 1, + logToConsole("ignoringReportOnlyDirective", params, u""_ns, u""_ns, 0, 0, nsIScriptError::warningFlag); } } diff --git a/dom/security/nsCSPParser.cpp b/dom/security/nsCSPParser.cpp index 7d9fae1d7a54..b2b6573a842f 100644 --- a/dom/security/nsCSPParser.cpp +++ b/dom/security/nsCSPParser.cpp @@ -174,7 +174,7 @@ void nsCSPParser::logWarningErrorToConsole(uint32_t aSeverityFlag, u""_ns, // aSourceName u""_ns, // aSourceLine 0, // aLineNumber - 1, // aColumnNumber + 0, // aColumnNumber aSeverityFlag); // aFlags } diff --git a/dom/security/nsContentSecurityUtils.cpp b/dom/security/nsContentSecurityUtils.cpp index 057954895781..20b471b3a964 100644 --- a/dom/security/nsContentSecurityUtils.cpp +++ b/dom/security/nsContentSecurityUtils.cpp @@ -687,7 +687,7 @@ bool nsContentSecurityUtils::IsEvalAllowed(JSContext* cx, // Check the allowlist for the provided filename. getFilename is a helper // function nsAutoCString fileName; - uint32_t lineNumber = 0, columnNumber = 1; + uint32_t lineNumber = 0, columnNumber = 0; nsJSUtils::GetCallingLocation(cx, fileName, &lineNumber, &columnNumber); if (fileName.IsEmpty()) { fileName = "unknown-file"_ns; @@ -1152,7 +1152,7 @@ void EnforceXFrameOptionsCheck(nsIChannel* aChannel, u""_ns, // no sourcefile u""_ns, // no scriptsample 0, // no linenumber - 1, // no columnnumber + 0, // no columnnumber nsIScriptError::warningFlag, "IgnoringSrcBecauseOfDirective"_ns, innerWindowID, privateWindow); diff --git a/dom/security/nsMixedContentBlocker.cpp b/dom/security/nsMixedContentBlocker.cpp index 7b7c5ba9f0ce..a5e4df7b00c0 100644 --- a/dom/security/nsMixedContentBlocker.cpp +++ b/dom/security/nsMixedContentBlocker.cpp @@ -810,7 +810,7 @@ nsresult nsMixedContentBlocker::ShouldLoad(bool aHadInsecureImageRedirect, u""_ns, // aSourceFile u""_ns, // aScriptSample 0, // aLineNumber - 1, // aColumnNumber + 0, // aColumnNumber nsIScriptError::errorFlag, "blockAllMixedContent"_ns, requestingWindow->Id(), !!aLoadInfo->GetOriginAttributes().mPrivateBrowsingId); diff --git a/dom/security/test/unit/test_csp_reports.js b/dom/security/test/unit/test_csp_reports.js index 36da1a13e533..1bd1a4893773 100644 --- a/dom/security/test/unit/test_csp_reports.js +++ b/dom/security/test/unit/test_csp_reports.js @@ -140,8 +140,8 @@ function run_test() { null, // nsICSPEventListener "", // aContentOfPseudoScript 0, // aLineNumber - 1 // aColumnNumber - ); + 0 + ); // aColumnNumber // this is not a report only policy, so it better block inline scripts Assert.ok(!inlineOK); @@ -181,8 +181,8 @@ function run_test() { // note that JSON is UTF8 encoded. "\u00a3\u00a5\u00b5\u5317\ud841\udf79", 1, // line number - 2 // column number - ); + 2 + ); // column number } } ); @@ -220,8 +220,8 @@ function run_test() { null, // nsICSPEventListener "", // aContentOfPseudoScript 0, // aLineNumber - 1 // aColumnNumber - ); + 0 + ); // aColumnNumber // this is a report only policy, so it better allow inline scripts Assert.ok(inlineOK); @@ -248,8 +248,8 @@ function run_test() { selfuri.asciiSpec, "script sample", 4, // line number - 5 // column number - ); + 5 + ); // column number } }); diff --git a/dom/serviceworkers/ServiceWorkerEvents.cpp b/dom/serviceworkers/ServiceWorkerEvents.cpp index acb8bb96c9bc..bb77062f5172 100644 --- a/dom/serviceworkers/ServiceWorkerEvents.cpp +++ b/dom/serviceworkers/ServiceWorkerEvents.cpp @@ -112,7 +112,7 @@ CancelChannelRunnable::Run() { FetchEvent::FetchEvent(EventTarget* aOwner) : ExtendableEvent(aOwner), mPreventDefaultLineNumber(0), - mPreventDefaultColumnNumber(1), + mPreventDefaultColumnNumber(0), mWaitToRespond(false) {} FetchEvent::~FetchEvent() = default; @@ -771,7 +771,7 @@ void FetchEvent::RespondWith(JSContext* aCx, Promise& aArg, ErrorResult& aRv) { // a file:// string here because service workers require http/https. nsCString spec; uint32_t line = 0; - uint32_t column = 1; + uint32_t column = 0; nsJSUtils::GetCallingLocation(aCx, spec, &line, &column); SafeRefPtr ir = mRequest->GetInternalRequest(); @@ -865,7 +865,7 @@ class WaitUntilHandler final : public PromiseNativeHandler { : mWorkerPrivate(aWorkerPrivate), mScope(mWorkerPrivate->ServiceWorkerScope()), mLine(0), - mColumn(1) { + mColumn(0) { mWorkerPrivate->AssertIsOnWorkerThread(); // Save the location of the waitUntil() call itself as a fallback diff --git a/dom/smil/SMILCSSValueType.cpp b/dom/smil/SMILCSSValueType.cpp index db18452311b1..8707637bae58 100644 --- a/dom/smil/SMILCSSValueType.cpp +++ b/dom/smil/SMILCSSValueType.cpp @@ -453,7 +453,7 @@ void SMILCSSValueType::ValueFromString(nsCSSPropertyID aPropID, } Document* doc = aTargetElement->GetComposedDoc(); - if (doc && !nsStyleUtil::CSPAllowsInlineStyle(nullptr, doc, nullptr, 0, 1, + if (doc && !nsStyleUtil::CSPAllowsInlineStyle(nullptr, doc, nullptr, 0, 0, aString, nullptr)) { return; } @@ -490,7 +490,7 @@ SMILValue SMILCSSValueType::ValueFromAnimationValue( // and an intermediate CSS value is not likely to be particularly useful // in that case, we just use a generic placeholder string instead. static const nsLiteralString kPlaceholderText = u"[SVG animation of CSS]"_ns; - if (doc && !nsStyleUtil::CSPAllowsInlineStyle(nullptr, doc, nullptr, 0, 1, + if (doc && !nsStyleUtil::CSPAllowsInlineStyle(nullptr, doc, nullptr, 0, 0, kPlaceholderText, nullptr)) { return result; } diff --git a/dom/svg/SVGScriptElement.cpp b/dom/svg/SVGScriptElement.cpp index 22fb23998094..4fe7d234c61e 100644 --- a/dom/svg/SVGScriptElement.cpp +++ b/dom/svg/SVGScriptElement.cpp @@ -141,8 +141,7 @@ void SVGScriptElement::FreezeExecutionAttrs(const Document* aOwnerDoc) { nsContentUtils::ReportToConsole( nsIScriptError::warningFlag, "SVG"_ns, OwnerDoc(), nsContentUtils::eDOM_PROPERTIES, "ScriptSourceInvalidUri", params, - nullptr, u""_ns, GetScriptLineNumber(), - GetScriptColumnNumber().oneOriginValue()); + nullptr, u""_ns, GetScriptLineNumber(), GetScriptColumnNumber()); } } else { AutoTArray params = {isHref ? u"href"_ns : u"xlink:href"_ns}; @@ -150,8 +149,7 @@ void SVGScriptElement::FreezeExecutionAttrs(const Document* aOwnerDoc) { nsContentUtils::ReportToConsole( nsIScriptError::warningFlag, "SVG"_ns, OwnerDoc(), nsContentUtils::eDOM_PROPERTIES, "ScriptSourceEmpty", params, nullptr, - u""_ns, GetScriptLineNumber(), - GetScriptColumnNumber().oneOriginValue()); + u""_ns, GetScriptLineNumber(), GetScriptColumnNumber()); } // At this point mUri will be null for invalid URLs. diff --git a/dom/system/IOUtils.cpp b/dom/system/IOUtils.cpp index fc81a267d512..691021479498 100644 --- a/dom/system/IOUtils.cpp +++ b/dom/system/IOUtils.cpp @@ -301,7 +301,7 @@ static bool AssertParentProcessWithCallerLocationImpl(GlobalObject& aGlobal, NS_ENSURE_TRUE(scriptFilename.get(), false); reason.AppendPrintf(" Called from %s:%d:%d.", scriptFilename.get(), lineNo, - colNo.oneOriginValue()); + colNo.zeroOriginValue()); return false; } diff --git a/dom/websocket/WebSocket.cpp b/dom/websocket/WebSocket.cpp index 21841e4a316e..01e78624d35a 100644 --- a/dom/websocket/WebSocket.cpp +++ b/dom/websocket/WebSocket.cpp @@ -134,7 +134,7 @@ class WebSocketImpl final : public nsIInterfaceRequestor, mCloseEventCode(nsIWebSocketChannel::CLOSE_ABNORMAL), mPort(0), mScriptLine(0), - mScriptColumn(1), + mScriptColumn(0), mInnerWindowID(0), mPrivateBrowsing(false), mIsChromeContext(false), @@ -229,8 +229,8 @@ class WebSocketImpl final : public nsIInterfaceRequestor, // Web Socket owner information: // - the script file name, UTF8 encoded. - // - source code line number and 1-origin column number where the Web Socket - // object was constructed. + // - source code line number and column number where the Web Socket object + // was constructed. // - the ID of the Web Socket owner window. Note that this may not // be the same as the inner window where the script lives. // e.g within iframes @@ -1382,7 +1382,7 @@ already_AddRefed WebSocket::ConstructorCommon( workerPrivate, webSocketImpl, workerPrivate->GlobalScope()->GetClientInfo(), !!aTransportProvider, aUrl, protocolArray, nsDependentCString(file.get()), lineno, - column.oneOriginValue()); + column.zeroOriginValue()); runnable->Dispatch(Canceling, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; @@ -1615,7 +1615,7 @@ nsresult WebSocketImpl::Init(JSContext* aCx, bool aIsSecure, if (JS::DescribeScriptedCaller(aCx, &file, &lineno, &column)) { mScriptFile = file.get(); mScriptLine = lineno; - mScriptColumn = column.oneOriginValue(); + mScriptColumn = column.zeroOriginValue(); } } @@ -1728,7 +1728,7 @@ nsresult WebSocketImpl::Init(JSContext* aCx, bool aIsSecure, u""_ns, // aSourceFile u""_ns, // aScriptSample 0, // aLineNumber - 1, // aColumnNumber + 0, // aColumnNumber nsIScriptError::warningFlag, "upgradeInsecureRequest"_ns, mInnerWindowID, mPrivateBrowsing); diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index bcfbe33925af..4fc3db17b202 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -531,7 +531,7 @@ bool ContentSecurityPolicyAllows(JSContext* aCx, JS::RuntimeCode aKind, RefPtr runnable = new LogViolationDetailsRunnable(worker, violationType, fileName, - lineNum, columnNum.oneOriginValue(), + lineNum, columnNum.zeroOriginValue(), scriptSample); ErrorResult rv; diff --git a/dom/xml/nsXMLContentSink.cpp b/dom/xml/nsXMLContentSink.cpp index 2e0a3de17bf0..b68b737eaa19 100644 --- a/dom/xml/nsXMLContentSink.cpp +++ b/dom/xml/nsXMLContentSink.cpp @@ -53,7 +53,6 @@ #include "mozilla/CycleCollectedJSContext.h" #include "mozilla/LoadInfo.h" #include "mozilla/UseCounter.h" -#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin using namespace mozilla; using namespace mozilla::dom; @@ -488,8 +487,7 @@ nsresult nsXMLContentSink::CreateElement( aNodeInfo->Equals(nsGkAtoms::script, kNameSpaceID_SVG)) { if (nsCOMPtr sele = do_QueryInterface(element)) { sele->SetScriptLineNumber(aLineNumber); - sele->SetScriptColumnNumber( - JS::ColumnNumberOneOrigin::fromZeroOrigin(aColumnNumber)); + sele->SetScriptColumnNumber(aColumnNumber); sele->SetCreatorParser(GetParser()); } else { MOZ_ASSERT(nsNameSpaceManager::GetInstance()->mSVGDisabled, @@ -521,7 +519,7 @@ nsresult nsXMLContentSink::CreateElement( } if (!aNodeInfo->Equals(nsGkAtoms::link, kNameSpaceID_XHTML)) { linkStyle->SetLineNumber(aFromParser ? aLineNumber : 0); - linkStyle->SetColumnNumber(aFromParser ? aColumnNumber + 1 : 1); + linkStyle->SetColumnNumber(aFromParser ? aColumnNumber : 0); } } @@ -1324,7 +1322,7 @@ nsXMLContentSink::ReportError(const char16_t* aErrorText, parsererror.Append((char16_t)0xFFFF); parsererror.AppendLiteral("parsererror"); - rv = HandleStartElement(parsererror.get(), noAtts, 0, (uint32_t)-1, 0); + rv = HandleStartElement(parsererror.get(), noAtts, 0, (uint32_t)-1, false); NS_ENSURE_SUCCESS(rv, rv); rv = HandleCharacterData(aErrorText, NS_strlen(aErrorText), false); @@ -1334,7 +1332,7 @@ nsXMLContentSink::ReportError(const char16_t* aErrorText, sourcetext.Append((char16_t)0xFFFF); sourcetext.AppendLiteral("sourcetext"); - rv = HandleStartElement(sourcetext.get(), noAtts, 0, (uint32_t)-1, 0); + rv = HandleStartElement(sourcetext.get(), noAtts, 0, (uint32_t)-1, false); NS_ENSURE_SUCCESS(rv, rv); rv = HandleCharacterData(aSourceText, NS_strlen(aSourceText), false); diff --git a/dom/xml/nsXMLContentSink.h b/dom/xml/nsXMLContentSink.h index d1a8c0104679..41acbbc0272e 100644 --- a/dom/xml/nsXMLContentSink.h +++ b/dom/xml/nsXMLContentSink.h @@ -7,7 +7,6 @@ #ifndef nsXMLContentSink_h__ #define nsXMLContentSink_h__ -#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin #include "mozilla/Attributes.h" #include "nsContentSink.h" #include "nsIXMLContentSink.h" diff --git a/js/public/ColumnNumber.h b/js/public/ColumnNumber.h index 9fd007f4bb4a..c6681ef04aad 100644 --- a/js/public/ColumnNumber.h +++ b/js/public/ColumnNumber.h @@ -5,15 +5,9 @@ // [SMDOC] Column numbers // -// Inside SpiderMonkey, column numbers are represented as 1-origin 32-bit -// unsigned integers. Some parts of the engine use the highest bit of a column -// number as a tag to indicate Wasm frame. -// -// These classes help clarifying the origin of the column number, and also -// figuring out whether the column number uses the wasm's tag or not, and also -// help converting between them. -// -// Also these classes support converting from 0-origin column number. +// Inside SpiderMonkey, column numbers are represented as 32-bit unsigned +// integers, either with 0-origin or 1-origin. Also, some parts of the engine +// use the highest bit of a column number as a tag to indicate Wasm frame. // // In a 0-origin context, column 0 is the first character of the line. // In a 1-origin context, column 1 is the first character of the line, @@ -23,6 +17,15 @@ // ^ ^ // 0-origin: 0 15 // 1-origin: 1 16 +// +// The column 0 in 1-origin is an invalid sentinel value used in some places, +// such as differential testing (bug 1848467). +// +// These classes help figuring out which origin and tag the column number +// uses, and also help converting between them. +// +// Eventually all SpiderMonkey API and internal use should switch to 1-origin +// (bug 1144340). #ifndef js_ColumnNumber_h #define js_ColumnNumber_h @@ -48,6 +51,7 @@ struct WasmFunctionIndex { // information can be used to synthesize a proper wasm frame. But when raw // column numbers are handed out, we just fix them to the first column to // avoid confusion. + static constexpr uint32_t DefaultBinarySourceColumnNumberZeroOrigin = 0; static constexpr uint32_t DefaultBinarySourceColumnNumberOneOrigin = 1; private: @@ -229,6 +233,12 @@ struct MaybeLimitedColumnNumber { return value_ >= rhs.value_; } + // Convert between origins. + uint32_t zeroOriginValue() const { + MOZ_ASSERT(valid()); + + return value_ - 1; + } uint32_t oneOriginValue() const { MOZ_ASSERT(valid()); @@ -402,6 +412,11 @@ struct TaggedColumnNumberOneOrigin { return WasmFunctionIndex(value_ & ~WasmFunctionTag); } + uint32_t zeroOriginValue() const { + return isWasmFunctionIndex() + ? WasmFunctionIndex::DefaultBinarySourceColumnNumberZeroOrigin + : toLimitedColumnNumber().zeroOriginValue(); + } uint32_t oneOriginValue() const { return isWasmFunctionIndex() ? WasmFunctionIndex::DefaultBinarySourceColumnNumberOneOrigin diff --git a/js/public/CompileOptions.h b/js/public/CompileOptions.h index 73a056e83426..26540faf0dfb 100644 --- a/js/public/CompileOptions.h +++ b/js/public/CompileOptions.h @@ -483,7 +483,7 @@ class JS_PUBLIC_API ReadOnlyCompileOptions : public TransitiveCompileOptions { this->TransitiveCompileOptions::dumpWith(print); # define PrintFields_(Name) print(#Name, Name) PrintFields_(lineno); - print("column", column.oneOriginValue()); + print("column", column.zeroOriginValue()); PrintFields_(scriptSourceOffset); PrintFields_(isRunOnce); PrintFields_(noScriptRval); diff --git a/js/src/builtin/ReflectParse.cpp b/js/src/builtin/ReflectParse.cpp index 5aed6953d834..8fbf762dd2d1 100644 --- a/js/src/builtin/ReflectParse.cpp +++ b/js/src/builtin/ReflectParse.cpp @@ -744,7 +744,7 @@ bool NodeBuilder::newNodeLoc(TokenPos* pos, MutableHandleValue dst) { if (!defineProperty(to, "line", val)) { return false; } - val.setNumber(startColumnIndex.oneOriginValue()); + val.setNumber(startColumnIndex.zeroOriginValue()); if (!defineProperty(to, "column", val)) { return false; } @@ -760,7 +760,7 @@ bool NodeBuilder::newNodeLoc(TokenPos* pos, MutableHandleValue dst) { if (!defineProperty(to, "line", val)) { return false; } - val.setNumber(endColumnIndex.oneOriginValue()); + val.setNumber(endColumnIndex.zeroOriginValue()); if (!defineProperty(to, "column", val)) { return false; } diff --git a/js/src/builtin/TestingUtility.cpp b/js/src/builtin/TestingUtility.cpp index c1b9769c1205..a54d58d231e4 100644 --- a/js/src/builtin/TestingUtility.cpp +++ b/js/src/builtin/TestingUtility.cpp @@ -86,10 +86,10 @@ bool js::ParseCompileOptions(JSContext* cx, JS::CompileOptions& options, if (!JS::ToInt32(cx, v, &c)) { return false; } - if (c < 1) { - c = 1; + if (c < 0) { + c = 0; } - options.setColumn(JS::ColumnNumberOneOrigin(c)); + options.setColumn(JS::ColumnNumberOneOrigin::fromZeroOrigin(c)); } if (!JS_GetProperty(cx, opts, "sourceIsLazy", &v)) { diff --git a/js/src/debugger/Object.cpp b/js/src/debugger/Object.cpp index 169eafbc6e7d..2cb72597fdf2 100644 --- a/js/src/debugger/Object.cpp +++ b/js/src/debugger/Object.cpp @@ -1246,9 +1246,6 @@ bool DebuggerObject::CallData::createSource() { if (!ToUint32(cx, v, &startColumn)) { return false; } - if (startColumn == 0) { - startColumn = 1; - } if (!JS_GetProperty(cx, options, "sourceMapURL", &v)) { return false; @@ -1270,7 +1267,8 @@ bool DebuggerObject::CallData::createSource() { JS::CompileOptions compileOptions(cx); compileOptions.lineno = startLine; - compileOptions.column = JS::ColumnNumberOneOrigin(startColumn); + compileOptions.column = + JS::ColumnNumberOneOrigin::fromZeroOrigin(startColumn); if (!JS::StringHasLatin1Chars(url)) { JS_ReportErrorASCII(cx, "URL must be a narrow string"); diff --git a/js/src/debugger/Script.cpp b/js/src/debugger/Script.cpp index 410b809856bb..09b728d149c2 100644 --- a/js/src/debugger/Script.cpp +++ b/js/src/debugger/Script.cpp @@ -384,7 +384,7 @@ bool DebuggerScript::CallData::getStartColumn() { return JS::LimitedColumnNumberOneOrigin( JS::WasmFunctionIndex::DefaultBinarySourceColumnNumberOneOrigin); }); - args.rval().setNumber(column.oneOriginValue()); + args.rval().setNumber(column.zeroOriginValue()); return true; } @@ -691,7 +691,7 @@ class DebuggerScript::GetPossibleBreakpointsMatcher { return false; } - value = NumberValue(colno.oneOriginValue()); + value = NumberValue(colno.zeroOriginValue()); if (!DefineDataProperty(cx_, entry, cx_->names().columnNumber, value)) { return false; } @@ -727,7 +727,12 @@ class DebuggerScript::GetPossibleBreakpointsMatcher { } bool parseColumnValue(HandleValue value, JS::LimitedColumnNumberOneOrigin* result) { - return parseIntValueImpl(value, result->addressOfValueForTranscode()); + uint32_t tmp; + if (!parseIntValueImpl(value, &tmp)) { + return false; + } + *result = JS::LimitedColumnNumberOneOrigin::fromZeroOrigin(tmp); + return true; } bool parseSizeTValue(HandleValue value, size_t* result) { return parseIntValueImpl(value, result); @@ -937,7 +942,16 @@ class DebuggerScript::GetPossibleBreakpointsMatcher { for (uint32_t i = 0; i < offsets.length(); i++) { uint32_t lineno = offsets[i].lineno; - JS::LimitedColumnNumberOneOrigin column(offsets[i].column); + // FIXME: wasm::ExprLoc::column contains "1". which is "1 in 1-origin", + // but currently the debugger API returns 0-origin column number, + // and the value becomes "0 in 0-origin". + // the existing wasm debug functionality expects the observable + // column number be "1", so it is "1 in 0-origin". + // Once the debugger API is rewritten to use 1-origin, this + // part also needs to be rewritten to directly pass the + // "1 in 1-origin" (bug 1863878). + JS::LimitedColumnNumberOneOrigin column = + JS::LimitedColumnNumberOneOrigin::fromZeroOrigin(offsets[i].column); size_t offset = offsets[i].offset; if (!maybeAppendEntry(offset, lineno, column, true)) { return false; @@ -1016,7 +1030,7 @@ class DebuggerScript::GetOffsetMetadataMatcher { return false; } - value = NumberValue(r.frontColumnNumber().oneOriginValue()); + value = NumberValue(r.frontColumnNumber().zeroOriginValue()); if (!DefineDataProperty(cx_, result_, cx_->names().columnNumber, value)) { return false; } @@ -1355,7 +1369,7 @@ class DebuggerScript::GetOffsetLocationMatcher { return false; } - value = NumberValue(column.oneOriginValue()); + value = NumberValue(column.zeroOriginValue()); if (!DefineDataProperty(cx_, result_, cx_->names().columnNumber, value)) { return false; } @@ -1823,7 +1837,7 @@ class DebuggerScript::GetAllColumnOffsetsMatcher { return false; } - value = NumberValue(column.oneOriginValue()); + value = NumberValue(column.zeroOriginValue()); if (!DefineDataProperty(cx_, entry, cx_->names().columnNumber, value)) { return false; } @@ -1892,7 +1906,9 @@ class DebuggerScript::GetAllColumnOffsetsMatcher { for (uint32_t i = 0; i < offsets.length(); i++) { uint32_t lineno = offsets[i].lineno; - JS::LimitedColumnNumberOneOrigin column(offsets[i].column); + // See the comment in GetPossibleBreakpointsMatcher::parseQuery. + JS::LimitedColumnNumberOneOrigin column = + JS::LimitedColumnNumberOneOrigin::fromZeroOrigin(offsets[i].column); size_t offset = offsets[i].offset; if (!appendColumnOffsetEntry(lineno, column, offset)) { return false; @@ -2413,7 +2429,8 @@ bool DebuggerScript::CallData::getOffsetsCoverage() { offsetValue.setNumber(double(offset)); lineNumberValue.setNumber(double(r.frontLineNumber())); - columnNumberValue.setNumber(double(r.frontColumnNumber().oneOriginValue())); + columnNumberValue.setNumber( + double(r.frontColumnNumber().zeroOriginValue())); countValue.setNumber(double(hits)); // Create a new object with the offset, line number, column number, the diff --git a/js/src/debugger/Source.cpp b/js/src/debugger/Source.cpp index 3136a4add1e5..4cbc4786f35a 100644 --- a/js/src/debugger/Source.cpp +++ b/js/src/debugger/Source.cpp @@ -363,7 +363,7 @@ class DebuggerSourceGetStartColumnMatcher { bool DebuggerSource::CallData::getStartColumn() { DebuggerSourceGetStartColumnMatcher matcher; JS::LimitedColumnNumberOneOrigin column = referent.match(matcher); - args.rval().setNumber(column.oneOriginValue()); + args.rval().setNumber(column.zeroOriginValue()); return true; } diff --git a/js/src/doc/Debugger/Debugger.Script.md b/js/src/doc/Debugger/Debugger.Script.md index 1c9665c4350d..1788e5230d1e 100644 --- a/js/src/doc/Debugger/Debugger.Script.md +++ b/js/src/doc/Debugger/Debugger.Script.md @@ -173,36 +173,37 @@ into the system; the entire string is not a valid URL. For **If the instance refers to WebAssembly code**, throw a `TypeError`. ### `startLine` -**If the instance refers to a `JSScript`**, the 1-origin number of the line at +**If the instance refers to a `JSScript`**, the number of the line at which this script's code starts, within the file or document named by `url`. ### `startColumn` -**If the instance refers to a `JSScript`**, the 1-origin column number at -which this script's code starts, within the file or document named by `url`. -For functions, this is the start of the function's arguments: +**If the instance refers to a `JSScript`**, the zero-indexed number of the +column at which this script's code starts, within the file or document +named by `url`. For functions, this is the start of the function's +arguments: ```js function f() { ... } -// ^ start (column 11) +// ^ start (column 10) let g = x => x*x; -// ^ start (column 9) +// ^ start (column 8) let h = (x) => x*x; -// ^ start (column 9) +// ^ start (column 8) ``` For default class constructors, it is the start of the `class` keyword: ```js let MyClass = class { }; -// ^ start (column 15) +// ^ start (column 14) ``` For scripts from other sources, such as `eval` or the `Function` constructor, it is typically 0: ```js let f = new Function(" console.log('hello world');"); -// ^ start (column 1, from the string's perspective) +// ^ start (column 0, from the string's perspective) ``` ### `lineCount` -**If the instance refers to a `JSScript`**, the 1-origin number of lines this +**If the instance refers to a `JSScript`**, the number of lines this script's code occupies, within the file or document named by `url`. ### `source` @@ -231,7 +232,7 @@ by `source`. **If the instance refers to WebAssembly code**, throw a `TypeError`. ### `mainOffset` -**If the instance refers to a `JSScript`**, the 0-origin offset of the main +**If the instance refers to a `JSScript`**, the offset of the main entry point of the script, excluding any prologue. **If the instance refers to WebAssembly code**, throw a `TypeError`. @@ -266,9 +267,9 @@ children can be reached by walking the tree. ### `getPossibleBreakpoints(query)` Query for the recommended breakpoint locations available in SpiderMonkey. Returns a result array of objects with the following properties: - * `offset: number` - The 0-origin offset the breakpoint. - * `lineNumber: number` - The 1-origin line number of the breakpoint. - * `columnNumber: number` - The 1-origin column number of the breakpoint. + * `offset: number` - The offset the breakpoint. + * `lineNumber: number` - The line number of the breakpoint. + * `columnNumber: number` - The column number of the breakpoint. * `isStepStart: boolean` - True if SpiderMonkey recommends that the breakpoint be treated as a step location when users of debuggers step to the next item. This _roughly_ translates to the start of @@ -277,13 +278,13 @@ Returns a result array of objects with the following properties: The `query` argument can be used to filter the set of breakpoints. The `query` object can contain the following properties: - * `minOffset: number` - The inclusive lower bound of `offset` values to include (0-origin). - * `maxOffset: number` - The exclusive upper bound of `offset` values to include (0-origin). - * `line: number` - Limit to breakpoints on the given line (1-origin). - * `minLine: number` - The inclusive lower bound of lines to include (1-origin). - * `minColumn: number` - The inclusive lower bound of the line/minLine column to include (1-origin). - * `maxLine: number` - The exclusive upper bound of lines to include (1-origin). - * `maxColumn: number` - The exclusive upper bound of the line/maxLine column to include (1-origin). + * `minOffset: number` - The inclusive lower bound of `offset` values to include. + * `maxOffset: number` - The exclusive upper bound of `offset` values to include. + * `line: number` - Limit to breakpoints on the given line. + * `minLine: number` - The inclusive lower bound of lines to include. + * `minColumn: number` - The inclusive lower bound of the line/minLine column to include. + * `maxLine: number` - The exclusive upper bound of lines to include. + * `maxColumn: number` - The exclusive upper bound of the line/maxLine column to include. ### `getPossibleBreakpointOffsets(query)` Query for the recommended breakpoint locations available in SpiderMonkey. @@ -291,10 +292,10 @@ Identical to getPossibleBreakpoints except this returns an array of `offset` values instead of offset metadata objects. ### `getOffsetMetadata(offset)` -Get metadata about a given bytecode offset (0-origin). +Get metadata about a given bytecode offset. Returns an object with the following properties: - * `lineNumber: number` - The 1-origin line number of the breakpoint. - * `columnNumber: number` - The 1-origin column number of the breakpoint. + * `lineNumber: number` - The line number of the breakpoint. + * `columnNumber: number` - The column number of the breakpoint. * `isBreakpoint: boolean` - True if this offset qualifies as a breakpoint, defined using the same semantics used for `getPossibleBreakpoints()`. * `isStepStart: boolean` - True if SpiderMonkey recommends that the @@ -304,8 +305,8 @@ Returns an object with the following properties: ### `setBreakpoint(offset, handler)` **If the instance refers to a `JSScript`**, set a breakpoint at the -bytecode instruction at offset (0-origin) in this script, reporting hits -to the `hit` method of handler. If offset is not a valid offset +bytecode instruction at offset in this script, reporting hits to +the `hit` method of handler. If offset is not a valid offset in this script, throw an error. Also, even if offset is valid offset in this script, some instructions for engine-internal operation (e.g. SetAliasedVar in the generator function initialization) don't allow setting @@ -336,7 +337,7 @@ global's scripts. ### `getBreakpoints([offset])` **If the instance refers to a `JSScript`**, return an array containing the -handler objects for all the breakpoints set at offset (0-origin) in this +handler objects for all the breakpoints set at offset in this script. If offset is omitted, return the handlers of all breakpoints set anywhere in this script. If offset is present, but not a valid offset in this script, throw an error. @@ -346,24 +347,24 @@ not a valid offset in this script, throw an error. ### `clearBreakpoint(handler, [offset])` **If the instance refers to a `JSScript`**, remove all breakpoints set in this [`Debugger`][debugger-object] instance that use handler as -their handler. If offset (0-origin) is given, remove only those -breakpoints set at offset that use handler; if offset is -not a valid offset in this script, throw an error. +their handler. If offset is given, remove only those breakpoints +set at offset that use handler; if offset is not a +valid offset in this script, throw an error. Note that, if breakpoints using other handler objects are set at the same location(s) as handler, they remain in place. ### `clearAllBreakpoints([offset])` **If the instance refers to a `JSScript`**, remove all breakpoints set in -this script. If offset (0-origin) is present, remove all breakpoints set -at that offset in this script; if offset is not a valid bytecode +this script. If offset is present, remove all breakpoints set at +that offset in this script; if offset is not a valid bytecode offset in this script, throw an error. ### `getEffectfulOffsets()` **If the instance refers to a `JSScript`**, return an array -containing the 0-origin offsets of all bytecodes in the script which can have -direct side effects that are visible outside the currently executing frame. -This includes, for example, operations that set properties or elements on +containing the offsets of all bytecodes in the script which can have direct +side effects that are visible outside the currently executing frame. This +includes, for example, operations that set properties or elements on objects, or that may set names in environments created outside the frame. This doesn't include some instructions for engine-internal operation (e.g. @@ -377,11 +378,11 @@ contains information about the coverage of all opcodes. The elements of the array are objects, each of which describes a single opcode, and contains the following properties: - * `lineNumber`: the 1-origin line number of the current opcode. + * `lineNumber`: the line number of the current opcode. - * `columnNumber`: the 1-origin column number of the current opcode. + * `columnNumber`: the column number of the current opcode. - * `offset`: the 0-origin bytecode instruction offset of the current opcode. + * `offset`: the bytecode instruction offset of the current opcode. * `count`: the number of times the current opcode got executed. @@ -392,8 +393,8 @@ the flag `Debugger.collectCoverageInfo` should be set to `true`. **If the instance refers to WebAssembly code**, throw a `TypeError`. ### `isInCatchScope([offset])` -**If the instance refers to a `JSScript`**, this is `true` if this 0-origin -offset falls within the scope of a try block, and `false` otherwise. +**If the instance refers to a `JSScript`**, this is `true` if this offset +falls within the scope of a try block, and `false` otherwise. **If the instance refers to WebAssembly code**, throw a `TypeError`. @@ -406,7 +407,7 @@ in their results. #### `getAllOffsets()` **If the instance refers to a `JSScript`**, return an array L -describing the relationship between bytecode instruction offsets (0-origin) and +describing the relationship between bytecode instruction offsets and source code positions in this script. L is sparse, and indexed by source line number. If a source line number line has no code, then L has no line property. If there is code for line, @@ -425,20 +426,20 @@ for (i=1; i < 10; i++) Calling `getAllOffsets()` on that code might yield an array like this: ```js -[, [0], [16, 75], , [52]] +[[0], [5, 20], , [10]] ``` This array indicates that: * the first line's code starts at offset 0 in the script; -* the `for` statement head has two entry points at offsets 16 and 75 (for +* the `for` statement head has two entry points at offsets 5 and 20 (for the initialization, which is performed only once, and the loop test, which is performed at the start of each iteration); * the third line has no code; -* and the fourth line begins at offset 52. +* and the fourth line begins at offset 10. **If the instance refers to WebAssembly code**, throw a `TypeError`. @@ -452,11 +453,11 @@ all offsets that are entry points for each (line, column) pair. The elements of the array are objects, each of which describes a single entry point, and contains the following properties: -* lineNumber: the 1-origin line number for which offset is an entry point +* lineNumber: the line number for which offset is an entry point -* columnNumber: the 1-origin column number for which offset is an entry point +* columnNumber: the column number for which offset is an entry point -* offset: the 0-origin bytecode instruction offset of the entry point +* offset: the bytecode instruction offset of the entry point For example, suppose we have a script for the following source code: @@ -470,12 +471,10 @@ for (i=1; i < 10; i++) Calling `getAllColumnOffsets()` on that code might yield an array like this: ```js -[{ lineNumber: 1, columnNumber: 1, offset: 0 }, - { lineNumber: 2, columnNumber: 6, offset: 16 }, - { lineNumber: 2, columnNumber: 11, offset: 28 }, - { lineNumber: 4, columnNumber: 5, offset: 52 }, - { lineNumber: 4, columnNumber: 14, offset: 67 }, - { lineNumber: 2, columnNumber: 19, offset: 75 }] +[{ lineNumber: 0, columnNumber: 0, offset: 0 }, + { lineNumber: 1, columnNumber: 5, offset: 5 }, + { lineNumber: 1, columnNumber: 10, offset: 20 }, + { lineNumber: 3, columnNumber: 4, offset: 10 }] ``` **If the instance refers to WebAssembly code**, throw a `TypeError`. @@ -483,17 +482,17 @@ Calling `getAllColumnOffsets()` on that code might yield an array like this: #### `getLineOffsets(line)` **If the instance refers to a `JSScript`**, return an array of bytecode instruction offsets representing the entry points to source line -line (1-origin). If the script contains no executable code at that line, -the array returned is empty. +line. If the script contains no executable code at that line, the +array returned is empty. #### `getOffsetLocation(offset)` **If the instance refers to a `JSScript`**, return an object describing the source code location responsible for the bytecode at offset in this script. The object has the following properties: -* `lineNumber`: the 1-origin line number for which offset is an entry point +* `lineNumber`: the line number for which offset is an entry point -* `columnNumber`: the 1-origin column number for which offset is an entry point +* `columnNumber`: the column number for which offset is an entry point * `isEntryPoint`: true if the offset is a column entry point, as would be reported by getAllColumnOffsets(); otherwise false. diff --git a/js/src/doc/Debugger/Debugger.Source.md b/js/src/doc/Debugger/Debugger.Source.md index 722446eec9f5..6561cdb23b71 100644 --- a/js/src/doc/Debugger/Debugger.Source.md +++ b/js/src/doc/Debugger/Debugger.Source.md @@ -111,9 +111,9 @@ source within the file or URL it was loaded from. This is normally `1`, but may have another value if the source is part of an HTML document. ### `startColumn` -**If the instance refers to JavaScript source**, the 1-origin start column in +**If the instance refers to JavaScript source**, the 0-origin start column in UTF-16 code units of the source within the file or URL it was loaded from. This -is normally `1`, but may have another value if the source is part of an HTML +is normally `0`, but may have another value if the source is part of an HTML document. ### `id` diff --git a/js/src/doc/Debugger/Debugger.md b/js/src/doc/Debugger/Debugger.md index 58bbd49634ad..e720eda259a9 100644 --- a/js/src/doc/Debugger/Debugger.md +++ b/js/src/doc/Debugger/Debugger.md @@ -398,6 +398,12 @@ instances for all debuggee scripts. The script must at least partially cover the given source line. If this property is present, the `url` property must be present as well. +* `column` + + The script must include given column on the line given by the `line`property. + If this property is present, the `url` and `line` properties must both be + present as well. + * `innermost` If this property is present and true, the script must be the innermost diff --git a/js/src/frontend/Stencil.cpp b/js/src/frontend/Stencil.cpp index 6f281b0982af..498487158e2f 100644 --- a/js/src/frontend/Stencil.cpp +++ b/js/src/frontend/Stencil.cpp @@ -4428,7 +4428,7 @@ void ScriptStencilExtra::dumpFields(js::JSONPrinter& json) const { json.property("toStringStart", extent.toStringStart); json.property("toStringEnd", extent.toStringEnd); json.property("lineno", extent.lineno); - json.property("column", extent.column.oneOriginValue()); + json.property("column", extent.column.zeroOriginValue()); json.endObject(); json.property("memberInitializers", memberInitializers_); @@ -4591,7 +4591,7 @@ static void DumpInputScriptFields(js::JSONPrinter& json, json.property("toStringStart", extent.toStringStart); json.property("toStringEnd", extent.toStringEnd); json.property("lineno", extent.lineno); - json.property("column", extent.column.oneOriginValue()); + json.property("column", extent.column.zeroOriginValue()); } json.endObject(); diff --git a/js/src/jit-test/lib/assert-offset-columns.js b/js/src/jit-test/lib/assert-offset-columns.js index f4d256090fee..6fb75ac74c29 100644 --- a/js/src/jit-test/lib/assert-offset-columns.js +++ b/js/src/jit-test/lib/assert-offset-columns.js @@ -41,7 +41,7 @@ function assertOffsetColumns(code, expectedBpts, expectedOrdering = null) { const { script } = debuggeeFn; for (const offset of script.getAllColumnOffsets()) { assertEq(offset.lineNumber, 1); - assertEq(offset.columnNumber <= execCode.length, true); + assertEq(offset.columnNumber < execCode.length, true); bpts.add(offset.columnNumber); script.setBreakpoint(offset.offset, { @@ -53,7 +53,7 @@ function assertOffsetColumns(code, expectedBpts, expectedOrdering = null) { global.f(3); const actualBpts = Array.from(execCode, (_, i) => { - return bpts.has(i + 1) ? "^" : " "; + return bpts.has(i) ? "^" : " "; }).join(""); if (actualBpts.trimEnd() !== expectedBpts.trimEnd()) { diff --git a/js/src/jit-test/tests/basic/getBacktrace-invalid.js b/js/src/jit-test/tests/basic/getBacktrace-invalid.js index 2a3f44989533..5b136e7da7d8 100644 --- a/js/src/jit-test/tests/basic/getBacktrace-invalid.js +++ b/js/src/jit-test/tests/basic/getBacktrace-invalid.js @@ -2,4 +2,4 @@ const backtrace = evaluate(` this.getBacktrace(this); `, { fileName: "\u86D9" }); -assertEq(backtrace.includes(`["\u86D9":2:6]`), true); +assertEq(backtrace.includes(`["\u86D9":2:5]`), true); diff --git a/js/src/jit-test/tests/class/default-constructor-position.js b/js/src/jit-test/tests/class/default-constructor-position.js index 02b6efefd084..abe2eeb7ab83 100644 --- a/js/src/jit-test/tests/class/default-constructor-position.js +++ b/js/src/jit-test/tests/class/default-constructor-position.js @@ -55,7 +55,7 @@ for (text of source.split("\n")) { // Check lineno/column. assertEq(getStartLine(className), lineno); - assertEq(getStartColumn(className), column + 1); + assertEq(getStartColumn(className), column); // Check sourceStart/sourceEnd. offset = source.indexOf("class " + className) diff --git a/js/src/jit-test/tests/debug/Frame-onPop-source-location.js b/js/src/jit-test/tests/debug/Frame-onPop-source-location.js index fef9df7770c7..b0a01436d334 100644 --- a/js/src/jit-test/tests/debug/Frame-onPop-source-location.js +++ b/js/src/jit-test/tests/debug/Frame-onPop-source-location.js @@ -55,4 +55,4 @@ C(); D(); new E(); `); -assertEq(g.log.join(","), "A,pop(8:1),B,pop(14:1),C,pop(20:1),D,pop(26:1),E,pop(27:17),pop(34:5)"); +assertEq(g.log.join(","), "A,pop(8:0),B,pop(14:0),C,pop(20:0),D,pop(26:0),E,pop(27:16),pop(34:4)"); diff --git a/js/src/jit-test/tests/debug/Object-createSource.js b/js/src/jit-test/tests/debug/Object-createSource.js index 53f1c28c1be3..c137202a0202 100644 --- a/js/src/jit-test/tests/debug/Object-createSource.js +++ b/js/src/jit-test/tests/debug/Object-createSource.js @@ -8,13 +8,13 @@ let source = gdbg.createSource({ text: "x = 3", url: "foo.js", startLine: 3, - startColumn: 43, + startColumn: 42, sourceMapURL: "sourceMapURL", isScriptElement: true, }); assertEq(source.text, "x = 3"); assertEq(source.url, "foo.js"); assertEq(source.startLine, 3); -assertEq(source.startColumn, 43); +assertEq(source.startColumn, 42); assertEq(source.sourceMapURL, "sourceMapURL"); assertEq(source.introductionType, "inlineScript"); diff --git a/js/src/jit-test/tests/debug/Script-getPossibleBreakpoints-02.js b/js/src/jit-test/tests/debug/Script-getPossibleBreakpoints-02.js index ed267437109c..56ea6620d3a0 100644 --- a/js/src/jit-test/tests/debug/Script-getPossibleBreakpoints-02.js +++ b/js/src/jit-test/tests/debug/Script-getPossibleBreakpoints-02.js @@ -29,31 +29,31 @@ function onDebuggerStatement(frame) { assertBPCount({ line: 9 }, 1); assertBPCount({ line: 10 }, 1); - assertBPCount({ line: 6, minColumn: 8 }, 3); - assertBPCount({ line: 6, maxColumn: 17 }, 3); - assertBPCount({ line: 6, minColumn: 8, maxColumn: 17 }, 2); + assertBPCount({ line: 6, minColumn: 7 }, 3); + assertBPCount({ line: 6, maxColumn: 16 }, 3); + assertBPCount({ line: 6, minColumn: 7, maxColumn: 16 }, 2); assertBPError({ line: 1, minLine: 1 }, "line", "not allowed alongside 'minLine'/'maxLine'"); assertBPError({ line: 1, maxLine: 1 }, "line", "not allowed alongside 'minLine'/'maxLine'"); assertBPError({ line: "1" }, "line", "not an integer"); assertBPCount({ minLine: 9 }, 2); - assertBPCount({ minLine: 9, minColumn: 1 }, 2); - assertBPCount({ minLine: 9, minColumn: 9 }, 1); + assertBPCount({ minLine: 9, minColumn: 0 }, 2); + assertBPCount({ minLine: 9, minColumn: 8 }, 1); assertBPError({ minLine: "1" }, "minLine", "not an integer"); - assertBPError({ minColumn: 2 }, "minColumn", "not allowed without 'line' or 'minLine'"); - assertBPError({ minLine: 1, minColumn: "2" }, "minColumn", "not an integer"); + assertBPError({ minColumn: 1 }, "minColumn", "not allowed without 'line' or 'minLine'"); + assertBPError({ minLine: 1, minColumn: "1" }, "minColumn", "not an integer"); assertBPCount({ maxLine: 7 }, 5); - assertBPCount({ maxLine: 7, maxColumn: 1 }, 5); - assertBPCount({ maxLine: 7, maxColumn: 9 }, 6); + assertBPCount({ maxLine: 7, maxColumn: 0 }, 5); + assertBPCount({ maxLine: 7, maxColumn: 8 }, 6); assertBPError({ maxLine: "1" }, "maxLine", "not an integer"); - assertBPError({ maxColumn: 2 }, "maxColumn", "not allowed without 'line' or 'maxLine'"); - assertBPError({ maxLine: 1, maxColumn: "2" }, "maxColumn", "not an integer"); + assertBPError({ maxColumn: 1 }, "maxColumn", "not allowed without 'line' or 'maxLine'"); + assertBPError({ maxLine: 1, maxColumn: "1" }, "maxColumn", "not an integer"); assertBPCount({ minLine: 6, maxLine: 8 }, 6); - assertBPCount({ minLine: 6, minColumn: 9, maxLine: 8 }, 5); - assertBPCount({ minLine: 6, maxLine: 8, maxColumn: 9 }, 7); - assertBPCount({ minLine: 6, minColumn: 9, maxLine: 8, maxColumn: 9 }, 6); + assertBPCount({ minLine: 6, minColumn: 8, maxLine: 8 }, 5); + assertBPCount({ minLine: 6, maxLine: 8, maxColumn: 8 }, 7); + assertBPCount({ minLine: 6, minColumn: 8, maxLine: 8, maxColumn: 8 }, 6); assertBPCount({ minOffset: fScript.getPossibleBreakpoints({ line: 6 })[3].offset, diff --git a/js/src/jit-test/tests/debug/Script-getPossibleBreakpoints.js b/js/src/jit-test/tests/debug/Script-getPossibleBreakpoints.js index 0277b651894d..5c52f52de33b 100644 --- a/js/src/jit-test/tests/debug/Script-getPossibleBreakpoints.js +++ b/js/src/jit-test/tests/debug/Script-getPossibleBreakpoints.js @@ -379,6 +379,6 @@ function createOffsetLookup(code) { if (!lineOffsets.hasOwnProperty(line)) { throw new Error("Unknown line " + line + " column " + column); } - return lineOffsets[line] + column - 1; + return lineOffsets[line] + column; }; } diff --git a/js/src/jit-test/tests/debug/Script-startColumn.js b/js/src/jit-test/tests/debug/Script-startColumn.js index d61e9d0d29ee..922f4019ada1 100644 --- a/js/src/jit-test/tests/debug/Script-startColumn.js +++ b/js/src/jit-test/tests/debug/Script-startColumn.js @@ -13,33 +13,33 @@ function test(f, expected) { g.eval(` function f1() { } `); -test(g.f1, 12); +test(g.f1, 11); g.eval(` var f2 = function({ a, b, c }, d, e, ...more) { }; `); -test(g.f2, 18); +test(g.f2, 17); g.eval(` var f3 = function *() { }; `); -test(g.f3, 20); +test(g.f3, 19); g.eval(` var f4 = async function () { }; `); -test(g.f4, 3); +test(g.f4, 2); g.eval(` var f5 = (a, b) => a + b; `); -test(g.f5, 10); +test(g.f5, 9); g.eval(` var f6 = a => a + 1; `); -test(g.f6, 10); +test(g.f6, 9); g.eval(` var MyClass = class { @@ -47,8 +47,8 @@ var MyClass = class { }; var myInstance = new MyClass(); `); -test(g.myInstance.method, 11); -test(g.myInstance.constructor, 15); +test(g.myInstance.method, 10); +test(g.myInstance.constructor, 14); const g2 = newGlobal({newCompartment: true, useWindowProxy: true}); const dbg2 = Debugger(g2); @@ -60,20 +60,20 @@ function f7() { } }); const f7w = g2Wrapped.makeDebuggeeValue(g2.f7); assertEq(f7w.callable, true); -assertEq(f7w.script.startColumn, 12); +assertEq(f7w.script.startColumn, 11); g.eval(` function f8() { return function f8Inner() { } } `); -test(g.f8, 12); -test(g.f8(), 28); +test(g.f8, 11); +test(g.f8(), 27); g.eval(` var f9 = new Function(\"\"); `); -test(g.f9, 1); +test(g.f9, 0); let hit = 0; let column; @@ -83,7 +83,7 @@ dbg.onDebuggerStatement = function (frame) { }; g.eval(` debugger;`); -assertEq(column, 1); +assertEq(column, 0); assertEq(hit, 1); const location = { fileName: "column.js", lineNumber: 1, columnNumber: 1 }; @@ -98,4 +98,4 @@ test(g.f10, 20); g.evaluate(` var f11 = function () { }; `, location); -test(g.f11, 20); +test(g.f11, 19); diff --git a/js/src/jit-test/tests/debug/Source-reparse.js b/js/src/jit-test/tests/debug/Source-reparse.js index 53700abe0530..e12244d48fec 100644 --- a/js/src/jit-test/tests/debug/Source-reparse.js +++ b/js/src/jit-test/tests/debug/Source-reparse.js @@ -23,11 +23,7 @@ function g() { } f(); -`, { - fileName: "foobar.js", - lineNumber: 3, - columnNumber: 42, -}); +`, { fileName: "foobar.js", lineNumber: 3, columnNumber: 42 }); let onNewScriptCalls = 0; dbg.onNewScript = script => { onNewScriptCalls++; }; diff --git a/js/src/jit-test/tests/debug/Source-startLine-startColumn.js b/js/src/jit-test/tests/debug/Source-startLine-startColumn.js index 50ca279424cf..2ce17203f3f3 100644 --- a/js/src/jit-test/tests/debug/Source-startLine-startColumn.js +++ b/js/src/jit-test/tests/debug/Source-startLine-startColumn.js @@ -6,7 +6,7 @@ var gw = dbg.addDebuggee(g); g.evaluate("function f(x) {}"); var fw = gw.getOwnPropertyDescriptor("f").value; assertEq(fw.script.source.startLine, 1); -assertEq(fw.script.source.startColumn, 1); +assertEq(fw.script.source.startColumn, 0); g.evaluate("function g(x) {}", { lineNumber: 10, columnNumber: 5 }); var gw = gw.getOwnPropertyDescriptor("g").value; assertEq(gw.script.source.startLine, 10); diff --git a/js/src/jit-test/tests/debug/onExceptionUnwind-16.js b/js/src/jit-test/tests/debug/onExceptionUnwind-16.js index ece3e02c1bbd..10a9086fdb6d 100644 --- a/js/src/jit-test/tests/debug/onExceptionUnwind-16.js +++ b/js/src/jit-test/tests/debug/onExceptionUnwind-16.js @@ -18,7 +18,7 @@ dbg.onExceptionUnwind = function (frame, exc) { assertEq(frame.older.type, "call"); const { lineNumber, columnNumber } = frame.script.getOffsetMetadata(frame.offset); assertEq(lineNumber, 3); - assertEq(columnNumber, 5); + assertEq(columnNumber, 4); const isInCatchScope = frame.script.isInCatchScope(frame.offset); assertEq(isInCatchScope, false); @@ -31,7 +31,7 @@ dbg.onExceptionUnwind = function (frame, exc) { assertEq(older.type, "call"); const { lineNumber, columnNumber } = older.script.getOffsetMetadata(older.offset); assertEq(lineNumber, 7); - assertEq(columnNumber, 5); + assertEq(columnNumber, 4); const isInCatchScope = older.script.isInCatchScope(older.offset); assertEq(isInCatchScope, false); diff --git a/js/src/jit-test/tests/debug/onExceptionUnwind-17.js b/js/src/jit-test/tests/debug/onExceptionUnwind-17.js index 5f2e9bf4fe92..5ced81758cfe 100644 --- a/js/src/jit-test/tests/debug/onExceptionUnwind-17.js +++ b/js/src/jit-test/tests/debug/onExceptionUnwind-17.js @@ -18,7 +18,7 @@ dbg.onExceptionUnwind = function (frame, exc) { assertEq(frame.older.type, "call"); const { lineNumber, columnNumber } = frame.script.getOffsetMetadata(frame.offset); assertEq(lineNumber, 3); - assertEq(columnNumber, 5); + assertEq(columnNumber, 4); const isInCatchScope = frame.script.isInCatchScope(frame.offset); assertEq(isInCatchScope, false); @@ -31,7 +31,7 @@ dbg.onExceptionUnwind = function (frame, exc) { assertEq(older.type, "call"); const { lineNumber, columnNumber } = older.script.getOffsetMetadata(older.offset); assertEq(lineNumber, 8); - assertEq(columnNumber, 7); + assertEq(columnNumber, 6); const isInCatchScope = older.script.isInCatchScope(older.offset); assertEq(isInCatchScope, true); diff --git a/js/src/jit-test/tests/debug/onExceptionUnwind-18.js b/js/src/jit-test/tests/debug/onExceptionUnwind-18.js index 5f402dd904da..3d6cbe5fda02 100644 --- a/js/src/jit-test/tests/debug/onExceptionUnwind-18.js +++ b/js/src/jit-test/tests/debug/onExceptionUnwind-18.js @@ -18,7 +18,7 @@ dbg.onExceptionUnwind = function (frame, exc) { assertEq(frame.older.type, "call"); const { lineNumber, columnNumber } = frame.script.getOffsetMetadata(frame.offset); assertEq(lineNumber, 3); - assertEq(columnNumber, 5); + assertEq(columnNumber, 4); const isInCatchScope = frame.script.isInCatchScope(frame.offset); assertEq(isInCatchScope, false); @@ -31,7 +31,7 @@ dbg.onExceptionUnwind = function (frame, exc) { assertEq(older.type, "call"); const { lineNumber, columnNumber } = older.script.getOffsetMetadata(older.offset); assertEq(lineNumber, 8); - assertEq(columnNumber, 7); + assertEq(columnNumber, 6); const isInCatchScope = older.script.isInCatchScope(older.offset); assertEq(isInCatchScope, true); diff --git a/js/src/jit-test/tests/fields/field-initializer-position.js b/js/src/jit-test/tests/fields/field-initializer-position.js index 7944642f28d8..f1c7f6f2d3ba 100644 --- a/js/src/jit-test/tests/fields/field-initializer-position.js +++ b/js/src/jit-test/tests/fields/field-initializer-position.js @@ -45,8 +45,8 @@ for (var i = 0; i < NumInitializers; ++i) { // Check the initializer lambda has expected line/column assertEq(script.startLine, START + 1 + i); - assertEq(script.startColumn, 21); + assertEq(script.startColumn, 20); // Check that source length matches expectations. - assertEq(script.startColumn + script.sourceLength + ';'.length, lineText.length + 1); + assertEq(script.startColumn + script.sourceLength + ';'.length, lineText.length); } diff --git a/js/src/jit-test/tests/modules/export-declaration.js b/js/src/jit-test/tests/modules/export-declaration.js index 52205427c3e2..12c394efad1d 100644 --- a/js/src/jit-test/tests/modules/export-declaration.js +++ b/js/src/jit-test/tests/modules/export-declaration.js @@ -460,9 +460,9 @@ var loc = parseAsModule("export { a as b } from 'c'", { }).body[0].loc; assertEq(loc.start.line, 1); -assertEq(loc.start.column, 1); +assertEq(loc.start.column, 0); assertEq(loc.start.line, 1); -assertEq(loc.end.column, 27); +assertEq(loc.end.column, 26); assertThrowsInstanceOf(function () { parseAsModule("function f() { export a }"); diff --git a/js/src/jit-test/tests/modules/import-declaration.js b/js/src/jit-test/tests/modules/import-declaration.js index b5def7828640..24c6032392b7 100644 --- a/js/src/jit-test/tests/modules/import-declaration.js +++ b/js/src/jit-test/tests/modules/import-declaration.js @@ -402,9 +402,9 @@ var loc = parseAsModule("import { a as b } from 'c'", { }).body[0].loc; assertEq(loc.start.line, 1); -assertEq(loc.start.column, 1); +assertEq(loc.start.column, 0); assertEq(loc.start.line, 1); -assertEq(loc.end.column, 27); +assertEq(loc.end.column, 26); assertThrowsInstanceOf(function () { parseAsModule("function f() { import a from 'b' }"); diff --git a/js/src/jit-test/tests/parser/bug-1161312.js b/js/src/jit-test/tests/parser/bug-1161312.js index ef7f7905c106..c6974716073c 100644 --- a/js/src/jit-test/tests/parser/bug-1161312.js +++ b/js/src/jit-test/tests/parser/bug-1161312.js @@ -1,3 +1,3 @@ // Test that lazy scripts can handle OOB column numbers. -assertEq(evaluate(`var f = x=>saveStack().column; f()`, { columnNumber: 1730 }), 1741); +assertEq(evaluate(`var f = x=>saveStack().column; f()`, { columnNumber: 1729 }), 1741); diff --git a/js/src/jit-test/tests/parser/bug-975484.js b/js/src/jit-test/tests/parser/bug-975484.js index dfbd0818d1f0..b164492240ff 100644 --- a/js/src/jit-test/tests/parser/bug-975484.js +++ b/js/src/jit-test/tests/parser/bug-975484.js @@ -1,7 +1,7 @@ var loc = Reflect.parse("f()").body[0].expression.loc; -assertEq(loc.start.column, 1); -assertEq(loc.end.column, 4); +assertEq(loc.start.column, 0); +assertEq(loc.end.column, 3); loc = Reflect.parse("f(x)").body[0].expression.loc; -assertEq(loc.start.column, 1); -assertEq(loc.end.column, 5); +assertEq(loc.start.column, 0); +assertEq(loc.end.column, 4); diff --git a/js/src/jit-test/tests/parser/columnNumber.js b/js/src/jit-test/tests/parser/columnNumber.js index 122309dc4b95..19f0736cad51 100644 --- a/js/src/jit-test/tests/parser/columnNumber.js +++ b/js/src/jit-test/tests/parser/columnNumber.js @@ -3,9 +3,9 @@ load(libdir + 'asserts.js'); assertEq(evaluate("saveStack().column"), 1); -assertEq(evaluate("saveStack().column", { columnNumber: 1729 }), 1729); +assertEq(evaluate("saveStack().column", { columnNumber: 1729 }), 1730); assertEq(evaluate("\nsaveStack().column", { columnNumber: 1729 }), 1); -assertEq(evaluate("saveStack().column", { columnNumber: "42" }), 42); +assertEq(evaluate("saveStack().column", { columnNumber: "42" }), 43); // columnNumber < 1 is fixed to 1. assertEq(evaluate("saveStack().column", { columnNumber: -10 }), 1); assertThrowsInstanceOf(() => evaluate("saveStack().column", { columnNumber: Math.pow(2,30) }), @@ -27,7 +27,7 @@ if (helperThreadCount() > 0) { print("offThreadCompileToStencil 3"); offThreadCompileToStencil("saveStack().column", { columnNumber: 10000 }); stencil = finishOffThreadStencil(); - assertEq(evalStencil(stencil), 10000); + assertEq(evalStencil(stencil), 10001); } // Check handling of columns near the limit of our ability to represent them. @@ -35,7 +35,7 @@ if (helperThreadCount() > 0) { // it's probably not worth it to be thorough.) const maxColumn = Math.pow(2, 30) - 2; assertEq(evaluate("saveStack().column", { columnNumber: maxColumn }), - maxColumn); + maxColumn + 1); // Check the saturation behavior when we reach the limit of the column // representation. diff --git a/js/src/jit-test/tests/parser/script-source-extent.js b/js/src/jit-test/tests/parser/script-source-extent.js index 01624ed1430b..db440621e903 100644 --- a/js/src/jit-test/tests/parser/script-source-extent.js +++ b/js/src/jit-test/tests/parser/script-source-extent.js @@ -38,7 +38,7 @@ function getScriptSourceExtent(source) { // to test multi-line sources, this will need to be updated. for (let script of scripts) { assertEq(script.startLine, 1); - assertEq(script.startColumn, script.sourceStart + 1); + assertEq(script.startColumn, script.sourceStart); } // Map each found script to a source extent string. @@ -334,4 +334,4 @@ testSourceExtent(` class C { static set #prop(v) { } }`, // Static Class Blocks testSourceExtent(` class C { static { 10; } }`, ` ^-------------^ `, - ` ^-------------------------`); + ` ^-------------------------`); \ No newline at end of file diff --git a/js/src/jit-test/tests/profiler/interpreter-stacks.js b/js/src/jit-test/tests/profiler/interpreter-stacks.js index 737a8fce181e..71ebb681a899 100644 --- a/js/src/jit-test/tests/profiler/interpreter-stacks.js +++ b/js/src/jit-test/tests/profiler/interpreter-stacks.js @@ -25,7 +25,7 @@ function testBasic() { // Test non-function frames. assertStack(evaluate("eval(`(function foo() { return readGeckoInterpProfilingStack(); })()`)"), - ["testBasic", "@evaluate", "@evaluate line 1 > eval:1:1", "foo"]); + ["testBasic", "@evaluate", "@evaluate line 1 > eval:1:0", "foo"]); } testBasic(); testBasic(); diff --git a/js/src/jit/BaselineBailouts.cpp b/js/src/jit/BaselineBailouts.cpp index 9ca8649f5d03..7d58a39dac7f 100644 --- a/js/src/jit/BaselineBailouts.cpp +++ b/js/src/jit/BaselineBailouts.cpp @@ -479,7 +479,7 @@ bool BaselineStackBuilder::initFrame() { JitSpew(JitSpew_BaselineBailouts, " Unpacking %s:%u:%u", script_->filename(), script_->lineno(), - script_->column().oneOriginValue()); + script_->column().zeroOriginValue()); JitSpew(JitSpew_BaselineBailouts, " [BASELINE-JS FRAME]"); // Write the previous frame pointer value. For the outermost frame we reuse @@ -1496,7 +1496,7 @@ bool BaselineStackBuilder::buildOneFrame() { " Resuming %s pc offset %d (op %s) (line %u) of %s:%u:%u", resumeAfter() ? "after" : "at", (int)pcOff, CodeName(op_), PCToLineNumber(script_, pc()), script_->filename(), script_->lineno(), - script_->column().oneOriginValue()); + script_->column().zeroOriginValue()); JitSpew(JitSpew_BaselineBailouts, " Bailout kind: %s", BailoutKindString(bailoutKind())); #endif @@ -1582,7 +1582,7 @@ bool jit::BailoutIonToBaseline(JSContext* cx, JitActivation* activation, JitSpew(JitSpew_BaselineBailouts, "Bailing to baseline %s:%u:%u (IonScript=%p) (FrameType=%d)", iter.script()->filename(), iter.script()->lineno(), - iter.script()->column().oneOriginValue(), (void*)iter.ionScript(), + iter.script()->column().zeroOriginValue(), (void*)iter.ionScript(), (int)prevFrameType); if (excInfo) { @@ -1628,7 +1628,7 @@ bool jit::BailoutIonToBaseline(JSContext* cx, JitActivation* activation, if (iter.maybeCallee()) { JitSpew(JitSpew_BaselineBailouts, " Callee function (%s:%u:%u)", iter.script()->filename(), iter.script()->lineno(), - iter.script()->column().oneOriginValue()); + iter.script()->column().zeroOriginValue()); } else { JitSpew(JitSpew_BaselineBailouts, " No callee!"); } @@ -1733,8 +1733,8 @@ static void HandleLexicalCheckFailure(JSContext* cx, HandleScript outerScript, JitSpew(JitSpew_IonBailouts, "Lexical check failure %s:%u:%u, inlined into %s:%u:%u", innerScript->filename(), innerScript->lineno(), - innerScript->column().oneOriginValue(), outerScript->filename(), - outerScript->lineno(), outerScript->column().oneOriginValue()); + innerScript->column().zeroOriginValue(), outerScript->filename(), + outerScript->lineno(), outerScript->column().zeroOriginValue()); if (!innerScript->failedLexicalCheck()) { innerScript->setFailedLexicalCheck(); @@ -1962,10 +1962,10 @@ bool jit::FinishBailoutToBaseline(BaselineBailoutInfo* bailoutInfoArg) { " Restored outerScript=(%s:%u:%u,%u) innerScript=(%s:%u:%u,%u) " "(bailoutKind=%u)", outerScript->filename(), outerScript->lineno(), - outerScript->column().oneOriginValue(), outerScript->getWarmUpCount(), - innerScript->filename(), innerScript->lineno(), - innerScript->column().oneOriginValue(), innerScript->getWarmUpCount(), - (unsigned)bailoutKind); + outerScript->column().zeroOriginValue(), + outerScript->getWarmUpCount(), innerScript->filename(), + innerScript->lineno(), innerScript->column().zeroOriginValue(), + innerScript->getWarmUpCount(), (unsigned)bailoutKind); BailoutAction action = BailoutAction::InvalidateImmediately; DebugOnly saveFailedICHash = false; diff --git a/js/src/jit/BaselineCacheIRCompiler.cpp b/js/src/jit/BaselineCacheIRCompiler.cpp index 6ee5ec8e17ae..efa092224321 100644 --- a/js/src/jit/BaselineCacheIRCompiler.cpp +++ b/js/src/jit/BaselineCacheIRCompiler.cpp @@ -2591,7 +2591,7 @@ ICAttachResult js::jit::AttachBaselineCacheIRStub( JitSpew(JitSpew_BaselineICFallback, "Tried attaching identical stub for (%s:%u:%u)", outerScript->filename(), outerScript->lineno(), - outerScript->column().oneOriginValue()); + outerScript->column().zeroOriginValue()); return ICAttachResult::DuplicateStub; } diff --git a/js/src/jit/BaselineCodeGen.cpp b/js/src/jit/BaselineCodeGen.cpp index 8f88102f2b1c..6bf3a569550c 100644 --- a/js/src/jit/BaselineCodeGen.cpp +++ b/js/src/jit/BaselineCodeGen.cpp @@ -201,11 +201,11 @@ MethodStatus BaselineCompiler::compile() { Rooted script(cx, handler.script()); JitSpew(JitSpew_BaselineScripts, "Baseline compiling script %s:%u:%u (%p)", script->filename(), script->lineno(), - script->column().oneOriginValue(), script.get()); + script->column().zeroOriginValue(), script.get()); JitSpew(JitSpew_Codegen, "# Emitting baseline code for script %s:%u:%u", script->filename(), script->lineno(), - script->column().oneOriginValue()); + script->column().zeroOriginValue()); AutoIncrementalTimer timer(cx->realm()->timers.baselineCompileTime); @@ -286,7 +286,7 @@ MethodStatus BaselineCompiler::compile() { JitSpew(JitSpew_BaselineScripts, "Created BaselineScript %p (raw %p) for %s:%u:%u", (void*)baselineScript.get(), (void*)code->raw(), script->filename(), - script->lineno(), script->column().oneOriginValue()); + script->lineno(), script->column().zeroOriginValue()); baselineScript->copyRetAddrEntries(handler.retAddrEntries().begin()); baselineScript->copyOSREntries(handler.osrEntries().begin()); @@ -312,7 +312,7 @@ MethodStatus BaselineCompiler::compile() { JitSpew(JitSpew_Profiling, "Added JitcodeGlobalEntry for baseline script %s:%u:%u (%p)", script->filename(), script->lineno(), - script->column().oneOriginValue(), baselineScript.get()); + script->column().zeroOriginValue(), baselineScript.get()); // Generate profiling string. UniqueChars str = GeckoProfilerRuntime::allocProfileString(cx, script); diff --git a/js/src/jit/BaselineDebugModeOSR.cpp b/js/src/jit/BaselineDebugModeOSR.cpp index 37b01fe93ab9..c25b8522d197 100644 --- a/js/src/jit/BaselineDebugModeOSR.cpp +++ b/js/src/jit/BaselineDebugModeOSR.cpp @@ -206,7 +206,7 @@ static void SpewPatchBaselineFrame(const uint8_t* oldReturnAddress, JitSpew(JitSpew_BaselineDebugModeOSR, "Patch return %p -> %p on BaselineJS frame (%s:%u:%u) from %s at %s", oldReturnAddress, newReturnAddress, script->filename(), - script->lineno(), script->column().oneOriginValue(), + script->lineno(), script->column().zeroOriginValue(), RetAddrEntryKindToString(frameKind), CodeName(JSOp(*pc))); } @@ -412,7 +412,7 @@ static bool RecompileBaselineScriptForDebugMode( JitSpew(JitSpew_BaselineDebugModeOSR, "Recompiling (%s:%u:%u) for %s", script->filename(), script->lineno(), - script->column().oneOriginValue(), + script->column().zeroOriginValue(), observing ? "DEBUGGING" : "NORMAL EXECUTION"); AutoKeepJitScripts keepJitScripts(cx); diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index 705dcb8e4627..67057838623e 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -158,9 +158,10 @@ void FallbackICSpew(JSContext* cx, ICFallbackStub* stub, const char* fmt, ...) { JitSpew( JitSpew_BaselineICFallback, "Fallback hit for (%s:%u:%u) (pc=%zu,line=%u,uses=%u,stubs=%zu): %s", - script->filename(), script->lineno(), script->column().oneOriginValue(), - script->pcToOffset(pc), PCToLineNumber(script, pc), - script->getWarmUpCount(), stub->numOptimizedStubs(), fmtbuf); + script->filename(), script->lineno(), + script->column().zeroOriginValue(), script->pcToOffset(pc), + PCToLineNumber(script, pc), script->getWarmUpCount(), + stub->numOptimizedStubs(), fmtbuf); } } #endif // JS_JITSPEW diff --git a/js/src/jit/BytecodeAnalysis.cpp b/js/src/jit/BytecodeAnalysis.cpp index a7ffdf39747c..4134c69dda56 100644 --- a/js/src/jit/BytecodeAnalysis.cpp +++ b/js/src/jit/BytecodeAnalysis.cpp @@ -321,7 +321,7 @@ bool BytecodeAnalysis::init(TempAllocator& alloc) { JitSpew_IonAbort, "Disabling Warp support for %s:%d:%d due to Yield being in a loop", script_->filename(), script_->lineno(), - script_->column().oneOriginValue()); + script_->column().zeroOriginValue()); script_->disableIon(); } } @@ -337,7 +337,7 @@ void BytecodeAnalysis::checkWarpSupport(JSOp op) { if (script_->canIonCompile()) { JitSpew(JitSpew_IonAbort, "Disabling Warp support for %s:%d:%d due to %s", script_->filename(), script_->lineno(), - script_->column().oneOriginValue(), CodeName(op)); + script_->column().zeroOriginValue(), CodeName(op)); script_->disableIon(); } break; diff --git a/js/src/jit/CacheIRHealth.cpp b/js/src/jit/CacheIRHealth.cpp index 5a5ac279b37d..6e37d8fac7a0 100644 --- a/js/src/jit/CacheIRHealth.cpp +++ b/js/src/jit/CacheIRHealth.cpp @@ -142,7 +142,8 @@ void CacheIRHealth::spewShapeInformation(AutoStructuredSpewer& spew, { spew->property("filename", baseScript->filename()); spew->property("line", baseScript->lineno()); - spew->property("column", baseScript->column().oneOriginValue()); + spew->property("column", + baseScript->column().zeroOriginValue()); } spew->endObject(); } @@ -273,7 +274,7 @@ bool CacheIRHealth::spewICEntryHealth(AutoStructuredSpewer& spew, JSContext* cx, // API call below. JS::LimitedColumnNumberOneOrigin column; spew->property("lineno", PCToLineNumber(script, pc, &column)); - spew->property("column", column.oneOriginValue()); + spew->property("column", column.zeroOriginValue()); ICStub* firstStub = entry->firstStub(); if (!firstStub->isFallback()) { @@ -306,7 +307,7 @@ void CacheIRHealth::spewScriptFinalWarmUpCount(JSContext* cx, spew->property("filename", filename); spew->property("line", script->lineno()); - spew->property("column", script->column().oneOriginValue()); + spew->property("column", script->column().zeroOriginValue()); spew->property("finalWarmUpCount", warmUpCount); } diff --git a/js/src/jit/CacheIRSpewer.cpp b/js/src/jit/CacheIRSpewer.cpp index 9165ebbb2165..39f75f8da2d3 100644 --- a/js/src/jit/CacheIRSpewer.cpp +++ b/js/src/jit/CacheIRSpewer.cpp @@ -343,7 +343,7 @@ void CacheIRSpewer::beginCache(const IRGenerator& gen) { if (jsbytecode* pc = gen.pc_) { JS::LimitedColumnNumberOneOrigin column; j.property("line", PCToLineNumber(gen.script_, pc, &column)); - j.property("column", column.oneOriginValue()); + j.property("column", column.zeroOriginValue()); j.formatProperty("pc", "%p", pc); } } diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index 6e85f8e99ea8..89d82e4154bd 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -7313,7 +7313,7 @@ bool CodeGenerator::generateBody() { JitSpew(JitSpew_Codegen, "--------------------------------"); JitSpew(JitSpew_Codegen, "# block%zu %s:%zu:%u%s:", i, filename ? filename : "?", lineNumber, - columnNumber.oneOriginValue(), + columnNumber.zeroOriginValue(), current->mir()->isLoopHeader() ? " (loop header)" : ""); #endif @@ -14118,7 +14118,7 @@ bool CodeGenerator::generate() { JitSpew(JitSpew_Codegen, "# Emitting code for script %s:%u:%u", gen->outerInfo().script()->filename(), gen->outerInfo().script()->lineno(), - gen->outerInfo().script()->column().oneOriginValue()); + gen->outerInfo().script()->column().zeroOriginValue()); // Initialize native code table with an entry to the start of // top-level script. diff --git a/js/src/jit/InterpreterEntryTrampoline.cpp b/js/src/jit/InterpreterEntryTrampoline.cpp index 6332e99fe5ec..216466e64259 100644 --- a/js/src/jit/InterpreterEntryTrampoline.cpp +++ b/js/src/jit/InterpreterEntryTrampoline.cpp @@ -242,7 +242,7 @@ JitCode* JitRuntime::generateEntryTrampolineForScript(JSContext* cx, JitSpew(JitSpew_Codegen, "# Emitting Interpreter Entry Trampoline for %s (%s:%u:%u)", funName ? funName.get() : "*", script->filename(), script->lineno(), - script->column().oneOriginValue()); + script->column().zeroOriginValue()); } TempAllocator temp(&cx->tempLifoAlloc()); diff --git a/js/src/jit/Ion.cpp b/js/src/jit/Ion.cpp index f766e3eb3202..ed673d98e54d 100644 --- a/js/src/jit/Ion.cpp +++ b/js/src/jit/Ion.cpp @@ -1676,7 +1676,7 @@ static AbortReason IonCompile(JSContext* cx, HandleScript script, "Can't log script %s:%u:%u" ". (Compiled on background thread.)", script->filename(), script->lineno(), - script->column().oneOriginValue()); + script->column().zeroOriginValue()); IonCompileTask* task = alloc->new_(cx, *mirGen, snapshot); if (!task) { @@ -1792,7 +1792,7 @@ static bool ScriptIsTooLarge(JSContext* cx, JSScript* script) { JitSpew(JitSpew_IonAbort, "Script too large (%zu bytes) (%zu locals/args) @ %s:%u:%u", script->length(), numLocalsAndArgs, script->filename(), - script->lineno(), script->column().oneOriginValue()); + script->lineno(), script->column().zeroOriginValue()); return true; } @@ -1838,7 +1838,7 @@ static MethodStatus Compile(JSContext* cx, HandleScript script, if (!CanIonCompileScript(cx, script)) { JitSpew(JitSpew_IonAbort, "Aborted compilation of %s:%u:%u", script->filename(), script->lineno(), - script->column().oneOriginValue()); + script->column().zeroOriginValue()); return Method_CantCompile; } @@ -2104,7 +2104,7 @@ static bool IonCompileScriptForBaseline(JSContext* cx, BaselineFrame* frame, "WarmUpCounter for %s:%u:%u reached %d at pc %p, trying to switch to " "Ion!", script->filename(), script->lineno(), - script->column().oneOriginValue(), (int)script->getWarmUpCount(), + script->column().zeroOriginValue(), (int)script->getWarmUpCount(), (void*)pc); MethodStatus stat; @@ -2299,7 +2299,7 @@ static void InvalidateActivation(JS::GCContext* gcx, JitSpew(JitSpew_IonInvalidate, "#%zu %s JS frame @ %p, %s:%u:%u (fun: %p, script: %p, pc %p)", frameno, type, frame.fp(), script->maybeForwardedFilename(), - script->lineno(), script->column().oneOriginValue(), + script->lineno(), script->column().zeroOriginValue(), frame.maybeCallee(), script, frame.resumePCinCurrentFrame()); break; } @@ -2474,7 +2474,7 @@ void jit::Invalidate(JSContext* cx, const RecompileInfoVector& invalid, JitSpew(JitSpew_IonInvalidate, " Invalidate %s:%u:%u, IonScript %p", info.script()->filename(), info.script()->lineno(), - info.script()->column().oneOriginValue(), ionScript); + info.script()->column().zeroOriginValue(), ionScript); // Keep the ion script alive during the invalidation and flag this // ionScript as being invalidated. This increment is removed by the @@ -2561,7 +2561,7 @@ void jit::Invalidate(JSContext* cx, JSScript* script, bool resetUses, // Construct the descriptive string. UniqueChars buf = JS_smprintf("%s:%u:%u", filename, script->lineno(), - script->column().oneOriginValue()); + script->column().zeroOriginValue()); // Ignore the event on allocation failure. if (buf) { @@ -2596,7 +2596,7 @@ void jit::FinishInvalidation(JS::GCContext* gcx, JSScript* script) { void jit::ForbidCompilation(JSContext* cx, JSScript* script) { JitSpew(JitSpew_IonAbort, "Disabling Ion compilation of script %s:%u:%u", script->filename(), script->lineno(), - script->column().oneOriginValue()); + script->column().zeroOriginValue()); CancelOffThreadIonCompile(script); diff --git a/js/src/jit/JitScript.cpp b/js/src/jit/JitScript.cpp index ec3eab94c23b..3e6787874be1 100644 --- a/js/src/jit/JitScript.cpp +++ b/js/src/jit/JitScript.cpp @@ -567,7 +567,7 @@ void jit::JitSpewBaselineICStats(JSScript* script, const char* dumpReason) { spew->property("op", CodeName(JSOp(*pc))); spew->property("pc", pcOffset); spew->property("line", line); - spew->property("column", column.oneOriginValue()); + spew->property("column", column.zeroOriginValue()); spew->beginListProperty("counts"); ICStub* stub = entry.firstStub(); diff --git a/js/src/jit/JitcodeMap.cpp b/js/src/jit/JitcodeMap.cpp index d1c0e4666252..8ca7a989c6b5 100644 --- a/js/src/jit/JitcodeMap.cpp +++ b/js/src/jit/JitcodeMap.cpp @@ -1007,7 +1007,7 @@ bool JitcodeIonTable::WriteIonTable(CompactBufferWriter& writer, JitSpew(JitSpew_Profiling, "Writing native to bytecode map for %s:%u:%u (%zu entries)", scriptList[0].script->filename(), scriptList[0].script->lineno(), - scriptList[0].script->column().oneOriginValue(), + scriptList[0].script->column().zeroOriginValue(), mozilla::PointerRangeSize(start, end)); JitSpew(JitSpew_Profiling, " ScriptList of size %u", @@ -1015,7 +1015,7 @@ bool JitcodeIonTable::WriteIonTable(CompactBufferWriter& writer, for (uint32_t i = 0; i < scriptList.length(); i++) { JitSpew(JitSpew_Profiling, " Script %u - %s:%u:%u", i, scriptList[i].script->filename(), scriptList[i].script->lineno(), - scriptList[i].script->column().oneOriginValue()); + scriptList[i].script->column().zeroOriginValue()); } // Write out runs first. Keep a vector tracking the positive offsets from diff --git a/js/src/jit/PerfSpewer.cpp b/js/src/jit/PerfSpewer.cpp index aa6eaf95306b..d6c1d550a049 100644 --- a/js/src/jit/PerfSpewer.cpp +++ b/js/src/jit/PerfSpewer.cpp @@ -158,7 +158,7 @@ static void WriteJitDumpDebugEntry(uint64_t addr, const char* filename, uint32_t lineno, JS::LimitedColumnNumberOneOrigin colno, AutoLockPerfSpewer& lock) { - JitDumpDebugEntry entry = {addr, lineno, colno.oneOriginValue()}; + JitDumpDebugEntry entry = {addr, lineno, colno.zeroOriginValue()}; WriteToJitDumpFile(&entry, sizeof(entry), lock); WriteToJitDumpFile(filename, strlen(filename) + 1, lock); } @@ -884,11 +884,11 @@ static UniqueChars GetFunctionDesc(const char* tierName, JSContext* cx, if (stubName) { return JS_smprintf("%s: %s : %s (%s:%u:%u)", tierName, stubName, funName ? funName.get() : "*", script->filename(), - script->lineno(), script->column().oneOriginValue()); + script->lineno(), script->column().zeroOriginValue()); } return JS_smprintf("%s: %s (%s:%u:%u)", tierName, funName ? funName.get() : "*", script->filename(), - script->lineno(), script->column().oneOriginValue()); + script->lineno(), script->column().zeroOriginValue()); } void PerfSpewer::saveDebugInfo(JSScript* script, JitCode* code, diff --git a/js/src/jit/TrialInlining.cpp b/js/src/jit/TrialInlining.cpp index 8bb5c7292b47..52a7238ad1a1 100644 --- a/js/src/jit/TrialInlining.cpp +++ b/js/src/jit/TrialInlining.cpp @@ -92,7 +92,7 @@ bool DoTrialInlining(JSContext* cx, BaselineFrame* frame) { "Trial inlining for %s script '%s' (%s:%u:%u (%p)) (inliningRoot=%p)", (isRecursive ? "inner" : "outer"), funName ? funName.get() : "", script->filename(), - script->lineno(), script->column().oneOriginValue(), frame->script(), + script->lineno(), script->column().zeroOriginValue(), frame->script(), root); JitSpewIndent spewIndent(JitSpew_WarpTrialInlining); } @@ -547,7 +547,7 @@ TrialInliningDecision TrialInliner::getInliningDecision(JSFunction* target, funName ? funName.get() : "", baseScript ? baseScript->filename() : "", baseScript ? baseScript->lineno() : 0, - baseScript ? baseScript->column().oneOriginValue() : 0); + baseScript ? baseScript->column().zeroOriginValue() : 0); JitSpewIndent spewIndent(JitSpew_WarpTrialInlining); } #endif diff --git a/js/src/jit/WarpOracle.cpp b/js/src/jit/WarpOracle.cpp index fbc99f7334cd..765bf9133655 100644 --- a/js/src/jit/WarpOracle.cpp +++ b/js/src/jit/WarpOracle.cpp @@ -144,7 +144,7 @@ AbortReasonOr WarpOracle::createSnapshot() { JitSpew(JitSpew_IonScripts, "Warp %s script %s:%u:%u (%p) (warmup-counter=%" PRIu32 ",%s%s)", mode, outerScript_->filename(), outerScript_->lineno(), - outerScript_->column().oneOriginValue(), + outerScript_->column().zeroOriginValue(), static_cast(outerScript_), outerScript_->getWarmUpCount(), outerScript_->isGenerator() ? " isGenerator" : "", outerScript_->isAsync() ? " isAsync" : ""); @@ -803,7 +803,7 @@ AbortReasonOr WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots, "fallback stub (entered-count: %" PRIu32 ") for JSOp::%s @ %s:%u:%u", fallbackStub->enteredCount(), CodeName(loc.getOp()), - script_->filename(), line, column.oneOriginValue()); + script_->filename(), line, column.zeroOriginValue()); // If the fallback stub was used but there's no optimized stub, use an IC. if (fallbackStub->enteredCount() != 0) { @@ -828,7 +828,7 @@ AbortReasonOr WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots, JitSpew(JitSpew_WarpTranspiler, "Failed to attach for JSOp::%s @ %s:%u:%u", CodeName(loc.getOp()), script_->filename(), line, - column.oneOriginValue()); + column.zeroOriginValue()); return Ok(); } @@ -866,7 +866,7 @@ AbortReasonOr WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots, JitSpew(JitSpew_WarpTranspiler, "multiple active stubs for JSOp::%s @ %s:%u:%u", CodeName(loc.getOp()), script_->filename(), line, - column.oneOriginValue()); + column.zeroOriginValue()); return Ok(); } @@ -893,7 +893,7 @@ AbortReasonOr WarpScriptOracle::maybeInlineIC(WarpOpSnapshotList& snapshots, JitSpew(JitSpew_WarpTranspiler, "unsupported CacheIR opcode %s for JSOp::%s @ %s:%u:%u", CacheIROpNames[size_t(op)], CodeName(loc.getOp()), - script_->filename(), line, column.oneOriginValue()); + script_->filename(), line, column.zeroOriginValue()); return Ok(); } diff --git a/js/src/jit/WarpSnapshot.cpp b/js/src/jit/WarpSnapshot.cpp index be0160526fd1..655af44a9721 100644 --- a/js/src/jit/WarpSnapshot.cpp +++ b/js/src/jit/WarpSnapshot.cpp @@ -78,7 +78,7 @@ void WarpScriptSnapshot::dump(GenericPrinter& out) const { out.printf("WarpScriptSnapshot (0x%p)\n", this); out.printf("------------------------------\n"); out.printf("Script: %s:%u:%u (0x%p)\n", script_->filename(), - script_->lineno(), script_->column().oneOriginValue(), + script_->lineno(), script_->column().zeroOriginValue(), static_cast(script_)); out.printf(" moduleObject: 0x%p\n", moduleObject()); out.printf(" isArrowFunction: %u\n", isArrowFunction()); diff --git a/js/src/jit/shared/CodeGenerator-shared.cpp b/js/src/jit/shared/CodeGenerator-shared.cpp index 84e60412a908..1752e1ab1372 100644 --- a/js/src/jit/shared/CodeGenerator-shared.cpp +++ b/js/src/jit/shared/CodeGenerator-shared.cpp @@ -311,7 +311,7 @@ void CodeGeneratorShared::dumpNativeToBytecodeEntries() { InlineScriptTree* topTree = gen->outerInfo().inlineScriptTree(); JitSpewStart(JitSpew_Profiling, "Native To Bytecode Entries for %s:%u:%u\n", topTree->script()->filename(), topTree->script()->lineno(), - topTree->script()->column().oneOriginValue()); + topTree->script()->column().zeroOriginValue()); for (unsigned i = 0; i < nativeToBytecodeList_.length(); i++) { dumpNativeToBytecodeEntry(i); } @@ -337,12 +337,12 @@ void CodeGeneratorShared::dumpNativeToBytecodeEntry(uint32_t idx) { JitSpew_Profiling, " %08zx [+%-6u] => %-6ld [%-4u] {%-10s} (%s:%u:%u", ref.nativeOffset.offset(), nativeDelta, (long)(ref.pc - script->code()), pcDelta, CodeName(JSOp(*ref.pc)), script->filename(), script->lineno(), - script->column().oneOriginValue()); + script->column().zeroOriginValue()); for (tree = tree->caller(); tree; tree = tree->caller()) { JitSpewCont(JitSpew_Profiling, " <= %s:%u:%u", tree->script()->filename(), tree->script()->lineno(), - tree->script()->column().oneOriginValue()); + tree->script()->column().zeroOriginValue()); } JitSpewCont(JitSpew_Profiling, ")"); JitSpewFin(JitSpew_Profiling); diff --git a/js/src/tests/non262/reflect-parse/computedPropNames.js b/js/src/tests/non262/reflect-parse/computedPropNames.js index c8cf8bc0f06d..d96e73152b5b 100644 --- a/js/src/tests/non262/reflect-parse/computedPropNames.js +++ b/js/src/tests/non262/reflect-parse/computedPropNames.js @@ -21,7 +21,7 @@ assertExpr('a= {[1]: 1, 2 : 2}', // Bug 924688: computed property names - location information var node = Reflect.parse("a = {[field1]: 5}"); Pattern({ body: [ { expression: { right: { properties: [ {key: { loc: - { start: { line: 1, column: 6 }, end: { line: 1, column: 14 }}}}]}}}]}).match(node); + { start: { line: 1, column: 5 }, end: { line: 1, column: 13 }}}}]}}}]}).match(node); // Bug 1048384 - Getter/setter syntax with computed names assertExpr("b = { get [meth]() { } }", aExpr("=", ident("b"), diff --git a/js/src/tests/non262/reflect-parse/location.js b/js/src/tests/non262/reflect-parse/location.js index 09d3870848c3..7e7a26a9e67c 100644 --- a/js/src/tests/non262/reflect-parse/location.js +++ b/js/src/tests/non262/reflect-parse/location.js @@ -6,22 +6,22 @@ var withoutFileOrLine = Reflect.parse("42"); var withFile = Reflect.parse("42", {source:"foo.js"}); var withFileAndLine = Reflect.parse("42", {source:"foo.js", line:111}); -Pattern({ source: null, start: { line: 1, column: 1 }, end: { line: 1, column: 3 } }).match(withoutFileOrLine.loc); -Pattern({ source: "foo.js", start: { line: 1, column: 1 }, end: { line: 1, column: 3 } }).match(withFile.loc); -Pattern({ source: "foo.js", start: { line: 111, column: 1 }, end: { line: 111, column: 3 } }).match(withFileAndLine.loc); +Pattern({ source: null, start: { line: 1, column: 0 }, end: { line: 1, column: 2 } }).match(withoutFileOrLine.loc); +Pattern({ source: "foo.js", start: { line: 1, column: 0 }, end: { line: 1, column: 2 } }).match(withFile.loc); +Pattern({ source: "foo.js", start: { line: 111, column: 0 }, end: { line: 111, column: 2 } }).match(withFileAndLine.loc); var withoutFileOrLine2 = Reflect.parse("foo +\nbar"); var withFile2 = Reflect.parse("foo +\nbar", {source:"foo.js"}); var withFileAndLine2 = Reflect.parse("foo +\nbar", {source:"foo.js", line:111}); -Pattern({ source: null, start: { line: 1, column: 1 }, end: { line: 2, column: 4 } }).match(withoutFileOrLine2.loc); -Pattern({ source: "foo.js", start: { line: 1, column: 1 }, end: { line: 2, column: 4 } }).match(withFile2.loc); -Pattern({ source: "foo.js", start: { line: 111, column: 1 }, end: { line: 112, column: 4 } }).match(withFileAndLine2.loc); +Pattern({ source: null, start: { line: 1, column: 0 }, end: { line: 2, column: 3 } }).match(withoutFileOrLine2.loc); +Pattern({ source: "foo.js", start: { line: 1, column: 0 }, end: { line: 2, column: 3 } }).match(withFile2.loc); +Pattern({ source: "foo.js", start: { line: 111, column: 0 }, end: { line: 112, column: 3 } }).match(withFileAndLine2.loc); var nested = Reflect.parse("(-b + sqrt(sqr(b) - 4 * a * c)) / (2 * a)", {source:"quad.js"}); var fourAC = nested.body[0].expression.left.right.arguments[0].right; -Pattern({ source: "quad.js", start: { line: 1, column: 21 }, end: { line: 1, column: 30 } }).match(fourAC.loc); +Pattern({ source: "quad.js", start: { line: 1, column: 20 }, end: { line: 1, column: 29 } }).match(fourAC.loc); // No source location diff --git a/js/src/tests/non262/reflect-parse/templateStrings.js b/js/src/tests/non262/reflect-parse/templateStrings.js index d6c424c2341c..fb12afd00f8e 100644 --- a/js/src/tests/non262/reflect-parse/templateStrings.js +++ b/js/src/tests/non262/reflect-parse/templateStrings.js @@ -26,13 +26,13 @@ assertExpr("func`hey${4}``${5}there``mine`", // multi-line template string - line numbers var node = Reflect.parse("`\n\n ${2}\n\n\n`"); -Pattern({loc:{start:{line:1, column:1}, end:{line:6, column:2}, source:null}, type:"Program", -body:[{loc:{start:{line:1, column:1}, end:{line:6, column:2}, source:null}, -type:"ExpressionStatement", expression:{loc:{start:{line:1, column:1}, end:{line:6, column:2}, -source:null}, type:"TemplateLiteral", elements:[{loc:{start:{line:1, column:1}, end:{line:3, -column:6}, source:null}, type:"Literal", value:"\n\n "}, {loc:{start:{line:3, column:6}, -end:{line:3, column:7}, source:null}, type:"Literal", value:2}, {loc:{start:{line:3, column:7}, -end:{line:6, column:2}, source:null}, type:"Literal", value:"\n\n\n"}]}}]}).match(node); +Pattern({loc:{start:{line:1, column:0}, end:{line:6, column:1}, source:null}, type:"Program", +body:[{loc:{start:{line:1, column:0}, end:{line:6, column:1}, source:null}, +type:"ExpressionStatement", expression:{loc:{start:{line:1, column:0}, end:{line:6, column:1}, +source:null}, type:"TemplateLiteral", elements:[{loc:{start:{line:1, column:0}, end:{line:3, +column:5}, source:null}, type:"Literal", value:"\n\n "}, {loc:{start:{line:3, column:5}, +end:{line:3, column:6}, source:null}, type:"Literal", value:2}, {loc:{start:{line:3, column:6}, +end:{line:6, column:1}, source:null}, type:"Literal", value:"\n\n\n"}]}}]}).match(node); assertStringExpr("\"hey there\"", literal("hey there")); diff --git a/js/src/tests/non262/syntax/column-numbers-in-long-lines.js b/js/src/tests/non262/syntax/column-numbers-in-long-lines.js index cba09792205c..56ce74f86b56 100644 --- a/js/src/tests/non262/syntax/column-numbers-in-long-lines.js +++ b/js/src/tests/non262/syntax/column-numbers-in-long-lines.js @@ -84,8 +84,8 @@ const columnsAreCodePoints = (function() assertEq(script.type, "Program"); assertEq(script.loc.start.line, 1); assertEq(script.loc.end.line, 1); - assertEq(script.loc.start.column, 1); - checkColumn(script.loc.end.column, 8, 12); + assertEq(script.loc.start.column, 0); + checkColumn(script.loc.end.column, 7, 11); var body = script.body; assertEq(body.length, 1); @@ -94,16 +94,16 @@ const columnsAreCodePoints = (function() assertEq(stmt.type, "ExpressionStatement"); assertEq(stmt.loc.start.line, 1); assertEq(stmt.loc.end.line, 1); - assertEq(stmt.loc.start.column, 1); - checkColumn(stmt.loc.end.column, 8, 12); + assertEq(stmt.loc.start.column, 0); + checkColumn(stmt.loc.end.column, 7, 11); var expr = stmt.expression; assertEq(expr.type, "Literal"); assertEq(expr.value, "😱😱😱😱"); assertEq(expr.loc.start.line, 1); assertEq(expr.loc.end.line, 1); - assertEq(expr.loc.start.column, 1); - checkColumn(expr.loc.end.column, 7, 11); + assertEq(expr.loc.start.column, 0); + checkColumn(expr.loc.end.column, 6, 10); var checkResult = columnTypes.join(","); @@ -126,47 +126,47 @@ function testSimple() // index of the array within the outer array. let simpleCodeArray = [ - 'var Q = [[', // column 1, offset 0 + 'var Q = [[', // column 0, offset 0 // REPEAT - '"😱😱(x"],["', // column 11, offset 10 - '😱😱)x"],["😱', // column 21, offset 22 - '😱*x"],["😱😱', // column 31, offset 35 - '+x"],["😱😱,', // column 41, offset 48 - 'x"],["😱😱-x', // column 51, offset 60 - '"],["😱😱.x"', // column 61, offset 72 - '],["😱😱/x"]', // column 71, offset 84 - ',["😱😱0x"],', // column 81, offset 96 - '["😱😱1x"],[', // column 91, offset 108 + '"😱😱(x"],["', // column 10, offset 10 + '😱😱)x"],["😱', // column 20, offset 22 + '😱*x"],["😱😱', // column 30, offset 35 + '+x"],["😱😱,', // column 40, offset 48 + 'x"],["😱😱-x', // column 50, offset 60 + '"],["😱😱.x"', // column 60, offset 72 + '],["😱😱/x"]', // column 70, offset 84 + ',["😱😱0x"],', // column 80, offset 96 + '["😱😱1x"],[', // column 90, offset 108 // REPEAT - '"😱😱2x"],["', // column 101, offset 120 -- chunk limit between "] - '😱😱3x"],["😱', // column 111, offset 132 - '😱4x"],["😱😱', // column 121, offset 145 - '5x"],["😱😱6', // column 131, offset 158 - 'x"],["😱😱7x', // column 141, offset 170 - '"],["😱😱8x"', // column 151, offset 182 - '],["😱😱9x"]', // column 161, offset 194 - ',["😱😱:x"],', // column 171, offset 206 - '["😱😱;x"],[', // column 181, offset 218 + '"😱😱2x"],["', // column 100, offset 120 -- chunk limit between "] + '😱😱3x"],["😱', // column 110, offset 132 + '😱4x"],["😱😱', // column 120, offset 145 + '5x"],["😱😱6', // column 130, offset 158 + 'x"],["😱😱7x', // column 140, offset 170 + '"],["😱😱8x"', // column 150, offset 182 + '],["😱😱9x"]', // column 160, offset 194 + ',["😱😱:x"],', // column 170, offset 206 + '["😱😱;x"],[', // column 180, offset 218 // REPEAT - '"😱😱x"],["😱😱', // column 211, offset 255 -- chunk limit splits first 😱 - '?x"],["😱😱@', // column 221, offset 268 - 'x"],["😱😱Ax', // column 231, offset 280 - '"],["😱😱Bx"', // column 241, offset 292 - '],["😱😱Cx"]', // column 251, offset 304 - ',["😱😱Dx"],', // column 261, offset 316 - '["😱😱Ex"],[', // column 271, offset 328 + '"😱😱x"],["😱😱', // column 210, offset 255 -- chunk limit splits first 😱 + '?x"],["😱😱@', // column 220, offset 268 + 'x"],["😱😱Ax', // column 230, offset 280 + '"],["😱😱Bx"', // column 240, offset 292 + '],["😱😱Cx"]', // column 250, offset 304 + ',["😱😱Dx"],', // column 260, offset 316 + '["😱😱Ex"],[', // column 270, offset 328 // REPEAT - '"😱😱Fx"],["', // column 281, offset 340 - '😱😱Gx"],["😱', // column 291, offset 352 - '😱Hx"],["😱😱', // column 301, offset 365 - 'Ix"],["😱😱J', // column 311, offset 378 -- chunk limit between [" - 'x"],["😱😱Kx', // column 321, offset 390 - '"],["😱😱Lx"', // column 331, offset 402 - '],["😱😱Mx"]', // column 341, offset 414 - ',["😱😱Nx"],', // column 351, offset 426 - '["😱😱Ox"]];', // column 361 (10 long), offset 438 (+12 to end) + '"😱😱Fx"],["', // column 280, offset 340 + '😱😱Gx"],["😱', // column 290, offset 352 + '😱Hx"],["😱😱', // column 300, offset 365 + 'Ix"],["😱😱J', // column 310, offset 378 -- chunk limit between [" + 'x"],["😱😱Kx', // column 320, offset 390 + '"],["😱😱Lx"', // column 330, offset 402 + '],["😱😱Mx"]', // column 340, offset 414 + ',["😱😱Nx"],', // column 350, offset 426 + '["😱😱Ox"]];', // column 360 (10 long), offset 438 (+12 to end) ]; let simpleCode = simpleCodeArray.join(""); @@ -290,19 +290,19 @@ function testGuaranteedSingleUnit() // End one array *outside* the first chunk to test a computation inside a // first chunk *after* we know we have a long line and have computed a first // chunk. - let mixedChunksCode = "var Z = [ [ [],"; // column 1, offset 0 + let mixedChunksCode = "var Z = [ [ [],"; // column 0, offset 0 assertEq(mixedChunksCode.length, 15); assertEq(lengthInCodePoints(mixedChunksCode), 15); mixedChunksCode += - " ".repeat(128 - mixedChunksCode.length); // column 16, offset 15 + " ".repeat(128 - mixedChunksCode.length); // column 15, offset 15 assertEq(mixedChunksCode.length, 128); assertEq(lengthInCodePoints(mixedChunksCode), 128); // Fill out a second chunk as also single-unit, with an outer array literal // that begins in this chunk but finishes in the next (to test column // computation in a prior, guaranteed-single-unit chunk). - mixedChunksCode += "[" + "[],".repeat(42) + " "; // column 129, offset 128 + mixedChunksCode += "[" + "[],".repeat(42) + " "; // column 128, offset 128 assertEq(mixedChunksCode.length, 256); assertEq(lengthInCodePoints(mixedChunksCode), 256); @@ -313,7 +313,7 @@ function testGuaranteedSingleUnit() // multi-unit code points. For good measure, make the chunk *end* in the // middle of such a code point, so that the relevant chunk limit must be // retracted one code unit. - mixedChunksCode += "[] ], '" + "😱".repeat(61); // column 257, offset 256 + mixedChunksCode += "[] ], '" + "😱".repeat(61); // column 256, offset 256 assertEq(mixedChunksCode.length, 384 + 1); assertEq(lengthInCodePoints(mixedChunksCode), 324); @@ -324,7 +324,7 @@ function testGuaranteedSingleUnit() // terminator. The terminator invalidates the column computation cache, so // when the outermost array is closed, location info for it will not hit the // cache. Finally, tack on the terminating semicolon for good measure. - mixedChunksCode += "' ], '\u2028' ];"; // column 325, offset 385 + mixedChunksCode += "' ], '\u2028' ];"; // column 324, offset 385 assertEq(mixedChunksCode.length, 396); assertEq(lengthInCodePoints(mixedChunksCode), 335); diff --git a/js/src/util/DumpFunctions.cpp b/js/src/util/DumpFunctions.cpp index 9ef8c24b7bdd..1d2a9c6a3922 100644 --- a/js/src/util/DumpFunctions.cpp +++ b/js/src/util/DumpFunctions.cpp @@ -355,7 +355,8 @@ static bool FormatFrame(JSContext* cx, const FrameIter& iter, Sprinter& sp, // print filename, line number and column sp.printf("%s [\"%s\":%u:%u]\n", fun ? ")" : "", - filename ? filename : "", lineno, column.oneOriginValue()); + filename ? filename : "", lineno, + column.zeroOriginValue()); // Note: Right now we don't dump the local variables anymore, because // that is hard to support across all the JITs etc. diff --git a/js/src/util/StructuredSpewer.cpp b/js/src/util/StructuredSpewer.cpp index f74570ab0c39..daac70a31af4 100644 --- a/js/src/util/StructuredSpewer.cpp +++ b/js/src/util/StructuredSpewer.cpp @@ -88,7 +88,7 @@ static bool MatchJSScript(JSScript* script, const char* pattern) { char signature[2048] = {0}; SprintfLiteral(signature, "%s:%u:%u", script->filename(), script->lineno(), - script->column().oneOriginValue()); + script->column().zeroOriginValue()); // Trivial containment match. char* result = strstr(signature, pattern); @@ -131,7 +131,7 @@ void StructuredSpewer::startObject(JSContext* cx, const JSScript* script, json.beginObjectProperty("location"); json.property("filename", script->filename()); json.property("line", script->lineno()); - json.property("column", script->column().oneOriginValue()); + json.property("column", script->column().zeroOriginValue()); json.endObject(); } } diff --git a/js/src/vm/BytecodeUtil.cpp b/js/src/vm/BytecodeUtil.cpp index e4384e3cb191..f7e7ea2daa10 100644 --- a/js/src/vm/BytecodeUtil.cpp +++ b/js/src/vm/BytecodeUtil.cpp @@ -114,7 +114,7 @@ static bool DecompileArgumentFromStack(JSContext* cx, int formalIndex, lineNumber = PCToLineNumber(script, script->offsetToPC(block.offset()), &columnNumber); sp->printf("BB #%" PRIu32 " [%05u,%u,%u]", block.id(), block.offset(), - lineNumber, columnNumber.oneOriginValue()); + lineNumber, columnNumber.zeroOriginValue()); if (block.description()) { sp->printf(" [inlined %s]", block.description()); } diff --git a/js/src/vm/GeckoProfiler.cpp b/js/src/vm/GeckoProfiler.cpp index 330bcd1fa67c..068ff1ba4169 100644 --- a/js/src/vm/GeckoProfiler.cpp +++ b/js/src/vm/GeckoProfiler.cpp @@ -284,7 +284,7 @@ UniqueChars GeckoProfilerRuntime::allocProfileString(JSContext* cx, if (hasName || script->isFunction() || script->isForEval()) { lineAndColumnLength = SprintfLiteral(lineAndColumnStr, "%u:%u", script->lineno(), - script->column().oneOriginValue()); + script->column().zeroOriginValue()); hasLineAndColumn = true; } diff --git a/js/src/vm/JSScript.cpp b/js/src/vm/JSScript.cpp index a0111bf79f37..df1496f5cd25 100644 --- a/js/src/vm/JSScript.cpp +++ b/js/src/vm/JSScript.cpp @@ -3381,7 +3381,7 @@ bool JSScript::dump(JSContext* cx, JS::Handle script, } json.property("lineno", script->lineno()); - json.property("column", script->column().oneOriginValue()); + json.property("column", script->column().zeroOriginValue()); json.beginListProperty("immutableFlags"); DumpImmutableScriptFlags(json, script->immutableFlags()); @@ -3488,7 +3488,7 @@ bool JSScript::dumpSrcNotes(JSContext* cx, JS::Handle script, SrcNoteType type = sn->type(); const char* name = sn->name(); sp->printf("%3u: %4u %6u %5u [%4u] %-16s", unsigned(sn - notes), lineno, - column.oneOriginValue(), offset, delta, name); + column.zeroOriginValue(), offset, delta, name); switch (type) { case SrcNoteType::Breakpoint: @@ -3512,7 +3512,7 @@ bool JSScript::dumpSrcNotes(JSContext* cx, JS::Handle script, case SrcNoteType::SetLineColumn: lineno = SrcNote::SetLineColumn::getLine(sn, script->lineno()); column = SrcNote::SetLineColumn::getColumn(sn); - sp->printf(" lineno %u column %u", lineno, column.oneOriginValue()); + sp->printf(" lineno %u column %u", lineno, column.zeroOriginValue()); break; case SrcNoteType::NewLine: @@ -3522,7 +3522,7 @@ bool JSScript::dumpSrcNotes(JSContext* cx, JS::Handle script, case SrcNoteType::NewLineColumn: column = SrcNote::NewLineColumn::getColumn(sn); - sp->printf(" column %u", column.oneOriginValue()); + sp->printf(" column %u", column.zeroOriginValue()); ++lineno; break; @@ -3628,7 +3628,7 @@ bool JSScript::dumpGCThings(JSContext* cx, JS::Handle script, if (fun->hasBaseScript()) { BaseScript* script = fun->baseScript(); sp->printf(" @ %u:%u\n", script->lineno(), - script->column().oneOriginValue()); + script->column().zeroOriginValue()); } else { sp->put(" (no script)\n"); } diff --git a/js/xpconnect/src/XPCWrappedNativeInfo.cpp b/js/xpconnect/src/XPCWrappedNativeInfo.cpp index aeb43e062cb4..ec20145cade4 100644 --- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp +++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp @@ -199,7 +199,7 @@ already_AddRefed XPCNativeInterface::NewInstance( intfNameChars); nsAutoString filename; - uint32_t lineno = 0, column = 1; + uint32_t lineno = 0, column = 0; nsJSUtils::GetCallingLocation(cx, filename, &lineno, &column); nsCOMPtr error( do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 40a79510e037..d40dd9c3fc39 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -226,7 +226,7 @@ bool ReportWrapperDenial(JSContext* cx, HandleId id, WrapperDenialType type, NS_WARNING( nsPrintfCString("Silently denied access to property %s: %s (@%s:%u:%u)", NS_LossyConvertUTF16toASCII(propertyName).get(), reason, - filename.get(), line, column.oneOriginValue()) + filename.get(), line, column.zeroOriginValue()) .get()); // If this isn't the first warning on this topic for this global, we've @@ -273,7 +273,7 @@ bool ReportWrapperDenial(JSContext* cx, HandleId id, WrapperDenialType type, nsString filenameStr(NS_ConvertASCIItoUTF16(filename.get())); nsresult rv = errorObject->InitWithWindowID( NS_ConvertASCIItoUTF16(errorMessage.ref()), filenameStr, u""_ns, line, - column.oneOriginValue(), nsIScriptError::warningFlag, "XPConnect", + column.zeroOriginValue(), nsIScriptError::warningFlag, "XPConnect", windowId); NS_ENSURE_SUCCESS(rv, true); rv = consoleService->LogMessage(errorObject); diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index b83d491dd093..a7805d6a97d9 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -2921,7 +2921,7 @@ static bool ShouldSecureUpgradeNoHSTS(nsIURI* aURI, nsILoadInfo* aLoadInfo) { u""_ns, // aSourceFile u""_ns, // aScriptSample 0, // aLineNumber - 1, // aColumnNumber + 0, // aColumnNumber nsIScriptError::warningFlag, "upgradeInsecureRequest"_ns, innerWindowId, !!aLoadInfo->GetOriginAttributes().mPrivateBrowsingId); diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h index 30b5f2843aa6..277faa499102 100644 --- a/parser/html/nsHtml5TreeBuilderCppSupplement.h +++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h @@ -227,8 +227,7 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement( } opSetScriptLineAndColumnNumberAndFreeze operation( content, tokenizer->getLineNumber(), - // NOTE: tokenizer->getColumnNumber() points '>'. - tokenizer->getColumnNumber() + 1); + tokenizer->getColumnNumber()); treeOp->Init(mozilla::AsVariant(operation)); nsHtml5String type = @@ -556,8 +555,7 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement( } opSetScriptLineAndColumnNumberAndFreeze operation( content, tokenizer->getLineNumber(), - // NOTE: tokenizer->getColumnNumber() points '>'. - tokenizer->getColumnNumber() + 1); + tokenizer->getColumnNumber()); treeOp->Init(mozilla::AsVariant(operation)); nsHtml5String url = @@ -621,9 +619,7 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement( return nullptr; } opSetScriptLineAndColumnNumberAndFreeze operation( - content, tokenizer->getLineNumber(), - // NOTE: tokenizer->getColumnNumber() points '>'. - tokenizer->getColumnNumber() + 1); + content, tokenizer->getLineNumber(), tokenizer->getColumnNumber()); treeOp->Init(mozilla::AsVariant(operation)); if (aNamespace == kNameSpaceID_XHTML) { // Although we come here in cases where the value of diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index fb28166e4684..a389e078c8d9 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -39,7 +39,6 @@ #include "nsIURI.h" #include "nsNetUtil.h" #include "nsTextNode.h" -#include "js/ColumnNumber.h" // JS::ColumnNumberOneOrigin using namespace mozilla; using namespace mozilla::dom; @@ -989,8 +988,7 @@ nsresult nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder, nsCOMPtr sele = do_QueryInterface(node); if (sele) { sele->SetScriptLineNumber(aOperation.mLineNumber); - sele->SetScriptColumnNumber( - JS::ColumnNumberOneOrigin(aOperation.mColumnNumber)); + sele->SetScriptColumnNumber(aOperation.mColumnNumber); sele->FreezeExecutionAttrs(node->OwnerDoc()); } else { MOZ_ASSERT(nsNameSpaceManager::GetInstance()->mSVGDisabled, diff --git a/parser/htmlparser/nsIExpatSink.idl b/parser/htmlparser/nsIExpatSink.idl index 56ca099feeb2..f505eda8c9cd 100644 --- a/parser/htmlparser/nsIExpatSink.idl +++ b/parser/htmlparser/nsIExpatSink.idl @@ -28,8 +28,7 @@ interface nsIExpatSink : nsISupports * present in aAtts. * @param aAttsCount the number of elements in aAtts. * @param aLineNumber the line number of the start tag in the data stream. - * @param aColumnNumber the 0-origin column number of the start tag in the - * data stream. + * @param aColumnNumber the column number of the start tag in the data stream. */ void HandleStartElement(in wstring aName, [array, size_is(aAttsCount)] in wstring aAtts, diff --git a/testing/modules/CoverageUtils.sys.mjs b/testing/modules/CoverageUtils.sys.mjs index a19432305a38..990d82ad7a2f 100644 --- a/testing/modules/CoverageUtils.sys.mjs +++ b/testing/modules/CoverageUtils.sys.mjs @@ -51,8 +51,7 @@ CoverageCollector.prototype._getLinesCovered = function () { this._allCoverage[scriptName] = {}; } - // NOTE: columnNumber is 1-origin. - let key = [lineNumber, columnNumber - 1, offset].join("#"); + let key = [lineNumber, columnNumber, offset].join("#"); if (!currentCoverage[scriptName][key]) { currentCoverage[scriptName][key] = count; } else { diff --git a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/blockeduri-eval.html b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/blockeduri-eval.html index c610195ae894..ddd5068df1f1 100644 --- a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/blockeduri-eval.html +++ b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/blockeduri-eval.html @@ -8,7 +8,7 @@ watcher.wait_for('securitypolicyviolation').then(t.step_func_done(e => { assert_equals(e.blockedURI, "eval"); assert_equals(e.lineNumber, 15); - assert_equals(e.columnNumber, 13); + assert_equals(e.columnNumber, 12); })); try { diff --git a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/blockeduri-inline.html b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/blockeduri-inline.html index f416cf0683a1..7cced9ef6903 100644 --- a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/blockeduri-inline.html +++ b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/blockeduri-inline.html @@ -8,7 +8,7 @@ watcher.wait_for('securitypolicyviolation').then(t.step_func_done(e => { assert_equals(e.blockedURI, "inline"); assert_equals(e.lineNumber, 15); - assert_equals(e.columnNumber, 9); + assert_equals(e.columnNumber, 8); })); }, "Inline violations have a blockedURI of 'inline'"); diff --git a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-cross-origin-image-from-script.sub.html b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-cross-origin-image-from-script.sub.html index 37499db4b5c2..318fae463451 100644 --- a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-cross-origin-image-from-script.sub.html +++ b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-cross-origin-image-from-script.sub.html @@ -17,7 +17,7 @@ assert_equals(e.disposition, "enforce"); assert_equals(new URL(e.sourceFile).pathname, "/content-security-policy/support/inject-image.sub.js"); assert_equals(e.lineNumber, 2); - assert_equals(e.columnNumber, 1); + assert_equals(e.columnNumber, 0); assert_equals(e.statusCode, 200); })); diff --git a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-cross-origin-image.sub.html b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-cross-origin-image.sub.html index f0152a9e82ae..44ca8d50e453 100644 --- a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-cross-origin-image.sub.html +++ b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-cross-origin-image.sub.html @@ -17,7 +17,7 @@ assert_equals(e.disposition, "enforce"); assert_equals(new URL(e.sourceFile).pathname, "/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-cross-origin-image.sub.html"); assert_equals(e.lineNumber, 25); - assert_equals(e.columnNumber, 5); + assert_equals(e.columnNumber, 4); assert_equals(e.statusCode, 200); })); diff --git a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-image-from-script.sub.html b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-image-from-script.sub.html index b75d3804a89d..c09643c20eba 100644 --- a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-image-from-script.sub.html +++ b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-image-from-script.sub.html @@ -17,7 +17,7 @@ assert_equals(e.disposition, "enforce"); assert_equals(new URL(e.sourceFile).pathname, "/content-security-policy/support/inject-image.sub.js"); assert_equals(e.lineNumber, 2); - assert_equals(e.columnNumber, 1); + assert_equals(e.columnNumber, 0); assert_equals(e.statusCode, 200); })); diff --git a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-image.sub.html b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-image.sub.html index 654a49e8bf1c..541c139533e8 100644 --- a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-image.sub.html +++ b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-image.sub.html @@ -17,7 +17,7 @@ assert_equals(e.disposition, "enforce"); assert_equals(new URL(e.sourceFile).pathname, "/content-security-policy/securitypolicyviolation/securitypolicyviolation-block-image.sub.html"); assert_equals(e.lineNumber, 25); - assert_equals(e.columnNumber, 5); + assert_equals(e.columnNumber, 4); assert_equals(e.statusCode, 200); })); diff --git a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/source-file-blob-scheme.html b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/source-file-blob-scheme.html index 49bb6e2459f1..ad3d9f36009a 100644 --- a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/source-file-blob-scheme.html +++ b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/source-file-blob-scheme.html @@ -9,7 +9,7 @@ assert_equals(e.blockedURI, "eval"); assert_equals(e.sourceFile, "blob"); assert_equals(e.lineNumber, 3); - assert_equals(e.columnNumber, 17); + assert_equals(e.columnNumber, 16); })); var scriptText = ` diff --git a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/source-file-data-scheme.html b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/source-file-data-scheme.html index 7e63f1f53ce4..06511571d4a1 100644 --- a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/source-file-data-scheme.html +++ b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/source-file-data-scheme.html @@ -9,7 +9,7 @@ assert_equals(e.blockedURI, "eval"); assert_equals(e.sourceFile, "data"); assert_equals(e.lineNumber, 3); - assert_equals(e.columnNumber, 17); + assert_equals(e.columnNumber, 16); })); var scriptText = ` diff --git a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/targeting.html b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/targeting.html index 6894e58bb5c6..b21273ca555c 100644 --- a/testing/web-platform/tests/content-security-policy/securitypolicyviolation/targeting.html +++ b/testing/web-platform/tests/content-security-policy/securitypolicyviolation/targeting.html @@ -36,28 +36,28 @@ .then(t.step_func(e => { assert_equals(e.blockedURI, "inline"); assert_equals(e.lineNumber, 118); - assert_in_array(e.columnNumber, [5, 7]); + assert_in_array(e.columnNumber, [4, 6]); assert_equals(e.target, document, "Elements created in this document, but pushed into a same-origin frame trigger on that frame's document, not on this frame's document."); return watcher.wait_for('securitypolicyviolation'); })) .then(t.step_func(e => { assert_equals(e.blockedURI, "inline"); assert_equals(e.lineNumber, 131); - assert_in_array(e.columnNumber, [5, 60]); + assert_in_array(e.columnNumber, [4, 59]); assert_equals(e.target, document, "Elements created in this document, but pushed into a same-origin frame trigger on that frame's document, not on this frame's document."); return watcher.wait_for('securitypolicyviolation'); })) .then(t.step_func(e => { assert_equals(e.blockedURI, "inline"); assert_equals(e.lineNumber, 139); - assert_in_array(e.columnNumber, [5, 7]); + assert_in_array(e.columnNumber, [4, 6]); assert_equals(e.target, document, "Inline event handlers for disconnected elements target the document."); return watcher.wait_for('securitypolicyviolation'); })) .then(t.step_func(e => { assert_equals(e.blockedURI, "inline"); assert_equals(e.lineNumber, 0); - assert_equals(e.columnNumber, 1); + assert_equals(e.columnNumber, 0); assert_equals(e.target, document, "Inline event handlers for elements disconnected after triggering target the document."); })) .then(t.step_func_done(_ => { diff --git a/toolkit/components/antitracking/ContentBlockingNotifier.cpp b/toolkit/components/antitracking/ContentBlockingNotifier.cpp index 84f58020ef57..5d397079d1bd 100644 --- a/toolkit/components/antitracking/ContentBlockingNotifier.cpp +++ b/toolkit/components/antitracking/ContentBlockingNotifier.cpp @@ -59,7 +59,7 @@ void ReportUnblockingToConsole( MOZ_ASSERT(aPrincipal); nsAutoString sourceLine; - uint32_t lineNumber = 0, columnNumber = 1; + uint32_t lineNumber = 0, columnNumber = 0; JSContext* cx = nsContentUtils::GetCurrentJSContext(); if (cx) { nsJSUtils::GetCallingLocation(cx, sourceLine, &lineNumber, &columnNumber); @@ -149,7 +149,7 @@ void ReportBlockingToConsole(uint64_t aWindowID, nsIURI* aURI, } nsAutoString sourceLine; - uint32_t lineNumber = 0, columnNumber = 1; + uint32_t lineNumber = 0, columnNumber = 0; JSContext* cx = nsContentUtils::GetCurrentJSContext(); if (cx) { nsJSUtils::GetCallingLocation(cx, sourceLine, &lineNumber, &columnNumber); diff --git a/tools/profiler/core/ProfileBuffer.cpp b/tools/profiler/core/ProfileBuffer.cpp index bc6314fa32ea..07b7121a6c59 100644 --- a/tools/profiler/core/ProfileBuffer.cpp +++ b/tools/profiler/core/ProfileBuffer.cpp @@ -227,7 +227,7 @@ void ProfileBufferCollector::CollectProfilingStackFrame( if (aFrame.pc()) { JS::LimitedColumnNumberOneOrigin col; line = Some(JS_PCToLineNumber(aFrame.script(), aFrame.pc(), &col)); - column = Some(col.oneOriginValue()); + column = Some(col.zeroOriginValue()); } }