forked from mirrors/gecko-dev
This changeset is the result of running `hg mv devtools/shared/fronts/ devtools/client` The necessary adaptations (renaming and moz.build changes) have been split in other patches for the review. Differential Revision: https://phabricator.services.mozilla.com/D67603 --HG-- rename : devtools/shared/fronts/accessibility.js => devtools/client/fronts/accessibility.js rename : devtools/shared/fronts/addon/addons.js => devtools/client/fronts/addon/addons.js rename : devtools/shared/fronts/addon/moz.build => devtools/client/fronts/addon/moz.build rename : devtools/shared/fronts/addon/webextension-inspected-window.js => devtools/client/fronts/addon/webextension-inspected-window.js rename : devtools/shared/fronts/animation.js => devtools/client/fronts/animation.js rename : devtools/shared/fronts/array-buffer.js => devtools/client/fronts/array-buffer.js rename : devtools/shared/fronts/changes.js => devtools/client/fronts/changes.js rename : devtools/shared/fronts/content-viewer.js => devtools/client/fronts/content-viewer.js rename : devtools/shared/fronts/css-properties.js => devtools/client/fronts/css-properties.js rename : devtools/shared/fronts/descriptors/frame.js => devtools/client/fronts/descriptors/frame.js rename : devtools/shared/fronts/descriptors/moz.build => devtools/client/fronts/descriptors/moz.build rename : devtools/shared/fronts/descriptors/process.js => devtools/client/fronts/descriptors/process.js rename : devtools/shared/fronts/descriptors/tab.js => devtools/client/fronts/descriptors/tab.js rename : devtools/shared/fronts/descriptors/webextension.js => devtools/client/fronts/descriptors/webextension.js rename : devtools/shared/fronts/device.js => devtools/client/fronts/device.js rename : devtools/shared/fronts/environment.js => devtools/client/fronts/environment.js rename : devtools/shared/fronts/frame.js => devtools/client/fronts/frame.js rename : devtools/shared/fronts/framerate.js => devtools/client/fronts/framerate.js rename : devtools/shared/fronts/highlighters.js => devtools/client/fronts/highlighters.js rename : devtools/shared/fronts/inspector.js => devtools/client/fronts/inspector.js rename : devtools/shared/fronts/inspector/moz.build => devtools/client/fronts/inspector/moz.build rename : devtools/shared/fronts/inspector/rule-rewriter.js => devtools/client/fronts/inspector/rule-rewriter.js rename : devtools/shared/fronts/layout.js => devtools/client/fronts/layout.js rename : devtools/shared/fronts/manifest.js => devtools/client/fronts/manifest.js rename : devtools/shared/fronts/memory.js => devtools/client/fronts/memory.js rename : devtools/shared/fronts/moz.build => devtools/client/fronts/moz.build rename : devtools/shared/fronts/node.js => devtools/client/fronts/node.js rename : devtools/shared/fronts/object.js => devtools/client/fronts/object.js rename : devtools/shared/fronts/perf.js => devtools/client/fronts/perf.js rename : devtools/shared/fronts/performance-recording.js => devtools/client/fronts/performance-recording.js rename : devtools/shared/fronts/performance.js => devtools/client/fronts/performance.js rename : devtools/shared/fronts/preference.js => devtools/client/fronts/preference.js rename : devtools/shared/fronts/property-iterator.js => devtools/client/fronts/property-iterator.js rename : devtools/shared/fronts/reflow.js => devtools/client/fronts/reflow.js rename : devtools/shared/fronts/responsive.js => devtools/client/fronts/responsive.js rename : devtools/shared/fronts/root.js => devtools/client/fronts/root.js rename : devtools/shared/fronts/screenshot.js => devtools/client/fronts/screenshot.js rename : devtools/shared/fronts/source.js => devtools/client/fronts/source.js rename : devtools/shared/fronts/storage.js => devtools/client/fronts/storage.js rename : devtools/shared/fronts/string.js => devtools/client/fronts/string.js rename : devtools/shared/fronts/styles.js => devtools/client/fronts/styles.js rename : devtools/shared/fronts/stylesheets.js => devtools/client/fronts/stylesheets.js rename : devtools/shared/fronts/symbol-iterator.js => devtools/client/fronts/symbol-iterator.js rename : devtools/shared/fronts/targets/browsing-context.js => devtools/client/fronts/targets/browsing-context.js rename : devtools/shared/fronts/targets/content-process.js => devtools/client/fronts/targets/content-process.js rename : devtools/shared/fronts/targets/local-tab.js => devtools/client/fronts/targets/local-tab.js rename : devtools/shared/fronts/targets/moz.build => devtools/client/fronts/targets/moz.build rename : devtools/shared/fronts/targets/target-mixin.js => devtools/client/fronts/targets/target-mixin.js rename : devtools/shared/fronts/targets/worker.js => devtools/client/fronts/targets/worker.js rename : devtools/shared/fronts/thread.js => devtools/client/fronts/thread.js rename : devtools/shared/fronts/walker.js => devtools/client/fronts/walker.js rename : devtools/shared/fronts/webconsole.js => devtools/client/fronts/webconsole.js rename : devtools/shared/fronts/websocket.js => devtools/client/fronts/websocket.js rename : devtools/shared/fronts/worker/moz.build => devtools/client/fronts/worker/moz.build rename : devtools/shared/fronts/worker/push-subscription.js => devtools/client/fronts/worker/push-subscription.js rename : devtools/shared/fronts/worker/service-worker-registration.js => devtools/client/fronts/worker/service-worker-registration.js rename : devtools/shared/fronts/worker/service-worker.js => devtools/client/fronts/worker/service-worker.js extra : moz-landing-system : lando
115 lines
3.3 KiB
JavaScript
115 lines
3.3 KiB
JavaScript
/* 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 {
|
|
FrontClassWithSpec,
|
|
registerFront,
|
|
} = require("devtools/shared/protocol");
|
|
const { webSocketSpec } = require("devtools/shared/specs/websocket");
|
|
|
|
/**
|
|
* A WebSocketFront is used as a front end for the WebSocketActor that is
|
|
* created on the server, hiding implementation details.
|
|
*/
|
|
class WebSocketFront extends FrontClassWithSpec(webSocketSpec) {
|
|
constructor(client, targetFront, parentFront) {
|
|
super(client, targetFront, parentFront);
|
|
|
|
this._onWebSocketOpened = this._onWebSocketOpened.bind(this);
|
|
this._onWebSocketClosed = this._onWebSocketClosed.bind(this);
|
|
this._onFrameSent = this._onFrameSent.bind(this);
|
|
this._onFrameReceived = this._onFrameReceived.bind(this);
|
|
|
|
// Attribute name from which to retrieve the actorID
|
|
// out of the target actor's form
|
|
this.formAttributeName = "webSocketActor";
|
|
|
|
this.on("serverWebSocketOpened", this._onWebSocketOpened);
|
|
this.on("serverWebSocketClosed", this._onWebSocketClosed);
|
|
this.on("serverFrameSent", this._onFrameSent);
|
|
this.on("serverFrameReceived", this._onFrameReceived);
|
|
}
|
|
|
|
/**
|
|
* Close the WebSocketFront.
|
|
*
|
|
*/
|
|
destroy() {
|
|
this.off("serverWebSocketOpened");
|
|
this.off("serverWebSocketClosed");
|
|
this.off("serverFrameSent");
|
|
this.off("serverFrameReceived");
|
|
return super.destroy();
|
|
}
|
|
|
|
/**
|
|
* The "webSocketOpened" message type handler. We redirect any message to
|
|
* the UI for displaying.
|
|
*
|
|
* @private
|
|
* @param number httpChannelId
|
|
* Channel ID of the websocket connection.
|
|
* @param string effectiveURI
|
|
* URI of the page.
|
|
* @param string protocols
|
|
* WebSocket procotols.
|
|
* @param string extensions
|
|
*/
|
|
async _onWebSocketOpened(httpChannelId, effectiveURI, protocols, extensions) {
|
|
this.emit(
|
|
"webSocketOpened",
|
|
httpChannelId,
|
|
effectiveURI,
|
|
protocols,
|
|
extensions
|
|
);
|
|
}
|
|
|
|
/**
|
|
* The "webSocketClosed" message type handler. We redirect any message to
|
|
* the UI for displaying.
|
|
*
|
|
* @private
|
|
* @param number httpChannelId
|
|
* @param boolean wasClean
|
|
* @param number code
|
|
* @param string reason
|
|
*/
|
|
async _onWebSocketClosed(httpChannelId, wasClean, code, reason) {
|
|
this.emit("webSocketClosed", httpChannelId, wasClean, code, reason);
|
|
}
|
|
|
|
/**
|
|
* The "frameReceived" message type handler. We redirect any message to
|
|
* the UI for displaying.
|
|
*
|
|
* @private
|
|
* @param string httpChannelId
|
|
* Channel ID of the websocket connection.
|
|
* @param object data
|
|
* The data received from the server.
|
|
*/
|
|
async _onFrameReceived(httpChannelId, data) {
|
|
this.emit("frameReceived", httpChannelId, data);
|
|
}
|
|
|
|
/**
|
|
* The "frameSent" message type handler. We redirect any message to
|
|
* the UI for displaying.
|
|
*
|
|
* @private
|
|
* @param string httpChannelId
|
|
* Channel ID of the websocket connection.
|
|
* @param object data
|
|
* The data received from the server.
|
|
*/
|
|
async _onFrameSent(httpChannelId, data) {
|
|
this.emit("frameSent", httpChannelId, data);
|
|
}
|
|
}
|
|
|
|
exports.WebSocketFront = WebSocketFront;
|
|
registerFront(WebSocketFront);
|