sanex3339
2017-12-03 18:29:19 +03:00
parent 7ece6583a0
commit 7c325d4193
10 changed files with 125 additions and 35 deletions
@@ -100,7 +100,7 @@ describe('DebugProtectionFunctionCallTemplate (): string', () => {
});
});
describe('variant #3: obfuscated code with removed debug protection function call', () => {
describe('variant #3: obfuscated code with removed debug protection code', () => {
const expectedEvaluationResult: number = 0;
let obfuscatedCode: string,
@@ -135,4 +135,39 @@ describe('DebugProtectionFunctionCallTemplate (): string', () => {
assert.equal(evaluationResult, expectedEvaluationResult);
});
});
describe('variant #4: single call of debug protection code', () => {
const expectedEvaluationResult: number = 1;
let obfuscatedCode: string,
evaluationResult: number = 0;
beforeEach((done) => {
const code: string = readFileAsString(__dirname + '/fixtures/single-call.js');
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
code,
{
...NO_CUSTOM_NODES_PRESET,
debugProtection: true
}
);
obfuscatedCode = obfuscationResult.getObfuscatedCode();
spawnThread(
() => obfuscatedCode,
(response: number) => {
evaluationResult = response;
done();
},
() => {
done();
}
);
});
it('should correctly evaluate code with enabled debug protection', () => {
assert.equal(evaluationResult, expectedEvaluationResult);
});
});
});
@@ -0,0 +1,21 @@
(function () {
function foo () {
function bar () {
function baz () {
return 1;
}
return baz();
}
return bar();
}
for (var i = 0; i <= 10000; i++) {
if (i < 10000) {
foo();
} else {
return foo();
}
}
})();