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

Changeset 249675 in webkit


Ignore:
Timestamp:
Sep 9, 2019, 4:35:12 PM (7 years ago)
Author:
Chris Dumez
Message:

Stop using testRunner.setPrivateBrowsingEnabled_DEPRECATED() in http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html
https://bugs.webkit.org/show_bug.cgi?id=201596

Reviewed by Alex Christensen.

Source/WebKit:

Allow WKFramePolicyListenerUseWithPolicies() C API to switch to a persistent non-default session.
This is important since WebKitTestRunner is not using the default session anymore and I need to
be able to switch it back to its normal session after going to an ephemeral one.

  • UIProcess/API/C/WKFramePolicyListener.cpp:

(useWithPolicies):

Tools:

Add new testRunner.setShouldSwapToEphemeralSessionOnNextNavigation() / testRunner.setShouldSwapToDefaultSessionOnNextNavigation()
test functions to support dynamic switching between ephemeral and default/persistent session in layout tests. The new methods
do the right thing for WebKit2 and truly switch session, unlike setPrivateBrowsingEnabled_DEPRECATED() which was merely making
the WebCore::Document think it changed session.

  • DumpRenderTree/TestRunner.cpp:

(setShouldSwapToEphemeralSessionOnNextNavigationCallback):
(setShouldSwapToDefaultSessionOnNextNavigationCallback):
(TestRunner::staticFunctions):
(TestRunner::willNavigate):

  • DumpRenderTree/TestRunner.h:

(TestRunner::setShouldSwapToEphemeralSessionOnNextNavigation):
(TestRunner::setShouldSwapToDefaultSessionOnNextNavigation):

  • DumpRenderTree/mac/FrameLoadDelegate.mm:

(-[FrameLoadDelegate webView:didStartProvisionalLoadForFrame:]):

  • WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setShouldSwapToEphemeralSessionOnNextNavigation):
(WTR::TestRunner::setShouldSwapToDefaultSessionOnNextNavigation):

  • WebKitTestRunner/InjectedBundle/TestRunner.h:
  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::decidePolicyForNavigationAction):

  • WebKitTestRunner/TestController.h:

(WTR::TestController::setShouldSwapToEphemeralSessionOnNextNavigation):
(WTR::TestController::setShouldSwapToDefaultSessionOnNextNavigation):

  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

Update layout test to use testRunner.setShouldSwapToEphemeralSessionOnNextNavigation() &
testRunner.setShouldSwapToDefaultSessionOnNextNavigation() instead of the legacy
testRunner.setPrivateBrowsingEnabled_DEPRECATED(). The test needed some extra steps to
navigate whenever we switch session but it is a lot more realistic and is really switching
session on WebKit2. The testRunner.setPrivateBrowsingEnabled_DEPRECATED() was not truly
switching session, just making the document think it did.

  • http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html:
