diff --git a/lib/server/controllers/apiController.js b/lib/server/controllers/apiController.js index a74d359..3c0462c 100644 --- a/lib/server/controllers/apiController.js +++ b/lib/server/controllers/apiController.js @@ -32,7 +32,8 @@ var ApiController = function(app) { url: req.body.url, waitForResponse: req.body.waitForResponse !== false && req.body.waitForResponse !== 'false' && req.body.waitForResponse !== 0, partialResult: req.body.partialResult || null, - screenshot: req.body.screenshot || false + screenshot: req.body.screenshot || false, + jsTimeline: req.body.jsTimeline || false } }; @@ -64,7 +65,8 @@ var ApiController = function(app) { debug('Launching test %s on %s', run.runId, run.params.url); var runOptions = { - screenshot: run.params.screenshot ? screenshot.getTmpFilePath() : false + screenshot: run.params.screenshot ? screenshot.getTmpFilePath() : false, + jsDeepAnalysis: run.params.jsTimeline }; return ylt(run.params.url, runOptions); @@ -107,7 +109,16 @@ var ApiController = function(app) { // Save results .then(function() { + // Remove uneeded temp screenshot path delete data.params.options.screenshot; + + // Empty javascriptExecutionTree if not needed + if (!run.params.jsTimeline) { + data.javascriptExecutionTree = {}; + } + + // Remove tools results if not needed + return resultsDatastore.saveResult(data); }) diff --git a/test/api/apiTest.js b/test/api/apiTest.js index 4e960d2..74be9f3 100644 --- a/test/api/apiTest.js +++ b/test/api/apiTest.js @@ -159,7 +159,10 @@ describe('api', function() { body.should.have.a.property('scoreProfiles').that.is.an('object'); body.should.have.a.property('rules').that.is.an('object'); body.should.have.a.property('toolsResults').that.is.an('object'); + + // javascriptExecutionTree should only be filled if option jsTimeline is true body.should.have.a.property('javascriptExecutionTree').that.is.an('object'); + body.javascriptExecutionTree.should.deep.equal({}); // Check if the screenshot temporary file was correctly removed body.params.options.should.not.have.a.property('screenshot'); @@ -188,7 +191,8 @@ describe('api', function() { url: serverUrl + '/api/runs', body: { url: wwwUrl + '/simple-page.html', - waitForResponse: false + waitForResponse: false, + jsTimeline: true }, json: true, headers: {