mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
001f607134
--HG-- rename : browser/devtools/framework/Sidebar.jsm => browser/devtools/framework/sidebar.js rename : browser/devtools/framework/Target.jsm => browser/devtools/framework/target.js rename : browser/devtools/framework/ToolboxHosts.jsm => browser/devtools/framework/toolbox-hosts.js rename : browser/devtools/framework/Toolbox.jsm => browser/devtools/framework/toolbox.js rename : browser/devtools/inspector/Breadcrumbs.jsm => browser/devtools/inspector/breadcrumbs.js rename : browser/devtools/inspector/Highlighter.jsm => browser/devtools/inspector/highlighter.js rename : browser/devtools/inspector/InspectorPanel.jsm => browser/devtools/inspector/inspector-panel.js rename : browser/devtools/inspector/Selection.jsm => browser/devtools/inspector/selection.js rename : browser/devtools/inspector/SelectorSearch.jsm => browser/devtools/inspector/selector-search.js rename : browser/devtools/framework/ToolDefinitions.jsm => browser/devtools/main.js rename : browser/devtools/markupview/MarkupView.jsm => browser/devtools/markupview/markup-view.js rename : browser/devtools/shared/EventEmitter.jsm => browser/devtools/shared/event-emitter.js rename : browser/devtools/shared/InplaceEditor.jsm => browser/devtools/shared/inplace-editor.js rename : browser/devtools/shared/Undo.jsm => browser/devtools/shared/undo.js rename : browser/devtools/styleinspector/CssHtmlTree.jsm => browser/devtools/styleinspector/computed-view.js rename : browser/devtools/styleinspector/CssLogic.jsm => browser/devtools/styleinspector/css-logic.js rename : browser/devtools/styleinspector/CssRuleView.jsm => browser/devtools/styleinspector/rule-view.js rename : browser/devtools/styleinspector/StyleInspector.jsm => browser/devtools/styleinspector/style-inspector.js rename : browser/devtools/tilt/TiltGL.jsm => browser/devtools/tilt/tilt-gl.js rename : browser/devtools/tilt/TiltMath.jsm => browser/devtools/tilt/tilt-math.js rename : browser/devtools/tilt/TiltUtils.jsm => browser/devtools/tilt/tilt-utils.js rename : browser/devtools/tilt/TiltVisualizerStyle.jsm => browser/devtools/tilt/tilt-visualizer-style.js rename : browser/devtools/tilt/TiltVisualizer.jsm => browser/devtools/tilt/tilt-visualizer.js rename : browser/devtools/tilt/Tilt.jsm => browser/devtools/tilt/tilt.js
81 lines
1.6 KiB
JavaScript
81 lines
1.6 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
function test() {
|
|
testEmitter();
|
|
testEmitter({});
|
|
}
|
|
|
|
|
|
function testEmitter(aObject) {
|
|
Cu.import("resource:///modules/devtools/shared/event-emitter.js", this);
|
|
|
|
let emitter;
|
|
|
|
if (aObject) {
|
|
emitter = aObject;
|
|
EventEmitter.decorate(emitter);
|
|
} else {
|
|
emitter = new EventEmitter();
|
|
}
|
|
|
|
ok(emitter, "We have an event emitter");
|
|
|
|
emitter.on("next", next);
|
|
emitter.emit("next", "abc", "def");
|
|
|
|
let beenHere1 = false;
|
|
function next(eventName, str1, str2) {
|
|
is(eventName, "next", "Got event");
|
|
is(str1, "abc", "Argument 1 is correct");
|
|
is(str2, "def", "Argument 2 is correct");
|
|
|
|
ok(!beenHere1, "first time in next callback");
|
|
beenHere1 = true;
|
|
|
|
emitter.off("next", next);
|
|
|
|
emitter.emit("next");
|
|
|
|
emitter.once("onlyonce", onlyOnce);
|
|
|
|
emitter.emit("onlyonce");
|
|
emitter.emit("onlyonce");
|
|
}
|
|
|
|
let beenHere2 = false;
|
|
function onlyOnce() {
|
|
ok(!beenHere2, "\"once\" listner has been called once");
|
|
beenHere2 = true;
|
|
emitter.emit("onlyonce");
|
|
|
|
killItWhileEmitting();
|
|
}
|
|
|
|
function killItWhileEmitting() {
|
|
function c1() {
|
|
ok(true, "c1 called");
|
|
}
|
|
function c2() {
|
|
ok(true, "c2 called");
|
|
emitter.off("tick", c3);
|
|
}
|
|
function c3() {
|
|
ok(false, "c3 should not be called");
|
|
}
|
|
function c4() {
|
|
ok(true, "c4 called");
|
|
}
|
|
|
|
emitter.on("tick", c1);
|
|
emitter.on("tick", c2);
|
|
emitter.on("tick", c3);
|
|
emitter.on("tick", c4);
|
|
|
|
emitter.emit("tick");
|
|
|
|
delete emitter;
|
|
finish();
|
|
}
|
|
}
|