Bug 1350525 - Storage Inspector should trim port from hosts for cookies r=pbro

MozReview-Commit-ID: FfsfiXTt96o

--HG--
extra : rebase_source : 1a06fe13348c07d86435d195ab6610aa225cee05
This commit is contained in:
Michael Ratcliffe 2017-04-11 17:09:40 +01:00
parent 1ba2ac9f16
commit 4257730704
4 changed files with 40 additions and 4 deletions

View File

@ -31,6 +31,7 @@ tags = usercontextid
[browser_storage_cache_error.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]

View File

@ -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();
});

View File

@ -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;

View File

@ -492,7 +492,7 @@ StorageActors.createActor({
return host == null;
}
host = trimHttpHttps(host);
host = trimHttpHttpsPort(host);
if (cookie.host.startsWith(".")) {
return ("." + host).endsWith(cookie.host);
@ -742,7 +742,7 @@ var cookieHelpers = {
host = "";
}
host = trimHttpHttps(host);
host = trimHttpHttpsPort(host);
let cookies = Services.cookies.getCookiesFromHost(host, originAttributes);
let store = [];
@ -878,7 +878,7 @@ var cookieHelpers = {
opts.path = split[2];
}
host = trimHttpHttps(host);
host = trimHttpHttpsPort(host);
function hostMatches(cookieHost, matchHost) {
if (cookieHost == null) {
@ -2418,7 +2418,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);
}