зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1164564 - Clean up the helper functions for the debugger tests;r=jlong
This commit is contained in:
Родитель
0bc9390f36
Коммит
73173673b8
|
@ -34,7 +34,7 @@ function test() {
|
|||
yield ensureThreadClientState(aPanel, "resumed");
|
||||
|
||||
let paused = waitForCaretAndScopes(aPanel, 48);
|
||||
sendMouseClickToTab(gTab, content.document.body);
|
||||
generateMouseClickInTab(gTab, "content.document.body");
|
||||
yield paused;
|
||||
yield ensureThreadClientState(aPanel, "paused");
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ function test() {
|
|||
ok(isCaretPos(gPanel, 9),
|
||||
"The editor location is correct before pausing.");
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
|
||||
return finished;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ function testResume() {
|
|||
});
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ function test() {
|
|||
});
|
||||
|
||||
function testClosure() {
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
|
||||
return waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
|
||||
let gVars = gDebugger.DebuggerView.Variables;
|
||||
|
|
|
@ -49,7 +49,7 @@ function pauseDebuggee(aThreadClient) {
|
|||
deferred.resolve(aThreadClient);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ function pauseDebuggee(aThreadClient) {
|
|||
deferred.resolve(aThreadClient);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ function pauseDebuggee(aThreadClient) {
|
|||
deferred.resolve(aThreadClient);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ function test() {
|
|||
}
|
||||
|
||||
function clickButton() {
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
}
|
||||
|
||||
function testHitCounts() {
|
||||
|
|
|
@ -45,7 +45,7 @@ function test() {
|
|||
}
|
||||
|
||||
function clickButton() {
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
}
|
||||
|
||||
function testHitCountsBeforeStopping() {
|
||||
|
|
|
@ -19,7 +19,7 @@ function test() {
|
|||
|
||||
// Spin the event loop before causing the debuggee to pause, to allow
|
||||
// this function to return first.
|
||||
sendMouseClickToTab(tab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(tab, "content.document.querySelector('button')");
|
||||
|
||||
yield waitForDebuggerEvents(panel, gDebugger.EVENTS.FETCHED_SCOPES);
|
||||
let gVars = gDebugger.DebuggerView.Variables;
|
||||
|
|
|
@ -77,7 +77,7 @@ function testPauseOnExceptionsDisabled() {
|
|||
return finished;
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
|
||||
return finished;
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ function testPauseOnExceptionsEnabled() {
|
|||
return finished;
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
|
||||
return finished;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ function testPauseOnExceptionsAfterReload() {
|
|||
return finished;
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
|
||||
return finished;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ function testNormalReturn() {
|
|||
gDebugger);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.getElementById("return"));
|
||||
generateMouseClickInTab(gTab, "content.document.getElementById('return')");
|
||||
}
|
||||
|
||||
function testReturnWithException() {
|
||||
|
@ -62,7 +62,7 @@ function testReturnWithException() {
|
|||
gDebugger);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.getElementById("throw"));
|
||||
generateMouseClickInTab(gTab, "content.document.getElementById('throw')");
|
||||
}
|
||||
|
||||
function resumeDebuggee() {
|
||||
|
|
|
@ -36,7 +36,7 @@ function test() {
|
|||
}
|
||||
|
||||
function clickButton() {
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
}
|
||||
|
||||
function testTraceLogs() {
|
||||
|
|
|
@ -39,7 +39,7 @@ function test() {
|
|||
}
|
||||
|
||||
function clickButton() {
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
}
|
||||
|
||||
function highlightCall() {
|
||||
|
|
|
@ -50,7 +50,7 @@ function test() {
|
|||
}
|
||||
|
||||
function clickButton() {
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
}
|
||||
|
||||
function clickTraceLog() {
|
||||
|
|
|
@ -40,7 +40,7 @@ function test() {
|
|||
}
|
||||
|
||||
function clickButton() {
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
}
|
||||
|
||||
function clickTraceCall() {
|
||||
|
|
|
@ -69,7 +69,7 @@ function testNoEmptyText() {
|
|||
}
|
||||
|
||||
function clickButton() {
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
|
|
|
@ -60,7 +60,7 @@ function test() {
|
|||
}
|
||||
|
||||
function clickButton() {
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
}
|
||||
|
||||
function pushPref() {
|
||||
|
|
|
@ -114,7 +114,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ function addBreakpoint() {
|
|||
}
|
||||
|
||||
function pauseDebuggee() {
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
|
||||
// The first 'with' scope should be expanded by default, but the
|
||||
// variables haven't been fetched yet. This is how 'with' scopes work.
|
||||
|
|
|
@ -45,7 +45,7 @@ function addBreakpoint() {
|
|||
}
|
||||
|
||||
function pauseDebuggee() {
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
|
||||
// The first 'with' scope should be expanded by default, but the
|
||||
// variables haven't been fetched yet. This is how 'with' scopes work.
|
||||
|
|
|
@ -29,7 +29,7 @@ function test() {
|
|||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
});
|
||||
|
||||
sendMouseClickToTab(gTab, content.document.querySelector("button"));
|
||||
generateMouseClickInTab(gTab, "content.document.querySelector('button')");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -9,59 +9,77 @@ loadSubScript("chrome://marionette/content/EventUtils.js", EventUtils);
|
|||
|
||||
dump("Frame script loaded.\n");
|
||||
|
||||
addMessageListener("test:call", function (message) {
|
||||
dump("Calling function with name " + message.data.name + ".\n");
|
||||
|
||||
let data = message.data;
|
||||
let result = XPCNativeWrapper.unwrap(content)[data.name].apply(undefined, data.args);
|
||||
if (result && result.then) {
|
||||
result.then(() => {
|
||||
sendAsyncMessage("test:call");
|
||||
});
|
||||
} else {
|
||||
sendAsyncMessage("test:call");
|
||||
}
|
||||
});
|
||||
|
||||
addMessageListener("test:click", function (message) {
|
||||
dump("Sending mouse click.\n");
|
||||
|
||||
let target = message.objects.target;
|
||||
EventUtils.synthesizeMouseAtCenter(target, {},
|
||||
target.ownerDocument.defaultView);
|
||||
});
|
||||
|
||||
addMessageListener("test:eval", function (message) {
|
||||
dump("Evalling string " + message.data.string + ".\n");
|
||||
|
||||
let result = content.eval(message.data.string);
|
||||
if (result.then) {
|
||||
result.then(() => {
|
||||
sendAsyncMessage("test:eval");
|
||||
});
|
||||
} else {
|
||||
sendAsyncMessage("test:eval");
|
||||
}
|
||||
});
|
||||
|
||||
let workers = {}
|
||||
|
||||
addMessageListener("test:createWorker", function (message) {
|
||||
dump("Creating worker with url '" + message.data.url + "'.\n");
|
||||
this.call = function (name, args) {
|
||||
dump("Calling function with name " + name + ".\n");
|
||||
|
||||
let url = message.data.url;
|
||||
let worker = new content.Worker(message.data.url);
|
||||
dump("args " + JSON.stringify(args) + "\n");
|
||||
return XPCNativeWrapper.unwrap(content)[name].apply(undefined, args);
|
||||
};
|
||||
|
||||
this._eval = function (string) {
|
||||
dump("Evalling string.\n");
|
||||
|
||||
return content.eval(string);
|
||||
};
|
||||
|
||||
this.generateMouseClick = function (path) {
|
||||
dump("Generating mouse click.\n");
|
||||
|
||||
let target = eval(path);
|
||||
EventUtils.synthesizeMouseAtCenter(target, {},
|
||||
target.ownerDocument.defaultView);
|
||||
};
|
||||
|
||||
this.createWorker = function (url) {
|
||||
dump("Creating worker with url '" + url + "'.\n");
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
let worker = new content.Worker(url);
|
||||
worker.addEventListener("message", function listener() {
|
||||
worker.removeEventListener("message", listener);
|
||||
sendAsyncMessage("test:createWorker");
|
||||
});
|
||||
workers[url] = worker;
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
addMessageListener("test:terminateWorker", function (message) {
|
||||
dump("Terminating worker with url '" + message.data.url + "'.\n");
|
||||
this.terminateWorker = function (url) {
|
||||
dump("Terminating worker with url '" + url + "'.\n");
|
||||
|
||||
let url = message.data.url;
|
||||
workers[url].terminate();
|
||||
delete workers[url];
|
||||
};
|
||||
|
||||
this.postMessageToWorker = function (url, message) {
|
||||
dump("Posting message to worker with url '" + url + "'.\n");
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
let worker = workers[url];
|
||||
worker.postMessage(message);
|
||||
worker.addEventListener("message", function listener() {
|
||||
worker.removeEventListener("message", listener);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
addMessageListener("jsonrpc", function ({ data: { method, params, id } }) {
|
||||
method = this[method];
|
||||
Promise.resolve().then(function () {
|
||||
return method.apply(undefined, params);
|
||||
}).then(function (result) {
|
||||
sendAsyncMessage("jsonrpc", {
|
||||
result: result,
|
||||
error: null,
|
||||
id: id
|
||||
});
|
||||
}, function (error) {
|
||||
sendAsyncMessage("jsonrpc", {
|
||||
result: null,
|
||||
error: error.message.toString(),
|
||||
id: id
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -959,51 +959,6 @@ function popPrefs() {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
function sendMessageToTab(tab, name, data, objects) {
|
||||
info("Sending message with name " + name + " to tab.");
|
||||
|
||||
tab.linkedBrowser.messageManager.sendAsyncMessage(name, data, objects);
|
||||
}
|
||||
|
||||
function waitForMessageFromTab(tab, name) {
|
||||
info("Waiting for message with name " + name + " from tab.");
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
let messageManager = tab.linkedBrowser.messageManager;
|
||||
messageManager.addMessageListener(name, function listener(message) {
|
||||
messageManager.removeMessageListener(name, listener);
|
||||
resolve(message);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function callInTab(tab, name) {
|
||||
info("Calling function with name " + name + " in tab.");
|
||||
|
||||
sendMessageToTab(tab, "test:call", {
|
||||
name: name,
|
||||
args: Array.prototype.slice.call(arguments, 2)
|
||||
});
|
||||
return waitForMessageFromTab(tab, "test:call");
|
||||
}
|
||||
|
||||
function evalInTab(tab, string) {
|
||||
info("Evalling string " + string + " in tab.");
|
||||
|
||||
sendMessageToTab(tab, "test:eval", {
|
||||
string: string,
|
||||
});
|
||||
return waitForMessageFromTab(tab, "test:eval");
|
||||
}
|
||||
|
||||
function sendMouseClickToTab(tab, target) {
|
||||
info("Sending mouse click to tab.");
|
||||
|
||||
sendMessageToTab(tab, "test:click", undefined, {
|
||||
target: target
|
||||
});
|
||||
}
|
||||
|
||||
// Source helpers
|
||||
|
||||
function getSelectedSourceURL(aSources) {
|
||||
|
@ -1026,22 +981,68 @@ function getSourceForm(aSources, aURL) {
|
|||
return item.attachment.source;
|
||||
}
|
||||
|
||||
let nextId = 0;
|
||||
|
||||
function jsonrpc(tab, method, params) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
let currentId = nextId++;
|
||||
let messageManager = tab.linkedBrowser.messageManager;
|
||||
messageManager.sendAsyncMessage("jsonrpc", {
|
||||
method: method,
|
||||
params: params,
|
||||
id: currentId
|
||||
});
|
||||
messageManager.addMessageListener("jsonrpc", function listener({
|
||||
data: { result, error, id }
|
||||
}) {
|
||||
if (id !== currentId) {
|
||||
return;
|
||||
}
|
||||
|
||||
messageManager.removeMessageListener("jsonrpc", listener);
|
||||
if (error != null) {
|
||||
reject(error);
|
||||
}
|
||||
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function callInTab(tab, name) {
|
||||
info("Calling function with name '" + name + "' in tab.");
|
||||
|
||||
return jsonrpc(tab, "call", [name, Array.prototype.slice.call(arguments, 2)]);
|
||||
}
|
||||
|
||||
function evalInTab(tab, string) {
|
||||
info("Evalling string in tab.");
|
||||
|
||||
return jsonrpc(tab, "_eval", [string]);
|
||||
}
|
||||
|
||||
function createWorkerInTab(tab, url) {
|
||||
info("Creating worker with url '" + url + "' in tab.");
|
||||
|
||||
sendMessageToTab(tab, "test:createWorker", {
|
||||
url: url
|
||||
});
|
||||
return waitForMessageFromTab(tab, "test:createWorker");
|
||||
return jsonrpc(tab, "createWorker", [url]);
|
||||
}
|
||||
|
||||
function terminateWorkerInTab(tab, url) {
|
||||
info("Terminating worker with url '" + url + "' in tab.");
|
||||
|
||||
sendMessageToTab(tab, "test:terminateWorker", {
|
||||
url: url
|
||||
});
|
||||
return waitForMessageFromTab(tab, "test:terminateWorker");
|
||||
return jsonrpc(tab, "terminateWorker", [url]);
|
||||
}
|
||||
|
||||
function postMessageToWorkerInTab(tab, url, message) {
|
||||
info("Posting message to worker with url '" + url + "' in tab.");
|
||||
|
||||
return jsonrpc(tab, "postMessageToWorker", [url, message]);
|
||||
}
|
||||
|
||||
function generateMouseClickInTab(tab, path) {
|
||||
info("Generating mouse click in tab.");
|
||||
|
||||
return jsonrpc(tab, "generateMouseClick", [path]);
|
||||
}
|
||||
|
||||
function connect(client) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче