Bug 1264993 - Unable to list/edit certain cookies in GCLI r=jwalker
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Mon, 18 Apr 2016 13:54:23 +0100
changeset 331977 a4dc7ffd8a5fe88f29080999a5b1cbef6c3bb70e
parent 331976 2ca0a1672d8ff4500d37bbb7d753fc03b729cabf
child 331978 4ac3b4265ce2205bab28de9f09da31379e23b785
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalker
bugs1264993
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1264993 - Unable to list/edit certain cookies in GCLI r=jwalker Simple patch to correct errors in cookie host matching: 1. Match domains starting with a . in case this style was used e.g. .test.example.com 2. Match localhost URLS. MozReview-Commit-ID: 9qqnsNaW5oK
devtools/client/commandline/test/browser.ini
devtools/client/commandline/test/browser_cmd_cookie.html
devtools/client/commandline/test/browser_cmd_cookie_host.js
devtools/shared/gcli/commands/cookie.js
--- a/devtools/client/commandline/test/browser.ini
+++ b/devtools/client/commandline/test/browser.ini
@@ -29,16 +29,18 @@ support-files =
   browser_cmd_appcache_valid_page1.html
   browser_cmd_appcache_valid_page2.html
   browser_cmd_appcache_valid_page3.html
 [browser_cmd_commands.js]
 [browser_cmd_cookie.js]
 support-files =
  browser_cmd_cookie.html
 [browser_cmd_cookie_host.js]
+support-files =
+ browser_cmd_cookie.html
 [browser_cmd_csscoverage_oneshot.js]
 support-files =
  browser_cmd_csscoverage_page1.html
  browser_cmd_csscoverage_page2.html
  browser_cmd_csscoverage_page3.html
  browser_cmd_csscoverage_sheetA.css
  browser_cmd_csscoverage_sheetB.css
  browser_cmd_csscoverage_sheetC.css
--- a/devtools/client/commandline/test/browser_cmd_cookie.html
+++ b/devtools/client/commandline/test/browser_cmd_cookie.html
@@ -6,13 +6,14 @@
 </head>
 <body>
 
   <p>Cookie test</p>
   <p id=result></p>
   <script type="text/javascript">
     document.cookie = "zap=zep";
     document.cookie = "zip=zop";
+    document.cookie = "zig=zag; domain=.mochi.test";
     document.getElementById("result").innerHTML = document.cookie;
   </script>
 
 </body>
 </html>
--- a/devtools/client/commandline/test/browser_cmd_cookie_host.js
+++ b/devtools/client/commandline/test/browser_cmd_cookie_host.js
@@ -1,23 +1,25 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+"use strict";
+
 // Tests that the cookie command works for host with a port specified
 
-const TEST_URI = "http://mochi.test:8888/browser/devtools/client/commandline/"+
+const TEST_URI = "http://mochi.test:8888/browser/devtools/client/commandline/" +
                  "test/browser_cmd_cookie.html";
 
 function test() {
   helpers.addTabWithToolbar(TEST_URI, function(options) {
     return helpers.audit(options, [
         {
           setup: 'cookie list',
           exec: {
-            output: [ /zap=zep/, /zip=zop/ ],
+            output: [ /zap=zep/, /zip=zop/, /zig=zag/ ],
           }
         },
         {
           setup: "cookie set zup banana",
           check: {
             args: {
               name: { value: 'zup' },
               value: { value: 'banana' },
@@ -25,15 +27,15 @@ function test() {
           },
           exec: {
             output: ""
           }
         },
         {
           setup: "cookie list",
           exec: {
-            output: [ /zap=zep/, /zip=zop/, /zup=banana/, /Edit/ ]
+            output: [ /zap=zep/, /zip=zop/, /zig=zag/, /zup=banana/, /Edit/ ]
           }
         }
     ]);
   }).then(finish, helpers.handleError);
 }
 
--- a/devtools/shared/gcli/commands/cookie.js
+++ b/devtools/shared/gcli/commands/cookie.js
@@ -54,17 +54,20 @@ function translateExpires(expires) {
 /**
  * Check if a given cookie matches a given host
  */
 function isCookieAtHost(cookie, host) {
   if (cookie.host == null) {
     return host == null;
   }
   if (cookie.host.startsWith(".")) {
-    return host.endsWith(cookie.host);
+    return ("." + host).endsWith(cookie.host);
+  }
+  if (cookie.host === "") {
+    return host.startsWith("file://" + cookie.path);
   }
   return cookie.host == host;
 }
 
 exports.items = [
   {
     name: "cookie",
     description: l10n.lookup("cookieDesc"),