Bug 1261785 - Part 1: Fix promise rejections in storage inspector tests. r=mratcliffe
☠☠ backed out by f8c0dd78206c ☠ ☠
authorJarda Snajdr <jsnajdr@gmail.com>
Wed, 13 Apr 2016 04:01:00 -0400
changeset 293392 ff8aa19ba327597352157dbe53c7af971d38052a
parent 293391 c5b30ad336bd5004f87738fd0c4f48a60f22bbeb
child 293393 5d81dab28e18ffa65aed7e996996a386dce44199
push id18755
push userryanvm@gmail.com
push dateFri, 15 Apr 2016 20:28:27 +0000
treeherderfx-team@63f11876b0b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmratcliffe
bugs1261785
milestone48.0a1
Bug 1261785 - Part 1: Fix promise rejections in storage inspector tests. r=mratcliffe
devtools/client/storage/test/browser.ini
devtools/client/storage/test/browser_storage_cookies_edit.js
devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js
devtools/client/storage/test/browser_storage_cookies_tab_navigation.js
devtools/client/storage/test/browser_storage_localstorage_edit.js
devtools/client/storage/test/browser_storage_sessionstorage_edit.js
devtools/client/storage/test/head.js
devtools/client/storage/ui.js
--- a/devtools/client/storage/test/browser.ini
+++ b/devtools/client/storage/test/browser.ini
@@ -23,12 +23,11 @@ support-files =
 [browser_storage_cookies_tab_navigation.js]
 [browser_storage_dynamic_updates.js]
 [browser_storage_localstorage_edit.js]
 [browser_storage_delete.js]
 [browser_storage_delete_all.js]
 [browser_storage_delete_tree.js]
 [browser_storage_overflow.js]
 [browser_storage_search.js]
-skip-if = os == "linux" && e10s # Bug 1240804 - unhandled promise rejections
 [browser_storage_sessionstorage_edit.js]
 [browser_storage_sidebar.js]
 [browser_storage_values.js]
