From e2210f4437886afacd3aabaa4a97a3ef3531d3c1 Mon Sep 17 00:00:00 2001
From: Shane Tomlinson <stomlinson@mozilla.com>
Date: Fri, 24 Feb 2012 16:01:16 +0000
Subject: [PATCH] Removing the offline check code that was already disabled.

* Remove checks, tests and strings.

issue #1188
---
 .../static/dialog/controllers/actions.js      |  4 --
 resources/static/dialog/controllers/dialog.js | 52 ++++++-------------
 resources/static/dialog/resources/state.js    |  4 --
 resources/static/dialog/views/offline.ejs     | 12 -----
 resources/static/shared/error-messages.js     |  5 --
 .../static/test/cases/controllers/actions.js  | 11 ----
 .../static/test/cases/resources/state.js      |  8 +--
 7 files changed, 18 insertions(+), 78 deletions(-)
 delete mode 100644 resources/static/dialog/views/offline.ejs

diff --git a/resources/static/dialog/controllers/actions.js b/resources/static/dialog/controllers/actions.js
index bdc78df16..320877daf 100644
--- a/resources/static/dialog/controllers/actions.js
+++ b/resources/static/dialog/controllers/actions.js
@@ -67,10 +67,6 @@ BrowserID.Modules.Actions = (function() {
       this.renderError(template, info);
     },
 
-    doOffline: function() {
-      this.renderError("offline", {});
-    },
-
     doCancel: function() {
       if(onsuccess) onsuccess(null);
     },
diff --git a/resources/static/dialog/controllers/dialog.js b/resources/static/dialog/controllers/dialog.js
index 7192887df..74a30d092 100644
--- a/resources/static/dialog/controllers/dialog.js
+++ b/resources/static/dialog/controllers/dialog.js
@@ -16,15 +16,6 @@ BrowserID.Modules.Dialog = (function() {
       channel,
       sc;
 
-  function checkOnline() {
-    if (false && 'onLine' in navigator && !navigator.onLine) {
-      this.publish("offline");
-      return false;
-    }
-
-    return true;
-  }
-
   function startActions(onsuccess, onerror) {
     var actions = BrowserID.Modules.Actions.create();
     actions.start({
@@ -121,35 +112,26 @@ BrowserID.Modules.Dialog = (function() {
       var actions = startActions.call(self, success, error);
       startStateMachine.call(self, actions);
 
-      if(checkOnline.call(self)) {
-        params = params || {};
-
-        params.hostname = user.getHostname();
-
-        // XXX Perhaps put this into the state machine.
-        self.bind(win, "unload", onWindowUnload);
+      params = params || {};
+      params.hostname = user.getHostname();
 
-        if(hash.indexOf("#CREATE_EMAIL=") === 0) {
-          var email = hash.replace(/#CREATE_EMAIL=/, "");
-          params.type = "primary";
-          params.email = email;
-          params.add = false;
-        }
-        else if(hash.indexOf("#ADD_EMAIL=") === 0) {
-          var email = hash.replace(/#ADD_EMAIL=/, "");
-          params.type = "primary";
-          params.email = email;
-          params.add = true;
-        }
-
-        /*
-        if(hash.indexOf("REQUIRED=true") > -1) {
-          params.requiredEmail = params.email;
-        }
-        */
+      // XXX Perhaps put this into the state machine.
+      self.bind(win, "unload", onWindowUnload);
 
-        self.publish("start", params);
+      if(hash.indexOf("#CREATE_EMAIL=") === 0) {
+        var email = hash.replace(/#CREATE_EMAIL=/, "");
+        params.type = "primary";
+        params.email = email;
+        params.add = false;
+      }
+      else if(hash.indexOf("#ADD_EMAIL=") === 0) {
+        var email = hash.replace(/#ADD_EMAIL=/, "");
+        params.type = "primary";
+        params.email = email;
+        params.add = true;
       }
+
+      self.publish("start", params);
     }
 
     // BEGIN TESTING API
diff --git a/resources/static/dialog/resources/state.js b/resources/static/dialog/resources/state.js
index 846eaddb7..9759b9a3c 100644
--- a/resources/static/dialog/resources/state.js
+++ b/resources/static/dialog/resources/state.js
@@ -32,10 +32,6 @@ BrowserID.State = (function() {
         },
         cancelState = self.popState.bind(self);
 
-    subscribe("offline", function(msg, info) {
-      startState("doOffline");
-    });
-
     subscribe("start", function(msg, info) {
       info = info || {};
 
diff --git a/resources/static/dialog/views/offline.ejs b/resources/static/dialog/views/offline.ejs
deleted file mode 100644
index 942e98958..000000000
--- a/resources/static/dialog/views/offline.ejs
+++ /dev/null
@@ -1,12 +0,0 @@
-<!-- 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/. -->
-
-
-  <h2 id="offline"><%= gettext('You are offline!') %></h2>
-
-  <p>
-    <%= gettext('We are sorry, but we cannot communicate with BrowserID while you are offline.') %>
-  </p>
-
-
diff --git a/resources/static/shared/error-messages.js b/resources/static/shared/error-messages.js
index fcedfc5ce..3616066ba 100644
--- a/resources/static/shared/error-messages.js
+++ b/resources/static/shared/error-messages.js
@@ -78,11 +78,6 @@ BrowserID.Errors = (function(){
       title: "Logout Failed"
     },
 
-    offline: {
-      title: gettext("You are offline!"),
-      message: gettext("Unfortunately, BrowserID cannot communicate while offline!")
-    },
-
     primaryAuthentication: {
       title: "Authenticating with Identity Provider",
       message: "We had trouble communicating with your email provider, please try again!"
diff --git a/resources/static/test/cases/controllers/actions.js b/resources/static/test/cases/controllers/actions.js
index 20593ecac..c670633e8 100644
--- a/resources/static/test/cases/controllers/actions.js
+++ b/resources/static/test/cases/controllers/actions.js
@@ -54,17 +54,6 @@
     });
   });
 
-  asyncTest("doOffline - print offline error screen", function() {
-    createController({
-      ready: function() {
-        controller.doOffline();
-        ok($("#error .contents").text().length, "contents have been written");
-        ok($("#error #offline").text().length, "offline error message has been written");
-        start();
-      }
-    });
-  });
-
   asyncTest("doProvisionPrimaryUser - start the provision_primary_user service", function() {
     createController({
       ready: function() {
diff --git a/resources/static/test/cases/resources/state.js b/resources/static/test/cases/resources/state.js
index 9bdb1d44c..c951c5ec9 100644
--- a/resources/static/test/cases/resources/state.js
+++ b/resources/static/test/cases/resources/state.js
@@ -67,12 +67,6 @@
     equal(error, "start: controller must be specified", "creating a state machine without a controller fails");
   });
 
-  test("offline does offline", function() {
-    mediator.publish("offline");
-
-    equal(actions.called.doOffline, true, "controller is offline");
-  });
-
   test("user_staged - call doConfirmUser", function() {
     mediator.publish("user_staged", {
       email: "testuser@testuser.com"
@@ -359,7 +353,7 @@
 
     equal(error, "invalid email", "expected exception thrown");
   });
-  
+
   test("null assertion generated - preserve original options in doPickEmail", function() {
     mediator.publish("start", { allowPersistent: true });
     mediator.publish("assertion_generated", { assertion: null });
-- 
GitLab