diff --git a/lib/configuration.js b/lib/configuration.js index 3d8844623454906d01137f9fce3ea44b4b40ee94..ddd270369d86d632043e2d4cedb4c334f4fd13ec 100644 --- a/lib/configuration.js +++ b/lib/configuration.js @@ -98,7 +98,7 @@ g_configs.production = { g_configs.local = { URL: 'http://127.0.0.1:10002', email_to_console: true, // don't send email, just dump verification URLs to console. - use_minified_resources: true, + use_minified_resources: false, var_path: path.join(__dirname, "..", "var"), database: { driver: "json", diff --git a/resources/static/dialog/controllers/code_check.js b/resources/static/dialog/controllers/code_check.js index 8c2f25132d9200057cd0230514adbf98d8bebe82..4543cda71796f0623ef98d549393127a48d9a377 100644 --- a/resources/static/dialog/controllers/code_check.js +++ b/resources/static/dialog/controllers/code_check.js @@ -51,21 +51,22 @@ BrowserID.Modules.CodeCheck = (function() { data = data || {}; - if (data.code_ver) { - expectedCodeVer = data.code_ver; + self.checkRequired(data, "code_ver", "environment"); + expectedCodeVer = data.code_ver; + + if(data.environment === "PRODUCTION") { + getMostRecentCodeVersion.call(self, function(version) { + if(version) { + updateCodeIfNeeded.call(self, complete, version); + } + else { + complete(); + } + }); } else { - throw "init: code_ver must be defined"; + complete(true); } - - getMostRecentCodeVersion.call(self, function(version) { - if(version) { - updateCodeIfNeeded.call(self, complete, version); - } - else { - complete(); - } - }); sc.start.call(self, data); } }); diff --git a/resources/static/dialog/start.js b/resources/static/dialog/start.js index 9566d978bfac61c2b51c2c305b3434902b7ce9bd..77834cc71dc76d45883ba291c754c59d3e4e7d04 100644 --- a/resources/static/dialog/start.js +++ b/resources/static/dialog/start.js @@ -15,7 +15,8 @@ moduleManager.register("code_check", modules.CodeCheck); moduleManager.start("code_check", { - code_ver: "ABC123", + environment: "__BROWSERID_ENVIRONMENT__", + code_ver: "__BROWSERID_CODE_VERSION__", ready: function(status) { // if status is false, that means the javascript is out of date and we // have to reload. diff --git a/resources/static/test/qunit/controllers/code_check_unit_test.js b/resources/static/test/qunit/controllers/code_check_unit_test.js index c99de573c66bd562d87061edc485277064cdc8d5..875ce63e9704951af6605a88575c5fbdbe5ce855 100644 --- a/resources/static/test/qunit/controllers/code_check_unit_test.js +++ b/resources/static/test/qunit/controllers/code_check_unit_test.js @@ -14,7 +14,8 @@ function createController(config) { var config = $.extend({ - code_ver: "ABC123" + code_ver: "ABC123", + environment: "PRODUCTION" }, config); controller = BrowserID.Modules.CodeCheck.create(); @@ -33,21 +34,36 @@ } }); - asyncTest("create controller with most recent scripts", function() { + asyncTest("create controller with 'environment: DEBUG' - no code check performed", function() { + var scriptCount = $("head > script").length; + createController({ + environment: "DEBUG", ready: function(mostRecent) { - equal(mostRecent, true, "scripts are the most recent"); + equal(mostRecent, true, "working on the most recent version"); + + var scripts = $("head > script"); + var scriptAdded = scripts.length !== scriptCount; + + equal(scriptAdded, false, "a script was not added"); + + if(scriptAdded) { + // Only remove the last script if the script was actually added. + scripts.last().remove(); + } + start(); } }); }); - test("create controller without code_ver specified", function() { - raises(function() { - createController({ - code_ver: null - }); - }, "init: code_ver must be defined", "code version not specified throws exception"); + asyncTest("create controller with most recent scripts", function() { + createController({ + ready: function(mostRecent) { + equal(mostRecent, true, "scripts are the most recent"); + start(); + } + }); }); asyncTest("create controller with out of date scripts", function() {