Changeset 130967 in webkit


Ignore:
Timestamp:
Oct 10, 2012 3:11:31 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[WK2][WTR] WebKitTestRunner UI process should be aware of Custom Policy Delegate
https://bugs.webkit.org/show_bug.cgi?id=95974

Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> on 2012-10-10
Reviewed by Kenneth Rohde Christiansen.

Tools:

Added TestController::decidePolicyForNavigationAction() function as a 'decidePolicyForNavigationAction' WKPagePolicyClient callback
for WTR UI process. WTR bundle client notifies UI process about Custom Policy Delegate via newly added message,
so that TestController is aware of whether Custom Policy Delegate as enabled and
permissive. This data is used then in TestController::decidePolicyForNavigationAction for making policy decision.

  • WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:

(WTR::InjectedBundle::setCustomPolicyDelegate):
(WTR):

  • WebKitTestRunner/InjectedBundle/InjectedBundle.h:

(InjectedBundle):

  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setCustomPolicyDelegate):

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::TestController):
(WTR::TestController::initialize):
(WTR::TestController::resetStateToConsistentValues):
(WTR::TestController::setCustomPolicyDelegate):
(WTR):
(WTR::TestController::decidePolicyForNavigationAction):

  • WebKitTestRunner/TestController.h:

(TestController):

  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

LayoutTests:

