LayoutTests:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Apr 2007 19:54:13 +0000 (19:54 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Apr 2007 19:54:13 +0000 (19:54 +0000)
        Reviewed by Brady.

        * plugins/open-and-close-window-with-plugin.html:
        Manage open windows manually for this test.

WebKitTools:

        Reviewed by Brady.

        By default, close any windows that have been opened during a test. This can be overridden by
        calling setCloseRemainingWindowsWhenComplete(false).

        Change the windows set to an array so we can gurantee the enumeration order.

        * DumpRenderTree/DumpRenderTree.m:
        (+[LayoutTestController isSelectorExcludedFromWebScript:]):
        (+[LayoutTestController webScriptNameForSelector:]):
        (-[LayoutTestController setCloseRemainingWindowsWhenComplete:]):
        (runTest):
        (-[DumpRenderTreeWindow initWithContentRect:styleMask:backing:defer:]):
        (-[DumpRenderTreeWindow dealloc]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@20876 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/plugins/open-and-close-window-with-plugin.html
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/DumpRenderTree.m

index 7ffeae2..3e5913d 100644 (file)
@@ -1,3 +1,10 @@
+2007-04-13  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Brady.
+
+        * plugins/open-and-close-window-with-plugin.html:
+        Manage open windows manually for this test.
+
 2007-04-12  Deneb Meketa  <dmeketa@adobe.com>
 
         Reviewed by Darin Adler.
index 024ad03..963d83b 100644 (file)
@@ -9,7 +9,7 @@ layoutTestController.dumpAsText();
 layoutTestController.waitUntilDone();
 layoutTestController.setCallCloseOnWebViews(false);
 layoutTestController.setCanOpenWindows();
-
+layoutTestController.setCloseRemainingWindowsWhenComplete(false);
 window.open('resources/open-and-close-window-with-plugin.html');
 </script>
 This tests that opening a window with a WebView that contains a plugin, and then closing the window without calling -[WebView close] does not leak the window or the web view.
index 0378ba5..177481c 100644 (file)
@@ -1,3 +1,20 @@
+2007-04-13  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Brady.
+
+        By default, close any windows that have been opened during a test. This can be overridden by
+        calling setCloseRemainingWindowsWhenComplete(false).
+        
+        Change the windows set to an array so we can gurantee the enumeration order.
+        
+        * DumpRenderTree/DumpRenderTree.m:
+        (+[LayoutTestController isSelectorExcludedFromWebScript:]):
+        (+[LayoutTestController webScriptNameForSelector:]):
+        (-[LayoutTestController setCloseRemainingWindowsWhenComplete:]):
+        (runTest):
+        (-[DumpRenderTreeWindow initWithContentRect:styleMask:backing:defer:]):
+        (-[DumpRenderTreeWindow dealloc]):
+
 2007-04-13  Geoffrey Garen  <ggaren@apple.com>
 
         Build fix.
index d301145..d12bc1a 100644 (file)
@@ -107,6 +107,7 @@ NSMutableSet *disallowedURLs = 0;
 BOOL waitToDump;     // TRUE if waitUntilDone() has been called, but notifyDone() has not yet been called
 BOOL canOpenWindows;
 BOOL closeWebViews;
+BOOL closeRemainingWindowsWhenComplete = YES;
 
 static void runTest(const char *pathOrURL);
 static NSString *md5HashStringForBitmap(CGImageRef bitmap);
@@ -166,7 +167,7 @@ static BOOL workQueueFrozen;
 const unsigned maxViewHeight = 600;
 const unsigned maxViewWidth = 800;
 
-static CFMutableSetRef allWindowsRef;
+static CFMutableArrayRef allWindowsRef;
 
 static pthread_mutex_t javaScriptThreadsMutex = PTHREAD_MUTEX_INITIALIZER;
 static BOOL javaScriptThreadsShouldTerminate;
@@ -1030,7 +1031,8 @@ static void dump(void)
             || aSelector == @selector(objCClassNameOf:)
             || aSelector == @selector(addDisallowedURL:)    
             || aSelector == @selector(setCanOpenWindows)
-            || aSelector == @selector(setCallCloseOnWebViews:))
+            || aSelector == @selector(setCallCloseOnWebViews:)
+            || aSelector == @selector(setCloseRemainingWindowsWhenComplete:))
         return NO;
     return YES;
 }