--- a/devtools/client/storage/test/browser_storage_cookies_edit.js
+++ b/devtools/client/storage/test/browser_storage_cookies_edit.js
@@ -3,18 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Basic test to check the editing of cookies.
 
 "use strict";
 
 add_task(function* () {
   yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cookies.html");
-  yield gUI.table.once(TableWidget.EVENTS.FIELDS_EDITABLE);
-
   showAllColumns(true);
 
   yield editCell("test3", "name", "newTest3");
   yield editCell("newTest3", "path", "/");
   yield editCell("newTest3", "host", "test1.example.org");
   yield editCell("newTest3", "expires", "Tue, 14 Feb 2040 17:41:14 GMT");
   yield editCell("newTest3", "value", "newValue3");
   yield editCell("newTest3", "isSecure", "true");
--- a/devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js
+++ b/devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js
@@ -3,18 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Basic test to check the editing of cookies with the keyboard.
 
 "use strict";
 
 add_task(function* () {
   yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cookies.html");
-  yield gUI.table.once(TableWidget.EVENTS.FIELDS_EDITABLE);
-
   showAllColumns(true);
 
   yield startCellEdit("test4", "name");
   yield typeWithTerminator("test6", "VK_TAB");
   yield typeWithTerminator("/", "VK_TAB");
   yield typeWithTerminator(".example.org", "VK_TAB");
   yield typeWithTerminator("Tue, 25 Dec 2040 12:00:00 GMT", "VK_TAB");
   yield typeWithTerminator("test6value", "VK_TAB");
--- a/devtools/client/storage/test/browser_storage_cookies_tab_navigation.js
+++ b/devtools/client/storage/test/browser_storage_cookies_tab_navigation.js
@@ -3,18 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Basic test to check cookie table tab navigation.
 
 "use strict";
 
 add_task(function* () {
   yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cookies.html");
-  yield gUI.table.once(TableWidget.EVENTS.FIELDS_EDITABLE);
-
   showAllColumns(true);
 
   yield startCellEdit("test1", "name");
 
   PressKeyXTimes("VK_TAB", 18);
   is(getCurrentEditorValue(), "value3",
      "We have tabbed to the correct cell.");
 
--- a/devtools/client/storage/test/browser_storage_localstorage_edit.js
+++ b/devtools/client/storage/test/browser_storage_localstorage_edit.js
@@ -5,17 +5,16 @@
 // Basic test to check the editing of localStorage.
 
 "use strict";
 
 add_task(function* () {
   yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-localstorage.html");
 
   yield selectTreeItem(["localStorage", "http://test1.example.org"]);
-  yield gUI.table.once(TableWidget.EVENTS.FIELDS_EDITABLE);
 
   yield editCell("TestLS1", "name", "newTestLS1");
   yield editCell("newTestLS1", "value", "newValueLS1");
 
   yield editCell("TestLS3", "name", "newTestLS3");
   yield editCell("newTestLS3", "value", "newValueLS3");
 
   yield editCell("TestLS5", "name", "newTestLS5");
--- a/devtools/client/storage/test/browser_storage_sessionstorage_edit.js
+++ b/devtools/client/storage/test/browser_storage_sessionstorage_edit.js
@@ -5,17 +5,16 @@
 // Basic test to check the editing of localStorage.
 
 "use strict";
 
 add_task(function* () {
   yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-sessionstorage.html");
 
   yield selectTreeItem(["sessionStorage", "http://test1.example.org"]);
-  yield gUI.table.once(TableWidget.EVENTS.FIELDS_EDITABLE);
 
   yield editCell("TestSS1", "name", "newTestSS1");
   yield editCell("newTestSS1", "value", "newValueSS1");
 
   yield editCell("TestSS3", "name", "newTestSS3");
   yield editCell("newTestSS3", "value", "newValueSS3");
 
   yield editCell("TestSS5", "name", "newTestSS5");
--- a/devtools/client/storage/test/head.js
+++ b/devtools/client/storage/test/head.js
@@ -29,23 +29,29 @@ var gToolbox, gPanelWindow, gWindow, gUI
 
 // Services.prefs.setBoolPref(DUMPEMIT_PREF, true);
 // Services.prefs.setBoolPref(DEBUGGERLOG_PREF, true);
 
 Services.prefs.setBoolPref(STORAGE_PREF, true);
 Services.prefs.setBoolPref(CACHES_ON_HTTP_PREF, true);
 DevToolsUtils.testing = true;
 registerCleanupFunction(() => {
+  DevToolsUtils.testing = false;
   gToolbox = gPanelWindow = gWindow = gUI = null;
   Services.prefs.clearUserPref(STORAGE_PREF);
   Services.prefs.clearUserPref(SPLIT_CONSOLE_PREF);
   Services.prefs.clearUserPref(DUMPEMIT_PREF);
   Services.prefs.clearUserPref(DEBUGGERLOG_PREF);
   Services.prefs.clearUserPref(CACHES_ON_HTTP_PREF);
-  DevToolsUtils.testing = false;
+});
+
+registerCleanupFunction(function* cleanup() {
+  let target = TargetFactory.forTab(gBrowser.selectedTab);
+  yield gDevTools.closeToolbox(target);
+
   while (gBrowser.tabs.length > 1) {
     gBrowser.removeCurrentTab();
   }
 });
 
 /**
  * Add a new test tab in the browser and load the given url.
  *
@@ -655,17 +661,17 @@ function getCellValue(id, column) {
  *        The uniqueId of the changed row.
  */
 function* editCell(id, column, newValue, validate = true) {
   let row = getRowCells(id, true);
   let editableFieldsEngine = gUI.table._editableFieldsEngine;
 
   editableFieldsEngine.edit(row[column]);
 
-  return yield typeWithTerminator(newValue, "VK_RETURN", validate);
+  yield typeWithTerminator(newValue, "VK_RETURN", validate);
 }
 
 /**
  * Begin edit mode for a cell.
  *
  * @param {String} id
  *        The uniqueId of the row.
  * @param {String} column
--- a/devtools/client/storage/ui.js
+++ b/devtools/client/storage/ui.js
@@ -1,16 +1,15 @@
 /* vim:set ts=2 sw=2 sts=2 et: */
 /* 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/. */
 
 "use strict";
 
-const {Cu} = require("chrome");
 const EventEmitter = require("devtools/shared/event-emitter");
 const {LocalizationHelper} = require("devtools/client/shared/l10n");
 
 loader.lazyRequireGetter(this, "TreeWidget",
                          "devtools/client/shared/widgets/TreeWidget", true);
 loader.lazyRequireGetter(this, "TableWidget",
                          "devtools/client/shared/widgets/TableWidget", true);
 loader.lazyImporter(this, "ViewHelpers",
@@ -189,25 +188,22 @@ StorageUI.prototype = {
   },
 
   getCurrentActor: function() {
     let type = this.table.datatype;
 
     return this.storageTypes[type];
   },
 
-  makeFieldsEditable: function() {
+  makeFieldsEditable: function* () {
     let actor = this.getCurrentActor();
 
     if (typeof actor.getEditableFields !== "undefined") {
-      actor.getEditableFields().then(fields => {
-        this.table.makeFieldsEditable(fields);
-      }).catch(() => {
-        // Do nothing
-      });
+      let fields = yield actor.getEditableFields();
+      this.table.makeFieldsEditable(fields);
     } else if (this.table._editableFieldsEngine) {
       this.table._editableFieldsEngine.destroy();
     }
   },
 
   editItem: function(eventType, data) {
     let actor = this.getCurrentActor();
 
@@ -399,43 +395,37 @@ StorageUI.prototype = {
    *        The type of storage. Ex. "cookies"
    * @param {string} host
    *        Hostname
    * @param {array} names
    *        Names of particular store objects. Empty if all are requested
    * @param {Constant} reason
    *        See REASON constant at top of file.
    */
-  fetchStorageObjects: function(type, host, names, reason) {
+  fetchStorageObjects: Task.async(function* (type, host, names, reason) {
     let fetchOpts = reason === REASON.NEXT_50_ITEMS ? {offset: this.itemOffset}
                                                     : {};
     let storageType = this.storageTypes[type];
 
     if (reason !== REASON.NEXT_50_ITEMS &&
         reason !== REASON.UPDATE &&
         reason !== REASON.NEW_ROW &&
         reason !== REASON.POPULATE) {
       throw new Error("Invalid reason specified");
     }
 
-    storageType.getStoreObjects(host, names, fetchOpts).then(({data}) => {
-      if (!data.length) {
-        this.emit("store-objects-updated");
-        return;
-      }
+    let {data} = yield storageType.getStoreObjects(host, names, fetchOpts);
+    if (data.length) {
       if (reason === REASON.POPULATE) {
-        this.resetColumns(data[0], type);
-        this.table.host = host;
+        yield this.resetColumns(data[0], type, host);
       }
       this.populateTable(data, reason);
-      this.emit("store-objects-updated");
-
-      this.makeFieldsEditable();
-    }, Cu.reportError);
-  },
+    }
+    this.emit("store-objects-updated");
+  }),
 
   /**
    * Populates the storage tree which displays the list of storages present for
    * the page.
    *
    * @param {object} storageTypes
    *        List of storages and their corresponding hosts returned by the
    *        StorageFront.listStores call.
@@ -661,35 +651,40 @@ StorageUI.prototype = {
    * Resets the column headers in the storage table with the pased object `data`
    *
    * @param {object} data
    *        The object from which key and values will be used for naming the
    *        headers of the columns
    * @param {string} type
    *        The type of storage corresponding to the after-reset columns in the
    *        table.
+   * @param {string} host
+   *        The host name corresponding to the table after reset.
    */
-  resetColumns: function(data, type) {
+  resetColumns: function* (data, type, host) {
     let columns = {};
     let uniqueKey = null;
     for (let key in data) {
       if (!uniqueKey) {
         this.table.uniqueId = uniqueKey = key;
       }
       columns[key] = key;
       try {
         columns[key] = L10N.getStr("table.headers." + type + "." + key);
       } catch (e) {
         console.error("Unable to localize table header type:" + type +
                       " key:" + key);
       }
     }
     this.table.setColumns(columns, null, HIDDEN_COLUMNS);
     this.table.datatype = type;
+    this.table.host = host;
     this.hideSidebar();
+
+    yield this.makeFieldsEditable();
   },
 
   /**
    * Populates or updates the rows in the storage table.
    *
    * @param {array[object]} data
    *        Array of objects to be populated in the storage table
    * @param {Constant} reason