Unskipped fast/loader/onload-policy-ignore-for-frame.html for WK2.

  • platform/wk2/TestExpectations:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r130965 r130967  
     12012-10-10  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
     2
     3        [WK2][WTR] WebKitTestRunner UI process should be aware of Custom Policy Delegate
     4        https://bugs.webkit.org/show_bug.cgi?id=95974
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Unskipped fast/loader/onload-policy-ignore-for-frame.html for WK2.
     9
     10        * platform/wk2/TestExpectations:
     11
    1122012-10-10  Adam Barth  <abarth@webkit.org>
    213
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r130824 r130967  
    553553inspector/geolocation-success.html
    554554
    555 # WebFrameLoaderClient::dispatchDecidePolicy methods should consider
    556 # 'WKBundlePagePolicyActionPassThrough' policy action
    557 # https://bugs.webkit.org/show_bug.cgi?id=95974
    558 fast/loader/onload-policy-ignore-for-frame.html
    559 
    560555### END OF (1) Classified failures with bug reports
    561556########################################
  • trunk/Tools/ChangeLog

    r130956 r130967  
     12012-10-10  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
     2
     3        [WK2][WTR] WebKitTestRunner UI process should be aware of Custom Policy Delegate
     4        https://bugs.webkit.org/show_bug.cgi?id=95974
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Added TestController::decidePolicyForNavigationAction() function as a 'decidePolicyForNavigationAction' WKPagePolicyClient callback
     9        for WTR UI process. WTR bundle client notifies UI process about Custom Policy Delegate via newly added message,
     10        so that TestController is aware of whether Custom Policy Delegate as enabled and
     11        permissive. This data is used then in TestController::decidePolicyForNavigationAction for making policy decision.
     12
     13        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     14        (WTR::InjectedBundle::setCustomPolicyDelegate):
     15        (WTR):
     16        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
     17        (InjectedBundle):
     18        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     19        (WTR::TestRunner::setCustomPolicyDelegate):
     20        * WebKitTestRunner/TestController.cpp:
     21        (WTR::TestController::TestController):
     22        (WTR::TestController::initialize):
     23        (WTR::TestController::resetStateToConsistentValues):
     24        (WTR::TestController::setCustomPolicyDelegate):
     25        (WTR):
     26        (WTR::TestController::decidePolicyForNavigationAction):
     27        * WebKitTestRunner/TestController.h:
     28        (TestController):
     29        * WebKitTestRunner/TestInvocation.cpp:
     30        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
     31
    1322012-10-10  Zoltan Horvath  <zoltan@webkit.org>
    233
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r130568 r130967  
    430430}
    431431
     432void InjectedBundle::setCustomPolicyDelegate(bool enabled, bool permissive)
     433{
     434    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetCustomPolicyDelegate"));
     435
     436    WKRetainPtr<WKMutableDictionaryRef> messageBody(AdoptWK, WKMutableDictionaryCreate());
     437
     438    WKRetainPtr<WKStringRef> enabledKeyWK(AdoptWK, WKStringCreateWithUTF8CString("enabled"));
     439    WKRetainPtr<WKBooleanRef> enabledWK(AdoptWK, WKBooleanCreate(enabled));
     440    WKDictionaryAddItem(messageBody.get(), enabledKeyWK.get(), enabledWK.get());
     441
     442    WKRetainPtr<WKStringRef> permissiveKeyWK(AdoptWK, WKStringCreateWithUTF8CString("permissive"));
     443    WKRetainPtr<WKBooleanRef> permissiveWK(AdoptWK, WKBooleanCreate(permissive));
     444    WKDictionaryAddItem(messageBody.get(), permissiveKeyWK.get(), permissiveWK.get());
     445
     446    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
     447}
     448
    432449} // namespace WTR
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h

    r130416 r130967  
    9696    void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
    9797
     98    // Policy delegate.
     99    void setCustomPolicyDelegate(bool enabled, bool permissive);
     100
    98101private:
    99102    InjectedBundle();
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r130776 r130967  
    124124}
    125125
    126 // FIXME: Needs a full implementation see https://bugs.webkit.org/show_bug.cgi?id=42546
    127126void TestRunner::setCustomPolicyDelegate(bool enabled, bool permissive)
    128127{
    129128    m_policyDelegateEnabled = enabled;
    130129    m_policyDelegatePermissive = permissive;
     130
     131    InjectedBundle::shared().setCustomPolicyDelegate(enabled, permissive);
    131132}
    132133
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r130522 r130967  
    9494    , m_isGeolocationPermissionSet(false)
    9595    , m_isGeolocationPermissionAllowed(false)
     96    , m_policyDelegateEnabled(false)
     97    , m_policyDelegatePermissive(false)
    9698#if PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
    9799    , m_eventSenderProxy(new EventSenderProxy(this))
     
    433435    };
    434436    WKPageSetPageLoaderClient(m_mainWebView->page(), &pageLoaderClient);
     437
     438    WKPagePolicyClient pagePolicyClient = {
     439        kWKPagePolicyClientCurrentVersion,
     440        this,
     441        decidePolicyForNavigationAction,
     442        0, // decidePolicyForNewWindowAction
     443        0, // decidePolicyForResponse
     444        0, // unableToImplementPolicy
     445    };
     446    WKPageSetPagePolicyClient(m_mainWebView->page(), &pagePolicyClient);
    435447}
    436448
     
    516528    m_isGeolocationPermissionAllowed = false;
    517529
     530    // Reset Custom Policy Delegate.
     531    setCustomPolicyDelegate(false, false);
     532
    518533    // Reset main page back to about:blank
    519534    m_doneResetting = false;
     
    10101025}
    10111026
     1027void TestController::setCustomPolicyDelegate(bool enabled, bool permissive)
     1028{
     1029    m_policyDelegateEnabled = enabled;
     1030    m_policyDelegatePermissive = permissive;
     1031}
     1032
    10121033void TestController::decidePolicyForGeolocationPermissionRequestIfPossible()
    10131034{
     
    10351056}
    10361057
     1058void TestController::decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo)
     1059{
     1060    static_cast<TestController*>(const_cast<void*>(clientInfo))->decidePolicyForNavigationAction(listener);
     1061}
     1062
     1063void TestController::decidePolicyForNavigationAction(WKFramePolicyListenerRef listener)
     1064{
     1065    if (m_policyDelegateEnabled && !m_policyDelegatePermissive) {
     1066        WKFramePolicyListenerIgnore(listener);
     1067        return;
     1068    }
     1069
     1070    WKFramePolicyListenerUse(listener);
     1071}
     1072
    10371073} // namespace WTR
  • trunk/Tools/WebKitTestRunner/TestController.h

    r130416 r130967  
    7474    void handleGeolocationPermissionRequest(WKGeolocationPermissionRequestRef);
    7575
     76    // Policy delegate.
     77    void setCustomPolicyDelegate(bool enabled, bool permissive);
     78
    7679    bool resetStateToConsistentValues();
    7780
     
    110113    static void decidePolicyForNotificationPermissionRequest(WKPageRef, WKSecurityOriginRef, WKNotificationPermissionRequestRef, const void*);
    111114    void decidePolicyForNotificationPermissionRequest(WKPageRef, WKSecurityOriginRef, WKNotificationPermissionRequestRef);
     115
     116    // WKPagePolicyClient
     117    static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef, const void*);
     118    void decidePolicyForNavigationAction(WKFramePolicyListenerRef);
    112119
    113120    static WKPageRef createOtherPage(WKPageRef oldPage, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*);
     
    159166    bool m_isGeolocationPermissionAllowed;
    160167
     168    bool m_policyDelegateEnabled;
     169    bool m_policyDelegatePermissive;
     170
    161171    EventSenderProxy* m_eventSenderProxy;
    162172};
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r130416 r130967  
    415415    }
    416416
     417    if (WKStringIsEqualToUTF8CString(messageName, "SetCustomPolicyDelegate")) {
     418        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     419        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
     420
     421        WKRetainPtr<WKStringRef> enabledKeyWK(AdoptWK, WKStringCreateWithUTF8CString("enabled"));
     422        WKBooleanRef enabledWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, enabledKeyWK.get()));
     423        bool enabled = WKBooleanGetValue(enabledWK);
     424
     425        WKRetainPtr<WKStringRef> permissiveKeyWK(AdoptWK, WKStringCreateWithUTF8CString("permissive"));
     426        WKBooleanRef permissiveWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, permissiveKeyWK.get()));
     427        bool permissive = WKBooleanGetValue(permissiveWK);
     428
     429        TestController::shared().setCustomPolicyDelegate(enabled, permissive);
     430        return;
     431    }
     432
    417433    ASSERT_NOT_REACHED();
    418434}
Note: See TracChangeset for help on using the changeset viewer.