From a2caffe93b79e8313f98f83b8749005d8eb6aa37 Mon Sep 17 00:00:00 2001 From: Shane Tomlinson <stomlinson@mozilla.com> Date: Thu, 9 Feb 2012 11:31:00 +0000 Subject: [PATCH] Removing the CodeCheck module and all the code_check* related js files. close #1082 --- resources/static/dialog/start.js | 47 +++----- resources/static/pages/start.js | 101 +++++++--------- resources/static/shared/modules/code_check.js | 77 ------------- .../test/cases/shared/modules/code_check.js | 109 ------------------ resources/views/dialog_layout.ejs | 1 - resources/views/layout.ejs | 1 - resources/views/test.ejs | 2 - scripts/compress-locales.sh | 4 +- 8 files changed, 64 insertions(+), 278 deletions(-) delete mode 100644 resources/static/shared/modules/code_check.js delete mode 100644 resources/static/test/cases/shared/modules/code_check.js diff --git a/resources/static/dialog/start.js b/resources/static/dialog/start.js index 1214df7df..8768ea7ac 100644 --- a/resources/static/dialog/start.js +++ b/resources/static/dialog/start.js @@ -19,35 +19,24 @@ ready: function(status) { if(!status) return; - moduleManager.register("code_check", modules.CodeCheck); - moduleManager.start("code_check", { - file_name_prefix: "dialog", - 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. - if(status) { - moduleManager.register("dialog", modules.Dialog); - moduleManager.register("add_email", modules.AddEmail); - moduleManager.register("authenticate", modules.Authenticate); - moduleManager.register("check_registration", modules.CheckRegistration); - moduleManager.register("forgot_password", modules.ForgotPassword); - moduleManager.register("pick_email", modules.PickEmail); - moduleManager.register("required_email", modules.RequiredEmail); - moduleManager.register("verify_primary_user", modules.VerifyPrimaryUser); - moduleManager.register("provision_primary_user", modules.ProvisionPrimaryUser); - moduleManager.register("primary_user_provisioned", modules.PrimaryUserProvisioned); - moduleManager.register("email_chosen", modules.EmailChosen); - moduleManager.register("xhr_delay", modules.XHRDelay); - moduleManager.register("xhr_disable_form", modules.XHRDisableForm); - - - moduleManager.start("xhr_delay"); - moduleManager.start("xhr_disable_form"); - moduleManager.start("dialog"); - } - } - }); + moduleManager.register("dialog", modules.Dialog); + moduleManager.register("add_email", modules.AddEmail); + moduleManager.register("authenticate", modules.Authenticate); + moduleManager.register("check_registration", modules.CheckRegistration); + moduleManager.register("forgot_password", modules.ForgotPassword); + moduleManager.register("pick_email", modules.PickEmail); + moduleManager.register("required_email", modules.RequiredEmail); + moduleManager.register("verify_primary_user", modules.VerifyPrimaryUser); + moduleManager.register("provision_primary_user", modules.ProvisionPrimaryUser); + moduleManager.register("primary_user_provisioned", modules.PrimaryUserProvisioned); + moduleManager.register("email_chosen", modules.EmailChosen); + moduleManager.register("xhr_delay", modules.XHRDelay); + moduleManager.register("xhr_disable_form", modules.XHRDisableForm); + + + moduleManager.start("xhr_delay"); + moduleManager.start("xhr_disable_form"); + moduleManager.start("dialog"); } }); }()); diff --git a/resources/static/pages/start.js b/resources/static/pages/start.js index 2d8f5dea3..250020b48 100644 --- a/resources/static/pages/start.js +++ b/resources/static/pages/start.js @@ -28,73 +28,60 @@ $(function() { xhr.init({ time_until_delay: 10 * 1000 }); network.init(); - moduleManager.register("code_check", CodeCheck); - $(".display_always,.display_auth,.display_nonauth").hide(); if ($('#vAlign').length) { $(window).bind('resize', function() { $('#vAlign').css({'height' : $(window).height() }); }).trigger('resize'); } + dom.addClass("body", "ready"); - moduleManager.start("code_check", { - file_name_prefix: "browserid", - code_ver: "__BROWSERID_CODE_VERSION", - ready: function(status) { - if(!status) return; - - dom.addClass("body", "ready"); - - moduleManager.register("xhr_delay", XHRDelay); - moduleManager.register("xhr_disable_form", XHRDisableForm); - if (!path || path === "/") { - bid.index(); - } - else if (path === "/signin") { - var module = bid.signIn.create(); - module.start({}); - } - else if (path === "/signup") { - bid.signUp(); - } - else if (path === "/forgot") { - bid.forgot(); - } - else if (path === "/add_email_address") { - var module = bid.addEmailAddress.create(); - module.start({ - token: token - }); - } - else if(token && path === "/verify_email_address") { - bid.verifyEmailAddress(token); - } - - $("a.signOut").click(function(event) { - event.preventDefault(); - event.stopPropagation(); - - user.logoutUser(function() { - document.location = "/"; - }, pageHelpers.getFailure(bid.Errors.logout)); - }); + moduleManager.register("xhr_delay", XHRDelay); + moduleManager.register("xhr_disable_form", XHRDisableForm); + if (!path || path === "/") { + bid.index(); + } + else if (path === "/signin") { + var module = bid.signIn.create(); + module.start({}); + } + else if (path === "/signup") { + bid.signUp(); + } + else if (path === "/forgot") { + bid.forgot(); + } + else if (path === "/add_email_address") { + var module = bid.addEmailAddress.create(); + module.start({ + token: token + }); + } + else if(token && path === "/verify_email_address") { + bid.verifyEmailAddress(token); + } - var ANIMATION_TIME = 500; - user.checkAuthentication(function(authenticated) { - $(".display_always").fadeIn(ANIMATION_TIME); + $("a.signOut").click(function(event) { + event.preventDefault(); + event.stopPropagation(); - dom.addClass("body", authenticated ? "authenticated" : "not_authenticated"); - if (authenticated) { - $(".display_auth").fadeIn(ANIMATION_TIME); - if ($('#emailList').length) { - bid.manageAccount(); - } - } - else { - $(".display_nonauth").fadeIn(ANIMATION_TIME); - } - }); + user.logoutUser(function() { + document.location = "/"; + }, pageHelpers.getFailure(bid.Errors.logout)); + }); + var ANIMATION_TIME = 500; + user.checkAuthentication(function(authenticated) { + $(".display_always").fadeIn(ANIMATION_TIME); + dom.addClass("body", authenticated ? "authenticated" : "not_authenticated"); + if (authenticated) { + $(".display_auth").fadeIn(ANIMATION_TIME); + if ($('#emailList').length) { + bid.manageAccount(); + } + } + else { + $(".display_nonauth").fadeIn(ANIMATION_TIME); } }); diff --git a/resources/static/shared/modules/code_check.js b/resources/static/shared/modules/code_check.js deleted file mode 100644 index 80856c524..000000000 --- a/resources/static/shared/modules/code_check.js +++ /dev/null @@ -1,77 +0,0 @@ -/*jshint browser:true, jQuery: true, forin: true, laxbreak:true */ -/*global BrowserID: true */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - - -BrowserID.Modules.CodeCheck = (function() { - "use strict"; - - var bid = BrowserID, - dom = bid.DOM, - sc, - expectedCodeVer, - fileNamePrefix; - - function getMostRecentCodeVersion(oncomplete) { - bid.Network.codeVersion(oncomplete, this.getErrorDialog(bid.Errors.checkScriptVersion, oncomplete)); - } - - function updateCodeIfNeeded(oncomplete, version) { - var mostRecent = version === expectedCodeVer; - - function ready() { - oncomplete && oncomplete(mostRecent); - } - - if(mostRecent) { - ready(); - } - else { - loadScript(version, ready); - } - } - - function loadScript(version, oncomplete) { - var script = document.createElement("script"); - script.type = "text/javascript"; - script.src = "https://browserid.org/production/" + fileNamePrefix + "_v" + version + ".js"; - document.head.appendChild(script); - - oncomplete(); - } - - var Module = bid.Modules.PageModule.extend({ - start: function(data) { - var self=this; - - function complete(val) { - data.ready && data.ready(val); - } - - data = data || {}; - - self.checkRequired(data, "code_ver", "file_name_prefix"); - expectedCodeVer = data.code_ver; - fileNamePrefix = data.file_name_prefix; - - getMostRecentCodeVersion.call(self, function(version) { - if(version) { - updateCodeIfNeeded.call(self, complete, version); - } - else { - complete(true); - } - }); - - sc.start.call(self, data); - } - }); - - sc = Module.sc; - - return Module; - -}()); - diff --git a/resources/static/test/cases/shared/modules/code_check.js b/resources/static/test/cases/shared/modules/code_check.js deleted file mode 100644 index c0701039d..000000000 --- a/resources/static/test/cases/shared/modules/code_check.js +++ /dev/null @@ -1,109 +0,0 @@ -/*jshint browsers:true, forin: true, laxbreak: true */ -/*global test: true, start: true, stop: true, module: true, ok: true, equal: true, BrowserID:true */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -(function() { - "use strict"; - - var bid = BrowserID, - transport = bid.Mocks.xhr, - helpers = bid.TestHelpers, - controller; - - function createController(config) { - var config = $.extend({ - file_name_prefix: "dialog", - code_ver: "ABC123" - }, config); - - controller = BrowserID.Modules.CodeCheck.create(); - controller.start(config); - } - - module("shared/modules/code_check", { - setup: function() { - helpers.setup(); - }, - - teardown: function() { - helpers.teardown(); - - controller.destroy(); - } - }); - - 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 no 'current' code_version given - do not update scripts", function() { - - transport.setContextInfo("code_version", undefined); - - var scriptCount = $("head > script").length; - - createController({ - code_ver: "ABC123", - ready: function(mostRecent) { - equal(mostRecent, true, "scripts are the most recent"); - var scripts = $("head > script"); - var scriptAdded = scripts.length !== scriptCount; - - equal(scriptAdded, false, "a script was not added to the dom"); - - if(scriptAdded) { - // Only remove the last script if the script was actually added. - scripts.last().remove(); - } - - start(); - } - }); - }); - asyncTest("create controller with out of date scripts", function() { - var scriptCount = $("head > script").length; - transport.setContextInfo("code_version", "ABC123"); - - createController({ - code_ver: "ABC122", - ready: function(mostRecent) { - equal(mostRecent, false, "scripts are not the most recent"); - var scripts = $("head > script"); - var scriptAdded = scripts.length !== scriptCount; - - equal(scriptAdded, true, "a script was added to the dom to force reload"); - - if(scriptAdded) { - // Only remove the last script if the script was actually added. - scripts.last().remove(); - } - - start(); - } - }); - }); - - asyncTest("create controller with XHR error during script check", function() { - transport.useResult("contextAjaxError"); - var scriptCount = $("head > script").length; - - createController({ - ready: function() { - helpers.checkNetworkError(); - var scripts = $("head > script"); - var scriptAdded = scripts.length !== scriptCount; - - equal(scriptAdded, false, "a script was not added on XHR error"); - start(); - } - }); - }); - -}()); - diff --git a/resources/views/dialog_layout.ejs b/resources/views/dialog_layout.ejs index 7a5e9b639..edefc45f3 100644 --- a/resources/views/dialog_layout.ejs +++ b/resources/views/dialog_layout.ejs @@ -93,7 +93,6 @@ <script src="/shared/modules/page_module.js"></script> <script src="/shared/modules/xhr_delay.js"></script> <script src="/shared/modules/xhr_disable_form.js"></script> - <script src="/shared/modules/code_check.js"></script> <script src="/shared/modules/cookie_check.js"></script> <script src="/dialog/resources/internal_api.js"></script> diff --git a/resources/views/layout.ejs b/resources/views/layout.ejs index 6dfd54115..118292f33 100644 --- a/resources/views/layout.ejs +++ b/resources/views/layout.ejs @@ -55,7 +55,6 @@ <script src="/shared/modules/page_module.js"></script> <script src="/shared/modules/xhr_delay.js"></script> <script src="/shared/modules/xhr_disable_form.js"></script> - <script src="/shared/modules/code_check.js"></script> <script src="/shared/modules/cookie_check.js"></script> <script src="/pages/page_helpers.js"></script> diff --git a/resources/views/test.ejs b/resources/views/test.ejs index 25d2928bd..073bc76d5 100644 --- a/resources/views/test.ejs +++ b/resources/views/test.ejs @@ -106,7 +106,6 @@ <script src="/shared/modules/page_module.js"></script> <script src="/shared/modules/xhr_delay.js"></script> <script src="/shared/modules/xhr_disable_form.js"></script> - <script src="/shared/modules/code_check.js"></script> <script src="/shared/modules/cookie_check.js"></script> <script src="/dialog/resources/internal_api.js"></script> @@ -156,7 +155,6 @@ <script src="cases/shared/modules/page_module.js"></script> <script src="cases/shared/modules/xhr_delay.js"></script> <script src="cases/shared/modules/xhr_disable_form.js"></script> - <script src="cases/shared/modules/code_check.js"></script> <script src="cases/shared/modules/cookie_check.js"></script> <script src="cases/pages/browserid.js"></script> diff --git a/scripts/compress-locales.sh b/scripts/compress-locales.sh index 987b3fd99..6264656b5 100755 --- a/scripts/compress-locales.sh +++ b/scripts/compress-locales.sh @@ -52,7 +52,7 @@ for locale in $locales; do mkdir -p $BUILD_PATH/../i18n/$locale # Touch as the trigger locale doesn't really exist touch $BUILD_PATH/../i18n/${locale}/client.json - cat lib/jquery-1.7.1.min.js lib/winchan.js lib/underscore-min.js lib/vepbundle.js lib/ejs.js shared/javascript-extensions.js i18n/${locale}/client.json shared/gettext.js shared/browserid.js lib/hub.js lib/dom-jquery.js lib/module.js lib/jschannel.js $BUILD_PATH/templates.js shared/renderer.js shared/class.js shared/mediator.js shared/tooltip.js shared/validation.js shared/helpers.js shared/screens.js shared/browser-support.js shared/wait-messages.js shared/error-messages.js shared/error-display.js shared/storage.js shared/xhr.js shared/network.js shared/provisioning.js shared/user.js shared/command.js shared/history.js shared/state_machine.js shared/modules/page_module.js shared/modules/xhr_delay.js shared/modules/xhr_disable_form.js shared/modules/code_check.js shared/modules/cookie_check.js dialog/resources/internal_api.js dialog/resources/helpers.js dialog/resources/state.js dialog/controllers/actions.js dialog/controllers/dialog.js dialog/controllers/authenticate.js dialog/controllers/forgot_password.js dialog/controllers/check_registration.js dialog/controllers/pick_email.js dialog/controllers/add_email.js dialog/controllers/required_email.js dialog/controllers/verify_primary_user.js dialog/controllers/provision_primary_user.js dialog/controllers/primary_user_provisioned.js dialog/controllers/email_chosen.js dialog/start.js > $BUILD_PATH/$locale/dialog.uncompressed.js + cat lib/jquery-1.7.1.min.js lib/winchan.js lib/underscore-min.js lib/vepbundle.js lib/ejs.js shared/javascript-extensions.js i18n/${locale}/client.json shared/gettext.js shared/browserid.js lib/hub.js lib/dom-jquery.js lib/module.js lib/jschannel.js $BUILD_PATH/templates.js shared/renderer.js shared/class.js shared/mediator.js shared/tooltip.js shared/validation.js shared/helpers.js shared/screens.js shared/browser-support.js shared/wait-messages.js shared/error-messages.js shared/error-display.js shared/storage.js shared/xhr.js shared/network.js shared/provisioning.js shared/user.js shared/command.js shared/history.js shared/state_machine.js shared/modules/page_module.js shared/modules/xhr_delay.js shared/modules/xhr_disable_form.js shared/modules/cookie_check.js dialog/resources/internal_api.js dialog/resources/helpers.js dialog/resources/state.js dialog/controllers/actions.js dialog/controllers/dialog.js dialog/controllers/authenticate.js dialog/controllers/forgot_password.js dialog/controllers/check_registration.js dialog/controllers/pick_email.js dialog/controllers/add_email.js dialog/controllers/required_email.js dialog/controllers/verify_primary_user.js dialog/controllers/provision_primary_user.js dialog/controllers/primary_user_provisioned.js dialog/controllers/email_chosen.js dialog/start.js > $BUILD_PATH/$locale/dialog.uncompressed.js done echo '' @@ -61,7 +61,7 @@ echo '' #produce the main site js for locale in $locales; do - cat lib/vepbundle.js lib/jquery-1.7.1.min.js lib/underscore-min.js lib/ejs.js shared/javascript-extensions.js i18n/${locale}/client.json shared/gettext.js shared/browserid.js lib/dom-jquery.js lib/module.js lib/jschannel.js lib/winchan.js lib/hub.js $BUILD_PATH/templates.js shared/renderer.js shared/class.js shared/mediator.js shared/tooltip.js shared/validation.js shared/helpers.js shared/screens.js shared/browser-support.js shared/wait-messages.js shared/error-messages.js shared/error-display.js shared/mediator.js shared/storage.js shared/xhr.js shared/network.js shared/provisioning.js shared/user.js shared/modules/page_module.js shared/modules/xhr_delay.js shared/modules/xhr_disable_form.js shared/modules/code_check.js shared/modules/cookie_check.js pages/page_helpers.js pages/start.js pages/index.js pages/add_email_address.js pages/verify_email_address.js pages/forgot.js pages/manage_account.js pages/signin.js pages/signup.js > $BUILD_PATH/$locale/browserid.uncompressed.js + cat lib/vepbundle.js lib/jquery-1.7.1.min.js lib/underscore-min.js lib/ejs.js shared/javascript-extensions.js i18n/${locale}/client.json shared/gettext.js shared/browserid.js lib/dom-jquery.js lib/module.js lib/jschannel.js lib/winchan.js lib/hub.js $BUILD_PATH/templates.js shared/renderer.js shared/class.js shared/mediator.js shared/tooltip.js shared/validation.js shared/helpers.js shared/screens.js shared/browser-support.js shared/wait-messages.js shared/error-messages.js shared/error-display.js shared/mediator.js shared/storage.js shared/xhr.js shared/network.js shared/provisioning.js shared/user.js shared/modules/page_module.js shared/modules/xhr_delay.js shared/modules/xhr_disable_form.js shared/modules/cookie_check.js pages/page_helpers.js pages/start.js pages/index.js pages/add_email_address.js pages/verify_email_address.js pages/forgot.js pages/manage_account.js pages/signin.js pages/signup.js > $BUILD_PATH/$locale/browserid.uncompressed.js done echo '' -- GitLab