Changeset 53277 in webkit


Ignore:
Timestamp:
Jan 14, 2010 11:29:51 AM (14 years ago)
Author:
Adam Roben
Message:

Treat all synchronous loads equally in FrameLoader::loadSubframe

Only loads of the empty URL or about:blank were being treated as
synchronous loads. But other loads can be synchronous (e.g., when we
receive a null ResourceRequest from requestFromDelegate or when a
policy decision of "ignore" is made). We now treat those loads the
same way we treated empty URLs and about:blank.

Fixes <rdar://problem/7533333> <http://webkit.org/b/33533>
window.onload never fires if page contains an <iframe> with a bad
scheme or whose load is cancelled by returning null from resource load
delegate's willSendRequest

Tests: fast/loader/onload-bad-scheme-for-frame.html

fast/loader/onload-policy-ignore-for-frame.html
fast/loader/onload-willSendRequest-null-for-frame.html

Reviewed by Brady Eidson.

WebCore:

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::loadSubframe):

  • Detect synchronous loads by checking the subframe's loader's state, rather than by checking its URL
  • Removed unnecessary call to completed(), since checkCompleted() will call completed() if needed (the call to completed() was added first and wasn't removed when the call to checkCompleted() was added in r8316)
  • Added more comments about the strange thing this function does with the subframe's loader

WebKitTools:

Add LayoutTestController API to force
-webView:resource:willSendRequest:: to return null

  • DumpRenderTree/LayoutTestController.cpp:

(LayoutTestController::LayoutTestController): Initialize new member.
(setWillSendRequestReturnsNullCallback): Call through to
LayoutTestController.
(LayoutTestController::staticFunctions): Added new function.

  • DumpRenderTree/LayoutTestController.h: Added

m_willSendRequestReturnsNull.
(LayoutTestController::willSendRequestReturnsNull):
(LayoutTestController::setWillSendRequestReturnsNull):
Added standard accessors.

  • DumpRenderTree/mac/ResourceLoadDelegate.mm:

(-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):

  • DumpRenderTree/win/ResourceLoadDelegate.cpp:

(ResourceLoadDelegate::willSendRequest):
Return null if LayoutTestController says to.

LayoutTests:

Add tests that show that onload still fires in various situations with
subframes

  • fast/loader/onload-bad-scheme-for-frame-expected.txt: Added.
  • fast/loader/onload-bad-scheme-for-frame.html: Added.

Tests that onload still fires when a subframe with an unrecognized
scheme is in the page.

  • fast/loader/onload-policy-ignore-for-frame-expected.txt: Added.
  • fast/loader/onload-policy-ignore-for-frame.html: Added.

Tests that onload still fires when the policy delegate says to ignore
the initial load of a subframe.

  • fast/loader/onload-willSendRequest-null-for-frame-expected.txt: Added.
  • fast/loader/onload-willSendRequest-null-for-frame.html: Added.

Tests that onload still fires when the resource load delegate returns
null from willSendRequest for the initial load of a subframe.

  • http/tests/loading/bad-scheme-subframe-expected.txt: Updated result

to show that we now fire onload for the main frame in this case. (This
is essentially the same as onload-bad-scheme-for-frame.html, but it
still seems useful to have that new, more explicit, test.)

Location:
trunk
Files:
6 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r53274 r53277  
    88        * fast/frames/cached-frame-counter-expected.txt: Added.
    99        * fast/frames/cached-frame-counter.html: Added.
     10
     112010-01-14  Adam Roben  <aroben@apple.com>
     12
     13        Add tests that show that onload still fires in various situations with
     14        subframes
     15
     16        Tests for <rdar://problem/7533333> <http://webkit.org/b/33533>
     17        window.onload never fires if page contains an <iframe> with a bad
     18        scheme or whose load is cancelled by returning null from resource load
     19        delegate's willSendRequest
     20
     21        Reviewed by Brady Eidson.
     22
     23        * fast/loader/onload-bad-scheme-for-frame-expected.txt: Added.
     24        * fast/loader/onload-bad-scheme-for-frame.html: Added.
     25        Tests that onload still fires when a subframe with an unrecognized
     26        scheme is in the page.
     27
     28        * fast/loader/onload-policy-ignore-for-frame-expected.txt: Added.
     29        * fast/loader/onload-policy-ignore-for-frame.html: Added.
     30        Tests that onload still fires when the policy delegate says to ignore
     31        the initial load of a subframe.
     32
     33        * fast/loader/onload-willSendRequest-null-for-frame-expected.txt: Added.
     34        * fast/loader/onload-willSendRequest-null-for-frame.html: Added.
     35        Tests that onload still fires when the resource load delegate returns
     36        null from willSendRequest for the initial load of a subframe.
     37
     38        * http/tests/loading/bad-scheme-subframe-expected.txt: Updated result
     39        to show that we now fire onload for the main frame in this case. (This
     40        is essentially the same as onload-bad-scheme-for-frame.html, but it
     41        still seems useful to have that new, more explicit, test.)
    1042
    11432010-01-14  Adam Roben  <aroben@apple.com>
  • trunk/LayoutTests/http/tests/loading/bad-scheme-subframe-expected.txt

    r30014 r53277  
    22main frame - didCommitLoadForFrame
    33main frame - didFinishDocumentLoadForFrame
     4main frame - didHandleOnloadEventsForFrame
    45main frame - didFinishLoadForFrame
    56This is a test of load callbacks. It is only useful inside the regression test tool.
  • trunk/WebCore/ChangeLog

    r53276 r53277  
     12010-01-14  Adam Roben  <aroben@apple.com>
     2
     3        Treat all synchronous loads equally in FrameLoader::loadSubframe
     4
     5        Only loads of the empty URL or about:blank were being treated as
     6        synchronous loads. But other loads can be synchronous (e.g., when we
     7        receive a null ResourceRequest from requestFromDelegate or when a
     8        policy decision of "ignore" is made). We now treat those loads the
     9        same way we treated empty URLs and about:blank.
     10
     11        Fixes <rdar://problem/7533333> <http://webkit.org/b/33533>
     12        window.onload never fires if page contains an <iframe> with a bad
     13        scheme or whose load is cancelled by returning null from resource load
     14        delegate's willSendRequest
     15
     16        Tests: fast/loader/onload-bad-scheme-for-frame.html
     17               fast/loader/onload-policy-ignore-for-frame.html
     18               fast/loader/onload-willSendRequest-null-for-frame.html
     19
     20        Reviewed by Brady Eidson.
     21
     22        * loader/FrameLoader.cpp:
     23        (WebCore::FrameLoader::loadSubframe):
     24          - Detect synchronous loads by checking the subframe's loader's
     25            state, rather than by checking its URL
     26          - Removed unnecessary call to completed(), since checkCompleted()
     27            will call completed() if needed (the call to completed() was added
     28            first and wasn't removed when the call to checkCompleted() was
     29            added in r8316)
     30          - Added more comments about the strange thing this function does
     31            with the subframe's loader
     32
    1332010-01-14  Diego Gonzalez  <diego.gonzalez@openbossa.org>
    234
  • trunk/WebCore/loader/FrameLoader.cpp

    r53171 r53277  
    404404    }
    405405   
     406    // All new frames will have m_isComplete set to true at this point due to synchronously loading
     407    // an empty document in FrameLoader::init(). But many frames will now be starting an
     408    // asynchronous load of url, so we set m_isComplete to false and then check if the load is
     409    // actually completed below. (Note that we set m_isComplete to false even for synchronous
     410    // loads, so that checkCompleted() below won't bail early.)
     411    // FIXME: Can we remove this entirely? m_isComplete normally gets set to false when a load is committed.
    406412    frame->loader()->m_isComplete = false;
    407413   
     
    413419    checkCallImplicitClose();
    414420   
     421    // Some loads are performed synchronously (e.g., about:blank and loads
     422    // cancelled by returning a null ResourceRequest from requestFromDelegate).
    415423    // In these cases, the synchronous load would have finished
    416424    // before we could connect the signals, so make sure to send the
    417     // completed() signal for the child by hand
     425    // completed() signal for the child by hand and mark the load as being
     426    // complete.
    418427    // FIXME: In this case the Frame will have finished loading before
    419428    // it's being added to the child list. It would be a good idea to
    420429    // create the child first, then invoke the loader separately.
    421     if (url.isEmpty() || url == blankURL()) {
    422         frame->loader()->completed();
     430    if (frame->loader()->state() == FrameStateComplete)
    423431        frame->loader()->checkCompleted();
    424     }
    425432
    426433    return frame.get();
  • trunk/WebKitTools/ChangeLog

    r53275 r53277  
     12010-01-14  Adam Roben  <aroben@apple.com>
     2
     3        Add LayoutTestController API to force
     4        -webView:resource:willSendRequest:: to return null
     5
     6        Enables tests for <rdar://problem/7533333> <http://webkit.org/b/33533>
     7        window.onload never fires if page contains an <iframe> with a bad
     8        scheme or whose load is cancelled by returning null from resource load
     9        delegate's willSendRequest
     10
     11        Reviewed by Brady Eidson.
     12
     13        * DumpRenderTree/LayoutTestController.cpp:
     14        (LayoutTestController::LayoutTestController): Initialize new member.
     15        (setWillSendRequestReturnsNullCallback): Call through to
     16        LayoutTestController.
     17        (LayoutTestController::staticFunctions): Added new function.
     18
     19        * DumpRenderTree/LayoutTestController.h: Added
     20        m_willSendRequestReturnsNull.
     21        (LayoutTestController::willSendRequestReturnsNull):
     22        (LayoutTestController::setWillSendRequestReturnsNull):
     23        Added standard accessors.
     24
     25        * DumpRenderTree/mac/ResourceLoadDelegate.mm:
     26        (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):
     27        * DumpRenderTree/win/ResourceLoadDelegate.cpp:
     28        (ResourceLoadDelegate::willSendRequest):
     29        Return null if LayoutTestController says to.
     30
    1312010-01-14  Kevin Ollivier  <kevino@theolliviers.com>
    232
  • trunk/WebKitTools/DumpRenderTree/LayoutTestController.cpp

    r51656 r53277  
    6767    , m_testRepaintSweepHorizontally(false)
    6868    , m_waitToDump(false)
     69    , m_willSendRequestReturnsNull(false)
    6970    , m_willSendRequestReturnsNullOnRedirect(false)
    7071    , m_windowIsKey(true)
     
    908909    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    909910    controller->setUserStyleSheetLocation(path.get());
     911
     912    return JSValueMakeUndefined(context);
     913}
     914
     915static JSValueRef setWillSendRequestReturnsNullCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     916{
     917    // Has cross-platform implementation
     918    if (argumentCount < 1)
     919        return JSValueMakeUndefined(context);
     920
     921    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
     922    controller->setWillSendRequestReturnsNull(JSValueToBoolean(context, arguments[0]));
    910923
    911924    return JSValueMakeUndefined(context);
     
    13081321        { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    13091322        { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1323        { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    13101324        { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    13111325        { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
  • trunk/WebKitTools/DumpRenderTree/LayoutTestController.h

    r51567 r53277  
    177177    void waitToDumpWatchdogTimerFired();
    178178
     179    bool willSendRequestReturnsNull() const { return m_willSendRequestReturnsNull; }
     180    void setWillSendRequestReturnsNull(bool returnsNull) { m_willSendRequestReturnsNull = returnsNull; }
     181
    179182    bool willSendRequestReturnsNullOnRedirect() const { return m_willSendRequestReturnsNullOnRedirect; }
    180183    void setWillSendRequestReturnsNullOnRedirect(bool returnsNull) { m_willSendRequestReturnsNullOnRedirect = returnsNull; }
     
    250253    bool m_testRepaintSweepHorizontally;
    251254    bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
     255    bool m_willSendRequestReturnsNull;
    252256    bool m_willSendRequestReturnsNullOnRedirect;
    253257    bool m_windowIsKey;
  • trunk/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm

    r48363 r53277  
    130130    }
    131131
     132    if (!done && gLayoutTestController->willSendRequestReturnsNull())
     133        return nil;
     134
    132135    if (!done && gLayoutTestController->willSendRequestReturnsNullOnRedirect() && redirectResponse) {
    133136        printf("Returning null for this redirect\n");
  • trunk/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp

    r48374 r53277  
    244244    }
    245245
     246    if (!done && gLayoutTestController->willSendRequestReturnsNull()) {
     247        *newRequest = 0;
     248        return S_OK;
     249    }
     250
    246251    if (!done && gLayoutTestController->willSendRequestReturnsNullOnRedirect() && redirectResponse) {
    247252        printf("Returning null for this redirect\n");
Note: See TracChangeset for help on using the changeset viewer.