Bug 1444073 - Remove old-event-emitter usage from webAudioEditor; r=pbro.
MozReview-Commit-ID: C9EozxGTRpa
--- a/devtools/client/webaudioeditor/includes.js
+++ b/devtools/client/webaudioeditor/includes.js
@@ -1,17 +1,16 @@
/* 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 { loader, require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
const { Task } = require("devtools/shared/task");
-const OldEventEmitter = require("devtools/shared/old-event-emitter");
const EventEmitter = require("devtools/shared/event-emitter");
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
const Services = require("Services");
const { gDevTools } = require("devtools/client/framework/devtools");
const { LocalizationHelper } = require("devtools/shared/l10n");
const { ViewHelpers } = require("devtools/client/shared/widgets/view-helpers");
// Use privileged promise in panel documents to prevent having them to freeze
@@ -76,17 +75,17 @@ XPCOMUtils.defineConstant(this, "EVENTS"
/**
* The current target and the Web Audio Editor front, set by this tool's host.
*/
var gToolbox, gTarget, gFront;
/**
* Convenient way of emitting events from the panel window.
*/
-OldEventEmitter.decorate(this);
+EventEmitter.decorate(this);
/**
* DOM query helper.
*/
function $(selector, target = document) { return target.querySelector(selector); }
function $$(selector, target = document) { return target.querySelectorAll(selector); }
/**
--- a/devtools/client/webaudioeditor/panel.js
+++ b/devtools/client/webaudioeditor/panel.js
@@ -1,17 +1,17 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* 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 { Cc, Ci, Cu, Cr } = require("chrome");
-const EventEmitter = require("devtools/shared/old-event-emitter");
+const EventEmitter = require("devtools/shared/event-emitter");
const { WebAudioFront } = require("devtools/shared/fronts/webaudio");
function WebAudioEditorPanel(iframeWindow, toolbox) {
this.panelWin = iframeWindow;
this._toolbox = toolbox;
this._destroyer = null;
EventEmitter.decorate(this);
--- a/devtools/client/webaudioeditor/test/head.js
+++ b/devtools/client/webaudioeditor/test/head.js
@@ -146,17 +146,17 @@ function getNSpread(front, eventName, co
* resolves when the graph was rendered with the correct count of
* nodes and edges.
*/
function waitForGraphRendered(front, nodeCount, edgeCount, paramEdgeCount) {
let eventName = front.EVENTS.UI_GRAPH_RENDERED;
info(`Wait for graph rendered with ${nodeCount} nodes, ${edgeCount} edges`);
return new Promise((resolve, reject) => {
- front.on(eventName, function onGraphRendered(_, nodes, edges, pEdges) {
+ front.on(eventName, function onGraphRendered(nodes, edges, pEdges) {
let paramEdgesDone = paramEdgeCount != null ? paramEdgeCount === pEdges : true;
info(`Got graph rendered with ${nodes} / ${nodeCount} nodes, ` +
`${edges} / ${edgeCount} edges`);
if (nodes === nodeCount && edges === edgeCount && paramEdgesDone) {
front.off(eventName, onGraphRendered);
resolve();
}
});
@@ -202,42 +202,42 @@ function checkVariableView(view, index,
}
function modifyVariableView(win, view, index, prop, value) {
let scope = view.getScopeAtIndex(index);
let aVar = scope.get(prop);
scope.expand();
return new Promise((resolve, reject) => {
- win.on(win.EVENTS.UI_SET_PARAM, handleSetting);
- win.on(win.EVENTS.UI_SET_PARAM_ERROR, handleSetting);
+ const onParamSetSuccess = () => {
+ win.off(win.EVENTS.UI_SET_PARAM_ERROR, onParamSetError);
+ resolve();
+ }
+
+ const onParamSetError = () => {
+ win.off(win.EVENTS.UI_SET_PARAM, onParamSetSuccess);
+ reject();
+ }
+ win.once(win.EVENTS.UI_SET_PARAM, onParamSetSuccess);
+ win.once(win.EVENTS.UI_SET_PARAM_ERROR, onParamSetError);
// Focus and select the variable to begin editing
win.focus();
aVar.focus();
EventUtils.sendKey("RETURN", win);
// Must wait for the scope DOM to be available to receive
// events
executeSoon(() => {
info("Setting " + value + " for " + prop + "....");
for (let c of (value + "")) {
EventUtils.synthesizeKey(c, {}, win);
}
EventUtils.sendKey("RETURN", win);
});
-
- function handleSetting(eventName) {
- win.off(win.EVENTS.UI_SET_PARAM, handleSetting);
- win.off(win.EVENTS.UI_SET_PARAM_ERROR, handleSetting);
- if (eventName === win.EVENTS.UI_SET_PARAM)
- resolve();
- if (eventName === win.EVENTS.UI_SET_PARAM_ERROR)
- reject();
- }
});
}
function findGraphEdge(win, source, target, param) {
let selector = ".edgePaths .edgePath[data-source='" + source + "'][data-target='" + target + "']";
if (param) {
selector += "[data-param='" + param + "']";
}
--- a/devtools/client/webaudioeditor/views/automation.js
+++ b/devtools/client/webaudioeditor/views/automation.js
@@ -148,12 +148,12 @@ var AutomationView = {
*/
_onResize: function () {
this.graph.refresh();
},
/**
* Called when the inspector view determines a node is selected.
*/
- _onNodeSet: function (_, id) {
+ _onNodeSet: function (id) {
this._setAudioNode(id != null ? gAudioNodes.get(id) : null);
}
};
--- a/devtools/client/webaudioeditor/views/context.js
+++ b/devtools/client/webaudioeditor/views/context.js
@@ -280,17 +280,17 @@ var ContextView = {
if (~GRAPH_REDRAW_EVENTS.indexOf(eventName)) {
this.draw();
}
},
/**
* Fired when the devtools theme changes.
*/
- _onThemeChange: function (eventName, theme) {
+ _onThemeChange: function (theme) {
let markerColor = MARKER_STYLING[theme];
let marker = $("#arrowhead");
if (marker) {
marker.setAttribute("style", "fill: " + markerColor);
}
},
/**
--- a/devtools/client/webaudioeditor/views/inspector.js
+++ b/devtools/client/webaudioeditor/views/inspector.js
@@ -136,17 +136,17 @@ var InspectorView = {
/**
* Event handlers
*/
/**
* Called on EVENTS.UI_SELECT_NODE, and takes an actorID `id`
* and calls `setCurrentAudioNode` to scaffold the inspector view.
*/
- _onNodeSelect: function (_, id) {
+ _onNodeSelect: function (id) {
this.setCurrentAudioNode(gAudioNodes.get(id));
// Ensure inspector is visible when selecting a new node
this.show();
},
_onResize: function () {
if (this.el.getAttribute("width") < MIN_INSPECTOR_WIDTH) {
--- a/devtools/client/webaudioeditor/views/properties.js
+++ b/devtools/client/webaudioeditor/views/properties.js
@@ -114,17 +114,17 @@ var PropertiesView = {
/**
* Event handlers
*/
/**
* Called when the inspector view determines a node is selected.
*/
- _onNodeSet: function (_, id) {
+ _onNodeSet: function (id) {
this._setAudioNode(gAudioNodes.get(id));
},
/**
* Executed when an audio prop is changed in the UI.
*/
_onEval: Task.async(function* (variable, value) {
let ownerScope = variable.ownerView;