From 336487645520117fa0029ca5676bcc4323e492b9 Mon Sep 17 00:00:00 2001
From: Shane Tomlinson <stomlinson@mozilla.com>
Date: Thu, 31 May 2012 16:27:02 +0100
Subject: [PATCH] Add some dev menu features.

* clear localStorage
* clear emails for sites
* force "Is this your computer?" screen
---
 resources/static/dialog/views/development.ejs |  3 +++
 .../static/shared/modules/development.js      | 26 ++++++++++++++++---
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/resources/static/dialog/views/development.ejs b/resources/static/dialog/views/development.ejs
index 18b5a2571..dd0b2d182 100644
--- a/resources/static/dialog/views/development.ejs
+++ b/resources/static/dialog/views/development.ejs
@@ -3,6 +3,9 @@
     <li><a id="showDelay" href="/">Show Delay</a></li>
     <li><a id="showWait" href="/">Show Wait</a></li>
     <li><a id="hideAll" href="/">Hide Screens</a></li>
+    <li><a id="clearLocalStorage" href="/">Clear localStorage</a></li>
+    <li><a id="clearEmailsForSites" href="/">Clear Site&lt;-&gt;Emails</a></li>
+    <li><a id="forceIsThisYourComputer" href="/">Force "Is This Your Computer"</a></li>
     <li><a id="closeDevelopment" href="/">Close</a></li>
 </ul>
 
diff --git a/resources/static/shared/modules/development.js b/resources/static/shared/modules/development.js
index e34b70c89..44257c215 100644
--- a/resources/static/shared/modules/development.js
+++ b/resources/static/shared/modules/development.js
@@ -10,14 +10,16 @@ BrowserID.Modules.Development = (function() {
   var bid = BrowserID,
       dom = bid.DOM,
       renderer = bid.Renderer,
-      count = 0;
+      storage = bid.Storage,
+      network = bid.Network,
+      clickCount = 0;
 
 
   function onDevelopmentClick(event) {
-    count++;
+    clickCount++;
 
 
-    if(count === 4) {
+    if(clickCount === 4) {
       if(!document.getElementById("development")) {
         renderer.append("body", "development", {});
       }
@@ -27,6 +29,9 @@ BrowserID.Modules.Development = (function() {
       this.click("#showDelay", showDelay);
       this.click("#showWait", showWait);
       this.click("#hideAll,footer,#errorBackground", hideScreens);
+      this.click("#clearLocalStorage", clearLocalStorage);
+      this.click("#clearEmailsForSites", clearEmailsForSites);
+      this.click("#forceIsThisYourComputer", forceIsThisYourComputer);
       this.click("#closeDevelopment", close);
     }
   }
@@ -64,10 +69,23 @@ BrowserID.Modules.Development = (function() {
     this.hideWait();
   }
 
+  function clearLocalStorage() {
+    for(var key in localStorage) {
+      localStorage.removeItem(key);
+    }
+  }
+
+  function clearEmailsForSites() {
+    localStorage.removeItem("siteInfo");
+  }
+
+  function forceIsThisYourComputer() {
+    storage.usersComputer.forceAsk(network.userid());
+  }
 
   function close() {
     dom.removeClass("body", "development");
-    count = 0;
+    clickCount = 0;
   }
 
   var Module = bid.Modules.PageModule.extend({
-- 
GitLab