moebius#339: Make it possible to add cookies, local and session storage entries

Issue #31
https://github.com/MoonchildProductions/moebius/pull/339
This commit is contained in:
janekptacijarabaci 2018-03-02 17:52:34 +01:00 committed by Roy Tam
commit 6d865bfda3
13 changed files with 309 additions and 43 deletions

View file

@ -22,6 +22,7 @@ support-files =
[browser_storage_basic.js]
[browser_storage_cache_delete.js]
[browser_storage_cache_error.js]
[browser_storage_cookies_add.js]
[browser_storage_cookies_delete_all.js]
[browser_storage_cookies_domain.js]
[browser_storage_cookies_edit.js]
@ -38,11 +39,13 @@ support-files =
[browser_storage_indexeddb_delete.js]
[browser_storage_indexeddb_delete_blocked.js]
[browser_storage_indexeddb_duplicate_names.js]
[browser_storage_localstorage_add.js]
[browser_storage_localstorage_edit.js]
[browser_storage_localstorage_error.js]
[browser_storage_overflow.js]
[browser_storage_search.js]
[browser_storage_search_keyboard_trap.js]
[browser_storage_sessionstorage_add.js]
[browser_storage_sessionstorage_edit.js]
[browser_storage_sidebar.js]
[browser_storage_sidebar_update.js]

View file

@ -0,0 +1,20 @@
/* 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/. */
// Basic test to check the adding of cookies.
"use strict";
add_task(function* () {
yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-cookies.html");
showAllColumns(true);
yield performAdd(["cookies", "http://test1.example.org"]);
yield performAdd(["cookies", "http://test1.example.org"]);
yield performAdd(["cookies", "http://test1.example.org"]);
yield performAdd(["cookies", "http://test1.example.org"]);
yield performAdd(["cookies", "http://test1.example.org"]);
yield finishTests();
});

View file

@ -18,8 +18,8 @@ add_task(function* () {
info("do the delete");
yield selectTreeItem(["indexedDB", "http://test1.example.org"]);
let actor = gUI.getCurrentActor();
let result = yield actor.removeDatabase("http://test1.example.org", "idb (default)");
let front = gUI.getCurrentFront();
let result = yield front.removeDatabase("http://test1.example.org", "idb (default)");
ok(result.blocked, "removeDatabase attempt is blocked");
@ -47,7 +47,7 @@ add_task(function* () {
info("try to delete database from nonexistent host");
let errorThrown = false;
try {
result = yield actor.removeDatabase("http://test2.example.org", "idb (default)");
result = yield front.removeDatabase("http://test2.example.org", "idb (default)");
} catch (ex) {
errorThrown = true;
}

View file

@ -0,0 +1,20 @@
/* 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/. */
// Basic test to check the adding of localStorage entries.
"use strict";
add_task(function* () {
yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-localstorage.html");
showAllColumns(true);
yield performAdd(["localStorage", "http://test1.example.org"]);
yield performAdd(["localStorage", "http://test1.example.org"]);
yield performAdd(["localStorage", "http://test1.example.org"]);
yield performAdd(["localStorage", "http://test1.example.org"]);
yield performAdd(["localStorage", "http://test1.example.org"]);
yield finishTests();
});

View file

@ -0,0 +1,20 @@
/* 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/. */
// Basic test to check the adding of sessionStorage entries.
"use strict";
add_task(function* () {
yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-sessionstorage.html");
showAllColumns(true);
yield performAdd(["sessionStorage", "http://test1.example.org"]);
yield performAdd(["sessionStorage", "http://test1.example.org"]);
yield performAdd(["sessionStorage", "http://test1.example.org"]);
yield performAdd(["sessionStorage", "http://test1.example.org"]);
yield performAdd(["sessionStorage", "http://test1.example.org"]);
yield finishTests();
});

View file

@ -897,3 +897,39 @@ function setPermission(url, permission) {
.addFromPrincipal(principal, permission,
nsIPermissionManager.ALLOW_ACTION);
}
/**
* Add an item.
* @param {Array} store
* An array containing the path to the store to which we wish to add an
* item.
*/
function* performAdd(store) {
let storeName = store.join(" > ");
let toolbar = gPanelWindow.document.getElementById("storage-toolbar");
let type = store[0];
yield selectTreeItem(store);
let menuAdd = toolbar.querySelector(
"#add-button");
if (menuAdd.hidden) {
is(menuAdd.hidden, false,
`performAdd called for ${storeName} but it is not supported`);
return;
}
let eventEdit = gUI.table.once("row-edit");
let eventWait = gUI.once("store-objects-updated");
menuAdd.click();
let rowId = yield eventEdit;
yield eventWait;
let key = type === "cookies" ? "uniqueKey" : "name";
let value = getCellValue(rowId, key);
is(rowId, value, `Row '${rowId}' was successfully added.`);
}