⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243848 in webkit


Ignore:
Timestamp:
Apr 3, 2019, 8:09:48 PM (7 years ago)
Author:
Chris Dumez
Message:

The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash
https://bugs.webkit.org/show_bug.cgi?id=196588
<rdar://problem/49365787>

Reviewed by Ryosuke Niwa.

Source/WebKit:

The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash.
This can lead to returning stale frames to the client if it asks for those.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::resetState):

Tools:

Add API test coverage.

  • TestWebKitAPI/Tests/WebKit/ReloadPageAfterCrash.cpp:

(TestWebKitAPI::nullJavaScriptCallback):
(TestWebKitAPI::didCrashCheckFrames):
(TestWebKitAPI::TEST):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r243847 r243848  
     12019-04-03  Chris Dumez  <cdumez@apple.com>
     2
     3        The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash
     4        https://bugs.webkit.org/show_bug.cgi?id=196588
     5        <rdar://problem/49365787>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash.
     10        This can lead to returning stale frames to the client if it asks for those.
     11
     12        * UIProcess/WebPageProxy.cpp:
     13        (WebKit::WebPageProxy::resetState):
     14
    1152019-04-03  Simon Fraser  <simon.fraser@apple.com>
    216
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r243847 r243848  
    67766776{
    67776777    m_mainFrame = nullptr;
     6778    m_focusedFrame = nullptr;
     6779    m_frameSetLargestFrame = nullptr;
    67786780
    67796781#if PLATFORM(COCOA)
  • trunk/Tools/ChangeLog

    r243842 r243848  
     12019-04-03  Chris Dumez  <cdumez@apple.com>
     2
     3        The page's focusedFrame / frameSetLargestFrame do not get cleared on process swap or crash
     4        https://bugs.webkit.org/show_bug.cgi?id=196588
     5        <rdar://problem/49365787>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/Tests/WebKit/ReloadPageAfterCrash.cpp:
     12        (TestWebKitAPI::nullJavaScriptCallback):
     13        (TestWebKitAPI::didCrashCheckFrames):
     14        (TestWebKitAPI::TEST):
     15
    1162019-04-03  Jonathan Bedard  <jbedard@apple.com>
    217
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/ReloadPageAfterCrash.cpp

    r239631 r243848  
    3131#include "PlatformWebView.h"
    3232#include "Test.h"
     33#include <WebKit/WKPagePrivate.h>
    3334#include <WebKit/WKRetainPtr.h>
     35#include <signal.h>
    3436
    3537namespace TestWebKitAPI {
     
    3739static bool loadBeforeCrash = false;
    3840static bool loadAfterCrash = false;
     41static bool calledCrashHandler = false;
    3942
    4043static void didFinishLoad(WKPageRef page, WKNavigationRef, WKTypeRef userData, const void* clientInfo)
     
    8992}
    9093
     94static void nullJavaScriptCallback(WKSerializedScriptValueRef, WKErrorRef, void*)
     95{
     96}
     97
     98static void didCrashCheckFrames(WKPageRef page, const void*)
     99{
     100    // Test if first load actually worked.
     101    EXPECT_TRUE(loadBeforeCrash);
     102
     103    EXPECT_TRUE(!WKPageGetMainFrame(page));
     104    EXPECT_TRUE(!WKPageGetFocusedFrame(page));
     105    EXPECT_TRUE(!WKPageGetFrameSetLargestFrame(page));
     106
     107    calledCrashHandler = true;
     108}
     109
     110TEST(WebKit, FocusedFrameAfterCrash)
     111{
     112    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreateWithConfiguration(nullptr));
     113    PlatformWebView webView(context.get());
     114
     115    WKPageNavigationClientV0 loaderClient;
     116    memset(&loaderClient, 0, sizeof(loaderClient));
     117
     118    loaderClient.base.version = 0;
     119    loaderClient.didFinishNavigation = didFinishLoad;
     120    loaderClient.webProcessDidCrash = didCrashCheckFrames;
     121
     122    WKPageSetPageNavigationClient(webView.page(), &loaderClient.base);
     123
     124    WKRetainPtr<WKURLRef> url = adoptWK(Util::createURLForResource("many-iframes", "html"));
     125    WKPageLoadURL(webView.page(), url.get());
     126    Util::run(&loadBeforeCrash);
     127
     128    EXPECT_FALSE(!WKPageGetMainFrame(webView.page()));
     129
     130    WKRetainPtr<WKStringRef> javaScriptString(AdoptWK, WKStringCreateWithUTF8CString("frames[2].focus()"));
     131    WKPageRunJavaScriptInMainFrame(webView.page(), javaScriptString.get(), 0, nullJavaScriptCallback);
     132
     133    while (!WKPageGetFocusedFrame(webView.page()))
     134        Util::spinRunLoop(10);
     135
     136    kill(WKPageGetProcessIdentifier(webView.page()), 9);
     137
     138    Util::run(&calledCrashHandler);
     139}
     140
     141TEST(WebKit, FrameSetLargestFramAfterCrash)
     142{
     143    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreateWithConfiguration(nullptr));
     144    PlatformWebView webView(context.get());
     145
     146    WKPageNavigationClientV0 loaderClient;
     147    memset(&loaderClient, 0, sizeof(loaderClient));
     148
     149    loaderClient.base.version = 0;
     150    loaderClient.didFinishNavigation = didFinishLoad;
     151    loaderClient.webProcessDidCrash = didCrashCheckFrames;
     152
     153    WKPageSetPageNavigationClient(webView.page(), &loaderClient.base);
     154
     155    WKRetainPtr<WKURLRef> baseURL = adoptWK(WKURLCreateWithUTF8CString("about:blank"));
     156    WKRetainPtr<WKStringRef> htmlString = Util::toWK("<frameset cols='25%,*,25%'><frame src='about:blank'><frame src='about:blank'><frame src='about:blank'></frameset>");
     157
     158    WKPageLoadHTMLString(webView.page(), htmlString.get(), baseURL.get());
     159    Util::run(&loadBeforeCrash);
     160
     161    EXPECT_FALSE(!WKPageGetMainFrame(webView.page()));
     162
     163    while (!WKPageGetFrameSetLargestFrame(webView.page()))
     164        Util::spinRunLoop(10);
     165
     166    kill(WKPageGetProcessIdentifier(webView.page()), 9);
     167
     168    Util::run(&calledCrashHandler);
     169}
     170
    91171} // namespace TestWebKitAPI
    92172
Note: See TracChangeset for help on using the changeset viewer.