WebPage::close needs to remove all message receivers associated with that WebPage...
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2019 19:29:21 +0000 (19:29 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Feb 2019 19:29:21 +0000 (19:29 +0000)
commitd71b53aa2363849453e4edc2775a43ea4e185f97
tree1b3ef1975ae77566713698c8cb0404adbe4c2454
parent230d3bc45e1696bbf851d215d804b4467d64f938
WebPage::close needs to remove all message receivers associated with that WebPage, not WebPage::~WebPage
https://bugs.webkit.org/show_bug.cgi?id=194522
<rdar://problem/47789393>

Reviewed by Chris Dumez.

Source/WebKit:

The InjectedBundle SPI can retain the WebPage or wrapping objects (WKWebProcessPlugInBrowserContextController/WKBundlePageRef).
This can make it so WebPage::close is called before WebPage::~WebPage, and if the SuspendedPageProxy is reused for a subsequent
navigation to the same domain, the WebProcess is reused with a different WebPage instance with the same PageID, which causes problems
when another WebPage registers message handlers and then the previous WebPage is destroyed, which removes both message handlers.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::~WebPage):
(WebKit::WebPage::close):
(WebKit::WebPage::mainFrameDidLayout):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebProcess.h:
(WebKit::WebProcess::eventDispatcher):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/BundleRetainPagePlugIn.mm: Added.
(-[BundleRetainPagePlugIn webProcessPlugIn:didCreateBrowserContextController:]):
* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241306 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebProcess.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleRetainPagePlugIn.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm