Title: [197407] trunk/Source/WebKit2
Revision
197407
Author
achristen...@apple.com
Date
2016-03-01 12:00:58 -0800 (Tue, 01 Mar 2016)

Log Message

Fix tests when using NetworkSession
https://bugs.webkit.org/show_bug.cgi?id=154866

Reviewed by Brady Eidson.

* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::globalCustomProtocolManager):
(WebKit::NetworkSession::setCustomProtocolManager):
        
Use a static NeverDestroyed instead of a local NeverDestroyed.
This fix was suggested by Darin after I broke the custom protocol tests in r197362.
        
(WebKit::NetworkSession::clearCredentials):
        
In r197223 I added code that I thought cleared the credentials of a session, but it was
actually trying (and failing) to remove the credentials from the NSURLCredentialStorage that
were stored with NSURLCredentialPersistencePermanent.
This was causing credentials stored in an NSURLSession with NSURLCredentialPersistenceForSession
to remain for the next tests, and was causing credentials from previous tests, usually from
http/tests/loading/basic-credentials-sent-automatically.html, to be used in future tests.
Creating a new NSURLSession is the equivalent of CredentialStorage::clearCredentials because it
removes all credentials stored with NSURLCredentialPersistenceForSession.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (197406 => 197407)


--- trunk/Source/WebKit2/ChangeLog	2016-03-01 19:47:31 UTC (rev 197406)
+++ trunk/Source/WebKit2/ChangeLog	2016-03-01 20:00:58 UTC (rev 197407)
@@ -1,3 +1,28 @@
+2016-03-01  Alex Christensen  <achristen...@webkit.org>
+
+        Fix tests when using NetworkSession
+        https://bugs.webkit.org/show_bug.cgi?id=154866
+
+        Reviewed by Brady Eidson.
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (WebKit::globalCustomProtocolManager):
+        (WebKit::NetworkSession::setCustomProtocolManager):
+        
+        Use a static NeverDestroyed instead of a local NeverDestroyed.
+        This fix was suggested by Darin after I broke the custom protocol tests in r197362.
+        
+        (WebKit::NetworkSession::clearCredentials):
+        
+        In r197223 I added code that I thought cleared the credentials of a session, but it was
+        actually trying (and failing) to remove the credentials from the NSURLCredentialStorage that
+        were stored with NSURLCredentialPersistencePermanent.
+        This was causing credentials stored in an NSURLSession with NSURLCredentialPersistenceForSession
+        to remain for the next tests, and was causing credentials from previous tests, usually from
+        http/tests/loading/basic-credentials-sent-automatically.html, to be used in future tests.
+        Creating a new NSURLSession is the equivalent of CredentialStorage::clearCredentials because it
+        removes all credentials stored with NSURLCredentialPersistenceForSession.
+
 2016-03-01  Carlos Garcia Campos  <cgar...@igalia.com>
 
         NetworkCache: Web process leaks resource buffer when using shareable reasources

Modified: trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm (197406 => 197407)


--- trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2016-03-01 19:47:31 UTC (rev 197406)
+++ trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2016-03-01 20:00:58 UTC (rev 197407)
@@ -218,8 +218,8 @@
 
 static RefPtr<CustomProtocolManager>& globalCustomProtocolManager()
 {
-    NeverDestroyed<RefPtr<CustomProtocolManager>> gCustomProtocolManager;
-    return gCustomProtocolManager.get();
+    static NeverDestroyed<RefPtr<CustomProtocolManager>> customProtocolManager;
+    return customProtocolManager.get();
 }
 
 void NetworkSession::setCustomProtocolManager(CustomProtocolManager* customProtocolManager)
@@ -266,14 +266,9 @@
 
 void NetworkSession::clearCredentials()
 {
-    NSURLCredentialStorage *credentialStorage = m_sessionWithCredentialStorage.get().configuration.URLCredentialStorage;
-    NSDictionary<NSURLProtectionSpace *, NSDictionary<NSString *, NSURLCredential *> *> *credentials = credentialStorage.allCredentials;
-    
-    for (NSURLProtectionSpace *protectionSpace in credentials) {
-        NSDictionary<NSString *, NSURLCredential *> *credentialsDict = [credentials objectForKey:protectionSpace];
-        for (NSString *user in credentialsDict)
-            [credentialStorage removeCredential:[credentialsDict objectForKey:user] forProtectionSpace:protectionSpace];
-    }
+    ASSERT(m_dataTaskMap.isEmpty());
+    ASSERT(m_downloadMap.isEmpty());
+    m_sessionWithCredentialStorage = [NSURLSession sessionWithConfiguration:m_sessionWithCredentialStorage.get().configuration delegate:static_cast<id>(m_sessionDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]];
 }
 
 NetworkDataTask* NetworkSession::dataTaskForIdentifier(NetworkDataTask::TaskIdentifier taskIdentifier)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to