mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1084525 - Part 1: Create initial PromisesActor skeleton r=fitzgen
This commit is contained in:
parent
dd5bb481cf
commit
83a240b339
38
toolkit/devtools/server/actors/promises.js
Normal file
38
toolkit/devtools/server/actors/promises.js
Normal file
@ -0,0 +1,38 @@
|
||||
/* 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 protocol = require("devtools/server/protocol");
|
||||
const { method, RetVal, Arg, types } = protocol;
|
||||
|
||||
/**
|
||||
* The Promises Actor provides support for getting the list of live promises and
|
||||
* observing changes to their settlement state.
|
||||
*/
|
||||
let PromisesActor = protocol.ActorClass({
|
||||
typeName: "promises",
|
||||
|
||||
/**
|
||||
* @param conn DebuggerServerConnection.
|
||||
* @param parent TabActor|RootActor
|
||||
*/
|
||||
initialize: function(conn, parent) {
|
||||
protocol.Actor.prototype.initialize.call(this, conn);
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
protocol.Actor.prototype.destroy.call(this, conn);
|
||||
},
|
||||
});
|
||||
|
||||
exports.PromisesActor = PromisesActor;
|
||||
|
||||
exports.PromisesFront = protocol.FrontClass(PromisesActor, {
|
||||
initialize: function(client, form) {
|
||||
protocol.Front.prototype.initialize.call(this, client, form);
|
||||
this.actorID = form.promisesActor;
|
||||
this.manage(this);
|
||||
}
|
||||
});
|
@ -544,6 +544,11 @@ var DebuggerServer = {
|
||||
constructor: "AnimationsActor",
|
||||
type: { tab: true }
|
||||
});
|
||||
this.registerModule("devtools/server/actors/promises", {
|
||||
prefix: "promises",
|
||||
constructor: "PromisesActor",
|
||||
type: { global: true, tab: true }
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -77,6 +77,7 @@ EXTRA_JS_MODULES.devtools.server.actors += [
|
||||
'actors/preference.js',
|
||||
'actors/pretty-print-worker.js',
|
||||
'actors/profiler.js',
|
||||
'actors/promises.js',
|
||||
'actors/root.js',
|
||||
'actors/script.js',
|
||||
'actors/settings.js',
|
||||
|
@ -301,6 +301,20 @@ function initTestDebuggerServer(aServer = DebuggerServer)
|
||||
aServer.init(function () { return true; });
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the testing debugger server with a tab whose title is |title|.
|
||||
*/
|
||||
function startTestDebuggerServer(title, server = DebuggerServer) {
|
||||
initTestDebuggerServer(server);
|
||||
addTestGlobal(title);
|
||||
DebuggerServer.addTabActors();
|
||||
|
||||
let transport = DebuggerServer.connectPipe();
|
||||
let client = new DebuggerClient(transport);
|
||||
|
||||
return connect(client).then(() => client);
|
||||
}
|
||||
|
||||
function initTestTracerServer(aServer = DebuggerServer)
|
||||
{
|
||||
aServer.registerModule("xpcshell-test/testactors");
|
||||
@ -338,6 +352,11 @@ function get_chrome_actors(callback)
|
||||
});
|
||||
}
|
||||
|
||||
function getChromeActors(client, server = DebuggerServer) {
|
||||
server.allowChromeProcess = true;
|
||||
return client.getProcess().then(response => response.form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a relative file path and returns the absolute file url for it.
|
||||
*/
|
||||
|
@ -0,0 +1,29 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test that the PromisesActor exists in the TabActors and ChromeActors.
|
||||
*/
|
||||
|
||||
add_task(function*() {
|
||||
let client = yield startTestDebuggerServer("promises-actor-test");
|
||||
|
||||
let response = yield listTabs(client);
|
||||
let targetTab = findTab(response.tabs, "promises-actor-test");
|
||||
ok(targetTab, "Found our target tab.")
|
||||
|
||||
// Attach to the TabActor and check the response
|
||||
client.request({ to: targetTab.actor, type: "attach" }, response => {
|
||||
ok(!("error" in response), "Expect no error in response.");
|
||||
ok(response.from, targetTab.actor,
|
||||
"Expect the target TabActor in response form field.");
|
||||
ok(response.type, "tabAttached",
|
||||
"Expect tabAttached in the response type.");
|
||||
is(typeof response.promisesActor === "string",
|
||||
"Should have a tab context PromisesActor.");
|
||||
});
|
||||
|
||||
let chromeActors = yield getChromeActors(client);
|
||||
ok(typeof chromeActors.promisesActor === "string",
|
||||
"Should have a chrome context PromisesActor.");
|
||||
});
|
@ -80,6 +80,7 @@ support-files =
|
||||
[test_eval-03.js]
|
||||
[test_eval-04.js]
|
||||
[test_eval-05.js]
|
||||
[test_promises_actor_exist.js]
|
||||
[test_protocol_abort.js]
|
||||
[test_protocol_async.js]
|
||||
[test_protocol_children.js]
|
||||
|
Loading…
Reference in New Issue
Block a user