Changeset 222322 in webkit


Ignore:
Timestamp:
Sep 21, 2017 9:41:11 AM (7 years ago)
Author:
achristensen@apple.com
Message:

REGRESSION(r221465) WKWebViews without WebGL delegate callbacks crash when WebGL contexts are created
https://bugs.webkit.org/show_bug.cgi?id=177306
<rdar://problem/34351988>

Reviewed by Chris Dumez.

Source/WebKit:

  • UIProcess/Cocoa/NavigationState.mm:

(WebKit::NavigationState::NavigationClient::webGLLoadPolicy const):
(WebKit::NavigationState::NavigationClient::resolveWebGLLoadPolicy const):
I forgot to early return after calling the default completion handler if there's no delegate selector.

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/WebGLPolicy.mm:

(-[WebGLTestDelegate webView:startURLSchemeTask:]):
(-[DelegateWithoutWebGL webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
(TEST):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r222320 r222322  
     12017-09-21  Alex Christensen  <achristensen@webkit.org>
     2
     3        REGRESSION(r221465) WKWebViews without WebGL delegate callbacks crash when WebGL contexts are created
     4        https://bugs.webkit.org/show_bug.cgi?id=177306
     5        <rdar://problem/34351988>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * UIProcess/Cocoa/NavigationState.mm:
     10        (WebKit::NavigationState::NavigationClient::webGLLoadPolicy const):
     11        (WebKit::NavigationState::NavigationClient::resolveWebGLLoadPolicy const):
     12        I forgot to early return after calling the default completion handler if there's no delegate selector.
     13
    1142017-09-21  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r222150 r222322  
    308308void NavigationState::NavigationClient::webGLLoadPolicy(WebPageProxy&, const WebCore::URL& url, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const
    309309{
    310     if (!m_navigationState.m_navigationDelegateMethods.webViewWebGLLoadPolicyForURL)
     310    if (!m_navigationState.m_navigationDelegateMethods.webViewWebGLLoadPolicyForURL) {
    311311        completionHandler(WebGLAllowCreation);
     312        return;
     313    }
    312314
    313315    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
     
    323325void NavigationState::NavigationClient::resolveWebGLLoadPolicy(WebPageProxy&, const WebCore::URL& url, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const
    324326{
    325     if (!m_navigationState.m_navigationDelegateMethods.webViewResolveWebGLLoadPolicyForURL)
     327    if (!m_navigationState.m_navigationDelegateMethods.webViewResolveWebGLLoadPolicyForURL) {
    326328        completionHandler(WebGLAllowCreation);
     329        return;
     330    }
    327331   
    328332    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
  • trunk/Tools/ChangeLog

    r222311 r222322  
     12017-09-21  Alex Christensen  <achristensen@webkit.org>
     2
     3        REGRESSION(r221465) WKWebViews without WebGL delegate callbacks crash when WebGL contexts are created
     4        https://bugs.webkit.org/show_bug.cgi?id=177306
     5        <rdar://problem/34351988>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/WebGLPolicy.mm:
     10        (-[WebGLTestDelegate webView:startURLSchemeTask:]):
     11        (-[DelegateWithoutWebGL webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
     12        (TEST):
     13
    1142017-09-20  Joseph Pecoraro  <pecoraro@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebGLPolicy.mm

    r221505 r222322  
    4444static RetainPtr<NSURL> htmlURL;
    4545
     46static NSString *data = @"<script>"
     47    "var canvas = document.createElement('canvas');"
     48    "var context = canvas.getContext('webgl');"
     49    "if (context) {"
     50        "var framebuffer = context.createFramebuffer();"
     51        "var status = context.checkFramebufferStatus(context.FRAMEBUFFER);"
     52        "if (status == context.FRAMEBUFFER_UNSUPPORTED)"
     53            "alert('doing stuff with webgl context failed');"
     54        "else if (status == context.FRAMEBUFFER_COMPLETE)"
     55            "alert('doing stuff with webgl context succeeded');"
     56        "else alert('unexpected status');"
     57    "} else alert('webgl context creation failed');"
     58"</script>";
     59
    4660@interface WebGLTestDelegate : NSObject <WKNavigationDelegatePrivate, WKUIDelegate, WKURLSchemeHandler>
    4761@end
     
    5165- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
    5266{
    53     NSString *data = @"<script>"
    54         "var canvas = document.createElement('canvas');"
    55         "var context = canvas.getContext('webgl');"
    56         "if (context) {"
    57             "var framebuffer = context.createFramebuffer();"
    58             "var status = context.checkFramebufferStatus(context.FRAMEBUFFER);"
    59             "if (status == context.FRAMEBUFFER_UNSUPPORTED)"
    60                 "alert('doing stuff with webgl context failed');"
    61             "else if (status == context.FRAMEBUFFER_COMPLETE)"
    62                 "alert('doing stuff with webgl context succeeded');"
    63             "else alert('unexpected status');"
    64         "} else alert('webgl context creation failed');"
    65     "</script>";
    6667    [urlSchemeTask didReceiveResponse:[[[NSURLResponse alloc] initWithURL:urlSchemeTask.request.URL MIMEType:@"text/html" expectedContentLength:data.length textEncodingName:nil] autorelease]];
    6768    [urlSchemeTask didReceiveData:[data dataUsingEncoding:NSUTF8StringEncoding]];
     
    141142}
    142143
     144@interface DelegateWithoutWebGL : NSObject <WKUIDelegate>
     145@end
     146
     147@implementation DelegateWithoutWebGL
     148
     149- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
     150{
     151    alert = message;
     152    testComplete = true;
     153    completionHandler();
     154}
     155
     156@end
     157
     158TEST(WebKit, WebGLPolicyNoDelegate)
     159{
     160    auto delegate = adoptNS([[DelegateWithoutWebGL alloc] init]);
     161    auto webView = adoptNS([[WKWebView alloc] init]);
     162    [webView setUIDelegate:delegate.get()];
     163    [webView loadHTMLString:data baseURL:[NSURL URLWithString:@"http://example.com/"]];
     164    TestWebKitAPI::Util::run(&testComplete);
     165    EXPECT_STREQ([alert UTF8String], "doing stuff with webgl context succeeded");
     166}
     167
    143168#endif // WK_API_ENABLED
Note: See TracChangeset for help on using the changeset viewer.