REGRESSION (r139343): WebKit crashes when canceling a load inside
authorAndy Estes <aestes@apple.com>
Mon, 10 Mar 2014 13:30:54 +0000 (14:30 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 10 Mar 2014 14:03:01 +0000 (15:03 +0100)
commit170372f09df04c19eb281cecd1550d6b2d297f3b
tree255419fbed92d0d7d9dfd82f15cc6a6fad361cc2
parentbb9c1f33975cd0f71a7f314fc1c0f755c1b75a32
REGRESSION (r139343): WebKit crashes when canceling a load inside

<https://webkit.org/b/119853> webView:resource:didFinishLoadingFromDataSource:

Reviewed by Brady Eidson.

Source/WebCore:

A client implementing webView:resource:didFinishLoadingFromDataSource:
might decide to call stopLoading: for the identifier that just finished
loading. If this happens we re-enter the loader and attempt to cancel a
load that has already finished and been removed from the set of active
loaders. Prevent this by clearing DocumentLoader's
m_identifierForLoadWithoutResourceLoader before calling
dispatchDidFinishLoading().

New API test: WebKit1.StopLoadingFromDidFinishLoading.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::finishedLoading): Set
m_identifierForLoadWithoutResourceLoader to 0 before calling
dispatchDidFinishLoading().

Tools:

Wrote an API test that verifies -[WebView stopLoading:] can be called
inside webView:resource:didFinishLoadingFromDataSource: without crashing.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/StopLoadingFromDidFinishLoading.mm: Added.
(-[StopLoadingFromDidFinishLoadingDelegate webView:resource:didFinishLoadingFromDataSource:]):
(TestWebKitAPI::TEST):

Change-Id: Ib5da6cfdd74eac0e284a512ee54e74353aba783b
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reviewed-by: Michael Bruning <michael.bruning@digia.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Source/WebCore/loader/DocumentLoader.cpp
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj