| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #import "config.h" | |
| 27 #import "PlatformUtilities.h" | |
| 28 #import <wtf/RetainPtr.h> | |
| 29 | |
| 30 @interface MemoryCachePruneTestResourceLoadDelegate : NSObject { | |
| 31 @public | |
| 32 NSWindow *_window; | |
| 33 } | |
| 34 @end | |
| 35 | |
| 36 static bool didFinishLoad; | |
| 37 | |
| 38 @implementation MemoryCachePruneTestResourceLoadDelegate | |
| 39 | |
| 40 - (id)webView:(WebView *)sender identifierForInitialRequest:(NSURLRequest *)requ
est fromDataSource:(WebDataSource *)dataSource | |
| 41 { | |
| 42 // We only care about an http request, which is our test XHR | |
| 43 if ([[[request URL] scheme] isEqualToString:@"http"]) | |
| 44 return self; | |
| 45 | |
| 46 return nil; | |
| 47 } | |
| 48 | |
| 49 - (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequ
est:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse f
romDataSource:(WebDataSource *)dataSource | |
| 50 { | |
| 51 if (identifier == nil) | |
| 52 return request; | |
| 53 | |
| 54 [_window close]; | |
| 55 return request; | |
| 56 } | |
| 57 | |
| 58 - (void)webView:(WebView *)sender resource:(id)identifier didFinishLoadingFromDa
taSource:(WebDataSource *)dataSource | |
| 59 { | |
| 60 if (identifier == nil) | |
| 61 return; | |
| 62 | |
| 63 didFinishLoad = true; | |
| 64 } | |
| 65 | |
| 66 - (void)webView:(WebView *)sender resource:(id)identifier didFailLoadingWithErro
r:(NSError *)error fromDataSource:(WebDataSource *)dataSource | |
| 67 { | |
| 68 if (identifier == nil) | |
| 69 return; | |
| 70 | |
| 71 didFinishLoad = true; | |
| 72 } | |
| 73 | |
| 74 @end | |
| 75 | |
| 76 namespace TestWebKitAPI { | |
| 77 | |
| 78 TEST(WebKit1, DISABLED_MemoryCachePruneWithinResourceLoadDelegate) | |
| 79 { | |
| 80 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
| 81 | |
| 82 RetainPtr<WebView> webView1(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRe
ct(0, 0, 120, 200) frameName:nil groupName:nil]); | |
| 83 RetainPtr<WebView> webView2(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRe
ct(0, 0, 120, 200) frameName:nil groupName:nil]); | |
| 84 | |
| 85 NSWindow* window = [[NSWindow alloc] initWithContentRect:webView2.get().fram
e styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]; | |
| 86 [window.contentView addSubview:webView2.get()]; | |
| 87 | |
| 88 RetainPtr<MemoryCachePruneTestResourceLoadDelegate> resourceLoadDelegate(Ado
ptNS, [[MemoryCachePruneTestResourceLoadDelegate alloc] init]); | |
| 89 resourceLoadDelegate.get()->_window = window; | |
| 90 webView1.get().resourceLoadDelegate = resourceLoadDelegate.get(); | |
| 91 | |
| 92 [[webView1.get() mainFrame] loadRequest:[NSURLRequest requestWithURL:[[NSBun
dle mainBundle] URLForResource:@"MemoryCachePruneWithinResourceLoadDelegate" wit
hExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]]; | |
| 93 | |
| 94 Util::run(&didFinishLoad); | |
| 95 | |
| 96 [pool drain]; | |
| 97 // If we finished without crashing, the test passed. | |
| 98 } | |
| 99 | |
| 100 } // namespace TestWebKitAPI | |
| OLD | NEW |