⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287077 in webkit


Ignore:
Timestamp:
Dec 15, 2021, 9:10:36 AM (5 years ago)
Author:
Chris Dumez
Message:

http/tests/security/basic-auth-subresource.html and some other http auth tests are flaky
https://bugs.webkit.org/show_bug.cgi?id=234314
<rdar://85150486>

Reviewed by Darin Adler.

http/tests/security/basic-auth-subresource.html and some other http auth tests are flaky.

No new tests, I will be able to unskip those layout tests in internal once this lands.

  • platform/network/ProtectionSpaceBase.cpp:

(WebCore::ProtectionSpaceBase::ProtectionSpaceBase):
(WebCore::ProtectionSpaceBase::host const): Deleted.
(WebCore::ProtectionSpaceBase::port const): Deleted.
(WebCore::ProtectionSpaceBase::serverType const): Deleted.
(WebCore::ProtectionSpaceBase::realm const): Deleted.
(WebCore::ProtectionSpaceBase::authenticationScheme const): Deleted.

  • platform/network/ProtectionSpaceBase.h:

(WebCore::ProtectionSpaceBase::host const):
(WebCore::ProtectionSpaceBase::port const):
(WebCore::ProtectionSpaceBase::serverType const):
(WebCore::ProtectionSpaceBase::realm const):
(WebCore::ProtectionSpaceBase::authenticationScheme const):
Clean up / modernise the ProtectionSpaceBase class.

  • platform/network/ProtectionSpaceHash.h:

