зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1601688 - Use emitForTests when events are only used in tests. r=Honza.
Differential Revision: https://phabricator.services.mozilla.com/D57500 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0449ac6039
Коммит
518e315e71
|
@ -654,7 +654,7 @@ class JSTerm extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
this.emit("set-input-value");
|
||||
this.emitForTests("set-input-value");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -79,7 +79,7 @@ class Message extends Component {
|
|||
timeStamp: PropTypes.number,
|
||||
timestampsVisible: PropTypes.bool.isRequired,
|
||||
serviceContainer: PropTypes.shape({
|
||||
emitEvent: PropTypes.func.isRequired,
|
||||
emitForTests: PropTypes.func.isRequired,
|
||||
onViewSource: PropTypes.func.isRequired,
|
||||
onViewSourceInDebugger: PropTypes.func,
|
||||
onViewSourceInStyleEditor: PropTypes.func,
|
||||
|
@ -135,7 +135,7 @@ class Message extends Component {
|
|||
// did not emit for them.
|
||||
emitNewMessage(node) {
|
||||
const { serviceContainer, messageId, timeStamp } = this.props;
|
||||
serviceContainer.emitEvent(
|
||||
serviceContainer.emitForTests(
|
||||
"new-messages",
|
||||
new Set([{ node, messageId, timeStamp }])
|
||||
);
|
||||
|
|
|
@ -47,7 +47,9 @@ function enableActorReleaser(webConsoleUI) {
|
|||
});
|
||||
|
||||
// Emit an event we can listen to to make sure all the fronts were released.
|
||||
Promise.all(promises).then(() => webConsoleUI.emit("fronts-released"));
|
||||
Promise.all(promises).then(() =>
|
||||
webConsoleUI.emitForTests("fronts-released")
|
||||
);
|
||||
|
||||
// Reset `frontsToRelease` in message reducer.
|
||||
state = reducer(state, {
|
||||
|
|
|
@ -26,7 +26,7 @@ function setupServiceContainer({
|
|||
const { screenX, screenY } = event;
|
||||
const menu = createEditContextMenu(window, "webconsole-menu");
|
||||
// Emit the "menu-open" event for testing.
|
||||
menu.once("open", () => webConsoleWrapper.emit("menu-open"));
|
||||
menu.once("open", () => webConsoleWrapper.emitForTests("menu-open"));
|
||||
menu.popup(screenX, screenY, hud.chromeWindow.document);
|
||||
},
|
||||
|
||||
|
@ -46,7 +46,7 @@ function setupServiceContainer({
|
|||
webConsoleUI.onMessageHover(type, message),
|
||||
getLongString: grip => webConsoleUI.getLongString(grip),
|
||||
getJsTermTooltipAnchor: () => webConsoleUI.getJsTermTooltipAnchor(),
|
||||
emitEvent: (event, value) => webConsoleUI.emit(event, value),
|
||||
emitForTests: (event, value) => webConsoleUI.emitForTests(event, value),
|
||||
attachRefToWebConsoleUI: (id, node) => webConsoleUI.attachRef(id, node),
|
||||
requestData: (id, type) => webConsoleWrapper.requestData(id, type),
|
||||
createElement: nodename => webConsoleWrapper.createElement(nodename),
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
module.exports = {
|
||||
attachRefToWebConsoleUI: () => {},
|
||||
canRewind: () => false,
|
||||
emitEvent: () => {},
|
||||
emitForTests: () => {},
|
||||
proxy: {
|
||||
client: {},
|
||||
releaseActor: actor => console.log("Release actor", actor),
|
||||
|
|
|
@ -131,6 +131,7 @@ function getWebConsoleUiMock(hud, proxyOverrides) {
|
|||
const proxy = getProxyMock(proxyOverrides);
|
||||
return {
|
||||
emit: () => {},
|
||||
emitForTests: () => {},
|
||||
hud,
|
||||
proxy,
|
||||
clearNetworkRequests: () => {},
|
||||
|
|
|
@ -293,7 +293,7 @@ function createContextMenu(event, message, webConsoleWrapper) {
|
|||
|
||||
// Emit the "menu-open" event for testing.
|
||||
const { screenX, screenY } = event;
|
||||
menu.once("open", () => webConsoleWrapper.emit("menu-open"));
|
||||
menu.once("open", () => webConsoleWrapper.emitForTests("menu-open"));
|
||||
menu.popup(screenX, screenY, hud.chromeWindow.document);
|
||||
|
||||
return menu;
|
||||
|
|
|
@ -229,7 +229,7 @@ class WebConsoleUI {
|
|||
if (clearStorage) {
|
||||
this.clearMessagesCache();
|
||||
}
|
||||
this.emit("messages-cleared");
|
||||
this.emitForTests("messages-cleared");
|
||||
}
|
||||
|
||||
clearNetworkRequests() {
|
||||
|
@ -252,7 +252,7 @@ class WebConsoleUI {
|
|||
clearPrivateMessages() {
|
||||
if (this.wrapper) {
|
||||
this.wrapper.dispatchPrivateMessagesClear();
|
||||
this.emit("private-messages-cleared");
|
||||
this.emitForTests("private-messages-cleared");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,38 +129,8 @@ class WebConsoleWrapper {
|
|||
});
|
||||
}
|
||||
|
||||
dispatchMessageAdd(packet, waitForResponse) {
|
||||
// Wait for the message to render to resolve with the DOM node.
|
||||
// This is just for backwards compatibility with old tests, and should
|
||||
// be removed once it's not needed anymore.
|
||||
// Can only wait for response if the action contains a valid message.
|
||||
let promise;
|
||||
// Also, do not expect any update while the panel is in background.
|
||||
if (waitForResponse && document.visibilityState === "visible") {
|
||||
const timeStampToMatch = packet.message
|
||||
? packet.message.timeStamp
|
||||
: packet.timestamp;
|
||||
|
||||
promise = new Promise(resolve => {
|
||||
this.webConsoleUI.on(
|
||||
"new-messages",
|
||||
function onThisMessage(messages) {
|
||||
for (const m of messages) {
|
||||
if (m.timeStamp === timeStampToMatch) {
|
||||
resolve(m.node);
|
||||
this.webConsoleUI.off("new-messages", onThisMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
});
|
||||
} else {
|
||||
promise = Promise.resolve();
|
||||
}
|
||||
|
||||
this.batchedMessageAdd(packet);
|
||||
return promise;
|
||||
dispatchMessageAdd(packet) {
|
||||
this.batchedMessagesAdd([packet]);
|
||||
}
|
||||
|
||||
dispatchMessagesAdd(messages) {
|
||||
|
@ -175,7 +145,7 @@ class WebConsoleWrapper {
|
|||
this.queuedMessageUpdates = [];
|
||||
this.queuedRequestUpdates = [];
|
||||
store.dispatch(actions.messagesClear());
|
||||
this.webConsoleUI.emit("messages-cleared");
|
||||
this.webConsoleUI.emitForTests("messages-cleared");
|
||||
}
|
||||
|
||||
dispatchPrivateMessagesClear() {
|
||||
|
@ -305,11 +275,6 @@ class WebConsoleWrapper {
|
|||
return this.setTimeoutIfNeeded();
|
||||
}
|
||||
|
||||
batchedMessageAdd(message) {
|
||||
this.queuedMessageAdds.push(message);
|
||||
this.setTimeoutIfNeeded();
|
||||
}
|
||||
|
||||
batchedMessagesAdd(messages) {
|
||||
this.queuedMessageAdds = this.queuedMessageAdds.concat(messages);
|
||||
this.setTimeoutIfNeeded();
|
||||
|
@ -384,7 +349,7 @@ class WebConsoleWrapper {
|
|||
await store.dispatch(
|
||||
actions.networkMessageUpdate(message, null, res)
|
||||
);
|
||||
this.webConsoleUI.emit("network-message-updated", res);
|
||||
this.webConsoleUI.emitForTests("network-message-updated", res);
|
||||
}
|
||||
this.queuedMessageUpdates = [];
|
||||
}
|
||||
|
@ -401,7 +366,7 @@ class WebConsoleWrapper {
|
|||
// (netmonitor/src/connector/firefox-data-provider).
|
||||
// This event might be utilized in tests to find the right
|
||||
// time when to finish.
|
||||
this.webConsoleUI.emit("network-request-payload-ready");
|
||||
this.webConsoleUI.emitForTests("network-request-payload-ready");
|
||||
}
|
||||
done();
|
||||
}, 50);
|
||||
|
|
|
@ -254,7 +254,7 @@ class WebConsole {
|
|||
}
|
||||
|
||||
await toolbox.viewSourceInDebugger(sourceURL, sourceLine, sourceColumn);
|
||||
this.ui.emit("source-in-debugger-opened");
|
||||
this.ui.emitForTests("source-in-debugger-opened");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -376,7 +376,7 @@ class WebConsole {
|
|||
);
|
||||
|
||||
this.recordEvent("jump_to_source");
|
||||
this.emit("source-in-debugger-opened");
|
||||
this.emitForTests("source-in-debugger-opened");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче