Bug 1643180 - Part 6: Remove unused source-map-url-service functions. r=jlast

Differential Revision: https://phabricator.services.mozilla.com/D78386
This commit is contained in:
Logan Smyth 2020-06-05 22:20:55 +00:00
Родитель 21ff25bf86
Коммит 3ce268493b
9 изменённых файлов: 26 добавлений и 92 удалений

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

@ -52,72 +52,6 @@ class SourceMapURLService {
Services.prefs.removeObserver(SOURCE_MAP_PREF, this._syncPrevValue);
}
/**
* Query for the original position of a location in a generated file.
*
* This function will wait for all sources to have loaded, since the
* sourcemap worker may not know about a particular source yet.
*
* @param {string} id The actor ID of the source.
* @param {number} line The line number in the source.
* @param {number} column The column number in the source.
*
* @return {Object | null} An object with url/line/column properties
* specifying a location in the original file, or null if no particular
* original location could be found.
*/
async originalPositionForID(id, line, column) {
await this._ensureAllSourcesPopulated();
if (!this._prefValue) {
return null;
}
const map = this._mapsById.get(id);
if (!map) {
return null;
}
const query = this._buildQuery(map, line, column);
return this._dispatchQuery(query);
}
/**
* Query for the original position of a location in a generated file.
*
* This function will wait for all sources to have loaded, since the
* sourcemap worker may not know about a particular source yet.
*
* @param {string} url The url of the source. If multiple files with this
* URL exist, the result is indeterminate.
* @param {number} line The line number in the source.
* @param {number} column The column number in the source.
*
* @return {Object | null} An object with url/line/column properties
* specifying a location in the original file, or null if no particular
* original location could be found.
*/
async originalPositionForURL(url, line, column) {
await this._ensureAllSourcesPopulated();
if (!this._prefValue) {
return null;
}
const id = this._urlToIDMap.get(url);
if (!id) {
return null;
}
const map = this._mapsById.get(id);
if (!map) {
return null;
}
const query = this._buildQuery(map, line, column);
return this._dispatchQuery(query);
}
/**
* Subscribe to notifications about the original location of a given
* generated location, as it may not be known at this time, may become
@ -399,15 +333,11 @@ class SourceMapURLService {
this._ensureSubscribersSynchronized(query);
}
}
return result;
})();
query.action = action;
}
this._ensureSubscribersSynchronized(query);
return query.action;
}
_ensureSubscribersSynchronized(query) {

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

@ -32,14 +32,14 @@ add_task(async function() {
await sourceSeen;
const loc1 = { url: JS_URL, line: 6 };
const newLoc1 = await service.originalPositionForURL(loc1.url, loc1.line, 4);
const newLoc1 = await new Promise(r =>
service.subscribeByURL(loc1.url, loc1.line, 4, r)
);
checkLoc1(loc1, newLoc1);
const loc2 = { url: JS_URL, line: 8, column: 3 };
const newLoc2 = await service.originalPositionForURL(
loc2.url,
loc2.line,
loc2.column
const newLoc2 = await new Promise(r =>
service.subscribeByURL(loc2.url, loc2.line, loc2.column, r)
);
checkLoc2(loc2, newLoc2);

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

@ -27,7 +27,9 @@ add_task(async function() {
await sourceSeen;
info(`checking original location for ${JS_URL}:6`);
const newLoc = await service.originalPositionForURL(JS_URL, 6, 4);
const newLoc = await await new Promise(r =>
service.subscribeByURL(JS_URL, 6, 4, r)
);
is(newLoc.url, ORIGINAL_URL, "check mapped URL");
is(newLoc.line, 4, "check mapped line number");

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

@ -33,7 +33,9 @@ add_task(async function() {
const service = toolbox.sourceMapURLService;
info(`checking original location for ${JS_URL}:${GENERATED_LINE}`);
const newLoc = await service.originalPositionForURL(JS_URL, GENERATED_LINE);
const newLoc = await new Promise(r =>
service.subscribeByURL(JS_URL, GENERATED_LINE, undefined, r)
);
is(newLoc.url, ORIGINAL_URL, "check mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check mapped line number");
});

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

@ -37,7 +37,9 @@ add_task(async function() {
const service = toolbox.sourceMapURLService;
info(`checking original location for ${JS_URL}:${GENERATED_LINE}`);
const newLoc = await service.originalPositionForURL(JS_URL, GENERATED_LINE);
const newLoc = await new Promise(r =>
service.subscribeByURL(JS_URL, GENERATED_LINE, undefined, r)
);
is(newLoc.url, ORIGINAL_URL, "check mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check mapped line number");

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

@ -29,7 +29,9 @@ add_task(async function() {
await sourceSeen;
info(`checking original location for ${JS_URL}:84`);
const newLoc = await service.originalPositionForURL(JS_URL, 84);
const newLoc = await new Promise(r =>
service.subscribeByURL(JS_URL, 84, undefined, r)
);
is(newLoc.url, ORIGINAL_URL, "check mapped URL");
is(newLoc.line, 11, "check mapped line number");

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

@ -35,7 +35,9 @@ add_task(async function() {
const service = toolbox.sourceMapURLService;
info(`checking original location for ${JS_URL}:${GENERATED_LINE}`);
const newLoc = await service.originalPositionForURL(JS_URL, GENERATED_LINE);
const newLoc = await new Promise(r =>
service.subscribeByURL(JS_URL, GENERATED_LINE, undefined, r)
);
is(newLoc.url, ORIGINAL_URL, "check mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check mapped line number");
});

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

@ -26,7 +26,9 @@ add_task(async function() {
await sourceSeen;
info(`checking original location for ${JS_URL}:${GENERATED_LINE}`);
let newLoc = await service.originalPositionForURL(JS_URL, GENERATED_LINE);
let newLoc = await new Promise(r =>
service.subscribeByURL(JS_URL, GENERATED_LINE, undefined, r)
);
is(newLoc.url, ORIGINAL_URL_1, "check mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check mapped line number");
@ -39,7 +41,9 @@ add_task(async function() {
info(
`checking post-reload original location for ${JS_URL}:${GENERATED_LINE}`
);
newLoc = await service.originalPositionForURL(JS_URL, GENERATED_LINE);
newLoc = await new Promise(r =>
service.subscribeByURL(JS_URL, GENERATED_LINE, undefined, r)
);
is(newLoc.url, ORIGINAL_URL_2, "check post-reload mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check post-reload mapped line number");

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

@ -24,16 +24,6 @@ module.exports = {
subscribeByLocation: () => {
return () => {};
},
originalPositionForURL: () => {
return new Promise(resolve => {
resolve();
});
},
originalPositionForID: () => {
return new Promise(resolve => {
resolve();
});
},
},
openLink: () => {},
// eslint-disable-next-line react/display-name