Skip to content

Commit 8dc157b

Browse files
committed
Expose problem due to This being passed to Unwrap
On Node 0.10.40, the test case will now fail with SIGABRT due to a failed assertion: node: ../../nan_object_wrap.h:33: static T* Nan::ObjectWrap::Unwrap(v8::Local<v8::Object>) [with T = MyObject]: Assertion `object->InternalFieldCount() > 0' failed. This is because This is not an instance of the type in question. Node >=0.12 seem to report a TypeError: Illegal invocation instead.
1 parent 367e82a commit 8dc157b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/js/objectwraphandle-test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const test = require('tap').test
1111
, bindings = require('bindings')({ module_root: testRoot, bindings: 'objectwraphandle' });
1212

1313
test('objectwraphandle', function (t) {
14-
t.plan(5);
14+
t.plan(7);
1515

1616
t.type(bindings.MyObject, 'function');
1717

@@ -21,4 +21,14 @@ test('objectwraphandle', function (t) {
2121
t.type(obj.getValue, 'function');
2222
t.type(obj.getHandle(), 'object');
2323
t.type(obj.getValue(), 'number');
24+
25+
var derived = Object.create(obj);
26+
t.type(derived, bindings.MyObject);
27+
try {
28+
// In Node 0.10 this call is valid:
29+
t.equal(derived.getValue(), 10);
30+
} catch (err) {
31+
// In Node >= 0.12 it throws instead:
32+
t.type(err, TypeError);
33+
}
2434
});

0 commit comments

Comments
 (0)