Location:
trunk
Files:
16 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r249672 r249675  
     12019-09-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Stop using testRunner.setPrivateBrowsingEnabled_DEPRECATED() in http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html
     4        https://bugs.webkit.org/show_bug.cgi?id=201596
     5
     6        Reviewed by Alex Christensen.
     7
     8        Update layout test to use testRunner.setShouldSwapToEphemeralSessionOnNextNavigation() &
     9        testRunner.setShouldSwapToDefaultSessionOnNextNavigation() instead of the legacy
     10        testRunner.setPrivateBrowsingEnabled_DEPRECATED(). The test needed some extra steps to
     11        navigate whenever we switch session but it is a lot more realistic and is really switching
     12        session on WebKit2. The testRunner.setPrivateBrowsingEnabled_DEPRECATED() was not truly
     13        switching session, just making the document think it did.
     14
     15        * http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html:
     16
    1172019-09-09  Chris Dumez  <cdumez@apple.com>
    218
  • trunk/LayoutTests/http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html

    r249542 r249675  
    4646        testRunner.dumpAdClickAttribution();
    4747        document.body.removeChild(document.getElementById("targetLink"));
    48         document.body.removeChild(document.getElementById("pixel"));
    4948
    5049        appendIframe("http://127.0.0.1:8000/adClickAttribution/resources/getConversionData.php?timeout_ms=1000&nonce=" + nonce, function() {
     
    5655        if (window.testRunner) {
    5756            if (window.location.search === "?stepTwo") {
    58                 testRunner.setPrivateBrowsingEnabled_DEPRECATED(true);
     57                testRunner.setShouldSwapToEphemeralSessionOnNextNavigation(true);
     58                window.location = "http://localhost:8000/adClickAttribution/conversion-disabled-in-ephemeral-session.html?stepThree";
     59            } else if (window.location.search === "?stepThree") {
    5960                let imageElement = document.createElement("img");
    6061                imageElement.src = "https://127.0.0.1:8443/adClickAttribution/resources/redirectToConversion.php?conversionData=12&nonce=" + nonce;
    6162                imageElement.id = "pixel";
    6263                imageElement.onerror = function() {
    63                     appendConversionDataIframeAndFinish();
     64                    testRunner.setShouldSwapToDefaultSessionOnNextNavigation(true);
     65                    window.location = "http://localhost:8000/adClickAttribution/conversion-disabled-in-ephemeral-session.html?stepFour";
    6466                };
    6567                document.body.appendChild(imageElement);
     68            } else if (window.location.search === "?stepFour") {
     69                appendConversionDataIframeAndFinish();
    6670            } else {
    6771                document.cookie = "cookieSetAsFirstParty=1; path=/";
  • trunk/Source/WebKit/ChangeLog

    r249671 r249675  
     12019-09-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Stop using testRunner.setPrivateBrowsingEnabled_DEPRECATED() in http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html
     4        https://bugs.webkit.org/show_bug.cgi?id=201596
     5
     6        Reviewed by Alex Christensen.
     7
     8        Allow WKFramePolicyListenerUseWithPolicies() C API to switch to a persistent non-default session.
     9        This is important since WebKitTestRunner is not using the default session anymore and I need to
     10        be able to switch it back to its normal session after going to an ephemeral one.
     11
     12        * UIProcess/API/C/WKFramePolicyListener.cpp:
     13        (useWithPolicies):
     14
    1152019-09-09  Alex Christensen  <achristensen@webkit.org>
    216
  • trunk/Source/WebKit/UIProcess/API/C/WKFramePolicyListener.cpp

    r235559 r249675  
    5454static void useWithPolicies(WKFramePolicyListenerRef policyListenerRef, WKWebsitePoliciesRef websitePolicies, ProcessSwapRequestedByClient processSwapRequestedByClient)
    5555{
    56     if (auto* websiteDataStore = toImpl(websitePolicies)->websiteDataStore()) {
    57         auto sessionID = websiteDataStore->websiteDataStore().sessionID();
    58         RELEASE_ASSERT_WITH_MESSAGE(sessionID.isEphemeral() || sessionID == PAL::SessionID::defaultSessionID(), "If WebsitePolicies specifies a WebsiteDataStore, the data store's session must be default or non-persistent.");
    59     }
    60 
    6156    toImpl(policyListenerRef)->use(toImpl(websitePolicies), processSwapRequestedByClient);
    6257}
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r249096 r249675  
    595595        if (apiWebsitePolicies) {
    596596            if (auto* websiteDataStore = apiWebsitePolicies->websiteDataStore()) {
    597                 auto sessionID = websiteDataStore->websiteDataStore().sessionID();
    598                 if (!sessionID.isEphemeral() && sessionID != PAL::SessionID::defaultSessionID())
    599                     [NSException raise:NSInvalidArgumentException format:@"WKWebpagePreferences._websiteDataStore must be nil, default, or non-persistent."];
    600597                if (subframeNavigation)
    601598                    [NSException raise:NSInvalidArgumentException format:@"WKWebpagePreferences._websiteDataStore must be nil for subframe navigations."];
  • trunk/Tools/ChangeLog

    r249667 r249675  
     12019-09-09  Chris Dumez  <cdumez@apple.com>
     2
     3        Stop using testRunner.setPrivateBrowsingEnabled_DEPRECATED() in http/tests/adClickAttribution/conversion-disabled-in-ephemeral-session.html
     4        https://bugs.webkit.org/show_bug.cgi?id=201596
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add new testRunner.setShouldSwapToEphemeralSessionOnNextNavigation() / testRunner.setShouldSwapToDefaultSessionOnNextNavigation()
     9        test functions to support dynamic switching between ephemeral and default/persistent session in layout tests. The new methods
     10        do the right thing for WebKit2 and truly switch session, unlike setPrivateBrowsingEnabled_DEPRECATED() which was merely making
     11        the WebCore::Document think it changed session.
     12
     13        * DumpRenderTree/TestRunner.cpp:
     14        (setShouldSwapToEphemeralSessionOnNextNavigationCallback):
     15        (setShouldSwapToDefaultSessionOnNextNavigationCallback):
     16        (TestRunner::staticFunctions):
     17        (TestRunner::willNavigate):
     18        * DumpRenderTree/TestRunner.h:
     19        (TestRunner::setShouldSwapToEphemeralSessionOnNextNavigation):
     20        (TestRunner::setShouldSwapToDefaultSessionOnNextNavigation):
     21        * DumpRenderTree/mac/FrameLoadDelegate.mm:
     22        (-[FrameLoadDelegate webView:didStartProvisionalLoadForFrame:]):
     23        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     24        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     25        (WTR::TestRunner::setShouldSwapToEphemeralSessionOnNextNavigation):
     26        (WTR::TestRunner::setShouldSwapToDefaultSessionOnNextNavigation):
     27        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     28        * WebKitTestRunner/TestController.cpp:
     29        (WTR::TestController::decidePolicyForNavigationAction):
     30        * WebKitTestRunner/TestController.h:
     31        (WTR::TestController::setShouldSwapToEphemeralSessionOnNextNavigation):
     32        (WTR::TestController::setShouldSwapToDefaultSessionOnNextNavigation):
     33        * WebKitTestRunner/TestInvocation.cpp:
     34        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     35
    1362019-09-09  Aakash Jain  <aakash_jain@apple.com>
    237
  • trunk/Tools/DumpRenderTree/DefaultPolicyDelegate.mm

    r249672 r249675  
    77//
    88
     9#import "config.h"
    910#import "DefaultPolicyDelegate.h"
    1011
     12#import "DumpRenderTree.h"
     13#import "TestRunner.h"
    1114#import <WebKit/WebPolicyDelegatePrivate.h>
    1215#import <WebKit/WebViewPrivate.h>
     
    1720{
    1821    if ([WebView _canHandleRequest:request]) {
     22        if (![frame frameElement])
     23            gTestRunner->willNavigate();
    1924        [listener use];
    2025        return;
     
    2227
    2328    WebNavigationType navType = (WebNavigationType)[[actionInformation objectForKey:WebActionNavigationTypeKey] intValue];
    24     if (navType == WebNavigationTypePlugInRequest) {
     29    if (static_cast<unsigned>(navType) == static_cast<unsigned>(WebNavigationTypePlugInRequest)) {
     30        if (![frame frameElement])
     31            gTestRunner->willNavigate();
    2532        [listener use];
    2633        return;
  • trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj

    r247898 r249675  
    6767                1A215BE711F27658008AD0F5 /* DocumentOpenInDestroyStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A215A7511F26072008AD0F5 /* DocumentOpenInDestroyStream.cpp */; };
    6868                1A24BAA9120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */; };
    69                 1A2FB84F178C80930059FD96 /* DefaultPolicyDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A2FB84D178C80930059FD96 /* DefaultPolicyDelegate.m */; };
     69                1A2FB84F178C80930059FD96 /* DefaultPolicyDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A2FB84D178C80930059FD96 /* DefaultPolicyDelegate.mm */; };
    7070                1A31EB3813466AC100017372 /* ConvertPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A31EB3713466AC100017372 /* ConvertPoint.cpp */; };
    7171                1A3E28AA1311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */; };
     
    269269                1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRuntimeObjectFromDestroyedPlugin.cpp; sourceTree = "<group>"; };
    270270                1A2FB84C178C80920059FD96 /* DefaultPolicyDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultPolicyDelegate.h; sourceTree = "<group>"; };
    271                 1A2FB84D178C80930059FD96 /* DefaultPolicyDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DefaultPolicyDelegate.m; sourceTree = "<group>"; };
     271                1A2FB84D178C80930059FD96 /* DefaultPolicyDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DefaultPolicyDelegate.mm; sourceTree = "<group>"; };
    272272                1A31EB3713466AC100017372 /* ConvertPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertPoint.cpp; sourceTree = "<group>"; };
    273273                1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURLDestroyingPlugin.cpp; sourceTree = "<group>"; };
     
    483483                                A134E53418905E6C00901D06 /* config.h */,
    484484                                1A2FB84C178C80920059FD96 /* DefaultPolicyDelegate.h */,
    485                                 1A2FB84D178C80930059FD96 /* DefaultPolicyDelegate.m */,
     485                                1A2FB84D178C80930059FD96 /* DefaultPolicyDelegate.mm */,
    486486                                9830F31E15C81181005AB206 /* DumpRenderTreeCommon.cpp */,
    487487                                32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */,
     
    11631163                                F44A531D21B89A4D00DBB99C /* ClassMethodSwizzler.mm in Sources */,
    11641164                                53CBB832134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp in Sources */,
    1165                                 1A2FB84F178C80930059FD96 /* DefaultPolicyDelegate.m in Sources */,
     1165                                1A2FB84F178C80930059FD96 /* DefaultPolicyDelegate.mm in Sources */,
    11661166                                BCA18C470C9B5B9400114369 /* DumpRenderTree.mm in Sources */,
    11671167                                A1158D581892740C0088C17B /* DumpRenderTreeBrowserView.mm in Sources */,
  • trunk/Tools/DumpRenderTree/TestRunner.cpp

    r249542 r249675  
    11251125    TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
    11261126    controller->setPrivateBrowsingEnabled(JSValueToBoolean(context, arguments[0]));
     1127
     1128    return JSValueMakeUndefined(context);
     1129}
     1130
     1131static JSValueRef setShouldSwapToEphemeralSessionOnNextNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     1132{
     1133    // Has mac & windows implementation
     1134    if (argumentCount < 1)
     1135        return JSValueMakeUndefined(context);
     1136
     1137    TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
     1138    controller->setShouldSwapToEphemeralSessionOnNextNavigation(JSValueToBoolean(context, arguments[0]));
     1139
     1140    return JSValueMakeUndefined(context);
     1141}
     1142
     1143static JSValueRef setShouldSwapToDefaultSessionOnNextNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     1144{
     1145    // Has mac & windows implementation
     1146    if (argumentCount < 1)
     1147        return JSValueMakeUndefined(context);
     1148
     1149    TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
     1150    controller->setShouldSwapToDefaultSessionOnNextNavigation(JSValueToBoolean(context, arguments[0]));
    11271151
    11281152    return JSValueMakeUndefined(context);
     
    22212245        { "setPrinting", setPrintingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    22222246        { "setPrivateBrowsingEnabled_DEPRECATED", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     2247        { "setShouldSwapToEphemeralSessionOnNextNavigation", setShouldSwapToEphemeralSessionOnNextNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     2248        { "setShouldSwapToDefaultSessionOnNextNavigation", setShouldSwapToDefaultSessionOnNextNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    22232249        { "setSerializeHTTPLoads", setSerializeHTTPLoadsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    22242250        { "setSpatialNavigationEnabled", setSpatialNavigationEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     
    25362562    clearTestRunnerCallbacks();
    25372563}
     2564
     2565void TestRunner::willNavigate()
     2566{
     2567    if (m_shouldSwapToEphemeralSessionOnNextNavigation || m_shouldSwapToDefaultSessionOnNextNavigation) {
     2568        ASSERT(m_shouldSwapToEphemeralSessionOnNextNavigation != m_shouldSwapToDefaultSessionOnNextNavigation);
     2569        setPrivateBrowsingEnabled(m_shouldSwapToEphemeralSessionOnNextNavigation);
     2570    }
     2571}
  • trunk/Tools/DumpRenderTree/TestRunner.h

    r248856 r249675  
    117117    void setPopupBlockingEnabled(bool);
    118118    void setPrivateBrowsingEnabled(bool);
     119
     120    void willNavigate();
     121    void setShouldSwapToEphemeralSessionOnNextNavigation(bool shouldSwap) { m_shouldSwapToEphemeralSessionOnNextNavigation = shouldSwap; }
     122    void setShouldSwapToDefaultSessionOnNextNavigation(bool shouldSwap) { m_shouldSwapToDefaultSessionOnNextNavigation = shouldSwap; }
     123
    119124    void setTabKeyCyclesThroughElements(bool);
    120125    void setUserStyleSheetEnabled(bool flag);
     
    459464    bool m_dumpJSConsoleLogInStdErr { false };
    460465    bool m_didCancelClientRedirect { false };
     466    bool m_shouldSwapToEphemeralSessionOnNextNavigation { false };
     467    bool m_shouldSwapToDefaultSessionOnNextNavigation { false };
    461468
    462469    double m_databaseDefaultQuota { -1 };
  • trunk/Tools/DumpRenderTree/mac/PolicyDelegate.mm

    r232452 r249675  
    8686    printf("%s\n", [message UTF8String]);
    8787
    88     if (permissiveDelegate)
     88    if (permissiveDelegate) {
     89        if (![frame frameElement])
     90            gTestRunner->willNavigate();
    8991        [listener use];
    90     else
     92    } else
    9193        [listener ignore];
    9294
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r249542 r249675  
    106106    void setShouldDownloadUndisplayableMIMETypes(boolean value);
    107107   
    108     // DEPRECATED: Use <!-- webkit-test-runner [ useEphemeralSession=true ] --> instead.
     108    // DEPRECATED: Use <!-- webkit-test-runner [ useEphemeralSession=true ] --> instead, or
     109    // testRunner.setShouldSwapToEphemeralSessionOnNextNavigation() / testRunner.setShouldSwapToDefaultSessionOnNextNavigation().
    109110    void setPrivateBrowsingEnabled_DEPRECATED(boolean value);
    110111
     
    253254
    254255    void setAllowsAnySSLCertificate(boolean value);
     256
     257    void setShouldSwapToEphemeralSessionOnNextNavigation(boolean value);
     258    void setShouldSwapToDefaultSessionOnNextNavigation(boolean value);
    255259
    256260    // Secure text input mode (Mac only)
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r249575 r249675  
    501501}
    502502
     503void TestRunner::setShouldSwapToEphemeralSessionOnNextNavigation(bool shouldSwap)
     504{
     505    auto& injectedBundle = InjectedBundle::singleton();
     506
     507    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetShouldSwapToEphemeralSessionOnNextNavigation"));
     508    WKRetainPtr<WKBooleanRef> messageBody = adoptWK(WKBooleanCreate(shouldSwap));
     509    WKBundlePagePostSynchronousMessageForTesting(injectedBundle.page()->page(), messageName.get(), messageBody.get(), nullptr);
     510}
     511
     512void TestRunner::setShouldSwapToDefaultSessionOnNextNavigation(bool shouldSwap)
     513{
     514    auto& injectedBundle = InjectedBundle::singleton();
     515
     516    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetShouldSwapToDefaultSessionOnNextNavigation"));
     517    WKRetainPtr<WKBooleanRef> messageBody = adoptWK(WKBooleanCreate(shouldSwap));
     518    WKBundlePagePostSynchronousMessageForTesting(injectedBundle.page()->page(), messageName.get(), messageBody.get(), nullptr);
     519}
     520
    503521void TestRunner::setAllowUniversalAccessFromFileURLs(bool enabled)
    504522{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r249542 r249675  
    128128    void setAsynchronousSpellCheckingEnabled(bool);
    129129    void setAllowsAnySSLCertificate(bool);
     130    void setShouldSwapToEphemeralSessionOnNextNavigation(bool);
     131    void setShouldSwapToDefaultSessionOnNextNavigation(bool);
    130132    void setEncryptedMediaAPIEnabled(bool);
    131133    void setMediaDevicesEnabled(bool);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r249619 r249675  
    6969#include <WebKit/WKWebsiteDataStoreConfigurationRef.h>
    7070#include <WebKit/WKWebsiteDataStoreRef.h>
     71#include <WebKit/WKWebsitePolicies.h>
    7172#include <algorithm>
    7273#include <cstdio>
     
    28122813    WKRetainPtr<WKNavigationActionRef> retainedNavigationAction { navigationAction };
    28132814    const bool shouldIgnore { m_policyDelegateEnabled && !m_policyDelegatePermissive };
    2814     auto decisionFunction = [shouldIgnore, retainedListener, retainedNavigationAction]() {
     2815    auto decisionFunction = [shouldIgnore, retainedListener, retainedNavigationAction, shouldSwapToEphemeralSessionOnNextNavigation = m_shouldSwapToEphemeralSessionOnNextNavigation, shouldSwapToDefaultSessionOnNextNavigation = m_shouldSwapToDefaultSessionOnNextNavigation]() {
    28152816        if (shouldIgnore)
    28162817            WKFramePolicyListenerIgnore(retainedListener.get());
    28172818        else if (WKNavigationActionShouldPerformDownload(retainedNavigationAction.get()))
    28182819            WKFramePolicyListenerDownload(retainedListener.get());
    2819         else
    2820             WKFramePolicyListenerUse(retainedListener.get());
     2820        else {
     2821            if (shouldSwapToEphemeralSessionOnNextNavigation || shouldSwapToDefaultSessionOnNextNavigation) {
     2822                ASSERT(shouldSwapToEphemeralSessionOnNextNavigation != shouldSwapToDefaultSessionOnNextNavigation);
     2823                auto policies = adoptWK(WKWebsitePoliciesCreate());
     2824                WKRetainPtr<WKWebsiteDataStoreRef> newSession = TestController::websiteDataStore();
     2825                if (shouldSwapToEphemeralSessionOnNextNavigation)
     2826                    newSession = adoptWK(WKWebsiteDataStoreCreateNonPersistentDataStore());
     2827                WKWebsitePoliciesSetDataStore(policies.get(), newSession.get());
     2828                WKFramePolicyListenerUseWithPolicies(retainedListener.get(), policies.get());
     2829            } else
     2830                WKFramePolicyListenerUse(retainedListener.get());
     2831        }
    28212832    };
     2833    m_shouldSwapToEphemeralSessionOnNextNavigation = false;
     2834    m_shouldSwapToDefaultSessionOnNextNavigation = false;
    28222835
    28232836    if (m_shouldDecideNavigationPolicyAfterDelay)
  • trunk/Tools/WebKitTestRunner/TestController.h

    r249614 r249675  
    187187    void setAuthenticationPassword(String password) { m_authenticationPassword = password; }
    188188    void setAllowsAnySSLCertificate(bool);
     189    void setShouldSwapToEphemeralSessionOnNextNavigation(bool value) { m_shouldSwapToEphemeralSessionOnNextNavigation = value; }
     190    void setShouldSwapToDefaultSessionOnNextNavigation(bool value) { m_shouldSwapToDefaultSessionOnNextNavigation = value; }
    189191
    190192    void setBlockAllPlugins(bool shouldBlock);
     
    594596    bool m_shouldDismissJavaScriptAlertsAsynchronously { false };
    595597    bool m_allowsAnySSLCertificate { true };
     598    bool m_shouldSwapToEphemeralSessionOnNextNavigation { false };
     599    bool m_shouldSwapToDefaultSessionOnNextNavigation { false };
    596600};
    597601
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r249619 r249675  
    926926        return nullptr;
    927927    }
     928   
     929    if (WKStringIsEqualToUTF8CString(messageName, "SetShouldSwapToEphemeralSessionOnNextNavigation")) {
     930        TestController::singleton().setShouldSwapToEphemeralSessionOnNextNavigation(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
     931        return nullptr;
     932    }
     933   
     934    if (WKStringIsEqualToUTF8CString(messageName, "SetShouldSwapToDefaultSessionOnNextNavigation")) {
     935        TestController::singleton().setShouldSwapToDefaultSessionOnNextNavigation(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
     936        return nullptr;
     937    }
    928938
    929939    if (WKStringIsEqualToUTF8CString(messageName, "ImageCountInGeneralPasteboard")) {
Note: See TracChangeset for help on using the changeset viewer.