summaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-04 01:58:43 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-04 01:58:43 +0100
commite78a87b4188fd266d6ec9662c95ef147dbbd92cd (patch)
tree0b0cf0ab3b3596ea43e57e59dfaca46c4ff2324c /devtools
parenta53fe8f5c92ceeb091df55ce41b69f49f7d6c6d6 (diff)
downloaduxp-e78a87b4188fd266d6ec9662c95ef147dbbd92cd.tar.gz
moebius#346: Storage Inspector should trim port from hosts for cookies
Issue #31 https://github.com/MoonchildProductions/moebius/pull/346
Diffstat (limited to 'devtools')
-rw-r--r--devtools/client/storage/test/browser.ini1
-rw-r--r--devtools/client/storage/test/browser_storage_cookies_domain_port.js29
-rw-r--r--devtools/client/storage/test/head.js1
-rw-r--r--devtools/server/actors/storage.js13
4 files changed, 40 insertions, 4 deletions
diff --git a/devtools/client/storage/test/browser.ini b/devtools/client/storage/test/browser.ini
index 52ea712268..0290aaa5e2 100644
--- a/devtools/client/storage/test/browser.ini
+++ b/devtools/client/storage/test/browser.ini
@@ -27,6 +27,7 @@ support-files =
[browser_storage_cookies_add.js]
[browser_storage_cookies_delete_all.js]
[browser_storage_cookies_domain.js]
+[browser_storage_cookies_domain_port.js]
[browser_storage_cookies_edit.js]
[browser_storage_cookies_edit_keyboard.js]
[browser_storage_cookies_tab_navigation.js]
diff --git a/devtools/client/storage/test/browser_storage_cookies_domain_port.js b/devtools/client/storage/test/browser_storage_cookies_domain_port.js
new file mode 100644
index 0000000000..a5bc2e5bee
--- /dev/null
+++ b/devtools/client/storage/test/browser_storage_cookies_domain_port.js
@@ -0,0 +1,29 @@
+/* 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/. */
+
+/* import-globals-from ../../framework/test/shared-head.js */
+
+"use strict";
+
+// Test that cookies with domain equal to full host name and port are listed.
+// E.g., ".example.org:8000" vs. example.org:8000).
+
+add_task(function* () {
+ yield openTabAndSetupStorage(MAIN_DOMAIN_WITH_PORT + "storage-cookies.html");
+
+ yield checkState([
+ [
+ ["cookies", "http://test1.example.org:8000"],
+ [
+ getCookieId("test1", ".test1.example.org", "/browser"),
+ getCookieId("test2", "test1.example.org", "/browser"),
+ getCookieId("test3", ".test1.example.org", "/browser"),
+ getCookieId("test4", "test1.example.org", "/browser"),
+ getCookieId("test5", ".test1.example.org", "/browser")
+ ]
+ ],
+ ]);
+
+ yield finishTests();
+});
diff --git a/devtools/client/storage/test/head.js b/devtools/client/storage/test/head.js
index 181132a450..c734f7b8f0 100644
--- a/devtools/client/storage/test/head.js
+++ b/devtools/client/storage/test/head.js
@@ -22,6 +22,7 @@ const DEBUGGERLOG_PREF = "devtools.debugger.log";
const CACHES_ON_HTTP_PREF = "dom.caches.testing.enabled";
const PATH = "browser/devtools/client/storage/test/";
const MAIN_DOMAIN = "http://test1.example.org/" + PATH;
+const MAIN_DOMAIN_WITH_PORT = "http://test1.example.org:8000/" + PATH;
const ALT_DOMAIN = "http://sectest1.example.org/" + PATH;
const ALT_DOMAIN_SECURED = "https://sectest1.example.org:443/" + PATH;
diff --git a/devtools/server/actors/storage.js b/devtools/server/actors/storage.js
index a7215b1524..c702e81451 100644
--- a/devtools/server/actors/storage.js
+++ b/devtools/server/actors/storage.js
@@ -494,7 +494,7 @@ StorageActors.createActor({
return host == null;
}
- host = trimHttpHttps(host);
+ host = trimHttpHttpsPort(host);
if (cookie.host.startsWith(".")) {
return ("." + host).endsWith(cookie.host);
@@ -761,7 +761,7 @@ var cookieHelpers = {
host = "";
}
- host = trimHttpHttps(host);
+ host = trimHttpHttpsPort(host);
let cookies = Services.cookies.getCookiesFromHost(host, originAttributes);
let store = [];
@@ -897,7 +897,7 @@ var cookieHelpers = {
opts.path = split[2];
}
- host = trimHttpHttps(host);
+ host = trimHttpHttpsPort(host);
function hostMatches(cookieHost, matchHost) {
if (cookieHost == null) {
@@ -2452,7 +2452,12 @@ exports.setupParentProcessForIndexedDB = function ({ mm, prefix }) {
/**
* General helpers
*/
-function trimHttpHttps(url) {
+function trimHttpHttpsPort(url) {
+ let match = url.match(/(.+):\d+$/);
+
+ if (match) {
+ url = match[1];
+ }
if (url.startsWith("http://")) {
return url.substr(7);
}