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

@ -15,6 +15,8 @@ const {isWindowIncluded} = require("devtools/shared/layout/utils");
const specs = require("devtools/shared/specs/storage");
const { Task } = require("devtools/shared/task");
const DEFAULT_VALUE = "value";
// GUID to be used as a separator in compound keys. This must match the same
// constant in devtools/client/storage/ui.js,
// devtools/client/storage/test/head.js and
@ -616,6 +618,14 @@ StorageActors.createActor({
this.editCookie(data);
}),
addItem: Task.async(function* (guid) {
let doc = this.storageActor.document;
let time = new Date().getTime();
let expiry = new Date(time + 3600 * 24 * 1000).toGMTString();
doc.cookie = `${guid}=${DEFAULT_VALUE};expires=${expiry}`;
}),
removeItem: Task.async(function* (host, name) {
let doc = this.storageActor.document;
this.removeCookie(host, name, doc.nodePrincipal
@ -954,6 +964,12 @@ var cookieHelpers = {
let rowdata = msg.data.args[0];
return cookieHelpers.editCookie(rowdata);
}
case "createNewCookie": {
let host = msg.data.args[0];
let guid = msg.data.args[1];
let originAttributes = msg.data.args[2];
return cookieHelpers.createNewCookie(host, guid, originAttributes);
}
case "removeCookie": {
let host = msg.data.args[0];
let name = msg.data.args[1];
@ -1094,6 +1110,14 @@ function getObjectForLocalOrSessionStorage(type) {
];
}),
addItem: Task.async(function* (guid, host) {
let storage = this.hostVsStores.get(host);
if (!storage) {
return;
}
storage.setItem(guid, DEFAULT_VALUE);
}),
/**
* Edit localStorage or sessionStorage fields.
*