(WebCore::ProtectionSpaceHash::hash):

  • Use Hasher in ProtectionSpaceHash::hash() as it is less error-prone. I believe the previous implementation was wrong because it was calling StringHasher::hashMemory(hashCodes, codeCount) instead of StringHasher::hashMemory(hashCodes, codeCount * sizeof(unsigned)). This could have resulted in inefficiencies I believe since we were not hashing the whole array memory.
  • Fix ProtectionSpace<ProtectionSpace> so that emptyValueIsZero is false instead of true. This was a bug since the ProtectionSpaceBase constructor initializes data members to non-zero values.
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287076 r287077  
     12021-12-15  Chris Dumez  <cdumez@apple.com>
     2
     3        http/tests/security/basic-auth-subresource.html and some other http auth tests are flaky
     4        https://bugs.webkit.org/show_bug.cgi?id=234314
     5        <rdar://85150486>
     6
     7        Reviewed by Darin Adler.
     8
     9        http/tests/security/basic-auth-subresource.html and some other http auth tests are flaky.
     10
     11        No new tests, I will be able to unskip those layout tests in internal once this lands.
     12
     13        * platform/network/ProtectionSpaceBase.cpp:
     14        (WebCore::ProtectionSpaceBase::ProtectionSpaceBase):
     15        (WebCore::ProtectionSpaceBase::host const): Deleted.
     16        (WebCore::ProtectionSpaceBase::port const): Deleted.
     17        (WebCore::ProtectionSpaceBase::serverType const): Deleted.
     18        (WebCore::ProtectionSpaceBase::realm const): Deleted.
     19        (WebCore::ProtectionSpaceBase::authenticationScheme const): Deleted.
     20        * platform/network/ProtectionSpaceBase.h:
     21        (WebCore::ProtectionSpaceBase::host const):
     22        (WebCore::ProtectionSpaceBase::port const):
     23        (WebCore::ProtectionSpaceBase::serverType const):
     24        (WebCore::ProtectionSpaceBase::realm const):
     25        (WebCore::ProtectionSpaceBase::authenticationScheme const):
     26        Clean up / modernise the ProtectionSpaceBase class.
     27
     28        * platform/network/ProtectionSpaceHash.h:
     29        (WebCore::ProtectionSpaceHash::hash):
     30        - Use Hasher in ProtectionSpaceHash::hash() as it is less error-prone. I believe the
     31          previous implementation was wrong because it was calling
     32          `StringHasher::hashMemory(hashCodes, codeCount)` instead of
     33          `StringHasher::hashMemory(hashCodes, codeCount * sizeof(unsigned))`.
     34          This could have resulted in inefficiencies I believe since we were not hashing the
     35          whole array memory.
     36        - Fix ProtectionSpace<ProtectionSpace> so that emptyValueIsZero is false instead of
     37          true. This was a bug since the ProtectionSpaceBase constructor initializes data
     38          members to non-zero values.
     39
    1402021-12-15  Gavin Phillips  <gavin.p@apple.com>
    241
  • trunk/Source/WebCore/platform/network/ProtectionSpaceBase.cpp

    r279872 r287077  
    3434
    3535namespace WebCore {
    36 
    37 // Need to enforce empty, non-null strings due to the pickiness of the String == String operator
    38 // combined with the semantics of the String(NSString*) constructor
    39 ProtectionSpaceBase::ProtectionSpaceBase()
    40     : m_host(emptyString())
    41     , m_port(0)
    42     , m_serverType(ProtectionSpaceServerHTTP)
    43     , m_realm(emptyString())
    44     , m_authenticationScheme(ProtectionSpaceAuthenticationSchemeDefault)
    45     , m_isHashTableDeletedValue(false)
    46 {
    47 }
    4836 
    4937// Need to enforce empty, non-null strings due to the pickiness of the String == String operator
     
    5139ProtectionSpaceBase::ProtectionSpaceBase(const String& host, int port, ProtectionSpaceServerType serverType, const String& realm, ProtectionSpaceAuthenticationScheme authenticationScheme)
    5240    : m_host(host.length() ? host : emptyString())
     41    , m_realm(realm.length() ? realm : emptyString())
    5342    , m_port(port)
    5443    , m_serverType(serverType)
    55     , m_realm(realm.length() ? realm : emptyString())
    5644    , m_authenticationScheme(authenticationScheme)
    57     , m_isHashTableDeletedValue(false)
    5845{   
    59 }
    60    
    61 const String& ProtectionSpaceBase::host() const
    62 {
    63     return m_host;
    64 }
    65 
    66 int ProtectionSpaceBase::port() const
    67 {
    68     return m_port;
    69 }
    70 
    71 ProtectionSpaceServerType ProtectionSpaceBase::serverType() const
    72 {
    73     return m_serverType;
    7446}
    7547
     
    8052            m_serverType == ProtectionSpaceProxyFTP ||
    8153            m_serverType == ProtectionSpaceProxySOCKS);
    82 }
    83 
    84 const String& ProtectionSpaceBase::realm() const
    85 {
    86     return m_realm;
    87 }
    88 
    89 ProtectionSpaceAuthenticationScheme ProtectionSpaceBase::authenticationScheme() const
    90 {
    91     return m_authenticationScheme;
    9254}
    9355
  • trunk/Source/WebCore/platform/network/ProtectionSpaceBase.h

    r279872 r287077  
    11/*
    2  * Copyright (C) 2007-2020 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2007-2021 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6565    bool isHashTableDeletedValue() const { return m_isHashTableDeletedValue; }
    6666   
    67     WEBCORE_EXPORT const String& host() const;
    68     WEBCORE_EXPORT int port() const;
    69     WEBCORE_EXPORT ProtectionSpaceServerType serverType() const;
     67    const String& host() const { return m_host; }
     68    int port() const { return m_port; }
     69    ProtectionSpaceServerType serverType() const { return m_serverType; }
    7070    WEBCORE_EXPORT bool isProxy() const;
    71     WEBCORE_EXPORT const String& realm() const;
    72     WEBCORE_EXPORT ProtectionSpaceAuthenticationScheme authenticationScheme() const;
     71    const String& realm() const { return m_realm; }
     72    ProtectionSpaceAuthenticationScheme authenticationScheme() const { return m_authenticationScheme; }
    7373   
    7474    WEBCORE_EXPORT bool receivesCredentialSecurely() const;
     
    8080
    8181protected:
    82     WEBCORE_EXPORT ProtectionSpaceBase();
     82    ProtectionSpaceBase() = default;
    8383    WEBCORE_EXPORT ProtectionSpaceBase(const String& host, int port, ProtectionSpaceServerType, const String& realm, ProtectionSpaceAuthenticationScheme);
    8484
     
    8989
    9090private:
    91     String m_host;
    92     int m_port;
    93     ProtectionSpaceServerType m_serverType;
    94     String m_realm;
    95     ProtectionSpaceAuthenticationScheme m_authenticationScheme;
    96     bool m_isHashTableDeletedValue;
     91    // Need to enforce empty, non-null strings due to the pickiness of the String == String operator
     92    // combined with the semantics of the String(NSString*) constructor
     93    String m_host { emptyString() };
     94    String m_realm { emptyString() };
     95
     96    int m_port { 0 };
     97    ProtectionSpaceServerType m_serverType { ProtectionSpaceServerHTTP };
     98    ProtectionSpaceAuthenticationScheme m_authenticationScheme { ProtectionSpaceAuthenticationSchemeDefault };
     99    bool m_isHashTableDeletedValue { false };
    97100};
    98101
  • trunk/Source/WebCore/platform/network/ProtectionSpaceHash.h

    r264488 r287077  
    11/*
    2  * Copyright (C) 2009 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2009-2021 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef ProtectionSpaceHash_h
    27 #define ProtectionSpaceHash_h
     26#pragma once
    2827
    2928#include "ProtectionSpace.h"
    3029#include <wtf/HashTraits.h>
     30#include <wtf/Hasher.h>
    3131
    3232namespace WebCore {
     
    3535    static unsigned hash(const ProtectionSpace& protectionSpace)
    3636    {
    37         unsigned hashCodes[5] = {
    38             protectionSpace.host().impl() ? protectionSpace.host().impl()->hash() : 0,
    39             static_cast<unsigned>(protectionSpace.port()),
    40             static_cast<unsigned>(protectionSpace.serverType()),
    41             static_cast<unsigned>(protectionSpace.authenticationScheme()),
    42             protectionSpace.realm().impl() ? protectionSpace.realm().impl()->hash() : 0
    43         };
    44 
    45         unsigned codeCount = sizeof(hashCodes);
    46         // Ignore realm for proxies.
    47         if (protectionSpace.isProxy())
    48             codeCount -= sizeof(hashCodes[0]);
    49         return StringHasher::hashMemory(hashCodes, codeCount);
     37        Hasher hasher;
     38        add(hasher, protectionSpace.host());
     39        add(hasher, protectionSpace.port());
     40        add(hasher, protectionSpace.serverType());
     41        add(hasher, protectionSpace.authenticationScheme());
     42        if (!protectionSpace.isProxy())
     43            add(hasher, protectionSpace.realm());
     44        return hasher.hash();
    5045    }
    5146   
    5247    static bool equal(const ProtectionSpace& a, const ProtectionSpace& b) { return a == b; }
    53     static const bool safeToCompareToEmptyOrDeleted = false;
     48    static constexpr bool safeToCompareToEmptyOrDeleted = false;
    5449};
    5550
     
    5853namespace WTF {
    5954
    60 template<> struct HashTraits<WebCore::ProtectionSpace> : SimpleClassHashTraits<WebCore::ProtectionSpace> { };
     55template<> struct HashTraits<WebCore::ProtectionSpace> : SimpleClassHashTraits<WebCore::ProtectionSpace> {
     56    static constexpr bool emptyValueIsZero = false;
     57};
    6158template<> struct DefaultHash<WebCore::ProtectionSpace> : WebCore::ProtectionSpaceHash { };
    6259
    6360} // namespace WTF
    64 
    65 
    66 #endif // ProtectionSpaceHash_h
Note: See TracChangeset for help on using the changeset viewer.