Bug 1166921 - Support storage inspector stores-cleared event. r=mratcliffe
authorTim Nguyen <ntim.bugs@gmail.com>
Mon, 17 Aug 2015 15:29:58 -0700
changeset 258171 698d20c94746543bcfece4766a440e0d78f90e85
parent 258170 28077c310d985f70241ab37f30e55dfbf94b1c64
child 258172 eba41ce99321f1c9a2c508164e6991dfc4aedde8
push id63843
push userryanvm@gmail.com
push dateTue, 18 Aug 2015 14:58:06 +0000
treeherdermozilla-inbound@d55e24c983aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmratcliffe
bugs1166921
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1166921 - Support storage inspector stores-cleared event. r=mratcliffe
browser/devtools/storage/ui.js
--- a/browser/devtools/storage/ui.js
+++ b/browser/devtools/storage/ui.js
@@ -77,18 +77,21 @@ this.StorageUI = function StorageUI(fron
   this.sidebar = this._panelDoc.getElementById("storage-sidebar");
   this.sidebar.setAttribute("width", "300");
   this.view = new VariablesView(this.sidebar.firstChild,
                                 GENERIC_VARIABLES_VIEW_SETTINGS);
 
   this.front.listStores().then(storageTypes => {
     this.populateStorageTree(storageTypes);
   }).then(null, Cu.reportError);
+
   this.onUpdate = this.onUpdate.bind(this);
   this.front.on("stores-update", this.onUpdate);
+  this.onCleared = this.onCleared.bind(this);
+  this.front.on("stores-cleared", this.onCleared);
 
   this.handleKeypress = this.handleKeypress.bind(this);
   this._panelDoc.addEventListener("keypress", this.handleKeypress);
 
   this._telemetry = new Telemetry();
   this._telemetry.toolOpened("storage");
 }
 
@@ -96,16 +99,17 @@ exports.StorageUI = StorageUI;
 
 StorageUI.prototype = {
 
   storageTypes: null,
   shouldResetColumns: true,
 
   destroy: function() {
     this.front.off("stores-update", this.onUpdate);
+    this.front.off("stores-cleared", this.onCleared);
     this._panelDoc.removeEventListener("keypress", this.handleKeypress);
     this._telemetry.toolClosed("storage");
   },
 
   /**
    * Empties and hides the object viewer sidebar
    */
   hideSidebar: function() {
@@ -131,16 +135,30 @@ StorageUI.prototype = {
       this.displayObjectSidebar();
     }
     else {
       this.table.remove(name);
     }
   },
 
   /**
+   * Event handler for "stores-cleared" event coming from the storage actor.
+   *
+   * @param {object} argument0
+   *        An object containing which storage types were cleared
+   */
+  onCleared: function(response) {
+    let [type, host, db, objectStore] = this.tree.selectedItem;
+    if (response.hasOwnProperty(type) && response[type].indexOf(host) > -1) {
+      this.table.clear();
+      this.hideSidebar();
+    }
+  },
+
+  /**
    * Event handler for "stores-update" event coming from the storage actor.
    *
    * @param {object} argument0
    *        An object containing the details of the added, changed and deleted
    *        storage objects.
    *        Each of these 3 objects are of the following format:
    *        {
    *          <store_type1>: {