Closed Bug 1790965 Opened 3 years ago Closed 2 years ago

CookieService::GetSessionCookies Interface implementation may have a clerical error

Categories

(Core :: Networking: Cookies, defect, P3)

defect

Tracking

()

RESOLVED FIXED
110 Branch
Tracking Status
firefox-esr102 --- wontfix
firefox108 --- wontfix
firefox109 --- wontfix
firefox110 --- fixed

People

(Reporter: linxin19812012, Assigned: edgul)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression, Whiteboard: [necko-triaged])

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0

Steps to reproduce:

Here is my test code for
...
nsresult rv0;
nsCOMPtr<nsICookieManager> cookieMgr = do_GetService(NS_COOKIEMANAGER_CONTRACTID, &rv0);

nsTArray<RefPtr<nsICookie>> aCookies;
cookieMgr->GetCookies(aCookies);

nsTArray<RefPtr<nsICookie>> aSessionCookies;
cookieMgr->GetSessionCookies(aSessionCookies);
...

Actual results:

The obtained aCookies and aSessionCookies data are identical.
It is found that the two interface implementations are identical. I guess this is a clerical error.

NS_IMETHODIMP
CookieService::GetCookies(nsTArray<RefPtr<nsICookie>>& aCookies) {
if (!IsInitialized()) {
return NS_ERROR_NOT_AVAILABLE;
}

mPersistentStorage->EnsureInitialized();

// We expose only non-private cookies.
mPersistentStorage->GetCookies(aCookies);

return NS_OK;
}

NS_IMETHODIMP
CookieService::GetSessionCookies(nsTArray<RefPtr<nsICookie>>& aCookies) {
if (!IsInitialized()) {
return NS_ERROR_NOT_AVAILABLE;
}

mPersistentStorage->EnsureInitialized();

// We expose only non-private cookies.
mPersistentStorage->GetCookies(aCookies);

return NS_OK;
}

CookieStorage provides two interfaces: GetCookies and GetSessionCookies, but only one is called here.

class CookieStorage : public nsIObserver, public nsSupportsWeakReference {
public:

void GetCookies(nsTArray<RefPtr<nsICookie>>& aCookies) const;
void GetSessionCookies(nsTArray<RefPtr<nsICookie>>& aCookies) const;
...

Setting this to Core > Networking: Cookies, if this is not the right component, please move it to the correct one. Thanks!

Component: Untriaged → Networking: Cookies
Product: Firefox → Core
Blocks: cookie
Severity: -- → S4
Priority: -- → P3
Whiteboard: [necko-triaged]

Indeed. The line here should be mPersistentStorage->GetSessionCookies(aCookies);

Regressed by: 1624146

:baku, since you are the author of the regressor, bug 1624146, could you take a look?

For more information, please visit auto_nag documentation.

Flags: needinfo?(amarchesini)
Assignee: nobody → edgul
Flags: needinfo?(edgul)
Flags: needinfo?(amarchesini)
Pushed by eguloien@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/dd4482632694 Correct CookieService to get only session cookies from persistent storage when requested for session cookies. r=necko-reviewers,kershaw
Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 110 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: