diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-02 17:52:34 +0100 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-02 17:52:34 +0100 |
commit | 166fb9f2893dcfb3375aa3227d116fb0ce2c6d42 (patch) | |
tree | 9bfd8bb159a20f00ff507ab9c27c22434155df23 /devtools/server/actors/storage.js | |
parent | 26e53627d6922b3b965afd76fc5d72e3cc1d9ba5 (diff) | |
download | UXP-166fb9f2893dcfb3375aa3227d116fb0ce2c6d42.tar UXP-166fb9f2893dcfb3375aa3227d116fb0ce2c6d42.tar.gz UXP-166fb9f2893dcfb3375aa3227d116fb0ce2c6d42.tar.lz UXP-166fb9f2893dcfb3375aa3227d116fb0ce2c6d42.tar.xz UXP-166fb9f2893dcfb3375aa3227d116fb0ce2c6d42.zip |
moebius#339: Make it possible to add cookies, local and session storage entries
Issue #31
https://github.com/MoonchildProductions/moebius/pull/339
Diffstat (limited to 'devtools/server/actors/storage.js')
-rw-r--r-- | devtools/server/actors/storage.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/devtools/server/actors/storage.js b/devtools/server/actors/storage.js index 6d1e2dc99..620a9acb9 100644 --- a/devtools/server/actors/storage.js +++ b/devtools/server/actors/storage.js @@ -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. * |