From 2f1fb39eee160b70963981f0d7065b852af5881f Mon Sep 17 00:00:00 2001 From: Noemi Erli Date: Tue, 13 Mar 2018 01:56:34 +0200 Subject: [PATCH] Backed out 2 changesets (bug 1444414, bug 1444357) for merge conflicts a=backout Backed out changeset 6f0c06b06b6e (bug 1444414) Backed out changeset ef01364e8730 (bug 1444357) --- devtools/client/shared/widgets/TreeWidget.js | 19 ------- .../browser_storage_cookies_delete_all.js | 2 +- .../storage/test/browser_storage_delete.js | 2 +- .../test/browser_storage_delete_tree.js | 2 +- .../browser_storage_delete_usercontextid.js | 2 +- ...browser_storage_dynamic_updates_cookies.js | 49 +++++++------------ ...er_storage_dynamic_updates_localStorage.js | 30 +++--------- ..._storage_dynamic_updates_sessionStorage.js | 31 +++--------- .../test/browser_storage_indexeddb_delete.js | 3 +- ...rowser_storage_indexeddb_delete_blocked.js | 4 +- devtools/client/storage/test/head.js | 19 ++++--- devtools/client/storage/ui.js | 22 ++++----- 12 files changed, 63 insertions(+), 122 deletions(-) diff --git a/devtools/client/shared/widgets/TreeWidget.js b/devtools/client/shared/widgets/TreeWidget.js index 8678f6176989..cc927b9c2c20 100644 --- a/devtools/client/shared/widgets/TreeWidget.js +++ b/devtools/client/shared/widgets/TreeWidget.js @@ -272,25 +272,6 @@ TreeWidget.prototype = { this.setPlaceholderText(""); }, - /** - * Check if an item exists. - * - * @param {array} item - * The array of ids leading up to the item. - */ - exists: function (item) { - let bookmark = this.root; - - for (let id of item) { - if (bookmark.items.has(id)) { - bookmark = bookmark.items.get(id); - } else { - return false; - } - } - return true; - }, - /** * Removes the specified item and all of its child items from the tree. * diff --git a/devtools/client/storage/test/browser_storage_cookies_delete_all.js b/devtools/client/storage/test/browser_storage_cookies_delete_all.js index 6fc8bc2a9b2a..b8c0418f895d 100644 --- a/devtools/client/storage/test/browser_storage_cookies_delete_all.js +++ b/devtools/client/storage/test/browser_storage_cookies_delete_all.js @@ -22,7 +22,7 @@ function* performDelete(store, rowName, action) { yield selectTreeItem(store); - let eventWait = gUI.once("store-objects-edit"); + let eventWait = gUI.once("store-objects-updated"); let cells = getRowCells(rowName, true); yield waitForContextMenu(contextMenu, cells.name, () => { diff --git a/devtools/client/storage/test/browser_storage_delete.js b/devtools/client/storage/test/browser_storage_delete.js index 4d02d8ac0d66..f154c6a6827c 100644 --- a/devtools/client/storage/test/browser_storage_delete.js +++ b/devtools/client/storage/test/browser_storage_delete.js @@ -38,7 +38,7 @@ add_task(function* () { let row = getRowCells(rowName); ok(gUI.table.items.has(rowName), `There is a row '${rowName}' in ${treeItemName}`); - let eventWait = gUI.once("store-objects-edit"); + let eventWait = gUI.once("store-objects-updated"); yield waitForContextMenu(contextMenu, row[cellToClick], () => { info(`Opened context menu in ${treeItemName}, row '${rowName}'`); diff --git a/devtools/client/storage/test/browser_storage_delete_tree.js b/devtools/client/storage/test/browser_storage_delete_tree.js index fbd56166c2b5..32fd410a0d84 100644 --- a/devtools/client/storage/test/browser_storage_delete_tree.js +++ b/devtools/client/storage/test/browser_storage_delete_tree.js @@ -50,7 +50,7 @@ add_task(function* () { yield selectTreeItem(store); let eventName = "store-objects-" + - (store[0] == "cookies" ? "edit" : "cleared"); + (store[0] == "cookies" ? "updated" : "cleared"); let eventWait = gUI.once(eventName); let selector = `[data-id='${JSON.stringify(store)}'] > .tree-widget-item`; diff --git a/devtools/client/storage/test/browser_storage_delete_usercontextid.js b/devtools/client/storage/test/browser_storage_delete_usercontextid.js index f690bbee6b43..c9b84771b51d 100644 --- a/devtools/client/storage/test/browser_storage_delete_usercontextid.js +++ b/devtools/client/storage/test/browser_storage_delete_usercontextid.js @@ -154,7 +154,7 @@ add_task(function* () { let row = getRowCells(rowName); ok(gUI.table.items.has(rowName), `There is a row '${rowName}' in ${treeItemName}`); - let eventWait = gUI.once("store-objects-edit"); + let eventWait = gUI.once("store-objects-updated"); yield waitForContextMenu(contextMenu, row[cellToClick], () => { info(`Opened context menu in ${treeItemName}, row '${rowName}'`); diff --git a/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js b/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js index de0e51b56c63..b4ab388e8820 100644 --- a/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js +++ b/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js @@ -52,8 +52,9 @@ add_task(function* () { ]); checkCell(c1id, "value", "1.2.3.4.5.6.7"); - yield addCookie("c1", '{"foo": 4,"bar":6}', "/browser"); - yield gUI.once("store-objects-edit"); + gWindow.addCookie("c1", '{"foo": 4,"bar":6}', "/browser"); + yield gUI.once("sidebar-updated"); + yield gUI.once("store-objects-updated"); yield findVariableViewProperties(finalValue[0], false); yield findVariableViewProperties(finalValue[1], true); @@ -70,9 +71,9 @@ add_task(function* () { checkCell(c1id, "value", '{"foo": 4,"bar":6}'); // Add a new entry - yield addCookie("c3", "booyeah"); + gWindow.addCookie("c3", "booyeah"); - yield gUI.once("store-objects-edit"); + yield gUI.once("store-objects-updated"); yield checkState([ [ @@ -90,9 +91,11 @@ add_task(function* () { checkCell(c3id, "value", "booyeah"); // Add another - yield addCookie("c4", "booyeah"); + gWindow.addCookie("c4", "booyeah"); - yield gUI.once("store-objects-edit"); + // Wait once for update and another time for value fetching + yield gUI.once("store-objects-updated"); + yield gUI.once("store-objects-updated"); yield checkState([ [ @@ -112,9 +115,10 @@ add_task(function* () { checkCell(c4id, "value", "booyeah"); // Removing cookies - yield removeCookie("c1", "/browser"); + gWindow.removeCookie("c1", "/browser"); - yield gUI.once("store-objects-edit"); + yield gUI.once("sidebar-updated"); + yield gUI.once("store-objects-updated"); yield checkState([ [ @@ -135,9 +139,9 @@ add_task(function* () { yield findVariableViewProperties([{name: "c2", value: "foobar"}]); // Keep deleting till no rows - yield removeCookie("c3"); + gWindow.removeCookie("c3"); - yield gUI.once("store-objects-edit"); + yield gUI.once("store-objects-updated"); yield checkState([ [ @@ -153,9 +157,10 @@ add_task(function* () { // Check if next element's value is visible in sidebar yield findVariableViewProperties([{name: "c2", value: "foobar"}]); - yield removeCookie("c2", "/browser"); + gWindow.removeCookie("c2", "/browser"); - yield gUI.once("store-objects-edit"); + yield gUI.once("sidebar-updated"); + yield gUI.once("store-objects-updated"); yield checkState([ [ @@ -170,9 +175,9 @@ add_task(function* () { // Check if next element's value is visible in sidebar yield findVariableViewProperties([{name: "c4", value: "booyeah"}]); - yield removeCookie("c4"); + gWindow.removeCookie("c4"); - yield gUI.once("store-objects-edit"); + yield gUI.once("store-objects-updated"); yield checkState([ [["cookies", "http://test1.example.org"], [ ]], @@ -182,19 +187,3 @@ add_task(function* () { yield finishTests(); }); - -function* addCookie(name, value, path) { - yield ContentTask.spawn(gBrowser.selectedBrowser, [name, value, path], - ([nam, valu, pat]) => { - content.wrappedJSObject.addCookie(nam, valu, pat); - } - ); -} - -function* removeCookie(name, path) { - yield ContentTask.spawn(gBrowser.selectedBrowser, [name, path], - ([nam, pat]) => { - content.wrappedJSObject.removeCookie(nam, pat); - } - ); -} diff --git a/devtools/client/storage/test/browser_storage_dynamic_updates_localStorage.js b/devtools/client/storage/test/browser_storage_dynamic_updates_localStorage.js index 074047e2c037..6980e3e55444 100644 --- a/devtools/client/storage/test/browser_storage_dynamic_updates_localStorage.js +++ b/devtools/client/storage/test/browser_storage_dynamic_updates_localStorage.js @@ -20,9 +20,9 @@ add_task(function* () { ], ]); - yield removeLocalStorageItem("ls4"); + gWindow.localStorage.removeItem("ls4"); - yield gUI.once("store-objects-edit"); + yield gUI.once("store-objects-updated"); yield checkState([ [ @@ -31,9 +31,10 @@ add_task(function* () { ], ]); - yield setLocalStorageItem("ls4", "again"); + gWindow.localStorage.setItem("ls4", "again"); - yield gUI.once("store-objects-edit"); + yield gUI.once("store-objects-updated"); + yield gUI.once("store-objects-updated"); yield checkState([ [ @@ -42,9 +43,10 @@ add_task(function* () { ], ]); // Updating a row - yield setLocalStorageItem("ls2", "ls2-changed"); + gWindow.localStorage.setItem("ls2", "ls2-changed"); - yield gUI.once("store-objects-edit"); + yield gUI.once("store-objects-updated"); + yield gUI.once("store-objects-updated"); checkCell("ls2", "value", "ls2-changed"); @@ -64,19 +66,3 @@ add_task(function* () { yield finishTests(); }); - -function* setLocalStorageItem(key, value) { - yield ContentTask.spawn(gBrowser.selectedBrowser, [key, value], - ([innerKey, innerValue]) => { - content.wrappedJSObject.localStorage.setItem(innerKey, innerValue); - } - ); -} - -function* removeLocalStorageItem(key) { - yield ContentTask.spawn(gBrowser.selectedBrowser, key, - innerKey => { - content.wrappedJSObject.localStorage.removeItem(innerKey); - } - ); -} diff --git a/devtools/client/storage/test/browser_storage_dynamic_updates_sessionStorage.js b/devtools/client/storage/test/browser_storage_dynamic_updates_sessionStorage.js index 75b0056c5ec3..bc2a2204cef9 100644 --- a/devtools/client/storage/test/browser_storage_dynamic_updates_sessionStorage.js +++ b/devtools/client/storage/test/browser_storage_dynamic_updates_sessionStorage.js @@ -20,9 +20,10 @@ add_task(function* () { ], ]); - yield setSessionStorageItem("ss4", "new-item"); + gWindow.sessionStorage.setItem("ss4", "new-item"); - yield gUI.once("store-objects-edit"); + yield gUI.once("store-objects-updated"); + yield gUI.once("store-objects-updated"); yield checkState([ [ @@ -33,13 +34,13 @@ add_task(function* () { // deleting item - yield removeSessionStorageItem("ss3"); + gWindow.sessionStorage.removeItem("ss3"); - yield gUI.once("store-objects-edit"); + yield gUI.once("store-objects-updated"); - yield removeSessionStorageItem("ss1"); + gWindow.sessionStorage.removeItem("ss1"); - yield gUI.once("store-objects-edit"); + yield gUI.once("store-objects-updated"); yield checkState([ [ @@ -55,7 +56,7 @@ add_task(function* () { // Checking for correct value in sidebar before update yield findVariableViewProperties([{name: "ss2", value: "foobar"}]); - yield setSessionStorageItem("ss2", "changed=ss2"); + gWindow.sessionStorage.setItem("ss2", "changed=ss2"); yield gUI.once("sidebar-updated"); @@ -79,19 +80,3 @@ add_task(function* () { yield finishTests(); }); - -function* setSessionStorageItem(key, value) { - yield ContentTask.spawn(gBrowser.selectedBrowser, [key, value], - ([innerKey, innerValue]) => { - content.wrappedJSObject.sessionStorage.setItem(innerKey, innerValue); - } - ); -} - -function* removeSessionStorageItem(key) { - yield ContentTask.spawn(gBrowser.selectedBrowser, key, - innerKey => { - content.wrappedJSObject.sessionStorage.removeItem(innerKey); - } - ); -} diff --git a/devtools/client/storage/test/browser_storage_indexeddb_delete.js b/devtools/client/storage/test/browser_storage_indexeddb_delete.js index 16757a474c21..b4f5db7ed63e 100644 --- a/devtools/client/storage/test/browser_storage_indexeddb_delete.js +++ b/devtools/client/storage/test/browser_storage_indexeddb_delete.js @@ -25,7 +25,8 @@ add_task(function* () { yield selectTreeItem(deletedDb); // Wait once for update and another time for value fetching - let eventWait = gUI.once("store-objects-updated"); + let eventWait = gUI.once("store-objects-updated").then( + () => gUI.once("store-objects-updated")); let selector = `[data-id='${JSON.stringify(deletedDb)}'] > .tree-widget-item`; let target = gPanelWindow.document.querySelector(selector); diff --git a/devtools/client/storage/test/browser_storage_indexeddb_delete_blocked.js b/devtools/client/storage/test/browser_storage_indexeddb_delete_blocked.js index 9136bc44aa6a..b4c42bf288d0 100644 --- a/devtools/client/storage/test/browser_storage_indexeddb_delete_blocked.js +++ b/devtools/client/storage/test/browser_storage_indexeddb_delete_blocked.js @@ -28,7 +28,7 @@ add_task(function* () { [["indexedDB", "http://test1.example.org"], ["idb (default)"]] ]); - let eventWait = gUI.once("store-objects-edit"); + let eventWait = gUI.once("store-objects-updated"); info("telling content to close the db"); yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () { @@ -36,7 +36,7 @@ add_task(function* () { yield win.closeDb(); }); - info("waiting for store edit events"); + info("waiting for store update events"); yield eventWait; info("test state after real delete"); diff --git a/devtools/client/storage/test/head.js b/devtools/client/storage/test/head.js index 0e7a44969c1a..f19472cab074 100644 --- a/devtools/client/storage/test/head.js +++ b/devtools/client/storage/test/head.js @@ -30,7 +30,7 @@ const ALT_DOMAIN_SECURED = "https://sectest1.example.org:443/" + PATH; // devtools/client/storage/ui.js and devtools/server/tests/browser/head.js const SEPARATOR_GUID = "{9d414cc5-8319-0a04-0586-c0a6ae01670a}"; -var gToolbox, gPanelWindow, gUI; +var gToolbox, gPanelWindow, gWindow, gUI; // Services.prefs.setBoolPref(DUMPEMIT_PREF, true); // Services.prefs.setBoolPref(DEBUGGERLOG_PREF, true); @@ -38,7 +38,7 @@ var gToolbox, gPanelWindow, gUI; Services.prefs.setBoolPref(STORAGE_PREF, true); Services.prefs.setBoolPref(CACHES_ON_HTTP_PREF, true); registerCleanupFunction(() => { - gToolbox = gPanelWindow = gUI = null; + gToolbox = gPanelWindow = gWindow = gUI = null; Services.prefs.clearUserPref(CACHES_ON_HTTP_PREF); Services.prefs.clearUserPref(DEBUGGERLOG_PREF); Services.prefs.clearUserPref(DOM_CACHE); @@ -57,6 +57,9 @@ registerCleanupFunction(() => { */ function* openTab(url, options = {}) { let tab = yield addTab(url, options); + let content = tab.linkedBrowser.contentWindowAsCPOW; + + gWindow = content.wrappedJSObject; // Setup the async storages in main window and for all its iframes yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () { @@ -216,6 +219,8 @@ function forceCollections() { * Cleans up and finishes the test */ function* finishTests() { + // Bug 1233497 makes it so that we can no longer yield CPOWs from Tasks. + // We work around this by calling clear() via a ContentTask instead. while (gBrowser.tabs.length > 1) { yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () { /** @@ -507,17 +512,11 @@ function matchVariablesViewProperty(prop, rule) { * The array id of the item in the tree */ function* selectTreeItem(ids) { + /* If this item is already selected, return */ if (gUI.tree.isSelected(ids)) { - info(`"${ids}" is already selected, returning.`); - return; - } - if (!gUI.tree.exists(ids)) { - info(`"${ids}" does not exist, returning.`); return; } - // The item exists but is not selected... select it. - info(`Selecting "${ids}".`); let updated = gUI.once("store-objects-updated"); gUI.tree.selectedItem = ids; yield updated; @@ -991,7 +990,7 @@ function* performAdd(store) { } let eventEdit = gUI.table.once("row-edit"); - let eventWait = gUI.once("store-objects-edit"); + let eventWait = gUI.once("store-objects-updated"); menuAdd.click(); diff --git a/devtools/client/storage/ui.js b/devtools/client/storage/ui.js index 109a14e17b47..51911630948e 100644 --- a/devtools/client/storage/ui.js +++ b/devtools/client/storage/ui.js @@ -141,8 +141,8 @@ class StorageUI { console.error(e); }); - this.onEdit = this.onEdit.bind(this); - this.front.on("stores-update", this.onEdit); + 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); @@ -216,7 +216,7 @@ class StorageUI { this.table.off(TableWidget.EVENTS.CELL_EDIT, this.editItem); this.table.destroy(); - this.front.off("stores-update", this.onEdit); + this.front.off("stores-update", this.onUpdate); this.front.off("stores-cleared", this.onCleared); this._panelDoc.removeEventListener("keypress", this.handleKeypress); this.searchBox.removeEventListener("input", this.filterItems); @@ -401,7 +401,7 @@ class StorageUI { * of the changed store objects. This array is empty for deleted object * if the host was completely removed. */ - async onEdit({ changed, added, deleted }) { + async onUpdate({ changed, added, deleted }) { if (added) { await this.handleAddedItems(added); } @@ -421,14 +421,14 @@ class StorageUI { } if (added || deleted || changed) { - this.emit("store-objects-edit"); + this.emit("store-objects-updated"); } } /** - * Handle added items received by onEdit + * Handle added items received by onUpdate * - * @param {object} See onEdit docs + * @param {object} See onUpdate docs */ async handleAddedItems(added) { for (let type in added) { @@ -460,9 +460,9 @@ class StorageUI { } /** - * Handle deleted items received by onEdit + * Handle deleted items received by onUpdate * - * @param {object} See onEdit docs + * @param {object} See onUpdate docs */ async handleDeletedItems(deleted) { for (let type in deleted) { @@ -512,9 +512,9 @@ class StorageUI { } /** - * Handle changed items received by onEdit + * Handle changed items received by onUpdate * - * @param {object} See onEdit docs + * @param {object} See onUpdate docs */ async handleChangedItems(changed) { let [type, host, db, objectStore] = this.tree.selectedItem;