Socket
Socket
Sign inDemoInstall

devtools-connection

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

devtools-connection - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

README.md

2

package.json
{
"name": "devtools-connection",
"version": "0.0.2",
"version": "0.0.3",
"description": "DevTools HTML Connection Logic",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,5 +0,1 @@

/* 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/. */
const promise = require("./utils/promise");

@@ -178,6 +174,4 @@ const EventEmitter = require("./utils/event-emitter");

if (!this.client) {
throw new Error(
"TabTarget#getActorDescription() can only be called on " +
"remote tabs.",
);
throw new Error("TabTarget#getActorDescription() can only be called on " +
"remote tabs.");
}

@@ -187,5 +181,4 @@

if (
this._protocolDescription && this._protocolDescription.types[actorName]
) {
if (this._protocolDescription &&
this._protocolDescription.types[actorName]) {
deferred.resolve(this._protocolDescription.types[actorName]);

@@ -211,8 +204,7 @@ } else {

if (!this.client) {
throw new Error(
"TabTarget#hasActor() can only be called on remote " + "tabs.",
);
throw new Error("TabTarget#hasActor() can only be called on remote " +
"tabs.");
}
if (this.form) {
return !!this.form[`${actorName}Actor`];
return !!this.form[actorName + "Actor"];
}

@@ -235,5 +227,4 @@ return false;

if (!this.client) {
throw new Error(
"TabTarget#actorHasMethod() can only be called on " + "remote tabs.",
);
throw new Error("TabTarget#actorHasMethod() can only be called on " +
"remote tabs.");
}

@@ -256,5 +247,4 @@ return this.getActorDescription(actorName).then(desc => {

if (!this.client) {
throw new Error(
"TabTarget#getTrait() can only be called on remote " + "tabs.",
);
throw new Error("TabTarget#getTrait() can only be called on remote " +
"tabs.");
}

@@ -292,3 +282,3 @@

if (response.error) {
reject(new Error(`${response.error}: ${response.message}`));
reject(new Error(response.error + ": " + response.message));
return;

@@ -349,3 +339,4 @@ }

get url() {
return this._tab ? this._tab.linkedBrowser.currentURI.spec : this._form.url;
return this._tab ? this._tab.linkedBrowser.currentURI.spec :
this._form.url;
},

@@ -358,5 +349,4 @@

get isAddon() {
return !!(this._form &&
this._form.actor &&
this._form.actor.match(/conn\d+\.addon\d+/));
return !!(this._form && this._form.actor &&
this._form.actor.match(/conn\d+\.addon\d+/));
},

@@ -425,7 +415,5 @@

let attachConsole = () => {
this._client.attachConsole(
this._form.consoleActor,
["NetworkActivity"],
onConsoleAttached,
);
this._client.attachConsole(this._form.consoleActor,
[ "NetworkActivity" ],
onConsoleAttached);
};

@@ -634,3 +622,3 @@

toString: function() {
let id = this._tab ? this._tab : this._form && this._form.actor;
let id = this._tab ? this._tab : (this._form && this._form.actor);
return `TabTarget:${id}`;

@@ -677,3 +665,3 @@ },

return {
consoleActor: this._workerClient.consoleActor,
consoleActor: this._workerClient.consoleActor
};

@@ -702,3 +690,3 @@ },

return Promise.resolve();
},
}
};

@@ -27,8 +27,2 @@ /**

/* DevToolsUtils.defineLazyGetter(this, "unicodeConverter", () => {
const unicodeConverter = Cc("@mozilla.org/intl/scriptableunicodeconverter")
.createInstance(Ci.nsIScriptableUnicodeConverter);
unicodeConverter.charset = "UTF-8";
return unicodeConverter;
});*/
const utf8 = require("./utf8");

@@ -61,9 +55,8 @@

Packet.fromHeader = function(header, transport) {
return (
JSONPacket.fromHeader(header, transport) ||
BulkPacket.fromHeader(header, transport)
);
return JSONPacket.fromHeader(header, transport) ||
BulkPacket.fromHeader(header, transport);
};
Packet.prototype = {
get length() {

@@ -75,5 +68,4 @@ return this._length;

if (length > PACKET_LENGTH_MAX) {
throw Error(
`Packet length ${length} exceeds the max length of ${PACKET_LENGTH_MAX}`,
);
throw Error("Packet length " + length + " exceeds the max length of " +
PACKET_LENGTH_MAX);
}

@@ -85,3 +77,4 @@ this._length = length;

this._transport = null;
},
}
};

