add unit tests for previous checkin.
authordwitte@stanford.edu
Tue, 10 Jul 2007 20:28:01 -0700
changeset 3315 756fa14d0699696bc3600b46a62a9a31149d1fd3
parent 3314 e7bc041cde01e2d5cb64d45d0b8c1e5e000ef3e5
child 3316 d8e7642fda323f34622c024f8e84e88548cdfdfc
push idunknown
push userunknown
push dateunknown
milestone1.9a7pre
add unit tests for previous checkin.
netwerk/test/TestCookie.cpp
--- a/netwerk/test/TestCookie.cpp
+++ b/netwerk/test/TestCookie.cpp
@@ -676,18 +676,23 @@ main(PRInt32 argc, char *argv[])
       SetACookie(cookieService, "http://httponly.test/", nsnull, "test=httponly; httponly; max-age=-1", nsnull);
       GetACookie(cookieService, "http://httponly.test/", nsnull, getter_Copies(cookie));
       rv[6] = CheckResult(cookie.get(), MUST_BE_NULL);
       // Non-Httponly cookies can replace HttpOnly cookies when set over http
       SetACookie(cookieService, "http://httponly.test/", nsnull, "test=httponly; httponly", nsnull);
       SetACookie(cookieService, "http://httponly.test/", nsnull, "test=not-httponly", nsnull);
       GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
       rv[7] = CheckResult(cookie.get(), MUST_EQUAL, "test=not-httponly");
+      // scripts should not be able to set httponly cookies by replacing an existing non-httponly cookie
+      SetACookie(cookieService, "http://httponly.test/", nsnull, "test=not-httponly", nsnull);
+      SetACookieNoHttp(cookieService, "http://httponly.test/", "test=httponly; httponly");
+      GetACookieNoHttp(cookieService, "http://httponly.test/", getter_Copies(cookie));
+      rv[8] = CheckResult(cookie.get(), MUST_EQUAL, "test=not-httponly");
 
-      allTestsPassed = PrintResult(rv, 8) && allTestsPassed;
+      allTestsPassed = PrintResult(rv, 9) && allTestsPassed;
 
 
       // *** nsICookieManager{2} interface tests
       printf("*** Beginning nsICookieManager{2} interface tests...\n");
       nsCOMPtr<nsICookieManager> cookieMgr = do_GetService(NS_COOKIEMANAGER_CONTRACTID, &rv0);
       if (NS_FAILED(rv0)) return -1;
       nsCOMPtr<nsICookieManager2> cookieMgr2 = do_QueryInterface(cookieMgr);
       if (!cookieMgr2) return -1;