Changeset 221923 in webkit
- Timestamp:
- Sep 12, 2017 9:42:23 AM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r221922 r221923 1 2017-09-12 Alex Christensen <achristensen@webkit.org> 2 3 Fix build after r221922. 4 https://bugs.webkit.org/show_bug.cgi?id=176728 5 6 * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm: 7 (-[ModalDelegate _webViewRunModal:]): 8 (-[ModalDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]): 9 (TEST): 10 svn-apply inserted the test too early in the file :( 11 Shift it down to where all the used static variables are declared. 12 1 13 2017-09-12 Alex Christensen <achristensen@webkit.org> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm
r221922 r221923 149 149 } 150 150 151 #if PLATFORM(MAC) 152 153 @class UITestDelegate; 154 155 static RetainPtr<WKWebView> webViewFromDelegateCallback; 156 static RetainPtr<WKWebView> createdWebView; 157 static RetainPtr<UITestDelegate> delegate; 158 159 @interface UITestDelegate : NSObject <WKUIDelegatePrivate, WKURLSchemeHandler> 160 @end 161 162 @implementation UITestDelegate 163 164 - (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures 165 { 166 createdWebView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]); 167 [createdWebView setUIDelegate:delegate.get()]; 168 return createdWebView.get(); 169 } 170 171 - (void)_showWebView:(WKWebView *)webView 172 { 173 webViewFromDelegateCallback = webView; 174 done = true; 175 } 176 177 - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask 178 { 179 NSString *data = @"<script>window.open('other.html');</script>"; 180 [urlSchemeTask didReceiveResponse:[[[NSURLResponse alloc] initWithURL:urlSchemeTask.request.URL MIMEType:@"text/html" expectedContentLength:data.length textEncodingName:nil] autorelease]]; 181 [urlSchemeTask didReceiveData:[data dataUsingEncoding:NSUTF8StringEncoding]]; 182 [urlSchemeTask didFinish]; 183 } 184 185 - (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask 186 { 187 } 188 189 @end 190 191 TEST(WebKit, ShowWebView) 192 { 193 delegate = adoptNS([[UITestDelegate alloc] init]); 194 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 195 [configuration setURLSchemeHandler:delegate.get() forURLScheme:@"test"]; 196 auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get()]); 197 [webView setUIDelegate:delegate.get()]; 198 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test:///first"]]]; 199 TestWebKitAPI::Util::run(&done); 200 201 ASSERT_EQ(webViewFromDelegateCallback, createdWebView); 202 } 203 151 204 @interface ModalDelegate : NSObject <WKUIDelegatePrivate> 152 205 @end … … 179 232 [webView sendClicksAtPoint:NSMakePoint(20, 600 - 20) numberOfClicks:1]; 180 233 TestWebKitAPI::Util::run(&done); 181 }182 183 #if PLATFORM(MAC)184 185 @class UITestDelegate;186 187 static RetainPtr<WKWebView> webViewFromDelegateCallback;188 static RetainPtr<WKWebView> createdWebView;189 static RetainPtr<UITestDelegate> delegate;190 191 @interface UITestDelegate : NSObject <WKUIDelegatePrivate, WKURLSchemeHandler>192 @end193 194 @implementation UITestDelegate195 196 - (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures197 {198 createdWebView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration]);199 [createdWebView setUIDelegate:delegate.get()];200 return createdWebView.get();201 }202 203 - (void)_showWebView:(WKWebView *)webView204 {205 webViewFromDelegateCallback = webView;206 done = true;207 }208 209 - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask210 {211 NSString *data = @"<script>window.open('other.html');</script>";212 [urlSchemeTask didReceiveResponse:[[[NSURLResponse alloc] initWithURL:urlSchemeTask.request.URL MIMEType:@"text/html" expectedContentLength:data.length textEncodingName:nil] autorelease]];213 [urlSchemeTask didReceiveData:[data dataUsingEncoding:NSUTF8StringEncoding]];214 [urlSchemeTask didFinish];215 }216 217 - (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask218 {219 }220 221 @end222 223 TEST(WebKit, ShowWebView)224 {225 delegate = adoptNS([[UITestDelegate alloc] init]);226 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);227 [configuration setURLSchemeHandler:delegate.get() forURLScheme:@"test"];228 auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get()]);229 [webView setUIDelegate:delegate.get()];230 [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test:///first"]]];231 TestWebKitAPI::Util::run(&done);232 233 ASSERT_EQ(webViewFromDelegateCallback, createdWebView);234 234 } 235 235
Note: See TracChangeset
for help on using the changeset viewer.