@@ -137,5 +130,3 @@

*/
get: function() {
return this._object;
},
get: function() { return this._object; },

@@ -150,3 +141,3 @@ /**

this.length = this._data.length;
},
}
});

@@ -169,4 +160,5 @@

this._object = JSON.parse(json);
} catch (e) {
let msg = `Error parsing incoming packet: ${json} (${e} - ${e.stack})`;
} catch(e) {
let msg = "Error parsing incoming packet: " + json + " (" + e +
" - " + e.stack + ")";
if (console.error) {

@@ -180,3 +172,3 @@ console.error(msg);

this._transport._onJSONObjectReady(this._object);
};
}

@@ -188,13 +180,10 @@ JSONPacket.prototype._readData = function(stream, scriptableStream) {

if (dumpv.wantVerbose) {
dumpv(
`Reading JSON data: _l: ${this.length} dL: ${this._data.length} sA: ${stream.available()}`,
);
dumpv("Reading JSON data: _l: " + this.length + " dL: " +
this._data.length + " sA: " + stream.available());
}
let bytesToRead = Math.min(
this.length - this._data.length,
stream.available(),
);
let bytesToRead = Math.min(this.length - this._data.length,
stream.available());
this._data += scriptableStream.readBytes(bytesToRead);
this._done = this._data.length === this.length;
};
}

@@ -206,3 +195,3 @@ JSONPacket.prototype.write = function(stream) {

// Format the serialized packet to a buffer
this._outgoing = `${this.length}:${this._data}`;
this._outgoing = this.length + ":" + this._data;
}

@@ -213,8 +202,6 @@

this._done = !this._outgoing.length;
};
}
Object.defineProperty(JSONPacket.prototype, "done", {
get: function() {
return this._done;
},
get: function() { return this._done; }
});

@@ -224,3 +211,3 @@

return JSON.stringify(this._object, null, 2);
};
}

@@ -272,3 +259,3 @@ exports.JSONPacket = JSONPacket;

type: match[2],
length: +match[3],
length: +match[3]
};

@@ -294,4 +281,4 @@ return packet;

length: this.length,
copyTo: output => {
dumpv(`CT length: ${this.length}`);
copyTo: (output) => {
dumpv("CT length: " + this.length);
let copying = StreamUtils.copyStream(stream, output, this.length);

@@ -302,3 +289,3 @@ deferred.resolve(copying);

stream: stream,
done: deferred,
done: deferred
});

@@ -317,3 +304,3 @@

};
};
}

@@ -326,3 +313,4 @@ BulkPacket.prototype.write = function(stream) {

// Format the serialized packet header to a buffer
this._outgoingHeader = `bulk ${this.actor} ${this.type} ${this.length}:`;
this._outgoingHeader = "bulk " + this.actor + " " + this.type + " " +
this.length + ":";
}

@@ -333,6 +321,4 @@

dumpv("Writing bulk packet header");
let written = stream.write(
this._outgoingHeader,
this._outgoingHeader.length,
);
let written = stream.write(this._outgoingHeader,
this._outgoingHeader.length);
this._outgoingHeader = this._outgoingHeader.slice(written);

@@ -350,4 +336,4 @@ return;

this._readyForWriting.resolve({
copyFrom: input => {
dumpv(`CF length: ${this.length}`);
copyFrom: (input) => {
dumpv("CF length: " + this.length);
let copying = StreamUtils.copyStream(input, stream, this.length);

@@ -358,3 +344,3 @@ deferred.resolve(copying);

stream: stream,
done: deferred,
done: deferred
});

@@ -373,3 +359,3 @@

};
};
}

@@ -379,3 +365,3 @@ Object.defineProperty(BulkPacket.prototype, "streamReadyForWriting", {

return this._readyForWriting.promise;
},
}
});

@@ -388,3 +374,3 @@

type: this.type,
length: this.length,
length: this.length
};

@@ -401,10 +387,9 @@ },

Object.defineProperty(BulkPacket.prototype, "done", {
get: function() {
return this._done;
},
get: function() { return this._done; },
});
BulkPacket.prototype.toString = function() {
return `Bulk: ${JSON.stringify(this.header, null, 2)}`;
};
return "Bulk: " + JSON.stringify(this.header, null, 2);
}

@@ -433,3 +418,3 @@ exports.BulkPacket = BulkPacket;

throw Error("Not implmented.");
};
}

@@ -440,10 +425,8 @@ RawPacket.prototype.write = function(stream) {

this._done = !this._data.length;
};
}
Object.defineProperty(RawPacket.prototype, "done", {
get: function() {
return this._done;
},
get: function() { return this._done; }
});
exports.RawPacket = RawPacket;

@@ -1,14 +0,9 @@

/* 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/. */
module.metadata = {
stability: "unstable",
"stability": "unstable"
};
const UNCAUGHT_ERROR =
"An error event was emitted for which there was no listener.";
const BAD_LISTENER = "The event listener must be a function.";
const UNCAUGHT_ERROR = 'An error event was emitted for which there was no listener.';
const BAD_LISTENER = 'The event listener must be a function.';
const { ns } = require("./namespace");
const { ns } = require('./namespace');

