forked from mirrors/gecko-dev
Bug 1849144 - Fix the number of whitespaces used for preserving the column number of inline script. r=ochameau,devtools-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D186596
This commit is contained in:
parent
48a0286c9f
commit
b2a6c970c5
7 changed files with 52 additions and 20 deletions
|
|
@ -2536,7 +2536,7 @@
|
||||||
"byName": {},
|
"byName": {},
|
||||||
"byBlocks": {},
|
"byBlocks": {},
|
||||||
"usedIds": {
|
"usedIds": {
|
||||||
"1": 1
|
"0": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2557,7 +2557,7 @@
|
||||||
"byName": {},
|
"byName": {},
|
||||||
"byBlocks": {},
|
"byBlocks": {},
|
||||||
"usedIds": {
|
"usedIds": {
|
||||||
"1": 1
|
"0": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30492,10 +30492,6 @@
|
||||||
return locations.map(parser);
|
return locations.map(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateWhitespace(length) {
|
|
||||||
return Array.from(new Array(length + 1)).join(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
function calcLineAndColumn(source, index) {
|
function calcLineAndColumn(source, index) {
|
||||||
const lines = source.substring(0, index).split(newLines);
|
const lines = source.substring(0, index).split(newLines);
|
||||||
const line = lines.length;
|
const line = lines.length;
|
||||||
|
|
@ -30513,7 +30509,8 @@
|
||||||
line,
|
line,
|
||||||
column,
|
column,
|
||||||
// prepend whitespace for scripts that do not start on the first column
|
// prepend whitespace for scripts that do not start on the first column
|
||||||
source: generateWhitespace(column) + location.source,
|
// NOTE: `column` is 1-based
|
||||||
|
source: " ".repeat(column - 1) + location.source,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,10 +71,6 @@ function parseScripts(locations, parser) {
|
||||||
return locations.map(parser);
|
return locations.map(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateWhitespace(length) {
|
|
||||||
return Array.from(new Array(length + 1)).join(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
function calcLineAndColumn(source, index) {
|
function calcLineAndColumn(source, index) {
|
||||||
const lines = source.substring(0, index).split(newLines);
|
const lines = source.substring(0, index).split(newLines);
|
||||||
const line = lines.length;
|
const line = lines.length;
|
||||||
|
|
@ -92,7 +88,8 @@ function adjustForLineAndColumn(fullSource, location) {
|
||||||
line,
|
line,
|
||||||
column,
|
column,
|
||||||
// prepend whitespace for scripts that do not start on the first column
|
// prepend whitespace for scripts that do not start on the first column
|
||||||
source: generateWhitespace(column) + location.source,
|
// NOTE: `column` is 1-based
|
||||||
|
source: " ".repeat(column - 1) + location.source,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,9 +129,4 @@ function parseScriptTags(source, parser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default parseScriptTags;
|
export default parseScriptTags;
|
||||||
export {
|
export { getCandidateScriptLocations, parseScripts, parseScriptTags };
|
||||||
generateWhitespace,
|
|
||||||
getCandidateScriptLocations,
|
|
||||||
parseScripts,
|
|
||||||
parseScriptTags,
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import * as types from "@babel/types";
|
||||||
import * as babelParser from "@babel/parser";
|
import * as babelParser from "@babel/parser";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
generateWhitespace,
|
|
||||||
getCandidateScriptLocations,
|
getCandidateScriptLocations,
|
||||||
parseScripts as customParseScripts,
|
parseScripts as customParseScripts,
|
||||||
parseScriptTags as customParseScriptTags,
|
parseScriptTags as customParseScriptTags,
|
||||||
|
|
@ -54,7 +53,6 @@ function parseScriptTags(source, parser = parseScript) {
|
||||||
export default parseScriptTags;
|
export default parseScriptTags;
|
||||||
export {
|
export {
|
||||||
extractScriptTags,
|
extractScriptTags,
|
||||||
generateWhitespace,
|
|
||||||
getCandidateScriptLocations,
|
getCandidateScriptLocations,
|
||||||
parseScript,
|
parseScript,
|
||||||
parseScripts,
|
parseScripts,
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@ skip-if = ccov && os == 'win' # Bug 1443132
|
||||||
[browser_dbg-inline-preview.js]
|
[browser_dbg-inline-preview.js]
|
||||||
skip-if = true # bug 1607636
|
skip-if = true # bug 1607636
|
||||||
[browser_dbg-inline-exceptions.js]
|
[browser_dbg-inline-exceptions.js]
|
||||||
|
[browser_dbg-inline-exceptions-inline-script.js]
|
||||||
[browser_dbg-inspector-integration.js]
|
[browser_dbg-inspector-integration.js]
|
||||||
[browser_dbg-keyboard-navigation.js]
|
[browser_dbg-keyboard-navigation.js]
|
||||||
[browser_dbg-keyboard-shortcuts-modal.js]
|
[browser_dbg-keyboard-shortcuts-modal.js]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||||
|
|
||||||
|
// This test checks the appearance of an inline exception in inline script
|
||||||
|
// and the content of the exception tooltip.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
add_task(async function () {
|
||||||
|
const dbg = await initDebugger("doc-exceptions-inline-script.html");
|
||||||
|
await selectSource(dbg, "doc-exceptions-inline-script.html");
|
||||||
|
|
||||||
|
info("Hovers over the inline exception mark text.");
|
||||||
|
await assertInlineExceptionPreview(dbg, 7, 39, {
|
||||||
|
fields: [
|
||||||
|
[
|
||||||
|
"<anonymous>",
|
||||||
|
"https://example.com/browser/devtools/client/debugger/test/mochitest/examples/doc-exceptions-inline-script.html:7",
|
||||||
|
],
|
||||||
|
],
|
||||||
|
result: "TypeError: [].plop is not a function",
|
||||||
|
expression: "plop",
|
||||||
|
});
|
||||||
|
|
||||||
|
const excLineEls = findAllElementsWithSelector(dbg, ".line-exception");
|
||||||
|
const excTextMarkEls = findAllElementsWithSelector(
|
||||||
|
dbg,
|
||||||
|
".mark-text-exception"
|
||||||
|
);
|
||||||
|
|
||||||
|
is(excLineEls.length, 1, "The editor has one exception line");
|
||||||
|
is(excTextMarkEls.length, 1, "One token is marked as an exception.");
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Debugger test page</title>
|
||||||
|
<script type="text/javascript">[].plop()</script>
|
||||||
|
</head>
|
||||||
|
<body></body>
|
||||||
|
</html>
|
||||||
Loading…
Reference in a new issue