Bug 1517167 Part 2 - Watch for dynamically generated <scripts> in devtools server/client, NOT REVIEWED YET.

--HG--
extra : rebase_source : 2c7d2c98f0d44cc0c07af6d3f5642425eb6cf0f2
This commit is contained in:
Brian Hackett 2019-01-03 06:27:48 -10:00
parent 655a9a04fe
commit 1ed7757baf
4 changed files with 27 additions and 2 deletions

View File

@ -88,7 +88,16 @@ function loadSourceMap(sourceId: SourceId) {
let urls = null;
try {
urls = await sourceMaps.getOriginalURLs(source);
const urlInfo = { ...source };
if (!urlInfo.url) {
// If the source was dynamically generated (via eval, dynamically
// created script elements, and so forth), it won't have a URL, so that
// it is not collapsed into other sources from the same place. The
// introduction URL will include the point it was constructed at,
// however, so use that for resolving any source maps in the source.
urlInfo.url = urlInfo.introductionUrl;
}
urls = await sourceMaps.getOriginalURLs(urlInfo);
} catch (e) {
console.error(e);
}

View File

@ -55,6 +55,7 @@ export function createSource(
isPrettyPrinted: false,
isWasm: false,
sourceMapURL: source.sourceMapURL,
introductionUrl: source.introductionUrl,
isBlackBoxed: false,
loadedState: "unloaded"
};

View File

@ -23,6 +23,14 @@ loader.lazyRequireGetter(this, "arrayBufferGrip", "devtools/server/actors/array-
function isEvalSource(source) {
const introType = source.introductionType;
// Script elements that are dynamically created are treated as eval sources.
// We detect these by looking at whether there was another script on the stack
// when the source was created.
if (introType == "scriptElement" && source.introductionScript) {
return true;
}
// These are all the sources that are essentially eval-ed (either
// by calling eval or passing a string to one of these functions).
return (introType === "eval" ||

View File

@ -238,7 +238,14 @@ TabSources.prototype = {
// script element, or does not have a src attribute.
const element = source.element ? source.element.unsafeDereference() : null;
if (element && (element.tagName !== "SCRIPT" || !element.hasAttribute("src"))) {
spec.isInlineSource = true;
if (source.introductionScript) {
// As for other evaluated sources, script elements which were
// dynamically generated when another script ran should have
// a javascript content-type.
spec.contentType = "text/javascript";
} else {
spec.isInlineSource = true;
}
} else if (source.introductionType === "wasm") {
// Wasm sources are not JavaScript. Give them their own content-type.
spec.contentType = "text/wasm";