@@ -24,7 +19,5 @@ const event = ns();

const observers = function observers(target, type) {
if (!target) {
throw TypeError("Event target must be an object");
}
if (!target) throw TypeError("Event target must be an object");
let listeners = event(target);
return type in listeners ? listeners[type] : (listeners[type] = []);
return type in listeners ? listeners[type] : listeners[type] = [];
};

@@ -43,15 +36,15 @@

function on(target, type, listener) {
if (typeof listener !== "function") {
if (typeof(listener) !== 'function')
throw new Error(BAD_LISTENER);
}
let listeners = observers(target, type);
if (!~listeners.indexOf(listener)) {
if (!~listeners.indexOf(listener))
listeners.push(listener);
}
}
exports.on = on;
var onceWeakMap = new WeakMap();
/**

@@ -92,3 +85,3 @@ * Registers an event `listener` that is called only the next time an event

*/
function emit(target, type, ...args) {
function emit (target, type, ...args) {
emitOnObject(target, type, target, ...args);

@@ -102,3 +95,3 @@ }

function emitOnObject(target, type, thisArg, ...args) {
let all = observers(target, "*").length;
let all = observers(target, '*').length;
let state = observers(target, type);

@@ -111,5 +104,4 @@ let listeners = state.slice();

// then print error message to the console.
if (count === 0 && type === "error" && all === 0) {
if (count === 0 && type === 'error' && all === 0)
console.exception(args[0]);
}
while (index < count) {

@@ -119,20 +111,15 @@ try {

// Dispatch only if listener is still registered.
if (~state.indexOf(listener)) {
if (~state.indexOf(listener))
listener.apply(thisArg, args);
}
} catch (error) {
}
catch (error) {
// If exception is not thrown by a error listener and error listener is
// registered emit `error` event. Otherwise dump exception to the console.
if (type !== "error") {
emit(target, "error", error);
} else {
console.exception(error);
}
if (type !== 'error') emit(target, 'error', error);
else console.exception(error);
}
index++;
}
// Also emit on `"*"` so that one could listen for all events.
if (type !== "*") {
emit(target, "*", type, ...args);
}
// Also emit on `"*"` so that one could listen for all events.
if (type !== '*') emit(target, '*', type, ...args);
}

@@ -163,8 +150,9 @@ exports.emitOnObject = emitOnObject;

let index = listeners.indexOf(listener);
if (~index) {
if (~index)
listeners.splice(index, 1);
}
} else if (length === 2) {
}
else if (length === 2) {
observers(target, type).splice(0);
} else if (length === 1) {
}
else if (length === 1) {
let listeners = event(target);

@@ -200,12 +188,9 @@ Object.keys(listeners).forEach(type => delete listeners[type]);

let type = match && match[1].toLowerCase();
if (!type) {
return;
}
if (!type) return;
let listener = listeners[key];
if (typeof listener === "function") {
if (typeof(listener) === 'function')
on(target, type, listener);
}
});
}
exports.setListeners = setListeners;

