Bug 1652679 - Generate consistent URLs when pretty-printing anonymous sources. r=davidwalsh

Differential Revision: https://phabricator.services.mozilla.com/D83724
This commit is contained in:
Logan Smyth 2020-07-17 14:55:39 +00:00
Родитель 8e5010f87c
Коммит 3b2321d039
3 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -39,6 +39,10 @@ import type {
SourceLocation,
} from "../../types";
function getPrettyOriginalSourceURL(generatedSource: Source) {
return getPrettySourceURL(generatedSource.url || generatedSource.id);
}
export async function prettyPrintSource(
sourceMaps: typeof SourceMaps,
generatedSource: Source,
@ -49,7 +53,7 @@ export async function prettyPrintSource(
throw new Error("Can't prettify non-javascript files.");
}
const url = getPrettySourceURL(generatedSource.url);
const url = getPrettyOriginalSourceURL(generatedSource);
const { code, mappings } = await prettyPrint({
text: content.value,
url,
@ -70,7 +74,7 @@ export async function prettyPrintSource(
export function createPrettySource(cx: Context, sourceId: SourceId) {
return async ({ dispatch, getState, sourceMaps }: ThunkArgs) => {
const source = getSourceFromId(getState(), sourceId);
const url = getPrettySourceURL(source.url || source.id);
const url = getPrettyOriginalSourceURL(source);
const id = generatedToOriginalId(sourceId, url);
const prettySource = {

Просмотреть файл

@ -123,6 +123,7 @@ skip-if = (verify && debug && (os == 'mac')) || (os == 'linux' && debug && bits
[browser_dbg-pretty-print-breakpoints-delete.js]
[browser_dbg-pretty-print-console.js]
[browser_dbg-pretty-print-paused.js]
[browser_dbg-pretty-print-paused-anonymous.js]
[browser_dbg-pretty-print-flow.js]
[browser_dbg-preview-getter.js]
[browser_dbg-preview.js]

Просмотреть файл

@ -0,0 +1,14 @@
/* 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/>. */
// Tests that pretty-printing a file with no URL works while paused.
add_task(async function() {
const dbg = await initDebugger("doc-minified.html");
const debuggerDone = dbg.client.evaluate("debugger; var foo;");
await waitForPaused(dbg);
// This will throw if things fail to pretty-print and render properly.
await prettyPrint(dbg);
});