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

Changeset 181446 in webkit


Ignore:
Timestamp:
Mar 12, 2015, 11:38:11 AM (11 years ago)
Author:
ap@apple.com
Message:

testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
https://bugs.webkit.org/show_bug.cgi?id=138687

Source/WebKit2:

Reviewed by Carlos Garcia Campos.

  • UIProcess/WebCookieManagerProxy.cpp:

(WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy): Don't change system-wide
cookie accept policy when in testing mode. Also, update the policy in WebProcesses too,
as we still do some networking there.

  • UIProcess/WebProcessPool.h:
  • WebProcess/InjectedBundle/API/c/WKBundle.cpp:

(WKBundleSetAlwaysAcceptCookies): Deleted.

  • WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
  • WebProcess/InjectedBundle/InjectedBundle.cpp:

(WebKit::InjectedBundle::setAlwaysAcceptCookies): Deleted.

  • WebProcess/InjectedBundle/InjectedBundle.h:

Remove WKBundleSetAlwaysAcceptCookies SPI, as WKTR now uses an API in UI process.

Tools:

Reviewed by Carlos Garcia Campos.

Always change cookie policy from UI process, as changing it from WebProcess doesn't
affect other processes.

The implementation is imperfect, because the change happens asynchronously, but I
don't expect it to be a problem in practice.

  • WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:

(WTR::InjectedBundle::beginTesting):

  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setAlwaysAcceptCookies):

  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::invoke):
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

Unreviewed (only code changes were reviewed).

  • platform/gtk/TestExpectations:
  • platform/mac-wk2/TestExpectations:

