Changeset 70367 in webkit


Ignore:
Timestamp:
Oct 22, 2010 4:47:35 PM (14 years ago)
Author:
andersca@apple.com
Message:

WebCore: Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work
https://bugs.webkit.org/show_bug.cgi?id=48014
<rdar://problem/8202716>

Reviewed by Adam Barth and Darin Adler.

  • loader/MainResourceLoader.cpp:

(WebCore::MainResourceLoader::continueAfterContentPolicy):
Resume loading.

(WebCore::MainResourceLoader::didReceiveResponse):
Defer loading until we hear back from the policy client.

WebKitTools: Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work
https://bugs.webkit.org/show_bug.cgi?id=48014
<rdar://problem/8202716>

Reviewed by Adam Barth and Darin Adler.

  • DumpRenderTree/LayoutTestController.cpp:

(setCustomPolicyDelegateCallback):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

  • DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:

(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

  • DumpRenderTree/mac/LayoutTestControllerMac.mm:

(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

  • DumpRenderTree/mac/PolicyDelegate.h:
  • DumpRenderTree/mac/PolicyDelegate.mm:

(-[PolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]):
If _callIgnoreInDecidePolicyForMIMETypeAfterOneSecond is true, call [listener ignore] after one second.

(-[PolicyDelegate setCallIgnoreInDecidePolicyForMIMETypeAfterOneSecond:]):
Update _callIgnoreInDecidePolicyForMIMETypeAfterOneSecond.

  • DumpRenderTree/win/LayoutTestControllerWin.cpp:

(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

  • DumpRenderTree/wx/LayoutTestControllerWx.cpp:

(LayoutTestController::setCustomPolicyDelegate):
Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.

LayoutTests: Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work
https://bugs.webkit.org/show_bug.cgi?id=48014
<rdar://problem/8202716>

Reviewed by Adam Barth and Darin Adler.

Add tests and update the skipped list.

  • fast/loader/decide-policy-for-mime-type-async-expected.txt: Added.
  • fast/loader/decide-policy-for-mime-type-async.html: Added.
  • platform/gtk/Skipped:
  • platform/mac-wk2/Skipped:
  • platform/qt/Skipped:
  • platform/qt-wk2/Skipped:
  • platform/win/Skipped:
Location:
trunk
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r70364 r70367  
     12010-10-20  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Adam Barth and Darin Adler.
     4
     5        Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work
     6        https://bugs.webkit.org/show_bug.cgi?id=48014
     7        <rdar://problem/8202716>
     8
     9        Add tests and update the skipped list.
     10
     11        * fast/loader/decide-policy-for-mime-type-async-expected.txt: Added.
     12        * fast/loader/decide-policy-for-mime-type-async.html: Added.
     13        * platform/gtk/Skipped:
     14        * platform/mac-wk2/Skipped:
     15        * platform/qt/Skipped:
     16        * platform/qt-wk2/Skipped:
     17        * platform/win/Skipped:
     18
    1192010-10-22  Dimitri Glazkov  <dglazkov@chromium.org>
    220
  • trunk/LayoutTests/platform/gtk/Skipped

    r70307 r70367  
    11481148fast/history/window-open.html
    11491149fast/html/tab-order.html
     1150fast/loader/decide-policy-for-mime-type-async.html
    11501151fast/loader/main-document-url-for-non-http-loads.html
    11511152fast/loader/onload-policy-ignore-for-frame.html
  • trunk/LayoutTests/platform/mac-wk2/Skipped

    r70269 r70367  
    15251525# WebKitTestRunner needs layoutTestController.setCustomPolicyDelegate
    15261526# <https://bugs.webkit.org/show_bug.cgi?id=42546>
     1527fast/loader/decide-policy-for-mime-type-async.html
    15271528fast/loader/javascript-url-hierarchical-execution.html
    15281529fast/loader/onload-policy-ignore-for-frame.html
  • trunk/LayoutTests/platform/qt-wk2/Skipped

    r69385 r70367  
    14731473# WebKitTestRunner needs layoutTestController.setCustomPolicyDelegate
    14741474# <https://bugs.webkit.org/show_bug.cgi?id=42546>
     1475fast/loader/decide-policy-for-mime-type-async.html
    14751476fast/loader/javascript-url-hierarchical-execution.html
    14761477fast/loader/onload-policy-ignore-for-frame.html
  • trunk/LayoutTests/platform/qt/Skipped

    r70164 r70367  
    101101compositing
    102102
     103fast/loader/decide-policy-for-mime-type-async.html
    103104fast/loader/subframe-navigate-during-main-frame-load.html
    104105
  • trunk/LayoutTests/platform/win/Skipped

    r70147 r70367  
    10421042# Requires WebP support.
    10431043fast/images/webp-image-decoding.html
     1044
     1045# Needs ovelroad of setCustomPolicyDelegate
     1046fast/loader/decide-policy-for-mime-type-async.html
  • trunk/WebCore/ChangeLog

    r70365 r70367  
     12010-10-20  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Adam Barth and Darin Adler.
     4
     5        Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work
     6        https://bugs.webkit.org/show_bug.cgi?id=48014
     7        <rdar://problem/8202716>
     8
     9        * loader/MainResourceLoader.cpp:
     10        (WebCore::MainResourceLoader::continueAfterContentPolicy):
     11        Resume loading.
     12
     13        (WebCore::MainResourceLoader::didReceiveResponse):
     14        Defer loading until we hear back from the policy client.
     15
    1162010-10-22  James Robinson  <jamesr@chromium.org>
    217
  • trunk/WebCore/loader/MainResourceLoader.cpp

    r69321 r70367  
    5858    , m_loadingMultipartContent(false)
    5959    , m_waitingForContentPolicy(false)
     60    , m_deferLoadingCount(0)
    6061{
    6162}
     
    232233    KURL url = request().url();
    233234    const String& mimeType = r.mimeType();
    234    
     235
     236    // This is balanced by a call to setDefersLoading(true) in didReceiveResponse.
     237    setDefersLoading(false);
     238
    235239    switch (contentPolicy) {
    236240    case PolicyUse: {
     
    374378    RefPtr<MainResourceLoader> protect(this);
    375379
     380    // Defer loading while we're waiting for a response.
     381    // This is balanced by a setDefersLoading(false) call in continueAfterContentPolicy.
     382    setDefersLoading(true);
     383   
    376384    m_documentLoader->setResponse(r);
    377385
     
    596604void MainResourceLoader::setDefersLoading(bool defers)
    597605{
     606    if (defers) {
     607        m_deferLoadingCount++;
     608        if (m_deferLoadingCount > 1)
     609            return;
     610    } else {
     611        ASSERT(m_deferLoadingCount);
     612        m_deferLoadingCount--;
     613        if (m_deferLoadingCount > 0)
     614            return;
     615    }
    598616    ResourceLoader::setDefersLoading(defers);
    599617
  • trunk/WebCore/loader/MainResourceLoader.h

    r69226 r70367  
    109109        bool m_waitingForContentPolicy;
    110110        double m_timeOfLastDataReceived;
     111        unsigned m_deferLoadingCount;
    111112    };
    112113
  • trunk/WebKitTools/ChangeLog

    r70352 r70367  
     12010-10-20  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Adam Barth and Darin Adler.
     4
     5        Using the decidePolicyForMIMEType delegate message in an asynchronous manner does not work
     6        https://bugs.webkit.org/show_bug.cgi?id=48014
     7        <rdar://problem/8202716>
     8       
     9        * DumpRenderTree/LayoutTestController.cpp:
     10        (setCustomPolicyDelegateCallback):
     11        Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.
     12
     13        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
     14        (LayoutTestController::setCustomPolicyDelegate):
     15        Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.
     16
     17        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
     18        (LayoutTestController::setCustomPolicyDelegate):
     19        Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.
     20
     21        * DumpRenderTree/mac/PolicyDelegate.h:
     22        * DumpRenderTree/mac/PolicyDelegate.mm:
     23        (-[PolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]):
     24        If _callIgnoreInDecidePolicyForMIMETypeAfterOneSecond is true, call [listener ignore] after one second.
     25
     26        (-[PolicyDelegate setCallIgnoreInDecidePolicyForMIMETypeAfterOneSecond:]):
     27        Update _callIgnoreInDecidePolicyForMIMETypeAfterOneSecond.
     28       
     29        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
     30        (LayoutTestController::setCustomPolicyDelegate):
     31        Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.
     32
     33        * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
     34        (LayoutTestController::setCustomPolicyDelegate):
     35        Add callIgnoreInDecidePolicyForMIMETypeAfterOneSecond argument.
     36
    1372010-10-22  Sam Weinig  <sam@webkit.org>
    238
  • trunk/WebKitTools/DumpRenderTree/LayoutTestController.cpp

    r70302 r70367  
    972972        permissive = JSValueToBoolean(context, arguments[1]);
    973973
    974     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    975     controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive);
     974    bool callIgnoreInDecidePolicyForMIMETypeAfterOneSecond = false;
     975    if (argumentCount >= 3)
     976        callIgnoreInDecidePolicyForMIMETypeAfterOneSecond = JSValueToBoolean(context, arguments[2]);
     977   
     978    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
     979    controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive, callIgnoreInDecidePolicyForMIMETypeAfterOneSecond);
    976980
    977981    return JSValueMakeUndefined(context);
  • trunk/WebKitTools/DumpRenderTree/LayoutTestController.h

    r70302 r70367  
    8585    void setAuthorAndUserStylesEnabled(bool);
    8686    void setCacheModel(int);
    87     void setCustomPolicyDelegate(bool setDelegate, bool permissive);
     87    void setCustomPolicyDelegate(bool setDelegate, bool permissive, bool callIgnoreInDecidePolicyForMIMETypeAfterOneSecond);
    8888    void setDatabaseQuota(unsigned long long quota);
    8989    void setDomainRelaxationForbiddenForURLScheme(bool forbidden, JSStringRef scheme);
  • trunk/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp

    r70302 r70367  
    269269}
    270270
    271 void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
     271void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive, bool callIgnoreInDecidePolicyForMIMETypeAfterOneSecond)
    272272{
    273273    // FIXME: implement
  • trunk/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm

    r70302 r70367  
    320320}
    321321
    322 void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
     322void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive, bool callIgnoreInDecidePolicyForMIMETypeAfterOneSecond)
    323323{
    324324    if (setDelegate) {
     325        [policyDelegate setCallIgnoreInDecidePolicyForMIMETypeAfterOneSecond:callIgnoreInDecidePolicyForMIMETypeAfterOneSecond];
    325326        [policyDelegate setPermissive:permissive];
    326327        [[mainFrame webView] setPolicyDelegate:policyDelegate];
  • trunk/WebKitTools/DumpRenderTree/mac/PolicyDelegate.h

    r42056 r70367  
    3232
    3333@interface PolicyDelegate : NSObject {
    34     BOOL permissiveDelegate;
    35     LayoutTestController* controllerToNotifyDone;
     34    BOOL _permissiveDelegate;
     35    BOOL _callIgnoreInDecidePolicyForMIMETypeAfterOneSecond;
     36    LayoutTestController* _controllerToNotifyDone;
    3637}
    3738
    3839- (void)setPermissive:(BOOL)permissive;
     40- (void)setCallIgnoreInDecidePolicyForMIMETypeAfterOneSecond:(BOOL)callIgnoreInDecidePolicyForMIMETypeAfterOneSecond;
    3941- (void)setControllerToNotifyDone:(LayoutTestController*)controller;
    4042
  • trunk/WebKitTools/DumpRenderTree/mac/PolicyDelegate.mm

    r46340 r70367  
    8484    printf("%s\n", [message UTF8String]);
    8585
    86     if (permissiveDelegate)
     86    if (_permissiveDelegate)
    8787        [listener use];
    8888    else
    8989        [listener ignore];
    9090
    91     if (controllerToNotifyDone) {
    92         controllerToNotifyDone->notifyDone();
    93         controllerToNotifyDone = 0;
     91    if (_controllerToNotifyDone) {
     92        _controllerToNotifyDone->notifyDone();
     93        _controllerToNotifyDone = 0;
    9494    }
     95}
     96
     97- (void)webView:(WebView *)webView decidePolicyForMIMEType:(NSString *)type
     98                                                   request:(NSURLRequest *)request
     99                                                     frame:(WebFrame *)frame
     100                                          decisionListener:(id<WebPolicyDecisionListener>)listener
     101{
     102    if (!_callIgnoreInDecidePolicyForMIMETypeAfterOneSecond) {
     103        [listener use];
     104        return;
     105    }
     106
     107    [(NSObject *)listener performSelector:@selector(ignore) withObject:nil afterDelay:1.0];
    95108}
    96109
     
    101114}
    102115
     116- (void)setCallIgnoreInDecidePolicyForMIMETypeAfterOneSecond:(BOOL)callIgnoreInDecidePolicyForMIMETypeAfterOneSecond
     117{
     118    _callIgnoreInDecidePolicyForMIMETypeAfterOneSecond = callIgnoreInDecidePolicyForMIMETypeAfterOneSecond;
     119}
     120
    103121- (void)setPermissive:(BOOL)permissive
    104122{
    105     permissiveDelegate = permissive;
     123    _permissiveDelegate = permissive;
    106124}
    107125
    108126- (void)setControllerToNotifyDone:(LayoutTestController*)controller
    109127{
    110     controllerToNotifyDone = controller;
     128    _controllerToNotifyDone = controller;
    111129}
    112130
  • trunk/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp

    r70302 r70367  
    369369}
    370370
    371 void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive)
     371void LayoutTestController::setCustomPolicyDelegate(bool setDelegate, bool permissive , bool callIgnoreInDecidePolicyForMIMETypeAfterOneSecond)
    372372{
    373373    COMPtr<IWebView> webView;
  • trunk/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp

    r70302 r70367  
    108108}
    109109
    110 void LayoutTestController::setCustomPolicyDelegate(bool, bool)
     110void LayoutTestController::setCustomPolicyDelegate(bool, bool, bool)
    111111{
    112112    // FIXME: implement
Note: See TracChangeset for help on using the changeset viewer.