9c385f0405
This method enables test of agent::restore methods. Bonus: forbid setCustomObjectFormatterEnabled on disabled agent. BUG=none R=dgozman@chromium.org Review-Url: https://codereview.chromium.org/2713023004 Cr-Commit-Position: refs/heads/master@{#43502}
94 lines
4.1 KiB
JavaScript
94 lines
4.1 KiB
JavaScript
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
InspectorTest.log("Checks that inspector correctly process compiled scripts");
|
|
|
|
function addScripts() {
|
|
// sourceURL in the same line
|
|
return addScript("function foo1(){}//# sourceURL=oneline.js\n")
|
|
// sourceURL without end line
|
|
.then(() => addScript("function foo2(){}//# sourceURL=oneline-without-nl.js"))
|
|
// other source urls
|
|
.then(() => addScript("function foo3(){}\n//# sourceURL=twoline.js\n"))
|
|
.then(() => addScript("function foo4(){}\n\n//# sourceURL=threeline.js\n"))
|
|
|
|
// sourceMappingURL in the same line
|
|
.then(() => addScript("function foo5(){}//# sourceMappingURL=oneline-map\n"))
|
|
// sourceMappingURL without end line
|
|
.then(() => addScript("function foo6(){}//# sourceMappingURL=oneline-without-nl-map"))
|
|
// other sourceMappingURLs
|
|
.then(() => addScript("function foo7(){}\n//# sourceMappingURL=twoline-map\n"))
|
|
.then(() => addScript("function foo8(){}\n\n//# sourceMappingURL=threeline-map\n"))
|
|
|
|
// sourceURL + sourceMappingURL
|
|
.then(() => addScript("function foo9(){}//# sourceMappingURL=source-mapping-url-map\n//# sourceURL=source-url.js"))
|
|
.then(() => addScript("function foo10(){}//# sourceURL=source-url.js\n//# sourceMappingURL=source-mapping-url-map"))
|
|
|
|
// non zero endLine and endColumn..
|
|
.then(() => addScript("function foo11(){}\n//# sourceURL=end1.js"))
|
|
// .. + 1 character
|
|
.then(() => addScript("function foo12(){}\n//# sourceURL=end2.js "))
|
|
// script without sourceURL
|
|
.then(() => addScript("function foo13(){}"))
|
|
// script in eval
|
|
.then(() => addScript("function foo15(){}; eval(\"function foo14(){}//# sourceURL=eval.js\")//# sourceURL=eval-wrapper.js"))
|
|
// sourceURL and sourceMappingURL works even for script with syntax error
|
|
.then(() => addScript("}//# sourceURL=failed.js\n//# sourceMappingURL=failed-map"))
|
|
// empty lines at end
|
|
.then(() => addScript("function foo16(){}\n"))
|
|
.then(() => addScript("function foo17(){}\n\n"))
|
|
.then(() => addScript("function foo18(){}\n\n\n"))
|
|
.then(() => addScript("function foo19(){}\n\n\n\n"));
|
|
}
|
|
|
|
Protocol.Debugger.onScriptParsed((message) => requestSourceAndDump(message, true));
|
|
Protocol.Debugger.onScriptFailedToParse((message) => requestSourceAndDump(message, false));
|
|
addScripts()
|
|
.then(() => Protocol.Debugger.enable())
|
|
.then(addScripts)
|
|
.then(() => Protocol.Debugger.disable())
|
|
.then(() => InspectorTest.log("Remove script references and re-enable debugger."))
|
|
.then(() => Protocol.Runtime.evaluate(
|
|
{ expression: "for (let i = 1; i < 20; ++i) eval(`foo${i} = undefined`);" }))
|
|
.then(() => Protocol.HeapProfiler.collectGarbage())
|
|
.then(() => Protocol.Debugger.enable())
|
|
.then(InspectorTest.completeTest);
|
|
|
|
function addScript(source) {
|
|
return Protocol.Runtime.evaluate({ expression: source });
|
|
}
|
|
|
|
function requestSourceAndDump(scriptParsedMessage, scriptParsed) {
|
|
Protocol.Debugger.getScriptSource({ scriptId: scriptParsedMessage.params.scriptId })
|
|
.then((sourceMessage) => dumpScriptParsed(scriptParsedMessage, sourceMessage, scriptParsed));
|
|
}
|
|
|
|
function dumpScriptParsed(scriptParsedMessage, sourceMessage, scriptParsed) {
|
|
var params = scriptParsedMessage.params;
|
|
var re = /[A-Z0-9]{40,40}/;
|
|
if (!params.hash || !matchExact(re, params.hash))
|
|
params.hash = "Invalid hash: " + params.hash;
|
|
else
|
|
params.hash = "<hash>";
|
|
if (params.executionContextId <= 0)
|
|
params.executionContextId = "Invalid executionContextId: " + params.executionContextId;
|
|
else
|
|
params.executionContextId = "<executionContextId>";
|
|
if (params.scriptId * 1 <= 0)
|
|
params.scriptId = "Invalid scriptId: " + params.scriptId;
|
|
else
|
|
params.scriptId = "<scriptId>";
|
|
|
|
var sourceResult = sourceMessage.result;
|
|
sourceResult.scriptSource = sourceResult.scriptSource.replace(/\n/g, "<nl>");
|
|
InspectorTest.log(scriptParsed ? "scriptParsed" : "scriptFailedToParse");
|
|
InspectorTest.logObject(sourceResult);
|
|
InspectorTest.logObject(params);
|
|
}
|
|
|
|
function matchExact(re, str) {
|
|
var match = str.match(re);
|
|
return match !== null && str === match[0];
|
|
}
|