diff --git a/lib/server/controllers/apiController.js b/lib/server/controllers/apiController.js index 3c0462c..657aba5 100644 --- a/lib/server/controllers/apiController.js +++ b/lib/server/controllers/apiController.js @@ -33,7 +33,8 @@ 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 + jsTimeline: req.body.jsTimeline || false, + device: req.body.device || 'desktop' } }; @@ -66,7 +67,8 @@ var ApiController = function(app) { var runOptions = { screenshot: run.params.screenshot ? screenshot.getTmpFilePath() : false, - jsDeepAnalysis: run.params.jsTimeline + jsDeepAnalysis: run.params.jsTimeline, + device: run.params.device }; return ylt(run.params.url, runOptions); diff --git a/lib/tools/phantomas/phantomasWrapper.js b/lib/tools/phantomas/phantomasWrapper.js index 3e84138..f9b78c2 100644 --- a/lib/tools/phantomas/phantomasWrapper.js +++ b/lib/tools/phantomas/phantomasWrapper.js @@ -11,11 +11,6 @@ var PhantomasWrapper = function() { /** * This is the phantomas launcher. It merges user chosen options into the default options - * Available options : - * - * - timeout : in seconds (default 60) - * - jsDeepAnalysis : should we inspect subrequests in the javascript execution tree? - * */ this.execute = function(data) { @@ -27,7 +22,9 @@ var PhantomasWrapper = function() { // Cusomizable options 'timeout': task.options.timeout || 60, 'js-deep-analysis': task.options.jsDeepAnalysis || false, - 'user-agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36', + 'user-agent': (task.options.device === 'desktop') ? 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36' : null, + 'tablet': (task.options.device === 'tablet'), + 'phone': (task.options.device === 'phone'), 'screenshot': task.options.screenshot || false, // Mandatory @@ -64,7 +61,13 @@ var PhantomasWrapper = function() { value = '"' + value + '"'; } - optionsString += ' ' + '--' + opt + '=' + value; + if (value === true) { + optionsString += ' ' + '--' + opt; + } else if (value === false || value === null) { + // Nothing + } else { + optionsString += ' ' + '--' + opt + '=' + value; + } } debug('node node_modules/phantomas/bin/phantomas.js --url=' + task.url + optionsString + ' --verbose');