зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1710417 - [devtools] Update pretty-fast to 0.2.6. r=ladybenko.
This fixes an issue we had with pretty printing scripts containing private fields. A test case is added in browser_dbg-pretty-print.js to ensure it stays this way. Differential Revision: https://phabricator.services.mozilla.com/D114816
This commit is contained in:
Родитель
16db20bb0e
Коммит
c7e36d6e02
|
@ -2212,7 +2212,7 @@
|
|||
"byName": {},
|
||||
"byBlocks": {},
|
||||
"usedIds": {
|
||||
"1": 1
|
||||
"0": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2233,7 +2233,7 @@
|
|||
"byName": {},
|
||||
"byBlocks": {},
|
||||
"usedIds": {
|
||||
"1": 1
|
||||
"0": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2254,7 +2254,7 @@
|
|||
"byName": {},
|
||||
"byBlocks": {},
|
||||
"usedIds": {
|
||||
"1": 1
|
||||
"0": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3615,7 +3615,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/* -*- indent-
|
|||
*/
|
||||
function isIdentifierLike(token) {
|
||||
var ttl = token.type.label;
|
||||
return ttl == "name" || ttl == "num" || !!token.type.keyword;
|
||||
return ttl == "name" || ttl == "num" || ttl == "privateId" || !!token.type.keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3981,7 +3981,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/* -*- indent-
|
|||
token.loc.start.line,
|
||||
token.loc.start.column);
|
||||
} else {
|
||||
write(String(token.value != null ? token.value : token.type.label),
|
||||
let value;
|
||||
if (token.value != null) {
|
||||
value = token.value;
|
||||
if (token.type.label === "privateId") {
|
||||
value = `#${value}`;
|
||||
}
|
||||
} else {
|
||||
value = token.type.label;
|
||||
}
|
||||
write(String(value),
|
||||
token.loc.start.line,
|
||||
token.loc.start.column);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"lodash-move": "^1.1.1",
|
||||
"lodash.kebabcase": "^4.1.1",
|
||||
"parse-script-tags": "github:loganfsmyth/parse-script-tags#d771732ca47e1b3554fe67d609fd18cc785c5f26",
|
||||
"pretty-fast": "^0.2.5",
|
||||
"pretty-fast": "^0.2.6",
|
||||
"react": "16.8.6",
|
||||
"react-aria-components": "^0.0.4",
|
||||
"react-dom": "16.8.6",
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
// Tests basic pretty-printing functionality.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
add_task(async function() {
|
||||
const dbg = await initDebugger("doc-minified.html", "math.min.js");
|
||||
|
@ -38,3 +39,86 @@ add_task(async function() {
|
|||
await selectSource(dbg, "math.min.js");
|
||||
ok(findElement(dbg, "prettyPrintButton"), "Pretty Print Button is visible");
|
||||
});
|
||||
|
||||
add_task(async function testPrivateFields() {
|
||||
// Create a source containing a class with private fields
|
||||
const httpServer = createTestHTTPServer();
|
||||
httpServer.registerContentType("html", "text/html");
|
||||
httpServer.registerContentType("js", "application/javascript");
|
||||
|
||||
httpServer.registerPathHandler(`/`, function(request, response) {
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
response.write(`
|
||||
<html>
|
||||
Test pretty-printing class with private fields
|
||||
<script type="text/javascript" src="class-with-private-fields.js"></script>
|
||||
</html>`);
|
||||
});
|
||||
|
||||
httpServer.registerPathHandler("/class-with-private-fields.js", function(
|
||||
request,
|
||||
response
|
||||
) {
|
||||
response.setHeader("Content-Type", "application/javascript");
|
||||
response.write(`
|
||||
class MyClass {
|
||||
constructor(a) {
|
||||
this.#a = a;this.#b = Math.random();this.ab = this.#getAB();
|
||||
}
|
||||
#a
|
||||
#b = "default value"
|
||||
static #someStaticPrivate
|
||||
#getA() {
|
||||
return this.#a;
|
||||
}
|
||||
#getAB() {
|
||||
return this.#getA()+this.
|
||||
#b
|
||||
}
|
||||
}
|
||||
`);
|
||||
});
|
||||
const port = httpServer.identity.primaryPort;
|
||||
const TEST_URL = `http://localhost:${port}/`;
|
||||
|
||||
info("Open toolbox");
|
||||
const dbg = await initDebuggerWithAbsoluteURL(TEST_URL);
|
||||
|
||||
info("Select script with private fields");
|
||||
await selectSource(dbg, "class-with-private-fields.js", 2);
|
||||
|
||||
info("Pretty print the script");
|
||||
clickElement(dbg, "prettyPrintButton");
|
||||
|
||||
info("Wait until the script is pretty-printed");
|
||||
await waitForSelectedSource(dbg, "class-with-private-fields.js:formatted");
|
||||
|
||||
info("Check that the script was pretty-printed as expected");
|
||||
const prettyPrintedSource = await findSourceContent(
|
||||
dbg,
|
||||
"class-with-private-fields.js:formatted"
|
||||
);
|
||||
|
||||
is(
|
||||
prettyPrintedSource.value.trim(),
|
||||
`
|
||||
class MyClass {
|
||||
constructor(a) {
|
||||
this.#a = a;
|
||||
this.#b = Math.random();
|
||||
this.ab = this.#getAB();
|
||||
}
|
||||
#a
|
||||
#b = 'default value'
|
||||
static #someStaticPrivate
|
||||
#getA() {
|
||||
return this.#a;
|
||||
}
|
||||
#getAB() {
|
||||
return this.#getA() + this.#b
|
||||
}
|
||||
}
|
||||
`.trim(),
|
||||
"script was pretty printed as expected"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -6292,10 +6292,10 @@ preserve@^0.2.0:
|
|||
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
|
||||
integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=
|
||||
|
||||
pretty-fast@^0.2.5:
|
||||
version "0.2.5"
|
||||
resolved "https://registry.yarnpkg.com/pretty-fast/-/pretty-fast-0.2.5.tgz#b4dbc37a945d0de52eb268f81f6ca696623aa96b"
|
||||
integrity sha512-olVM1CpLIrLhD0q8ZW42dMdTFuEfHynJhmuWirTS5EmWwN2w/v1Dl3WV4PeBLU7SH/a70Hy/HdeztVaLTqwaJw==
|
||||
pretty-fast@^0.2.6:
|
||||
version "0.2.6"
|
||||
resolved "https://registry.yarnpkg.com/pretty-fast/-/pretty-fast-0.2.6.tgz#1f3077331805080eefe345b52da45a816a361695"
|
||||
integrity sha512-mMRZ/SY5k//EDjrRD88hfrByU4Tjn869gbEU3Nj0zspMddrIn4ZyNr/Cw65tpq4mYM/T6ZKBwWgqb/d3QU6gVw==
|
||||
dependencies:
|
||||
acorn "~8.2.4"
|
||||
optimist "~0.6.1"
|
||||
|
|
Загрузка…
Ссылка в новой задаче