зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1349354 - remove now-unused source-map-service; r=jryans
MozReview-Commit-ID: umdc4XrpGf --HG-- extra : rebase_source : 3c4ff9485a970181123fe5d762cfa772b47f6338
This commit is contained in:
Родитель
850089e85b
Коммит
5b3ab3e49e
|
@ -1,103 +0,0 @@
|
||||||
/* 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/. */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const SOURCE_TOKEN = "<:>";
|
|
||||||
|
|
||||||
function LocationStore (store) {
|
|
||||||
this._store = store || new Map();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to get a promised location from the Store.
|
|
||||||
* @param location
|
|
||||||
* @returns Promise<Object>
|
|
||||||
*/
|
|
||||||
LocationStore.prototype.get = function (location) {
|
|
||||||
this._safeAccessInit(location.url);
|
|
||||||
return this._store.get(location.url).get(location);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to set a promised location to the Store
|
|
||||||
* @param location
|
|
||||||
* @param promisedLocation
|
|
||||||
*/
|
|
||||||
LocationStore.prototype.set = function (location, promisedLocation = null) {
|
|
||||||
this._safeAccessInit(location.url);
|
|
||||||
this._store.get(location.url).set(serialize(location), promisedLocation);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility method to verify if key exists in Store before accessing it.
|
|
||||||
* If not, initializing it.
|
|
||||||
* @param url
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
LocationStore.prototype._safeAccessInit = function (url) {
|
|
||||||
if (!this._store.has(url)) {
|
|
||||||
this._store.set(url, new Map());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility proxy method to Map.clear() method
|
|
||||||
*/
|
|
||||||
LocationStore.prototype.clear = function () {
|
|
||||||
this._store.clear();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves an object containing all locations to be resolved when `source-updated`
|
|
||||||
* event is triggered.
|
|
||||||
* @param url
|
|
||||||
* @returns {Array<String>}
|
|
||||||
*/
|
|
||||||
LocationStore.prototype.getByURL = function (url){
|
|
||||||
if (this._store.has(url)) {
|
|
||||||
return [...this._store.get(url).keys()];
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invalidates the stale location promises from the store when `source-updated`
|
|
||||||
* event is triggered, and when FrameView unsubscribes from a location.
|
|
||||||
* @param url
|
|
||||||
*/
|
|
||||||
LocationStore.prototype.clearByURL = function (url) {
|
|
||||||
this._safeAccessInit(url);
|
|
||||||
this._store.set(url, new Map());
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.LocationStore = LocationStore;
|
|
||||||
exports.serialize = serialize;
|
|
||||||
exports.deserialize = deserialize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility method to serialize the source
|
|
||||||
* @param source
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function serialize(source) {
|
|
||||||
let { url, line, column } = source;
|
|
||||||
line = line || 0;
|
|
||||||
column = column || 0;
|
|
||||||
return `${url}${SOURCE_TOKEN}${line}${SOURCE_TOKEN}${column}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility method to serialize the source
|
|
||||||
* @param source
|
|
||||||
* @returns Object
|
|
||||||
*/
|
|
||||||
function deserialize(source) {
|
|
||||||
let [ url, line, column ] = source.split(SOURCE_TOKEN);
|
|
||||||
line = parseInt(line);
|
|
||||||
column = parseInt(column);
|
|
||||||
if (column === 0) {
|
|
||||||
return { url, line };
|
|
||||||
}
|
|
||||||
return { url, line, column };
|
|
||||||
};
|
|
|
@ -20,12 +20,10 @@ DevToolsModules(
|
||||||
'devtools-browser.js',
|
'devtools-browser.js',
|
||||||
'devtools.js',
|
'devtools.js',
|
||||||
'gDevTools.jsm',
|
'gDevTools.jsm',
|
||||||
'location-store.js',
|
|
||||||
'menu-item.js',
|
'menu-item.js',
|
||||||
'menu.js',
|
'menu.js',
|
||||||
'selection.js',
|
'selection.js',
|
||||||
'sidebar.js',
|
'sidebar.js',
|
||||||
'source-map-service.js',
|
|
||||||
'source-map-url-service.js',
|
'source-map-url-service.js',
|
||||||
'target-from-url.js',
|
'target-from-url.js',
|
||||||
'target.js',
|
'target.js',
|
||||||
|
|
|
@ -1,209 +0,0 @@
|
||||||
/* 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/. */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const { Task } = require("devtools/shared/task");
|
|
||||||
const EventEmitter = require("devtools/shared/event-emitter");
|
|
||||||
const { LocationStore, serialize, deserialize } = require("./location-store");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A manager class that wraps a TabTarget and listens to source changes
|
|
||||||
* from source maps and resolves non-source mapped locations to the source mapped
|
|
||||||
* versions and back and forth, and creating smart elements with a location that
|
|
||||||
* auto-update when the source changes (from pretty printing, source maps loading, etc)
|
|
||||||
*
|
|
||||||
* @param {TabTarget} target
|
|
||||||
*/
|
|
||||||
|
|
||||||
function SourceMapService(target) {
|
|
||||||
this._target = target;
|
|
||||||
this._locationStore = new LocationStore();
|
|
||||||
this._isNotSourceMapped = new Map();
|
|
||||||
|
|
||||||
EventEmitter.decorate(this);
|
|
||||||
|
|
||||||
this._onSourceUpdated = this._onSourceUpdated.bind(this);
|
|
||||||
this._resolveLocation = this._resolveLocation.bind(this);
|
|
||||||
this._resolveAndUpdate = this._resolveAndUpdate.bind(this);
|
|
||||||
this.subscribe = this.subscribe.bind(this);
|
|
||||||
this.unsubscribe = this.unsubscribe.bind(this);
|
|
||||||
this.reset = this.reset.bind(this);
|
|
||||||
this.destroy = this.destroy.bind(this);
|
|
||||||
|
|
||||||
target.on("source-updated", this._onSourceUpdated);
|
|
||||||
target.on("navigate", this.reset);
|
|
||||||
target.on("will-navigate", this.reset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears the store containing the cached promised locations
|
|
||||||
*/
|
|
||||||
SourceMapService.prototype.reset = function () {
|
|
||||||
// Guard to prevent clearing the store when it is not initialized yet.
|
|
||||||
if (!this._locationStore) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._locationStore.clear();
|
|
||||||
this._isNotSourceMapped.clear();
|
|
||||||
};
|
|
||||||
|
|
||||||
SourceMapService.prototype.destroy = function () {
|
|
||||||
this.reset();
|
|
||||||
this._target.off("source-updated", this._onSourceUpdated);
|
|
||||||
this._target.off("navigate", this.reset);
|
|
||||||
this._target.off("will-navigate", this.reset);
|
|
||||||
this._target.off("close", this.destroy);
|
|
||||||
this._target = this._locationStore = this._isNotSourceMapped = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up listener for the callback to update the FrameView
|
|
||||||
* and tries to resolve location, if it is source-mappable
|
|
||||||
* @param location
|
|
||||||
* @param callback
|
|
||||||
*/
|
|
||||||
SourceMapService.prototype.subscribe = function (location, callback) {
|
|
||||||
// A valid candidate location for source-mapping should have a url and line.
|
|
||||||
// Abort if there's no `url`, which means it's unsourcemappable anyway,
|
|
||||||
// like an eval script.
|
|
||||||
// From previous attempts to source-map locations, we also determine if a location
|
|
||||||
// is not source-mapped.
|
|
||||||
if (!location.url || !location.line || this._isNotSourceMapped.get(location.url)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.on(serialize(location), callback);
|
|
||||||
this._locationStore.set(location);
|
|
||||||
this._resolveAndUpdate(location);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the listener for the location and clears cached locations
|
|
||||||
* @param location
|
|
||||||
* @param callback
|
|
||||||
*/
|
|
||||||
SourceMapService.prototype.unsubscribe = function (location, callback) {
|
|
||||||
this.off(serialize(location), callback);
|
|
||||||
// Check to see if the store exists before attempting to clear a location
|
|
||||||
// Sometimes un-subscribe happens during the destruction cascades and this
|
|
||||||
// condition is to protect against that. Could be looked into in the future.
|
|
||||||
if (!this._locationStore) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._locationStore.clearByURL(location.url);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tries to resolve the location and if successful,
|
|
||||||
* emits the resolved location
|
|
||||||
* @param location
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
SourceMapService.prototype._resolveAndUpdate = function (location) {
|
|
||||||
this._resolveLocation(location).then(resolvedLocation => {
|
|
||||||
// We try to source map the first console log to initiate the source-updated
|
|
||||||
// event from target. The isSameLocation check is to make sure we don't update
|
|
||||||
// the frame, if the location is not source-mapped.
|
|
||||||
if (resolvedLocation && !isSameLocation(location, resolvedLocation)) {
|
|
||||||
this.emit(serialize(location), location, resolvedLocation);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if there is existing promise to resolve location, if so returns cached promise
|
|
||||||
* if not, tries to resolve location and returns a promised location
|
|
||||||
* @param location
|
|
||||||
* @return Promise<Object>
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
SourceMapService.prototype._resolveLocation = Task.async(function* (location) {
|
|
||||||
let resolvedLocation;
|
|
||||||
const cachedLocation = this._locationStore.get(location);
|
|
||||||
if (cachedLocation) {
|
|
||||||
resolvedLocation = cachedLocation;
|
|
||||||
} else {
|
|
||||||
const promisedLocation = resolveLocation(this._target, location);
|
|
||||||
if (promisedLocation) {
|
|
||||||
this._locationStore.set(location, promisedLocation);
|
|
||||||
resolvedLocation = promisedLocation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resolvedLocation;
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the `source-updated` event is fired from the target.
|
|
||||||
* Checks to see if location store has the source url in its cache,
|
|
||||||
* if so, tries to update each stale location in the store.
|
|
||||||
* Determines if the source should be source-mapped or not.
|
|
||||||
* @param _
|
|
||||||
* @param sourceEvent
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
SourceMapService.prototype._onSourceUpdated = function (_, sourceEvent) {
|
|
||||||
let { type, source } = sourceEvent;
|
|
||||||
|
|
||||||
// If we get a new source, and it's not a source map, abort;
|
|
||||||
// we can have no actionable updates as this is just a new normal source.
|
|
||||||
// Check Source Actor for sourceMapURL property (after Firefox 48)
|
|
||||||
// If not present, utilize isSourceMapped and isPrettyPrinted properties
|
|
||||||
// to estimate if a source is not source-mapped.
|
|
||||||
const isNotSourceMapped = !(source.sourceMapURL ||
|
|
||||||
source.isSourceMapped || source.isPrettyPrinted);
|
|
||||||
if (type === "newSource" && isNotSourceMapped) {
|
|
||||||
this._isNotSourceMapped.set(source.url, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let sourceUrl = null;
|
|
||||||
if (source.generatedUrl && source.isSourceMapped) {
|
|
||||||
sourceUrl = source.generatedUrl;
|
|
||||||
} else if (source.url && source.isPrettyPrinted) {
|
|
||||||
sourceUrl = source.url;
|
|
||||||
}
|
|
||||||
const locationsToResolve = this._locationStore.getByURL(sourceUrl);
|
|
||||||
if (locationsToResolve.length) {
|
|
||||||
this._locationStore.clearByURL(sourceUrl);
|
|
||||||
for (let location of locationsToResolve) {
|
|
||||||
this._resolveAndUpdate(deserialize(location));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.SourceMapService = SourceMapService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Take a TabTarget and a location, containing a `url`, `line`, and `column`, resolve
|
|
||||||
* the location to the latest location (so a source mapped location, or if pretty print
|
|
||||||
* status has been updated)
|
|
||||||
*
|
|
||||||
* @param {TabTarget} target
|
|
||||||
* @param {Object} location
|
|
||||||
* @return {Promise<Object>}
|
|
||||||
*/
|
|
||||||
function resolveLocation(target, location) {
|
|
||||||
return Task.spawn(function* () {
|
|
||||||
let newLocation = yield target.resolveLocation({
|
|
||||||
url: location.url,
|
|
||||||
line: location.line,
|
|
||||||
column: location.column || Infinity
|
|
||||||
});
|
|
||||||
// Source or mapping not found, so don't do anything
|
|
||||||
if (newLocation.error) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return newLocation;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the original location and resolved location are the same
|
|
||||||
* @param location
|
|
||||||
* @param resolvedLocation
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
function isSameLocation(location, resolvedLocation) {
|
|
||||||
return location.url === resolvedLocation.url &&
|
|
||||||
location.line === resolvedLocation.line &&
|
|
||||||
location.column === resolvedLocation.column;
|
|
||||||
}
|
|
|
@ -52,8 +52,8 @@ SourceMapURLService.prototype._onSourceUpdated = function (_, sourceEvent) {
|
||||||
let { source } = sourceEvent;
|
let { source } = sourceEvent;
|
||||||
let { generatedUrl, url, actor: id, sourceMapURL } = source;
|
let { generatedUrl, url, actor: id, sourceMapURL } = source;
|
||||||
|
|
||||||
// As long as the actor is also handling source maps, we want the
|
// |generatedUrl| comes from the actor and is extracted from the
|
||||||
// generated URL if it is available. This will be going away in bug 1349354.
|
// source code by SpiderMonkey.
|
||||||
let seenUrl = generatedUrl || url;
|
let seenUrl = generatedUrl || url;
|
||||||
this._urls.set(seenUrl, { id, url: seenUrl, sourceMapURL });
|
this._urls.set(seenUrl, { id, url: seenUrl, sourceMapURL });
|
||||||
};
|
};
|
||||||
|
|
|
@ -667,20 +667,6 @@ TabTarget.prototype = {
|
||||||
let id = this._tab ? this._tab : (this._form && this._form.actor);
|
let id = this._tab ? this._tab : (this._form && this._form.actor);
|
||||||
return `TabTarget:${id}`;
|
return `TabTarget:${id}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TabActor.prototype.onResolveLocation
|
|
||||||
*/
|
|
||||||
resolveLocation(loc) {
|
|
||||||
let deferred = defer();
|
|
||||||
|
|
||||||
this.client.request(Object.assign({
|
|
||||||
to: this._form.actor,
|
|
||||||
type: "resolveLocation",
|
|
||||||
}, loc), deferred.resolve);
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,7 +12,6 @@ support-files =
|
||||||
code_binary_search.js
|
code_binary_search.js
|
||||||
code_binary_search.map
|
code_binary_search.map
|
||||||
code_math.js
|
code_math.js
|
||||||
code_ugly.js
|
|
||||||
doc_empty-tab-01.html
|
doc_empty-tab-01.html
|
||||||
head.js
|
head.js
|
||||||
shared-head.js
|
shared-head.js
|
||||||
|
@ -37,7 +36,6 @@ support-files =
|
||||||
[browser_menu_api.js]
|
[browser_menu_api.js]
|
||||||
[browser_new_activation_workflow.js]
|
[browser_new_activation_workflow.js]
|
||||||
[browser_source_map-01.js]
|
[browser_source_map-01.js]
|
||||||
[browser_source_map-02.js]
|
|
||||||
[browser_target_from_url.js]
|
[browser_target_from_url.js]
|
||||||
[browser_target_events.js]
|
[browser_target_events.js]
|
||||||
[browser_target_remote.js]
|
[browser_target_remote.js]
|
||||||
|
|
|
@ -1,113 +0,0 @@
|
||||||
/* vim: set ts=2 et sw=2 tw=80: */
|
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the SourceMapService updates generated sources when pretty printing
|
|
||||||
* and un pretty printing.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Force the old debugger UI since it's directly used (see Bug 1301705)
|
|
||||||
Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
|
|
||||||
registerCleanupFunction(function* () {
|
|
||||||
Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
|
|
||||||
});
|
|
||||||
|
|
||||||
const DEBUGGER_ROOT = "http://example.com/browser/devtools/client/debugger/test/mochitest/";
|
|
||||||
// Empty page
|
|
||||||
const PAGE_URL = `${DEBUGGER_ROOT}doc_empty-tab-01.html`;
|
|
||||||
const JS_URL = `${URL_ROOT}code_ugly.js`;
|
|
||||||
const { SourceMapService } = require("devtools/client/framework/source-map-service");
|
|
||||||
|
|
||||||
add_task(function* () {
|
|
||||||
let toolbox = yield openNewTabAndToolbox(PAGE_URL, "jsdebugger");
|
|
||||||
|
|
||||||
let service = new SourceMapService(toolbox.target);
|
|
||||||
|
|
||||||
let checkedPretty = false;
|
|
||||||
let checkedUnpretty = false;
|
|
||||||
|
|
||||||
function onUpdate(e, oldLoc, newLoc) {
|
|
||||||
if (oldLoc.line === 3) {
|
|
||||||
checkPrettified(oldLoc, newLoc);
|
|
||||||
checkedPretty = true;
|
|
||||||
} else if (oldLoc.line === 9) {
|
|
||||||
checkUnprettified(oldLoc, newLoc);
|
|
||||||
checkedUnpretty = true;
|
|
||||||
} else {
|
|
||||||
throw new Error(`Unexpected location update: ${JSON.stringify(oldLoc)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const loc1 = { url: JS_URL, line: 3 };
|
|
||||||
service.subscribe(loc1, onUpdate);
|
|
||||||
|
|
||||||
// Inject JS script
|
|
||||||
let sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_ugly.js");
|
|
||||||
yield createScript(JS_URL);
|
|
||||||
yield sourceShown;
|
|
||||||
|
|
||||||
let ppButton = toolbox.getCurrentPanel().panelWin.document.getElementById("pretty-print");
|
|
||||||
sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_ugly.js");
|
|
||||||
ppButton.click();
|
|
||||||
yield sourceShown;
|
|
||||||
yield waitUntil(() => checkedPretty);
|
|
||||||
|
|
||||||
// TODO check unprettified change once bug 1177446 fixed
|
|
||||||
// info("Testing un-pretty printing.");
|
|
||||||
// sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_ugly.js");
|
|
||||||
// ppButton.click();
|
|
||||||
// yield sourceShown;
|
|
||||||
// yield waitUntil(() => checkedUnpretty);
|
|
||||||
|
|
||||||
|
|
||||||
yield toolbox.destroy();
|
|
||||||
gBrowser.removeCurrentTab();
|
|
||||||
finish();
|
|
||||||
});
|
|
||||||
|
|
||||||
function checkPrettified(oldLoc, newLoc) {
|
|
||||||
is(oldLoc.line, 3, "Correct line for JS:3");
|
|
||||||
is(oldLoc.column, null, "Correct column for JS:3");
|
|
||||||
is(oldLoc.url, JS_URL, "Correct url for JS:3");
|
|
||||||
is(newLoc.line, 9, "Correct line for JS:3 -> PRETTY");
|
|
||||||
is(newLoc.column, 0, "Correct column for JS:3 -> PRETTY");
|
|
||||||
is(newLoc.url, JS_URL, "Correct url for JS:3 -> PRETTY");
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkUnprettified(oldLoc, newLoc) {
|
|
||||||
is(oldLoc.line, 9, "Correct line for JS:3 -> PRETTY");
|
|
||||||
is(oldLoc.column, 0, "Correct column for JS:3 -> PRETTY");
|
|
||||||
is(oldLoc.url, JS_URL, "Correct url for JS:3 -> PRETTY");
|
|
||||||
is(newLoc.line, 3, "Correct line for JS:3 -> UNPRETTIED");
|
|
||||||
is(newLoc.column, null, "Correct column for JS:3 -> UNPRETTIED");
|
|
||||||
is(newLoc.url, JS_URL, "Correct url for JS:3 -> UNPRETTIED");
|
|
||||||
}
|
|
||||||
|
|
||||||
function createScript(url) {
|
|
||||||
info(`Creating script: ${url}`);
|
|
||||||
let mm = getFrameScript();
|
|
||||||
let command = `
|
|
||||||
let script = document.createElement("script");
|
|
||||||
script.setAttribute("src", "${url}");
|
|
||||||
document.body.appendChild(script);
|
|
||||||
`;
|
|
||||||
return evalInDebuggee(mm, command);
|
|
||||||
}
|
|
||||||
|
|
||||||
function waitForSourceShown(debuggerPanel, url) {
|
|
||||||
let { panelWin } = debuggerPanel;
|
|
||||||
let deferred = defer();
|
|
||||||
|
|
||||||
info(`Waiting for source ${url} to be shown in the debugger...`);
|
|
||||||
panelWin.on(panelWin.EVENTS.SOURCE_SHOWN, function onSourceShown(_, source) {
|
|
||||||
let sourceUrl = source.url || source.introductionUrl;
|
|
||||||
|
|
||||||
if (sourceUrl.includes(url)) {
|
|
||||||
panelWin.off(panelWin.EVENTS.SOURCE_SHOWN, onSourceShown);
|
|
||||||
info(`Source shown for ${url}`);
|
|
||||||
deferred.resolve(source);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
function foo() { var a=1; var b=2; bar(a, b); }
|
|
||||||
function bar(c, d) { return c - d; }
|
|
||||||
foo();
|
|
|
@ -60,8 +60,6 @@ loader.lazyRequireGetter(this, "settleAll",
|
||||||
"devtools/shared/ThreadSafeDevToolsUtils", true);
|
"devtools/shared/ThreadSafeDevToolsUtils", true);
|
||||||
loader.lazyRequireGetter(this, "ToolboxButtons",
|
loader.lazyRequireGetter(this, "ToolboxButtons",
|
||||||
"devtools/client/definitions", true);
|
"devtools/client/definitions", true);
|
||||||
loader.lazyRequireGetter(this, "SourceMapService",
|
|
||||||
"devtools/client/framework/source-map-service", true);
|
|
||||||
loader.lazyRequireGetter(this, "SourceMapURLService",
|
loader.lazyRequireGetter(this, "SourceMapURLService",
|
||||||
"devtools/client/framework/source-map-url-service", true);
|
"devtools/client/framework/source-map-url-service", true);
|
||||||
loader.lazyRequireGetter(this, "HUDService",
|
loader.lazyRequireGetter(this, "HUDService",
|
||||||
|
@ -98,14 +96,6 @@ function Toolbox(target, selectedTool, hostType, contentWindow, frameId) {
|
||||||
this._toolPanels = new Map();
|
this._toolPanels = new Map();
|
||||||
this._telemetry = new Telemetry();
|
this._telemetry = new Telemetry();
|
||||||
|
|
||||||
// TODO: This approach to source maps uses server-side source maps, which we are
|
|
||||||
// replacing with client-side source maps. Do not use this in new code paths.
|
|
||||||
// To be removed in bug 1349354. Read more about ongoing work with source maps:
|
|
||||||
// https://docs.google.com/document/d/19TKnMJD3CMBzwByNE4aBBVWnl-AEan8Sf4hxi6J-eps/edit
|
|
||||||
if (Services.prefs.getBoolPref("devtools.source-map.locations.enabled")) {
|
|
||||||
this._deprecatedServerSourceMapService = new SourceMapService(this._target);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._initInspector = null;
|
this._initInspector = null;
|
||||||
this._inspector = null;
|
this._inspector = null;
|
||||||
|
|
||||||
|
@ -2316,11 +2306,6 @@ Toolbox.prototype = {
|
||||||
|
|
||||||
this._lastFocusedElement = null;
|
this._lastFocusedElement = null;
|
||||||
|
|
||||||
if (this._deprecatedServerSourceMapService) {
|
|
||||||
this._deprecatedServerSourceMapService.destroy();
|
|
||||||
this._deprecatedServerSourceMapService = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._sourceMapURLService) {
|
if (this._sourceMapURLService) {
|
||||||
this._sourceMapURLService.destroy();
|
this._sourceMapURLService.destroy();
|
||||||
this._sourceMapURLService = null;
|
this._sourceMapURLService = null;
|
||||||
|
|
|
@ -303,13 +303,6 @@ pref("devtools.webconsole.new-frontend-enabled", true);
|
||||||
pref("devtools.webconsole.new-frontend-enabled", false);
|
pref("devtools.webconsole.new-frontend-enabled", false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enable the server-side mapping service for source maps in console (deprecated)
|
|
||||||
// NOTE: This approach to source maps uses server-side source maps, which we are
|
|
||||||
// replacing with client-side source maps. Do not use this in new code paths.
|
|
||||||
// To be removed in bug 1349354. Read more about ongoing work with source maps:
|
|
||||||
// https://docs.google.com/document/d/19TKnMJD3CMBzwByNE4aBBVWnl-AEan8Sf4hxi6J-eps/edit
|
|
||||||
pref("devtools.source-map.locations.enabled", false);
|
|
||||||
|
|
||||||
// Enable client-side mapping service for source maps
|
// Enable client-side mapping service for source maps
|
||||||
pref("devtools.source-map.client-service.enabled", true);
|
pref("devtools.source-map.client-service.enabled", true);
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ var Services = require("Services");
|
||||||
var { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
var { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
var promise = require("promise");
|
var promise = require("promise");
|
||||||
var {
|
var {
|
||||||
ActorPool, createExtraActors, appendExtraActors, GeneratedLocation
|
ActorPool, createExtraActors, appendExtraActors
|
||||||
} = require("devtools/server/actors/common");
|
} = require("devtools/server/actors/common");
|
||||||
var { DebuggerServer } = require("devtools/server/main");
|
var { DebuggerServer } = require("devtools/server/main");
|
||||||
var DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
var DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||||
|
@ -1402,51 +1402,6 @@ TabActor.prototype = {
|
||||||
delete this._extraActors[name];
|
delete this._extraActors[name];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes a packet containing a url, line and column and returns
|
|
||||||
* the updated url, line and column based on the current source mapping
|
|
||||||
* (source mapped files, pretty prints).
|
|
||||||
*
|
|
||||||
* @param {String} request.url
|
|
||||||
* @param {Number} request.line
|
|
||||||
* @param {Number?} request.column
|
|
||||||
* @return {Promise<Object>}
|
|
||||||
*/
|
|
||||||
onResolveLocation(request) {
|
|
||||||
let { url, line } = request;
|
|
||||||
let column = request.column || 0;
|
|
||||||
const scripts = this.threadActor.dbg.findScripts({ url });
|
|
||||||
|
|
||||||
if (!scripts[0] || !scripts[0].source) {
|
|
||||||
return promise.resolve({
|
|
||||||
from: this.actorID,
|
|
||||||
type: "resolveLocation",
|
|
||||||
error: "SOURCE_NOT_FOUND"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const source = scripts[0].source;
|
|
||||||
const generatedActor = this.sources.createNonSourceMappedActor(source);
|
|
||||||
let generatedLocation = new GeneratedLocation(
|
|
||||||
generatedActor, line, column);
|
|
||||||
return this.sources.getOriginalLocation(generatedLocation).then(loc => {
|
|
||||||
// If no map found, return this packet
|
|
||||||
if (loc.originalLine == null) {
|
|
||||||
return {
|
|
||||||
type: "resolveLocation",
|
|
||||||
error: "MAP_NOT_FOUND"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
loc = loc.toJSON();
|
|
||||||
return {
|
|
||||||
from: this.actorID,
|
|
||||||
url: loc.source.url,
|
|
||||||
column: loc.column,
|
|
||||||
line: loc.line
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1462,7 +1417,6 @@ TabActor.prototype.requestTypes = {
|
||||||
"switchToFrame": TabActor.prototype.onSwitchToFrame,
|
"switchToFrame": TabActor.prototype.onSwitchToFrame,
|
||||||
"listFrames": TabActor.prototype.onListFrames,
|
"listFrames": TabActor.prototype.onListFrames,
|
||||||
"listWorkers": TabActor.prototype.onListWorkers,
|
"listWorkers": TabActor.prototype.onListWorkers,
|
||||||
"resolveLocation": TabActor.prototype.onResolveLocation
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.TabActor = TabActor;
|
exports.TabActor = TabActor;
|
||||||
|
|
|
@ -1463,19 +1463,6 @@ TabClient.prototype = {
|
||||||
attachWorker: function (workerActor, onResponse) {
|
attachWorker: function (workerActor, onResponse) {
|
||||||
return this.client.attachWorker(workerActor, onResponse);
|
return this.client.attachWorker(workerActor, onResponse);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve a location ({ url, line, column }) to its current
|
|
||||||
* source mapping location.
|
|
||||||
*
|
|
||||||
* @param {String} arg[0].url
|
|
||||||
* @param {Number} arg[0].line
|
|
||||||
* @param {Number?} arg[0].column
|
|
||||||
*/
|
|
||||||
resolveLocation: DebuggerClient.requester({
|
|
||||||
type: "resolveLocation",
|
|
||||||
location: arg(0)
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
eventSource(TabClient.prototype);
|
eventSource(TabClient.prototype);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче