From 14f60d8dd3b5b61b3a9db00227160ea4d6d534aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Thu, 24 Mar 2016 09:46:08 +0200 Subject: [PATCH] Remove --js-deep-analylis & jsTimeline options, they are now on by default --- bin/cli.js | 6 --- front/src/js/services/apiService.js | 1 - lib/server/controllers/apiController.js | 10 +---- .../custom_modules/core/scopeYLT/scopeYLT.js | 38 +++++++------------ lib/tools/phantomas/phantomasWrapper.js | 1 - test/api/apiTest.js | 3 +- 6 files changed, 16 insertions(+), 43 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index 54cfbe8..681e003 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -15,7 +15,6 @@ var cli = meow({ 'Options:', ' --device Use "phone" or "tablet" to simulate a mobile device (by user-agent and viewport size).', ' --screenshot Will take a screenshot and use this value as the output path. It needs to end with ".png".', - ' --js-deep-analysis When activated, the javascriptExecutionTree will contain sub-requests.', ' --wait-for-selector Once the page is loaded, Phantomas will wait until the given CSS selector matches some elements.', ' --cookie Adds a cookie on the main domain.', ' --auth-user Basic HTTP authentication username.', @@ -51,11 +50,6 @@ if (screenshot) { options.screenshot = cli.flags.screenshot; } -// Deep JS analysis option -if (cli.flags.jsDeepAnalysis === true || cli.flags.jsDeepAnalysis === 'true') { - options.jsDeepAnalysis = true; -} - // Device simulation options.device = cli.flags.device || 'desktop'; diff --git a/front/src/js/services/apiService.js b/front/src/js/services/apiService.js index 95aad1e..ba2680b 100644 --- a/front/src/js/services/apiService.js +++ b/front/src/js/services/apiService.js @@ -9,7 +9,6 @@ apiService.factory('API', ['$location', 'Runs', 'Results', function($location, R url: url, waitForResponse: false, screenshot: true, - jsTimeline: true, device: settings.device, waitForSelector: settings.waitForSelector, cookie: settings.cookie, diff --git a/lib/server/controllers/apiController.js b/lib/server/controllers/apiController.js index 28ecd81..952932d 100644 --- a/lib/server/controllers/apiController.js +++ b/lib/server/controllers/apiController.js @@ -34,7 +34,6 @@ var ApiController = function(app) { waitForResponse: req.body.waitForResponse !== false && req.body.waitForResponse !== 'false' && req.body.waitForResponse !== 0, partialResult: req.body.partialResult || null, screenshot: req.body.screenshot || false, - jsTimeline: req.body.jsTimeline || false, device: req.body.device || 'desktop', waitForSelector: req.body.waitForSelector || null, cookie: req.body.cookie || null, @@ -74,7 +73,6 @@ var ApiController = function(app) { var runOptions = { screenshot: run.params.screenshot ? screenshot.getTmpFilePath() : false, - jsDeepAnalysis: run.params.jsTimeline, device: run.params.device, waitForSelector: run.params.waitForSelector, cookie: run.params.cookie, @@ -135,13 +133,7 @@ var ApiController = function(app) { // Remove uneeded temp screenshot path delete data.params.options.screenshot; - // Empty javascriptExecutionTree if not needed - if (!run.params.jsTimeline) { - data.javascriptExecutionTree = {}; - data.scrollExecutionTree = {}; - } - - // Remove tools results if not needed + // Here we can remove tools results if not needed return resultsDatastore.saveResult(data); }) diff --git a/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js b/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js index 7acac57..aa0aaa7 100644 --- a/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js +++ b/lib/tools/phantomas/custom_modules/core/scopeYLT/scopeYLT.js @@ -19,7 +19,7 @@ exports.module = function(phantomas) { }); phantomas.on('init', function() { - phantomas.evaluate(function(responseEndTime, deepAnalysis) { + phantomas.evaluate(function(responseEndTime) { (function(phantomas) { // Overwritting phantomas spy function @@ -106,9 +106,6 @@ exports.module = function(phantomas) { var currentContext = root; var depth = 0; - if (deepAnalysis) { - phantomas.log('Entering deep Javascript analysis mode'); - } // Add a child but don't enter its context function pushContext(data) { @@ -129,9 +126,7 @@ exports.module = function(phantomas) { } } - if (depth === 0 || deepAnalysis) { - currentContext.addChild(data); - } + currentContext.addChild(data); } // Add a child to the current context and enter its context @@ -153,9 +148,7 @@ exports.module = function(phantomas) { } } - if (depth === 0 || deepAnalysis) { - currentContext = currentContext.addChild(data); - } + currentContext = currentContext.addChild(data); depth ++; } @@ -178,21 +171,18 @@ exports.module = function(phantomas) { } } - if (depth === 1 || deepAnalysis) { - - // Merge previous data with moreData (ovewrites if exists) - if (moreData) { - for (var key in moreData) { - currentContext.data[key] = moreData[key]; - } + // Merge previous data with moreData (ovewrites if exists) + if (moreData) { + for (var key in moreData) { + currentContext.data[key] = moreData[key]; } + } - var parent = currentContext.parent; - if (parent === null) { - console.error('Error: trying to close root context in ContextTree'); - } else { - currentContext = parent; - } + var parent = currentContext.parent; + if (parent === null) { + console.error('Error: trying to close root context in ContextTree'); + } else { + currentContext = parent; } depth --; @@ -255,6 +245,6 @@ exports.module = function(phantomas) { })(); })(window.__phantomas); - }, responseEndTime, phantomas.getParam('js-deep-analysis')); + }, responseEndTime); }); }; diff --git a/lib/tools/phantomas/phantomasWrapper.js b/lib/tools/phantomas/phantomasWrapper.js index 6eeb20f..ac1dfa5 100644 --- a/lib/tools/phantomas/phantomasWrapper.js +++ b/lib/tools/phantomas/phantomasWrapper.js @@ -22,7 +22,6 @@ var PhantomasWrapper = function() { // Cusomizable options 'engine': task.options.phantomasEngine || 'webkit', 'timeout': task.options.timeout || 30, - 'js-deep-analysis': task.options.jsDeepAnalysis || false, 'user-agent': (task.options.device === 'desktop') ? 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) YLT Chrome/27.0.1453.110 Safari/537.36' : null, 'tablet': (task.options.device === 'tablet'), 'phone': (task.options.device === 'phone'), diff --git a/test/api/apiTest.js b/test/api/apiTest.js index 10751d5..c47ec97 100644 --- a/test/api/apiTest.js +++ b/test/api/apiTest.js @@ -170,9 +170,8 @@ describe('api', function() { 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({}); + body.javascriptExecutionTree.should.not.deep.equal({}); // Check if settings are correctly sent and retrieved body.params.options.should.have.a.property('device').that.equals('tablet');