Skip to content

Commit

Permalink
fixup! src,lib: retrieve parsed source map url from v8
Browse files Browse the repository at this point in the history
  • Loading branch information
legendecas committed Sep 29, 2022
1 parent df4e7df commit 86de757
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/internal/vm.js
Expand Up @@ -22,7 +22,7 @@ const {
} = require('internal/errors').codes;

function isContext(object) {
validateObject(object, 'object', { allowArray: true });
validateObject(object, 'object', { __proto__: null, allowArray: true });

return _isContext(object);
}
Expand Down Expand Up @@ -68,7 +68,7 @@ function internalCompileFunction(code, params, options) {
validateArray(contextExtensions, 'options.contextExtensions');
ArrayPrototypeForEach(contextExtensions, (extension, i) => {
const name = `options.contextExtensions[${i}]`;
validateObject(extension, name, { nullable: true });
validateObject(extension, name, { __proto__: null, nullable: true });
});

const result = compileFunction(
Expand Down
27 changes: 27 additions & 0 deletions test/parallel/test-vm-source-map-url.js
@@ -0,0 +1,27 @@
'use strict';

require('../common');
const assert = require('assert');
const vm = require('vm');

function checkSourceMapUrl(source, expectedSourceMapURL) {
const script = new vm.Script(source);
assert.strictEqual(script.sourceMapURL, expectedSourceMapURL);
}

// No magic comment
checkSourceMapUrl(`
function myFunc() {}
`, undefined);

// Malformed magic comment
checkSourceMapUrl(`
function myFunc() {}
// sourceMappingURL=sourcemap.json
`, undefined);

// Expected magic comment
checkSourceMapUrl(`
function myFunc() {}
//# sourceMappingURL=sourcemap.json
`, 'sourcemap.json');

0 comments on commit 86de757

Please sign in to comment.