2019-09-20 22:16:42 +03:00
|
|
|
/* 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 {
|
|
|
|
createContextMenu,
|
|
|
|
} = require("devtools/client/webconsole/utils/context-menu");
|
|
|
|
|
|
|
|
const {
|
|
|
|
createEditContextMenu,
|
|
|
|
} = require("devtools/client/framework/toolbox-context-menu");
|
|
|
|
|
|
|
|
function setupServiceContainer({
|
|
|
|
webConsoleUI,
|
|
|
|
hud,
|
|
|
|
toolbox,
|
2019-10-03 01:50:25 +03:00
|
|
|
webConsoleWrapper,
|
2019-09-20 22:16:42 +03:00
|
|
|
}) {
|
|
|
|
const serviceContainer = {
|
2019-10-03 01:50:25 +03:00
|
|
|
openContextMenu: (event, message) =>
|
|
|
|
createContextMenu(event, message, webConsoleWrapper),
|
|
|
|
|
|
|
|
openEditContextMenu: event => {
|
|
|
|
const { screenX, screenY } = event;
|
|
|
|
const menu = createEditContextMenu(window, "webconsole-menu");
|
|
|
|
// Emit the "menu-open" event for testing.
|
2020-01-09 19:07:42 +03:00
|
|
|
menu.once("open", () => webConsoleWrapper.emitForTests("menu-open"));
|
2019-10-03 01:50:25 +03:00
|
|
|
menu.popup(screenX, screenY, hud.chromeWindow.document);
|
|
|
|
},
|
|
|
|
|
|
|
|
// NOTE these methods are proxied currently because the
|
|
|
|
// service container is passed down the tree. These methods should eventually
|
|
|
|
// be moved to redux actions.
|
|
|
|
recordTelemetryEvent: (event, extra = {}) => hud.recordEvent(event, extra),
|
|
|
|
openLink: (url, e) => hud.openLink(url, e),
|
|
|
|
openNodeInInspector: grip => hud.openNodeInInspector(grip),
|
|
|
|
getInputSelection: () => hud.getInputSelection(),
|
|
|
|
onViewSource: frame => hud.viewSource(frame.url, frame.line),
|
|
|
|
resendNetworkRequest: requestId => hud.resendNetworkRequest(requestId),
|
|
|
|
focusInput: () => hud.focusInput(),
|
|
|
|
setInputValue: value => hud.setInputValue(value),
|
|
|
|
canRewind: () => hud.canRewind(),
|
2019-10-09 00:48:06 +03:00
|
|
|
onMessageHover: (type, message) =>
|
|
|
|
webConsoleUI.onMessageHover(type, message),
|
2019-10-03 01:50:25 +03:00
|
|
|
getLongString: grip => webConsoleUI.getLongString(grip),
|
|
|
|
getJsTermTooltipAnchor: () => webConsoleUI.getJsTermTooltipAnchor(),
|
2020-01-09 19:07:42 +03:00
|
|
|
emitForTests: (event, value) => webConsoleUI.emitForTests(event, value),
|
2019-10-03 01:50:25 +03:00
|
|
|
attachRefToWebConsoleUI: (id, node) => webConsoleUI.attachRef(id, node),
|
|
|
|
requestData: (id, type) => webConsoleWrapper.requestData(id, type),
|
|
|
|
createElement: nodename => webConsoleWrapper.createElement(nodename),
|
2019-09-20 22:16:42 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
if (toolbox) {
|
2019-10-21 11:27:11 +03:00
|
|
|
const { highlight, unhighlight } = toolbox.getHighlighter();
|
2019-09-20 22:16:42 +03:00
|
|
|
|
|
|
|
Object.assign(serviceContainer, {
|
2019-10-03 01:50:25 +03:00
|
|
|
sourceMapService: toolbox.sourceMapURLService,
|
2019-09-20 22:16:42 +03:00
|
|
|
highlightDomElement: highlight,
|
|
|
|
unHighlightDomElement: unhighlight,
|
|
|
|
jumpToExecutionPoint: executionPoint =>
|
|
|
|
toolbox.threadFront.timeWarp(executionPoint),
|
2019-10-03 01:50:25 +03:00
|
|
|
onViewSourceInDebugger: frame => hud.onViewSourceInDebugger(frame),
|
|
|
|
onViewSourceInStyleEditor: frame => hud.onViewSourceInStyleEditor(frame),
|
2019-09-20 22:16:42 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return serviceContainer;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports.setupServiceContainer = setupServiceContainer;
|