Skip to content

Commit

Permalink
mozilla#155 - Working on mocha test migration
Browse files Browse the repository at this point in the history
  • Loading branch information
callicles committed Aug 17, 2014
1 parent 58fee7a commit 3f8e6d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions tests/cases/addEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
});
});
context(null, function () {
var good = 'var addEventListener = "variable with name";';
var good = acorn.parse('var addEventListener = "variable with name";', {locations: true});
it(good, function () {
chai.expect(ScanJS.scan(good, document.location.pathname)).to.be.empty;
});
});
});
context('detects dangerous patterns', function () {
context(null, function () {
var bad = 'var el = document.getElementById("outside");el.addEventListener("click", modifyText, false);';
var bad = acorn.parse('var el = document.getElementById("outside");el.addEventListener("click", modifyText, false);', {locations: true}) ;
it(bad, function () {
chai.expect(ScanJS.scan(bad, document.location.pathname)).not.to.be.empty;
});
});
context(null, function () {
var bad = 'addEventListener("click", errorPageEventHandler, true, false);';
var bad = acorn.parse('addEventListener("click", errorPageEventHandler, true, false);', {locations: true});
it(bad, function () {
chai.expect(ScanJS.scan(bad, document.location.pathname)).not.to.be.empty;
});
});
context(null, function () {
var bad = 'tab.linkedBrowser.addEventListener("load", function (event) {console.log(1);});';
var bad = acorn.parse('tab.linkedBrowser.addEventListener("load", function (event) {console.log(1);});', {locations: true});
it(bad, function () {
chai.expect(ScanJS.scan(bad, document.location.pathname)).not.to.be.empty;
});
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/production_ruletests.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ describe('Testing production rules (common/rules.json)', function () {
if(testsplit.trim()!=""){
it(rule.source + " should match " + testsplit, function () {
ScanJS.loadRules([rule]);
var results = ScanJS.scan(testsplit);
var results = ScanJS.scan(acorn.parse(testsplit, {locations: true}));
chai.expect(results.length).to.equal(1);
});
}
});

it(rule.name + " should not match " + rule.testmiss, function () {
ScanJS.loadRules([rule]);
var results = ScanJS.scan(rule.testmiss);
var results = ScanJS.scan(acorn.parse(rule.testmiss, {locations: true}));
chai.expect(results).to.have.length(0);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/test_ruletests.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ describe('Testing rule templates (common/template_rules.json)', function () {
if(testsplit.trim()!=""){
it(rule.source + " should match " + testsplit, function () {
ScanJS.loadRules([rule]);
var results = ScanJS.scan(testsplit);
var results = ScanJS.scan(acorn.parse(testsplit, {locations:true}));
chai.expect(results.length).to.equal(1);
});
}
});

it(rule.name + " should not match " + rule.testmiss, function () {
ScanJS.loadRules([rule]);
var results = ScanJS.scan(rule.testmiss);
var results = ScanJS.scan(acorn.parse(rule.testmiss, {locations:true}));
chai.expect(results).to.have.length(0);
});
});
Expand Down

0 comments on commit 3f8e6d1

Please sign in to comment.