From 95170b2aa188923b6934ea7501ab8447d038607a Mon Sep 17 00:00:00 2001 From: Tim Nguyen Date: Mon, 17 Aug 2015 15:29:58 -0700 Subject: [PATCH] Bug 1166921 - Support storage inspector stores-cleared event. r=mratcliffe --- browser/devtools/storage/ui.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/browser/devtools/storage/ui.js b/browser/devtools/storage/ui.js index f166954f6fb6..801a94d50d27 100644 --- a/browser/devtools/storage/ui.js +++ b/browser/devtools/storage/ui.js @@ -82,8 +82,11 @@ this.StorageUI = function StorageUI(front, target, panelWin) { 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); @@ -101,6 +104,7 @@ StorageUI.prototype = { 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"); }, @@ -135,6 +139,20 @@ StorageUI.prototype = { } }, + /** + * 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. *