Backed out 2 changesets (bug 1544694) for XPCshell failures in devtools/server/tests/unit/test_blackboxing-01.js. CLOSED TREE

Backed out changeset 63d133aae187 (bug 1544694)
Backed out changeset fc739beb6782 (bug 1544694)
This commit is contained in:
Dorel Luca 2019-04-23 13:09:41 +03:00
Родитель 31940b3696
Коммит e349607790
5 изменённых файлов: 101 добавлений и 0 удалений

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

@ -260,6 +260,25 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
});
},
/**
* Get all executable lines from the current source
* @return Array - Executable lines of the current script
*/
getExecutableLines: async function() {
const offsetsLines = new Set();
for (const s of this._findDebuggeeScripts()) {
for (const offset of s.getPossibleBreakpoints()) {
offsetsLines.add(offset.lineNumber);
}
}
const lines = [...offsetsLines];
lines.sort((a, b) => {
return a - b;
});
return lines;
},
getBreakpointPositions(query) {
const {
start: {

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

@ -0,0 +1,57 @@
/* 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";
/**
* Test if getExecutableLines return correct information
*/
var gDebuggee;
var gClient;
var gThreadClient;
const SOURCE_MAPPED_FILE = getFileUrl("sourcemapped.js");
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-get-executable-lines");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function _onConnect() {
attachTestTabAndResume(
gClient,
"test-get-executable-lines",
function(response, targetFront, threadClient) {
gThreadClient = threadClient;
test_executable_lines();
}
);
});
do_test_pending();
}
function test_executable_lines() {
gThreadClient.addOneTimeListener("newSource", function _onNewSource(evt, packet) {
Assert.equal(evt, "newSource");
gThreadClient.getSources(function({error, sources}) {
Assert.ok(!error);
const source = gThreadClient.source(sources[0]);
source.getExecutableLines(function(lines) {
Assert.ok(arrays_equal([2, 5, 7, 8, 10, 12, 14, 16, 17], lines));
finishClient(gClient);
});
});
});
const code = readFile("sourcemapped.js");
Cu.evalInSandbox(code, gDebuggee, "1.8",
SOURCE_MAPPED_FILE, 1);
}
function arrays_equal(a, b) {
return !(a < b || b < a);
}

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

@ -217,6 +217,7 @@ reason = bug 937197
[test_client_request.js]
[test_symbols-01.js]
[test_symbols-02.js]
[test_get-executable-lines.js]
[test_xpcshell_debugging.js]
support-files = xpcshell_debugging_script.js
[test_setBreakpoint-at-the-beginning-of-a-minified-fn.js]

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

@ -6,6 +6,8 @@
const {arg, DebuggerClient} = require("devtools/shared/client/debugger-client");
const noop = () => {};
/**
* A SourceClient provides a way to access the source text of a script.
*
@ -21,9 +23,15 @@ function SourceClient(client, form) {
}
SourceClient.prototype = {
get _transport() {
return this._client._transport;
},
get actor() {
return this._form.actor;
},
get request() {
return this._client.request;
},
get url() {
return this._form.url;
},
@ -54,6 +62,21 @@ SourceClient.prototype = {
},
),
/**
* Get Executable Lines from a source
*/
getExecutableLines: function(cb = noop) {
const packet = {
to: this._form.actor,
type: "getExecutableLines",
};
return this._client.request(packet).then(res => {
cb(res.lines);
return res.lines;
});
},
getBreakpointPositions: function(query) {
const packet = {
to: this._form.actor,

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

@ -22,6 +22,7 @@ const sourceSpec = generateActorSpec({
typeName: "source",
methods: {
getExecutableLines: { response: { lines: RetVal("json") } },
getBreakpointPositions: {
request: {
query: Arg(0, "nullable:breakpointquery"),