mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 23:38:38 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
76
devtools/server/tests/unit/test_monitor_actor.js
Normal file
76
devtools/server/tests/unit/test_monitor_actor.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test the monitor actor.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
function run_test()
|
||||
{
|
||||
let EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
function MonitorClient(client, form) {
|
||||
this.client = client;
|
||||
this.actor = form.monitorActor;
|
||||
this.events = ["update"];
|
||||
|
||||
EventEmitter.decorate(this);
|
||||
client.registerClient(this);
|
||||
}
|
||||
MonitorClient.prototype.destroy = function () {
|
||||
this.client.unregisterClient(this);
|
||||
};
|
||||
MonitorClient.prototype.start = function (callback) {
|
||||
this.client.request({
|
||||
to: this.actor,
|
||||
type: "start"
|
||||
}, callback);
|
||||
};
|
||||
MonitorClient.prototype.stop = function (callback) {
|
||||
this.client.request({
|
||||
to: this.actor,
|
||||
type: "stop"
|
||||
}, callback);
|
||||
};
|
||||
|
||||
let monitor, client;
|
||||
|
||||
// Start the monitor actor.
|
||||
get_chrome_actors((c, form) => {
|
||||
client = c;
|
||||
monitor = new MonitorClient(client, form);
|
||||
monitor.on("update", gotUpdate);
|
||||
monitor.start(update);
|
||||
});
|
||||
|
||||
let time = Date.now();
|
||||
|
||||
function update() {
|
||||
let event = {
|
||||
graph: "Test",
|
||||
curve: "test",
|
||||
value: 42,
|
||||
time: time,
|
||||
};
|
||||
Services.obs.notifyObservers(null, "devtools-monitor-update", JSON.stringify(event));
|
||||
}
|
||||
|
||||
function gotUpdate(type, packet) {
|
||||
packet.data.forEach(function (event) {
|
||||
// Ignore updates that were not sent by this test.
|
||||
if (event.graph === "Test") {
|
||||
do_check_eq(event.curve, "test");
|
||||
do_check_eq(event.value, 42);
|
||||
do_check_eq(event.time, time);
|
||||
monitor.stop(function (aResponse) {
|
||||
monitor.destroy();
|
||||
finishClient(client);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue