Changeset 243320 in webkit


Ignore:
Timestamp:
Mar 21, 2019, 1:31:19 PM (6 years ago)
Author:
Chris Dumez
Message:

WebKit should throw when trying to create a WKWebView with a related view that is using a different data store
https://bugs.webkit.org/show_bug.cgi?id=196041
<rdar://problem/49083230>

Reviewed by Alex Christensen.

Source/WebKit:

WebKit should throw when trying to create a WKWebView with a related view that is using a different data store.
We do not support having several WebsiteDataStores sharing the same WebProcess.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initializeWithConfiguration:]):

  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::createWebPage):

Tools:

Add API test coverage.

  • TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm:

(TEST):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/Source/WebKit/ChangeLog

    r243319 r243320  
     12019-03-21  Chris Dumez  <cdumez@apple.com>
     2
     3        WebKit should throw when trying to create a WKWebView with a related view that is using a different data store
     4        https://bugs.webkit.org/show_bug.cgi?id=196041
     5        <rdar://problem/49083230>
     6
     7        Reviewed by Alex Christensen.
     8
     9        WebKit should throw when trying to create a WKWebView with a related view that is using a different data store.
     10        We do not support having several WebsiteDataStores sharing the same WebProcess.
     11
     12        * UIProcess/API/Cocoa/WKWebView.mm:
     13        (-[WKWebView _initializeWithConfiguration:]):
     14        * UIProcess/WebProcessPool.cpp:
     15        (WebKit::WebProcessPool::createWebPage):
     16
    1172019-03-21  Alex Christensen  <achristensen@webkit.org>
    218
  • TabularUnified trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r243240 r243320  
    553553        if (processPool && processPool != relatedWebViewProcessPool)
    554554            [NSException raise:NSInvalidArgumentException format:@"Related web view %@ has process pool %@ but configuration specifies a different process pool %@", relatedWebView, relatedWebViewProcessPool, configuration.processPool];
     555        if ([relatedWebView->_configuration websiteDataStore] != [_configuration websiteDataStore])
     556            [NSException raise:NSInvalidArgumentException format:@"Related web view %@ has data store %@ but configuration specifies a different data store %@", relatedWebView, [relatedWebView->_configuration websiteDataStore], [_configuration websiteDataStore]];
    555557
    556558        [_configuration setProcessPool:relatedWebViewProcessPool];
  • TabularUnified trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r243163 r243320  
    12161216        // Sharing processes, e.g. when creating the page via window.open().
    12171217        process = &pageConfiguration->relatedPage()->process();
     1218        // We do not support several WebsiteDataStores sharing a single process.
     1219        ASSERT(process.get() == m_dummyProcessProxy || &pageConfiguration->websiteDataStore()->websiteDataStore() == &process->websiteDataStore());
     1220        ASSERT(&pageConfiguration->relatedPage()->websiteDataStore() == &pageConfiguration->websiteDataStore()->websiteDataStore());
    12181221    } else if (WebKit::isInspectorProcessPool(*this)) {
    12191222        // Do not delay process launch for inspector pages as inspector pages do not know how to transition from a terminated process.
  • TabularUnified trunk/Tools/ChangeLog

    r243319 r243320  
     12019-03-21  Chris Dumez  <cdumez@apple.com>
     2
     3        WebKit should throw when trying to create a WKWebView with a related view that is using a different data store
     4        https://bugs.webkit.org/show_bug.cgi?id=196041
     5        <rdar://problem/49083230>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm:
     12        (TEST):
     13
    1142019-03-21  Alex Christensen  <achristensen@webkit.org>
    215
  • TabularUnified trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm

    r242339 r243320  
    2929#import <WebKit/WKWebView.h>
    3030#import <WebKit/WKWebViewConfigurationPrivate.h>
     31#import <WebKit/WKWebsiteDataStore.h>
    3132#import <wtf/Function.h>
    3233#import <wtf/RetainPtr.h>
     
    6364    });
    6465#pragma clang diagnostic pop
     66
     67    // Related WebViews cannot use different data stores.
     68    auto configurationForEphemeralView = adoptNS([[WKWebViewConfiguration alloc] init]);
     69    configurationForEphemeralView.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
     70    auto ephemeralWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configurationForEphemeralView.get()]);
     71    shouldThrowExceptionWhenUsed([&](WKWebViewConfiguration *configuration) {
     72        [configuration _setRelatedWebView:ephemeralWebView.get()];
     73    });
    6574}
    6675
Note: See TracChangeset for help on using the changeset viewer.