@@ -18,3 +18,4 @@ const { Cc, Ci, Cu } = require("../utils/chrome");

*/
function WebConsoleClient(aDebuggerClient, aResponse, LongStringClient) {
function WebConsoleClient(aDebuggerClient, aResponse, LongStringClient)
{
this._actor = aResponse.from;

@@ -69,5 +70,3 @@ this._client = aDebuggerClient;

get actor() {
return this._actor;
},
get actor() { return this._actor; },

@@ -84,3 +83,4 @@ /**

*/
_onNetworkEvent: function(type, packet) {
_onNetworkEvent: function (type, packet)
{
if (packet.from == this._actor) {

@@ -105,3 +105,3 @@ let actor = packet.eventActor;

private: actor.private,
fromCache: actor.fromCache,
fromCache: actor.fromCache
};

@@ -124,3 +124,4 @@ this._networkRequests.set(actor.actor, networkInfo);

*/
_onNetworkEventUpdate: function(type, packet) {
_onNetworkEventUpdate: function (type, packet)
{
let networkInfo = this.getNetworkRequest(packet.from);

@@ -168,3 +169,3 @@ if (!networkInfo) {

packet: packet,
networkInfo,
networkInfo
});

@@ -183,3 +184,4 @@ },

*/
getCachedMessages: function WCC_getCachedMessages(types, aOnResponse) {
getCachedMessages: function WCC_getCachedMessages(types, aOnResponse)
{
let packet = {

@@ -201,6 +203,5 @@ to: this._actor,

*/
inspectObjectProperties: function WCC_inspectObjectProperties(
aActor,
aOnResponse,
) {
inspectObjectProperties:
function WCC_inspectObjectProperties(aActor, aOnResponse)
{
let packet = {

@@ -249,3 +250,4 @@ to: aActor,

*/
evaluateJS: function WCC_evaluateJS(aString, aOnResponse, aOptions = {}) {
evaluateJS: function WCC_evaluateJS(aString, aOnResponse, aOptions = {})
{
let packet = {

@@ -268,3 +270,4 @@ to: this._actor,

*/
evaluateJSAsync: function(aString, aOnResponse, aOptions = {}) {
evaluateJSAsync: function(aString, aOnResponse, aOptions = {})
{
// Pre-37 servers don't support async evaluation.

@@ -315,6 +318,4 @@ if (!this.traits.evaluateJSAsync) {

} else {
DevToolsUtils.reportException(
"onEvaluationResult",
`No response handler for an evaluateJSAsync result (resultID: ${aPacket.resultID})`,
);
DevToolsUtils.reportException("onEvaluationResult",
"No response handler for an evaluateJSAsync result (resultID: " + aPacket.resultID + ")");
}

@@ -335,8 +336,4 @@ },

*/
autocomplete: function WCC_autocomplete(
aString,
aCursor,
aOnResponse,
aFrameActor,
) {
autocomplete: function WCC_autocomplete(aString, aCursor, aOnResponse, aFrameActor)
{
let packet = {

@@ -355,3 +352,4 @@ to: this._actor,

*/
clearMessagesCache: function WCC_clearMessagesCache() {
clearMessagesCache: function WCC_clearMessagesCache()
{
let packet = {

@@ -372,3 +370,4 @@ to: this._actor,

*/
getPreferences: function WCC_getPreferences(aPreferences, aOnResponse) {
getPreferences: function WCC_getPreferences(aPreferences, aOnResponse)
{
let packet = {

@@ -390,3 +389,4 @@ to: this._actor,

*/
setPreferences: function WCC_setPreferences(aPreferences, aOnResponse) {
setPreferences: function WCC_setPreferences(aPreferences, aOnResponse)
{
let packet = {

@@ -408,3 +408,4 @@ to: this._actor,

*/
getRequestHeaders: function WCC_getRequestHeaders(aActor, aOnResponse) {
getRequestHeaders: function WCC_getRequestHeaders(aActor, aOnResponse)
{
let packet = {

@@ -425,3 +426,4 @@ to: aActor,

*/
getRequestCookies: function WCC_getRequestCookies(aActor, aOnResponse) {
getRequestCookies: function WCC_getRequestCookies(aActor, aOnResponse)
{
let packet = {

@@ -442,3 +444,4 @@ to: aActor,

*/
getRequestPostData: function WCC_getRequestPostData(aActor, aOnResponse) {
getRequestPostData: function WCC_getRequestPostData(aActor, aOnResponse)
{
let packet = {

@@ -459,3 +462,4 @@ to: aActor,

*/
getResponseHeaders: function WCC_getResponseHeaders(aActor, aOnResponse) {
getResponseHeaders: function WCC_getResponseHeaders(aActor, aOnResponse)
{
let packet = {

@@ -476,3 +480,4 @@ to: aActor,

*/
getResponseCookies: function WCC_getResponseCookies(aActor, aOnResponse) {
getResponseCookies: function WCC_getResponseCookies(aActor, aOnResponse)
{
let packet = {

@@ -493,3 +498,4 @@ to: aActor,

*/
getResponseContent: function WCC_getResponseContent(aActor, aOnResponse) {
getResponseContent: function WCC_getResponseContent(aActor, aOnResponse)
{
let packet = {

@@ -510,3 +516,4 @@ to: aActor,

*/
getEventTimings: function WCC_getEventTimings(aActor, aOnResponse) {
getEventTimings: function WCC_getEventTimings(aActor, aOnResponse)
{
let packet = {

@@ -527,3 +534,4 @@ to: aActor,

*/
getSecurityInfo: function WCC_getSecurityInfo(aActor, aOnResponse) {
getSecurityInfo: function WCC_getSecurityInfo(aActor, aOnResponse)
{
let packet = {

@@ -548,3 +556,3 @@ to: aActor,

type: "sendHTTPRequest",
request: aData,
request: aData
};

@@ -564,3 +572,4 @@ this._client.request(packet, aOnResponse);

*/
startListeners: function WCC_startListeners(aListeners, aOnResponse) {
startListeners: function WCC_startListeners(aListeners, aOnResponse)
{
let packet = {

@@ -584,3 +593,4 @@ to: this._actor,

*/
stopListeners: function WCC_stopListeners(aListeners, aOnResponse) {
stopListeners: function WCC_stopListeners(aListeners, aOnResponse)
{
let packet = {

@@ -602,3 +612,4 @@ to: this._actor,

*/
longString: function WCC_longString(aGrip) {
longString: function WCC_longString(aGrip)
{
if (aGrip.actor in this._longStrings) {

@@ -621,9 +632,7 @@ return this._longStrings[aGrip.actor];

*/
detach: function WCC_detach(aOnResponse) {
detach: function WCC_detach(aOnResponse)
{
this._client.removeListener("evaluationResult", this.onEvaluationResult);
this._client.removeListener("networkEvent", this.onNetworkEvent);
this._client.removeListener(
"networkEventUpdate",
this.onNetworkEventUpdate,
);
this._client.removeListener("networkEventUpdate", this.onNetworkEventUpdate);
this.stopListeners(null, aOnResponse);

@@ -638,3 +647,3 @@ this._longStrings = null;

clearNetworkRequests: function() {
clearNetworkRequests: function () {
this._networkRequests.clear();

@@ -665,3 +674,3 @@ },

let deferred = (stringGrip._fullText = promise.defer());
let deferred = stringGrip._fullText = promise.defer();
let { actor, initial, length } = stringGrip;

@@ -672,6 +681,4 @@ let longStringClient = this.longString(stringGrip);

if (aResponse.error) {
DevToolsUtils.reportException(
"getString",
`${aResponse.error}: ${aResponse.message}`,
);
DevToolsUtils.reportException("getString",
aResponse.error + ": " + aResponse.message);

@@ -685,3 +692,3 @@ deferred.reject(aResponse);

return deferred.promise;
},
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc