mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Updated escodegen, fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/638, added test
This commit is contained in:
+3
-11
@@ -7,17 +7,9 @@ import { NO_ADDITIONAL_NODES_PRESET } from '../../src/options/presets/NoCustomNo
|
||||
|
||||
let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
|
||||
`
|
||||
(function () {
|
||||
const foo = {
|
||||
prop1: 1,
|
||||
prop2: 2,
|
||||
calc: function () {
|
||||
return this.prop1 + this.prop2;
|
||||
}
|
||||
};
|
||||
|
||||
console.log(foo.calc());
|
||||
})();
|
||||
class Foo {
|
||||
[(1, Symbol.asyncIterator)]() {}
|
||||
}
|
||||
`,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
|
||||
@@ -571,6 +571,30 @@ describe('JavaScriptObfuscator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* https://github.com/estools/escodegen/pull/415
|
||||
*/
|
||||
describe('Precedence of `SequenceExpression` in computed property', () => {
|
||||
const regExp: RegExp = /class Foo *{ *\[\(bar, *baz\)]\(\) *{ *} * *}/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/precedence-of-sequence-expression-in-computed-property.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should generate a valid js code', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('new.target MetaProperty', () => {
|
||||
const regExp: RegExp = /new\.target *=== *Foo/;
|
||||
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
[(bar, baz)]() {}
|
||||
}
|
||||
Reference in New Issue
Block a user