Bug 1261785 - Part 1: Fix promise rejections in storage inspector tests. r=mratcliffe

This commit is contained in:
Jarda Snajdr 2016-04-13 04:01:00 -04:00
parent 7814d5af7a
commit 1eaa53ea74
8 changed files with 24 additions and 32 deletions

View File

@ -28,7 +28,6 @@ support-files =
[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]

View File

@ -8,8 +8,6 @@
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");

View File

@ -8,8 +8,6 @@
add_task(function* () {
yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cookies.html");
yield gUI.table.once(TableWidget.EVENTS.FIELDS_EDITABLE);
showAllColumns(true);
yield startCellEdit("test4", "name");

View File

@ -8,8 +8,6 @@
add_task(function* () {
yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cookies.html");
yield gUI.table.once(TableWidget.EVENTS.FIELDS_EDITABLE);
showAllColumns(true);
yield startCellEdit("test1", "name");

View File

@ -10,7 +10,6 @@ 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");

View File

@ -10,7 +10,6 @@ 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");

View File

@ -34,13 +34,19 @@ 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();
}
@ -660,7 +666,7 @@ function* editCell(id, column, newValue, validate = true) {
editableFieldsEngine.edit(row[column]);
return yield typeWithTerminator(newValue, "VK_RETURN", validate);
yield typeWithTerminator(newValue, "VK_RETURN", validate);
}
/**

View File

@ -5,7 +5,6 @@
"use strict";
const {Cu} = require("chrome");
const EventEmitter = require("devtools/shared/event-emitter");
const {LocalizationHelper} = require("devtools/client/shared/l10n");
@ -194,15 +193,12 @@ StorageUI.prototype = {
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();
}
@ -404,7 +400,7 @@ StorageUI.prototype = {
* @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];
@ -416,21 +412,15 @@ StorageUI.prototype = {
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
@ -666,8 +656,10 @@ StorageUI.prototype = {
* @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) {
@ -684,7 +676,10 @@ StorageUI.prototype = {
}
this.table.setColumns(columns, null, HIDDEN_COLUMNS);
this.table.datatype = type;
this.table.host = host;
this.hideSidebar();
yield this.makeFieldsEditable();
},
/**