🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
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

to
0.6.0

src/InjectedScriptHost.h

5

package.json
{
"name": "v8-debug",
"version": "0.5.4",
"version": "0.6.0",
"description": "v8 debugger extending API",

@@ -40,6 +40,7 @@ "homepage": "http://github.com/node-inspector/v8-debug",

"scripts": {
"preinstall": " ",
"preinstall": "node -e 'process.exit(0)'",
"install": "node-pre-gyp install --fallback-to-build",
"rebuild": "node-pre-gyp rebuild",
"test": "mocha --debug"
}
}

@@ -29,147 +29,2 @@ var expect = require('chai').expect;

});
describe('InjectedScriptHost', function() {
var 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(SyntaxError);
});
});
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();
});
it('should rethrow ReferenceError', function() {
expect(host.callFunction.bind(null, function() {
'use strict';
if (error_here) return;
}, this)).to.throw(ReferenceError);
});
});
});
});

28

test/v8-debug.js
var expect = require('chai').expect,
v8debug = require('../');
var NODE_NEXT = require('../tools/NODE_NEXT');
var _debugger = require('child_process').spawn('node', ['./test/helpers/debugger.js']);

@@ -35,13 +37,19 @@

it('enableWebkitProtocol should enable Webkit protocol', function() {
v8debug.enableWebkitProtocol();
expect(v8debug.enableWebkitProtocol.bind(v8debug)).to.not.throw();
});
if (NODE_NEXT) {
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.sendCommand('command');
});
it('if enabled registerAgentCommand should register command', function(done) {
expect(v8debug.registerAgentCommand.bind(v8debug, 'command', [], function() {
done();
})).to.not.throw();
v8debug.sendCommand('command');
});
} else {
it('enableWebkitProtocol should throw error', function() {
expect(v8debug.enableWebkitProtocol).to.throw();
});
}
});

@@ -48,0 +56,0 @@

@@ -10,2 +10,4 @@ var binary = require('node-pre-gyp');

var NODE_NEXT = require('./tools/NODE_NEXT');
// Don't cache debugger module

@@ -218,2 +220,6 @@ delete require.cache[module.id];

V8Debug.prototype.enableWebkitProtocol = function() {
if (!NODE_NEXT) {
throw new Error('WebKit protocol is not supported on target node version (' + process.version + ')');
}
if (this._webkitProtocolEnabled) return;

@@ -220,0 +226,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet