Bug 1351663 - Ensure that OriginAttributes is initialized when nsCookieService::Add receives a SameSite parameter r=valentin
authorRob Wu <rob@robwu.nl>
Sat, 09 Jun 2018 01:21:02 +0200
changeset 424664 75fd56bd459c258b415a619a11b57db3ade2c772
parent 424663 a146704d807d7c54c5b7c68474416a764e31c722
child 424665 75cbadc45030619eed2e40e7ea94bdfc1165e7ba
push id34220
push usertoros@mozilla.com
push dateMon, 02 Jul 2018 21:52:37 +0000
treeherdermozilla-central@959983b7d19e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1351663
milestone63.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 1351663 - Ensure that OriginAttributes is initialized when nsCookieService::Add receives a SameSite parameter r=valentin InitializeOriginAttributes takes aArgc and only initializes the parameter when aArgc is 1. nsCookieService::Add takes another optional parameter, namely aSameSite. If a caller sets this SameSite flag, then InitializeOriginAttributes would skip the initialization of the OriginAttributes. This was caught by a private browsing test in toolkit/components/extensions/test/mochitest/test_ext_cookies.html (after I added support for SameSite flag in the extension API) MozReview-Commit-ID: HLfte7x1X7T
netwerk/cookie/nsCookieService.cpp
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -2554,23 +2554,23 @@ nsCookieService::Add(const nsACString &a
                      bool              aIsHttpOnly,
                      bool              aIsSession,
                      int64_t           aExpiry,
                      JS::HandleValue   aOriginAttributes,
                      int32_t           aSameSite,
                      JSContext*        aCx,
                      uint8_t           aArgc)
 {
-  MOZ_ASSERT(aArgc == 0 || aArgc == 1);
+  MOZ_ASSERT(aArgc == 0 || aArgc == 1 || aArgc == 2);
 
   OriginAttributes attrs;
   nsresult rv = InitializeOriginAttributes(&attrs,
                                            aOriginAttributes,
                                            aCx,
-                                           aArgc,
+                                           aArgc == 0 ? 0 : 1,
                                            u"nsICookieManager.add()",
                                            u"2");
   NS_ENSURE_SUCCESS(rv, rv);
 
   return AddNative(aHost, aPath, aName, aValue, aIsSecure, aIsHttpOnly,
                    aIsSession, aExpiry, &attrs, aSameSite);
 }