Unskip tests that used to be affected.

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181441 r181446  
     12015-03-12  Alexey Proskuryakov  <ap@apple.com>
     2
     3        testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=138687
     5
     6        Unreviewed (only code changes were reviewed).
     7
     8        * platform/gtk/TestExpectations:
     9        * platform/mac-wk2/TestExpectations:
     10        Unskip tests that used to be affected.
     11
    1122015-03-12  Simon Fraser  <simon.fraser@apple.com>
    213
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r181291 r181446  
    15581558webkit.org/b/139357 js/dom/constructor-length.html [ Failure ]
    15591559
    1560 # testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
    1561 webkit.org/b/138687 http/tests/xmlhttprequest/cross-origin-cookie-storage.html [ Skip ]
    1562 
    15631560# PingLoader is still in WebProcess. As a result, this test fails and also fails to delete its cookie, breaking many other cookie tests.
    15641561webkit.org/b/138688 http/tests/navigation/ping-cookie.html [ Skip ]
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r181031 r181446  
    469469storage/websql/private-browsing-noread-nowrite.html [ Skip ]
    470470
    471 # testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
    472 webkit.org/b/138687 http/tests/cookies/third-party-cookie-relaxing.html [ Skip ]
    473 webkit.org/b/138687 http/tests/xmlhttprequest/cross-origin-cookie-storage.html [ Skip ]
    474 
    475471# FIXME: Needs bugzilla (<rdar://problem/12829991>)
    476472# PPT: PingLoader is still in WebProcess. As a result, this test fails and also fails to delete its cookie, breaking many other cookie tests.
  • trunk/Source/WebKit2/ChangeLog

    r181445 r181446  
     12015-03-12  Alexey Proskuryakov  <ap@apple.com>
     2
     3        testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=138687
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * UIProcess/WebCookieManagerProxy.cpp:
     9        (WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy): Don't change system-wide
     10        cookie accept policy when in testing mode. Also, update the policy in WebProcesses too,
     11        as we still do some networking there.
     12
     13        * UIProcess/WebProcessPool.h:
     14        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
     15        (WKBundleSetAlwaysAcceptCookies): Deleted.
     16        * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
     17        * WebProcess/InjectedBundle/InjectedBundle.cpp:
     18        (WebKit::InjectedBundle::setAlwaysAcceptCookies): Deleted.
     19        * WebProcess/InjectedBundle/InjectedBundle.h:
     20        Remove WKBundleSetAlwaysAcceptCookies SPI, as WKTR now uses an API in UI process.
     21
    1222015-03-12  Anders Carlsson  <andersca@apple.com>
    223
  • trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp

    r177692 r181446  
    153153{
    154154#if PLATFORM(COCOA)
    155     persistHTTPCookieAcceptPolicy(policy);
     155    if (!processPool()->isUsingTestingNetworkSession())
     156        persistHTTPCookieAcceptPolicy(policy);
    156157#endif
    157158#if USE(SOUP)
     
    159160#endif
    160161
    161     processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
     162    // The policy is not sent to newly created processes (only Soup does that via setInitialHTTPCookieAcceptPolicy()). This is not a serious problem, because:
     163    // - When testing, we only have one WebProcess and one NetworkProcess, and WebKitTestRunner never restarts them;
     164    // - When not testing, Cocoa has the policy persisted, and thus new processes use it (even for ephemeral sessions).
     165    processPool()->sendToAllProcesses(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
     166#if ENABLE(NETWORK_PROCESS)
     167    if (processPool()->usesNetworkProcess())
     168        processPool()->sendToNetworkingProcess(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
     169#endif
    162170}
    163171
  • trunk/Source/WebKit2/UIProcess/WebProcessPool.h

    r180354 r181446  
    247247
    248248    void useTestingNetworkSession();
     249    bool isUsingTestingNetworkSession() const { return m_shouldUseTestingNetworkSession; }
    249250
    250251    void allowSpecificHTTPSCertificateForHost(const WebCertificateInfo*, const String& host);
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp

    r180149 r181446  
    8484}
    8585
    86 void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundleRef, bool accept)
    87 {
    88     toImpl(bundleRef)->setAlwaysAcceptCookies(accept);
    89 }
    90 
    9186void WKBundleAddUserScript(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKBundleScriptWorldRef scriptWorldRef, WKStringRef sourceRef, WKURLRef urlRef, WKArrayRef whitelistRef, WKArrayRef blacklistRef, _WKUserScriptInjectionTime injectionTimeRef, WKUserContentInjectedFrames injectedFramesRef)
    9287{
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h

    r180149 r181446  
    4141#endif
    4242
    43 // TestRunner only SPI
    44 WK_EXPORT void WKBundleSetAlwaysAcceptCookies(WKBundleRef bundle, bool);
     43// TestRunner only SPIs.
    4544// Will make WebProcess ignore this preference until a preferences change notification, only for WebKitTestRunner use.
    4645WK_EXPORT void WKBundleOverrideBoolPreferenceForTestRunner(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKStringRef preference, bool enabled);
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp

    r180963 r181446  
    137137}
    138138
    139 void InjectedBundle::setAlwaysAcceptCookies(bool accept)
    140 {
    141     WebProcess::singleton().supplement<WebCookieManager>()->setHTTPCookieAcceptPolicy(accept ? HTTPCookieAcceptPolicyAlways : HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain);
    142 }
    143 
    144139void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* pageGroup, const String& preference, bool enabled)
    145140{
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h

    r180156 r181446  
    9898
    9999    // TestRunner only SPI
    100     void setAlwaysAcceptCookies(bool);
    101100    void overrideBoolPreferenceForTestRunner(WebPageGroupProxy*, const String& preference, bool enabled);
    102101    void overrideXSSAuditorEnabledForTestRunner(WebPageGroupProxy* pageGroup, bool enabled);
  • trunk/Tools/ChangeLog

    r181440 r181446  
     12015-03-12  Alexey Proskuryakov  <ap@apple.com>
     2
     3        testRunner.setAlwaysAcceptCookies does not work with NetworkProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=138687
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Always change cookie policy from UI process, as changing it from WebProcess doesn't
     9        affect other processes.
     10
     11        The implementation is imperfect, because the change happens asynchronously, but I
     12        don't expect it to be a problem in practice.
     13
     14        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     15        (WTR::InjectedBundle::beginTesting):
     16        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     17        (WTR::TestRunner::setAlwaysAcceptCookies):
     18        * WebKitTestRunner/TestInvocation.cpp:
     19        (WTR::TestInvocation::invoke):
     20        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     21
    1222015-03-12  Csaba Osztrogonác  <ossy@webkit.org>
    223
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r180149 r181446  
    250250    WKBundleSetPluginsEnabled(m_bundle, m_pageGroup, true);
    251251    WKBundleSetPopupBlockingEnabled(m_bundle, m_pageGroup, false);
    252     WKBundleSetAlwaysAcceptCookies(m_bundle, false); // FIXME: Do this from UI process, so that Networking process gets the preference, too.
    253252    WKBundleSetSerialLoadingEnabled(m_bundle, false);
    254253
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r180149 r181446  
    602602void TestRunner::setAlwaysAcceptCookies(bool accept)
    603603{
    604     WKBundleSetAlwaysAcceptCookies(InjectedBundle::singleton().bundle(), accept);
     604    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetAlwaysAcceptCookies"));
     605
     606    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(accept));
     607
     608    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), 0);
    605609}
    606610
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r180636 r181446  
    3232#include "TestController.h"
    3333#include <WebKit/WKContextPrivate.h>
     34#include <WebKit/WKCookieManager.h>
    3435#include <WebKit/WKData.h>
    3536#include <WebKit/WKDictionary.h>
     
    152153    TestController::singleton().setShouldLogHistoryClientCallbacks(shouldLogHistoryClientCallbacks());
    153154
     155    WKCookieManagerSetHTTPCookieAcceptPolicy(WKContextGetCookieManager(TestController::singleton().context()), kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain);
     156
    154157    // FIXME: We should clear out visited links here.
    155158
     
    643646        return result;
    644647    }
     648
     649    if (WKStringIsEqualToUTF8CString(messageName, "SetAlwaysAcceptCookies")) {
     650        WKBooleanRef accept = static_cast<WKBooleanRef>(messageBody);
     651        WKHTTPCookieAcceptPolicy policy = WKBooleanGetValue(accept) ? kWKHTTPCookieAcceptPolicyAlways : kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
     652        // FIXME: This updates the policy in WebProcess and in NetworkProcess asynchronously, which might break some tests' expectations.
     653        WKCookieManagerSetHTTPCookieAcceptPolicy(WKContextGetCookieManager(TestController::singleton().context()), policy);
     654        return 0;
     655    }
     656
    645657    ASSERT_NOT_REACHED();
    646658    return 0;
Note: See TracChangeset for help on using the changeset viewer.