@@ -1065,6 +1067,8 @@ static void dump(void)
         return @"addDisallowedURL";
     if (aSelector == @selector(setCallCloseOnWebViews:))
         return @"setCallCloseOnWebViews";
+    if (aSelector == @selector(setCloseRemainingWindowsWhenComplete:))
+        return @"setCloseRemainingWindowsWhenComplete";
 
     return nil;
 }
@@ -1084,6 +1088,11 @@ static void dump(void)
     [item release];
 }
 
+- (void)setCloseRemainingWindowsWhenComplete:(BOOL)closeWindows
+{
+    closeRemainingWindowsWhenComplete = closeWindows;
+}
+
 - (void)keepWebHistory
 {
     if (![WebHistory optionalSharedHistory]) {
@@ -1401,11 +1410,31 @@ static void runTest(const char *pathOrURL)
     }
     pool = [[NSAutoreleasePool alloc] init];
     [[frame webView] setSelectedDOMRange:nil affinity:NSSelectionAffinityDownstream];
+    
+    if (closeRemainingWindowsWhenComplete) {
+        NSArray* array = [(NSArray *)allWindowsRef copy];
+        
+        unsigned count = [array count];
+        for (unsigned i = 0; i < count; i++) {
+            NSWindow *window = [array objectAtIndex:i];
+
+            // Don't try to close the main window
+            if (window == [[frame webView] window])
+                continue;
+            
+            WebView *webView = [[[window contentView] subviews] objectAtIndex:0];
+
+            [webView close];
+            [window close];
+        }
+        [array release];
+    }
+    
     [pool release];
     
     // We should only have our main window left when we're done
-    assert(CFSetGetCount(allWindowsRef) == 1);
-    assert(CFSetContainsValue(allWindowsRef, [[frame webView] window]));
+    assert(CFArrayGetCount(allWindowsRef) == 1);
+    assert(CFArrayGetValueAtIndex(allWindowsRef, 0) == [[frame webView] window]);
     
     if (_shouldIgnoreWebCoreNodeLeaks)
         [WebCoreStatistics stopIgnoringWebCoreNodeLeaks];
@@ -1604,13 +1633,12 @@ static void displayWebView()
 
 @end
 
-static CFSetCallBacks NonRetainingSetCallbacks = {
+static CFArrayCallBacks NonRetainingArrayCallbacks = {
     0,
     NULL,
     NULL,
     CFCopyDescription,
-    CFEqual,
-    CFHash
+    CFEqual
 };
 
 @implementation DumpRenderTreeWindow
@@ -1618,18 +1646,20 @@ static CFSetCallBacks NonRetainingSetCallbacks = {
 - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
 {
     if (!allWindowsRef)
-        allWindowsRef = CFSetCreateMutable(NULL, 0, &NonRetainingSetCallbacks);
+        allWindowsRef = CFArrayCreateMutable(NULL, 0, &NonRetainingArrayCallbacks);
 
-    CFSetSetValue(allWindowsRef, self);
+    CFArrayAppendValue(allWindowsRef, self);
             
     return [super initWithContentRect:contentRect styleMask:styleMask backing:bufferingType defer:deferCreation];
 }
 
 - (void)dealloc
 {
-    assert(CFSetContainsValue(allWindowsRef, self));
-    
-    CFSetRemoveValue(allWindowsRef, self);
+    CFRange arrayRange = CFRangeMake(0, CFArrayGetCount(allWindowsRef));
+    CFIndex i = CFArrayGetFirstIndexOfValue(allWindowsRef, arrayRange, self);
+    assert(i != -1);
+
+    CFArrayRemoveValueAtIndex(allWindowsRef, i);
     [super dealloc];
 }