Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

v8-debug

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

v8-debug - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

InjectedScript/DebuggerScript.js

0

node_modules/node-pre-gyp/node_modules/rc/node_modules/deep-extend/README.md

@@ -0,0 +0,0 @@ Node.JS module “Deep Extend”

@@ -0,0 +0,0 @@ <a href="https://github.com/spumko"><img src="https://raw.github.com/spumko/spumko/master/images/from.png" align="right" /></a>

exports.x = 1;

@@ -0,0 +0,0 @@ var tar = require('../')

2

node_modules/node-pre-gyp/package.json

@@ -68,3 +68,3 @@ {

"_shasum": "8c91516f0009e4691413c8c3f2d8a060deb607ba",
"_from": "node-pre-gyp@0.5.x",
"_from": "node-pre-gyp@^0.5.0",
"_npmVersion": "1.4.28",

@@ -71,0 +71,0 @@ "_npmUser": {

{
"name": "v8-debug",
"version": "0.3.3",
"version": "0.3.4",
"description": "v8 debugger extending API",

@@ -31,4 +31,4 @@ "homepage": "http://github.com/node-inspector/v8-debug",

"dependencies": {
"node-pre-gyp": "^0.5.0",
"nan": "~1.2.0"
"node-pre-gyp": "^0.6.0",
"nan": "~1.5.0"
},

@@ -43,4 +43,4 @@ "bundledDependencies":["node-pre-gyp"],

"install": "node-pre-gyp install --fallback-to-build",
"test": "mocha"
"test": "mocha --debug"
}
}
var expect = require('chai').expect;
var binary = require('node-pre-gyp');
var path = require('path');
var binding_path = binary.find(path.resolve(path.join(__dirname,'../package.json')));
describe('Binary source', function() {
describe('binding', function() {
var binding;
it('was builded and can be accessed from script', function() {
binding = require('../build/Release/debug');
it('source was builded and can be accessed from script', function() {
binding = require(binding_path);
expect(binding).to.be.instanceof(Object);
});
});
describe('InjectedScriptHost', function() {
var host;
before(function() {
host = binding.InjectedScriptHost;
});
describe('function `subtype`', function() {
checksTypeValid(new Array(), 'array');
checksTypeValid(new Date(), 'date');
checksTypeValid(new RegExp(), 'regexp');
checksTypeValid(new Error(), 'error');
checksTypeValid(new String(), undefined);
function checksTypeValid(value, type) {
it('checks ' + type + ' subtype', function() {
expect(host.subtype(value)).to.equal(type);
});
}
it('should throw on wrong arguments', function() {
expect(host.subtype).to.throw();
});
});
describe('function `setNonEnumProperty`', function() {
it('should set non enumerable property to object', function() {
var object = {
'visibleProp': '1'
};
host.setNonEnumProperty(object, 'hiddenProp', 'value');
var keys = Object.keys(object);
expect(keys).to.deep.equal(['visibleProp']);
expect(object.hiddenProp).to.equal('value');
});
throwsOnArgs([]);
throwsOnArgs([{}, 'a']);
throwsOnArgs([{}, null, 'b']);
throwsOnArgs([null, {}, 'b']);
function throwsOnArgs(argvList) {
it('should throw on wrong arguments ' + JSON.stringify(argvList), function() {
expect(host.setNonEnumProperty.bind.apply(
host.setNonEnumProperty, [host].concat(argvList))).to.throw();
});
}
it('should not throw on valid arguments', function() {
expect(host.setNonEnumProperty.bind(host, {}, 'a', null)).to.not.throw();
expect(host.setNonEnumProperty.bind(host, {}, 'a', 'b')).to.not.throw();
});
});
describe('function `internalConstructorName`', function() {
checksNameValid(new Number(), 'Number');
checksNameValid(new Object(), 'Object');
function checksNameValid(value, name) {
it('checks new ' + name + '() constructor name', function() {
expect(host.internalConstructorName(value)).to.equal(name);
});
}
throwsOnArgs([]);
throwsOnArgs([1]);
throwsOnArgs([null]);
function throwsOnArgs(argvList) {
it('should throw on wrong arguments ' + JSON.stringify(argvList), function() {
expect(host.internalConstructorName.bind.apply(
host.internalConstructorName, [host].concat(argvList))).to.throw();
});
}
});
describe('function `functionDetailsWithoutScopes`', function() {
it('should return valid details', function() {
function example() {}
var details = host.functionDetailsWithoutScopes(example);
expect(details).to.include.keys(['location', 'functionName']);
expect(details.location).to.include.keys(['lineNumber', 'columnNumber', 'scriptId']);
});
throwsOnArgs([]);
throwsOnArgs([null]);
function throwsOnArgs(argvList) {
it('should throw on wrong arguments ' + JSON.stringify(argvList), function() {
expect(host.functionDetailsWithoutScopes.bind.apply(
host.functionDetailsWithoutScopes, [host].concat(argvList))).to.throw();
});
}
});
describe('function `eval`', function() {
it('should evaluate expression', function() {
expect(host.eval("[1]")).to.deep.equal([1]);
});
it('should throw on wrong arguments', function() {
expect(host.eval).to.throw();
});
it('should throw on wrong expression', function() {
expect(host.eval.bind(null, "[1")).to.throw();
});
});
describe('function `evaluateWithExceptionDetails`', function() {
it('should evaluate expression', function() {
expect(host.evaluateWithExceptionDetails("[1]")).to.deep.equal({
result: [1],
exceptionDetails: undefined
});
});
it('should throw on wrong arguments', function() {
expect(host.evaluateWithExceptionDetails).to.throw();
});
});
describe('function `callFunction`', function() {
it('should call function without args', function(done) {
host.callFunction(done, this);
});
it('should call function with args', function(done) {
host.callFunction(function(arg) {
expect(arg).to.equal(1);
done();
}, this, [1]);
});
it('should throw on wrong arguments', function() {
expect(host.callFunction.bind(null, null, null, [1])).to.throw();
expect(host.callFunction.bind(null, null, null, 1)).to.throw();
});
});
});
});

@@ -1,6 +0,19 @@

var expect = require('chai').expect;
var v8debug = require('../');
var expect = require('chai').expect,
v8debug = require('../');
var _debugger = require('child_process').spawn('node', ['./test/helpers/debugger.js']);
_debugger.stderr.on('data', function(data) {
throw new Error(data);
});
describe('v8-debug', function() {
describe('runInDebugContext', function() {
before(function(done) {
_debugger.stdout.on('data', function(data) {
console.log(' ' + data);
done();
});
});
describe('function `runInDebugContext`', function() {
it('returns Debug object', function() {

@@ -10,3 +23,3 @@ var Debug = v8debug.runInDebugContext('Debug');

});
it('returns compiled function object', function() {

@@ -17,2 +30,20 @@ var Debug = v8debug.runInDebugContext(function(){return Debug;});

});
describe('Webkit protocol', function() {
it('if disabled, registerAgentCommand should throw error', function() {
expect(v8debug.registerAgentCommand.bind(v8debug, 'command', [], function() {})).to.throw();
});
it('enableWebkitProtocol should enable Webkit protocol', function() {
v8debug.enableWebkitProtocol();
expect(v8debug.enableWebkitProtocol.bind(v8debug)).to.not.throw();
});
it('if enabled registerAgentCommand should register command', function(done) {
expect(v8debug.registerAgentCommand.bind(v8debug, 'command', [], function() {
done();
})).to.not.throw();
v8debug.execCommand('command');
});
});
});
var binary = require('node-pre-gyp');
var fs = require('fs');
var path = require('path');

@@ -8,4 +9,9 @@ var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json')));

var DebuggerScriptLink = require.resolve(__dirname + '/InjectedScript/DebuggerScript.js');
var InjectedScriptLink = require.resolve(__dirname + '/InjectedScript/InjectedScriptSource.js');
var InjectedScriptHostLink = require.resolve(__dirname + '/InjectedScript/InjectedScriptHost.js');
inherits(V8Debug, EventEmitter);
function V8Debug() {
this._webkitProtocolEnabled = false;
this._processor = this.runInDebugContext('DebugCommandProcessor').prototype;

@@ -127,3 +133,3 @@

var message = {
seq: 1,
seq: 0,
type: 'request',

@@ -157,2 +163,55 @@ command: name,

V8Debug.prototype.enableWebkitProtocol = function() {
if (this._webkitProtocolEnabled) return;
var DebuggerScriptSource,
DebuggerScript,
InjectedScriptSource,
InjectedScript,
InjectedScriptHostSource,
InjectedScriptHost;
function prepareSource(source) {
return 'var ToggleMirrorCache = ToggleMirrorCache || function() {};\n' +
'(function() {' +
('' + source).replace(/^.*?"use strict";(\r?\n.*?)*\(/m, '\r\n"use strict";\nreturn (') +
'}());';
}
DebuggerScriptSource = prepareSource(fs.readFileSync(DebuggerScriptLink, 'utf8'));
DebuggerScript = this.runInDebugContext(DebuggerScriptSource);
InjectedScriptSource = prepareSource(fs.readFileSync(InjectedScriptLink, 'utf8'));
InjectedScript = this.runInDebugContext(InjectedScriptSource);
InjectedScriptHostSource = prepareSource(fs.readFileSync(InjectedScriptHostLink, 'utf8'));
InjectedScriptHost = this.runInDebugContext(InjectedScriptHostSource)(binding, DebuggerScript);
var injectedScript = InjectedScript(InjectedScriptHost, global, 1);
this.registerAgentCommand = function(command, parameters, callback) {
this.registerCommand(command, new WebkitProtocolCallback(parameters, callback));
};
this._webkitProtocolEnabled = true;
function WebkitProtocolCallback(argsList, callback) {
return function(request, response) {
InjectedScriptHost.execState = this.exec_state_;
var args = argsList.map(function(name) {
return request.arguments[name];
});
callback.call(this, args, response, injectedScript, DebuggerScript);
InjectedScriptHost.execState = null;
}
}
};
V8Debug.prototype.registerAgentCommand = function(command, parameters, callback) {
throw new Error('Use "enableWebkitProtocol" before use this method');
};
module.exports = new V8Debug();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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