<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[20742] trunk</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/20742">20742</a></dd>
<dt>Author</dt> <dd>andersca</dd>
<dt>Date</dt> <dd>2007-04-05 20:05:48 -0700 (Thu, 05 Apr 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>LayoutTests:

        Reviewed by Adam.

        &lt;rdar://problem/5083023&gt;
        REGRESSION: In Real Player (10.1.0), video continues to play after closing window

        Add a test where a window containing a plugin is opened and then closed. The window is closed
        without calling -[WebView close].
        
        * plugins/open-and-close-window-with-plugin-expected.txt: Added.
        * plugins/open-and-close-window-with-plugin.html: Added.
        * plugins/resources/open-and-close-window-with-plugin.html: Added.

WebKit:

        Reviewed by Adam.

        &lt;rdar://problem/5083023&gt;
        REGRESSION: In Real Player (10.1.0), video continues to play after closing window
        
        This broke in <a href="http://trac.webkit.org/projects/webkit/changeset/18422">revision 18422</a> because now the plugin isn't stopped when the window is closed. Since the window is retained
        by the plugin view for as long as it is running (so that removeTrackingRect works even though the window has been closed),
        we would end up with a reference cycle (NSWindow -&gt; WebView -&gt; PluginView -&gt; NSWindow) and stopping the plug-in when the window
        was closed would break that cycle.
        
        Applications that call -[WebView close] when closing aren't affected, but RealPlayer doesn't do this.
        
        The bug that 18422 was supposed to fix was fixed by 19275, which is why it's safe to add back the check.
        
        * Plugins/WebBaseNetscapePluginView.mm:
        (-[WebBaseNetscapePluginView addWindowObservers]):
        (-[WebBaseNetscapePluginView removeWindowObservers]):
        (-[WebBaseNetscapePluginView windowWillClose:]):

WebKitTools:

        Reviewed by Adam.

        Add support for opening new windows in DumpRenderTree.
        
        (+[LayoutTestController isSelectorExcludedFromWebScript:]):
        (+[LayoutTestController webScriptNameForSelector:]):
        (-[LayoutTestController setCallCloseOnWebViews:]):
        (-[LayoutTestController setCanOpenWindows]):
        Add two new methods callable from JavaScript. setCanOpenWindows controls whether a test
        can open new windows, and setCallCloseOnWebViews controls whether -[WebView close] should be called on 
        web views that are about to be closed.
        
        (runTest):
        Make sure that only the main window is around when a test has finished running.
        
        (-[DumpRenderTreeWindow initWithContentRect:styleMask:backing:defer:]):
        (-[DumpRenderTreeWindow dealloc]):
        Manage the set of windows.
        
        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h:
        * DumpRenderTree/TestNetscapePlugIn.subproj/main.c:
        (NPP_Destroy):
        Add a &quot;logDestroy&quot; property which controls whether plugins should print when they are destroyed or not.
        
        * DumpRenderTree/UIDelegate.m:
        (-[UIDelegate webView:createWebViewWithRequest:]):
        Create new windows.
        
        (-[UIDelegate webViewClose:]):
        Close windows.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkWebKitChangeLog">trunk/WebKit/ChangeLog</a></li>
<li><a href="#trunkWebKitPluginsWebBaseNetscapePluginViewmm">trunk/WebKit/Plugins/WebBaseNetscapePluginView.mm</a></li>
<li><a href="#trunkWebKitToolsChangeLog">trunk/WebKitTools/ChangeLog</a></li>
<li><a href="#trunkWebKitToolsDumpRenderTreeDumpRenderTreeh">trunk/WebKitTools/DumpRenderTree/DumpRenderTree.h</a></li>
<li><a href="#trunkWebKitToolsDumpRenderTreeDumpRenderTreem">trunk/WebKitTools/DumpRenderTree/DumpRenderTree.m</a></li>
<li><a href="#trunkWebKitToolsDumpRenderTreeTestNetscapePlugInsubprojPluginObjectc">trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c</a></li>
<li><a href="#trunkWebKitToolsDumpRenderTreeTestNetscapePlugInsubprojPluginObjecth">trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h</a></li>
<li><a href="#trunkWebKitToolsDumpRenderTreeTestNetscapePlugInsubprojmainc">trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.c</a></li>
<li><a href="#trunkWebKitToolsDumpRenderTreeUIDelegatem">trunk/WebKitTools/DumpRenderTree/UIDelegate.m</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestspluginsopenandclosewindowwithpluginexpectedtxt">trunk/LayoutTests/plugins/open-and-close-window-with-plugin-expected.txt</a></li>
<li><a href="#trunkLayoutTestspluginsopenandclosewindowwithpluginhtml">trunk/LayoutTests/plugins/open-and-close-window-with-plugin.html</a></li>
<li><a href="#trunkLayoutTestspluginsresourcesopenandclosewindowwithpluginhtml">trunk/LayoutTests/plugins/resources/open-and-close-window-with-plugin.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (20741 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2007-04-06 01:46:42 UTC (rev 20741)
+++ trunk/LayoutTests/ChangeLog        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2007-04-05  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Reviewed by Adam.
+
+        &lt;rdar://problem/5083023&gt;
+        REGRESSION: In Real Player (10.1.0), video continues to play after closing window
+
+        Add a test where a window containing a plugin is opened and then closed. The window is closed
+        without calling -[WebView close].
+        
+        * plugins/open-and-close-window-with-plugin-expected.txt: Added.
+        * plugins/open-and-close-window-with-plugin.html: Added.
+        * plugins/resources/open-and-close-window-with-plugin.html: Added.
+
</ins><span class="cx"> 2007-04-05  Kevin McCullough  &lt;kmccullough@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Darin.
</span></span></pre></div>
<a id="trunkLayoutTestspluginsopenandclosewindowwithpluginexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/plugins/open-and-close-window-with-plugin-expected.txt (0 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/plugins/open-and-close-window-with-plugin-expected.txt                                (rev 0)
+++ trunk/LayoutTests/plugins/open-and-close-window-with-plugin-expected.txt        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+PLUGIN: NPP_Destroy
+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.
</ins></span></pre></div>
<a id="trunkLayoutTestspluginsopenandclosewindowwithpluginhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/plugins/open-and-close-window-with-plugin.html (0 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/plugins/open-and-close-window-with-plugin.html                                (rev 0)
+++ trunk/LayoutTests/plugins/open-and-close-window-with-plugin.html        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+&lt;html&gt;
+&lt;script&gt;
+if (!window.layoutTestController) {
+    alert('this test can only be run by DumpRenderTree')
+    return;
+}
+
+layoutTestController.dumpAsText();
+layoutTestController.waitUntilDone();
+layoutTestController.setCallCloseOnWebViews(false);
+layoutTestController.setCanOpenWindows();
+
+window.open('resources/open-and-close-window-with-plugin.html');
+&lt;/script&gt;
+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.
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestspluginsresourcesopenandclosewindowwithpluginhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/plugins/resources/open-and-close-window-with-plugin.html (0 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/plugins/resources/open-and-close-window-with-plugin.html                                (rev 0)
+++ trunk/LayoutTests/plugins/resources/open-and-close-window-with-plugin.html        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+&lt;script&gt;
+function runTest() {
+    var plugin = document.getElementById('testPlugin');
+    plugin.logDestroy = true;
+
+    // I would like to come up with something better than a timeout here
+    window.opener.setTimeout('layoutTestController.notifyDone()', 50);
+    window.close();
+}
+
+&lt;/script&gt;
+
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;embed id=&quot;testPlugin&quot; type=&quot;application/x-webkit-test-netscape&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;&lt;/embed&gt;
+
+&lt;/body&gt;
</ins></span></pre></div>
<a id="trunkWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/ChangeLog (20741 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/ChangeLog        2007-04-06 01:46:42 UTC (rev 20741)
+++ trunk/WebKit/ChangeLog        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2007-04-05  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Reviewed by Adam.
+
+        &lt;rdar://problem/5083023&gt;
+        REGRESSION: In Real Player (10.1.0), video continues to play after closing window
+        
+        This broke in revision 18422 because now the plugin isn't stopped when the window is closed. Since the window is retained
+        by the plugin view for as long as it is running (so that removeTrackingRect works even though the window has been closed),
+        we would end up with a reference cycle (NSWindow -&gt; WebView -&gt; PluginView -&gt; NSWindow) and stopping the plug-in when the window
+        was closed would break that cycle.
+        
+        Applications that call -[WebView close] when closing aren't affected, but RealPlayer doesn't do this.
+        
+        The bug that 18422 was supposed to fix was fixed by 19275, which is why it's safe to add back the check.
+        
+        * Plugins/WebBaseNetscapePluginView.mm:
+        (-[WebBaseNetscapePluginView addWindowObservers]):
+        (-[WebBaseNetscapePluginView removeWindowObservers]):
+        (-[WebBaseNetscapePluginView windowWillClose:]):
+
</ins><span class="cx"> 2007-04-05  Kevin McCullough  &lt;kmccullough@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Darin.
</span></span></pre></div>
<a id="trunkWebKitPluginsWebBaseNetscapePluginViewmm"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/Plugins/WebBaseNetscapePluginView.mm (20741 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/Plugins/WebBaseNetscapePluginView.mm        2007-04-06 01:46:42 UTC (rev 20741)
+++ trunk/WebKit/Plugins/WebBaseNetscapePluginView.mm        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -1292,6 +1292,8 @@
</span><span class="cx">     NSWindow *theWindow = [self window];
</span><span class="cx">     
</span><span class="cx">     NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
</span><ins>+    [notificationCenter addObserver:self selector:@selector(windowWillClose:) 
+                               name:NSWindowWillCloseNotification object:theWindow]; 
</ins><span class="cx">     [notificationCenter addObserver:self selector:@selector(windowBecameKey:)
</span><span class="cx">                                name:NSWindowDidBecomeKeyNotification object:theWindow];
</span><span class="cx">     [notificationCenter addObserver:self selector:@selector(windowResignedKey:)
</span><span class="lines">@@ -1310,6 +1312,7 @@
</span><span class="cx"> - (void)removeWindowObservers
</span><span class="cx"> {
</span><span class="cx">     NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
</span><ins>+    [notificationCenter removeObserver:self name:NSWindowWillCloseNotification        object:nil]; 
</ins><span class="cx">     [notificationCenter removeObserver:self name:NSWindowDidBecomeKeyNotification     object:nil];
</span><span class="cx">     [notificationCenter removeObserver:self name:NSWindowDidResignKeyNotification     object:nil];
</span><span class="cx">     [notificationCenter removeObserver:self name:NSWindowDidMiniaturizeNotification   object:nil];
</span><span class="lines">@@ -1823,6 +1826,11 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma mark NOTIFICATIONS
</span><span class="cx"> 
</span><ins>+- (void)windowWillClose:(NSNotification *)notification 
+{
+    [self stop]; 
+} 
+
</ins><span class="cx"> - (void)windowBecameKey:(NSNotification *)notification
</span><span class="cx"> {
</span><span class="cx">     [self sendActivateEvent:YES];
</span></span></pre></div>
<a id="trunkWebKitToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/ChangeLog (20741 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/ChangeLog        2007-04-06 01:46:42 UTC (rev 20741)
+++ trunk/WebKitTools/ChangeLog        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -1,5 +1,39 @@
</span><span class="cx"> 2007-04-05  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Reviewed by Adam.
+
+        Add support for opening new windows in DumpRenderTree.
+        
+        (+[LayoutTestController isSelectorExcludedFromWebScript:]):
+        (+[LayoutTestController webScriptNameForSelector:]):
+        (-[LayoutTestController setCallCloseOnWebViews:]):
+        (-[LayoutTestController setCanOpenWindows]):
+        Add two new methods callable from JavaScript. setCanOpenWindows controls whether a test
+        can open new windows, and setCallCloseOnWebViews controls whether -[WebView close] should be called on 
+        web views that are about to be closed.
+        
+        (runTest):
+        Make sure that only the main window is around when a test has finished running.
+        
+        (-[DumpRenderTreeWindow initWithContentRect:styleMask:backing:defer:]):
+        (-[DumpRenderTreeWindow dealloc]):
+        Manage the set of windows.
+        
+        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
+        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h:
+        * DumpRenderTree/TestNetscapePlugIn.subproj/main.c:
+        (NPP_Destroy):
+        Add a &quot;logDestroy&quot; property which controls whether plugins should print when they are destroyed or not.
+        
+        * DumpRenderTree/UIDelegate.m:
+        (-[UIDelegate webView:createWebViewWithRequest:]):
+        Create new windows.
+        
+        (-[UIDelegate webViewClose:]):
+        Close windows.
+        
+2007-04-05  Anders Carlsson  &lt;andersca@apple.com&gt;
+
</ins><span class="cx">         Reviewed by Maciej.
</span><span class="cx"> 
</span><span class="cx">         Move WebView and NSWindow creation to a separate function in preparation of supporting opening new
</span></span></pre></div>
<a id="trunkWebKitToolsDumpRenderTreeDumpRenderTreeh"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/DumpRenderTree/DumpRenderTree.h (20741 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/DumpRenderTree/DumpRenderTree.h        2007-04-06 01:46:42 UTC (rev 20741)
+++ trunk/WebKitTools/DumpRenderTree/DumpRenderTree.h        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> @class DumpRenderTreeDraggingInfo;
</span><span class="cx"> @class WebFrame;
</span><ins>+@class WebView;
</ins><span class="cx"> 
</span><span class="cx"> extern BOOL windowIsKey;
</span><span class="cx"> extern WebFrame *frame;
</span><span class="lines">@@ -35,3 +36,8 @@
</span><span class="cx"> extern volatile BOOL done;
</span><span class="cx"> extern BOOL shouldDumpResourceLoadCallbacks;
</span><span class="cx"> extern NSMutableSet *disallowedURLs;
</span><ins>+extern BOOL waitToDump;
+extern BOOL canOpenWindows;
+extern BOOL closeWebViews;
+
+WebView *createWebView();
</ins></span></pre></div>
<a id="trunkWebKitToolsDumpRenderTreeDumpRenderTreem"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/DumpRenderTree/DumpRenderTree.m (20741 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/DumpRenderTree/DumpRenderTree.m        2007-04-06 01:46:42 UTC (rev 20741)
+++ trunk/WebKitTools/DumpRenderTree/DumpRenderTree.m        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -104,6 +104,9 @@
</span><span class="cx"> BOOL shouldDumpEditingCallbacks;
</span><span class="cx"> BOOL shouldDumpResourceLoadCallbacks;
</span><span class="cx"> NSMutableSet *disallowedURLs = 0;
</span><ins>+BOOL waitToDump;     // TRUE if waitUntilDone() has been called, but notifyDone() has not yet been called
+BOOL canOpenWindows;
+BOOL closeWebViews;
</ins><span class="cx"> 
</span><span class="cx"> static void runTest(const char *pathOrURL);
</span><span class="cx"> static NSString *md5HashStringForBitmap(CGImageRef bitmap);
</span><span class="lines">@@ -130,7 +133,6 @@
</span><span class="cx"> // where a frameset is loaded, and then new content is loaded into one of the child frames,
</span><span class="cx"> // that child frame is the &quot;topmost frame that is loading&quot;.
</span><span class="cx"> static WebFrame *topLoadingFrame;     // !nil iff a load is in progress
</span><del>-static BOOL waitToDump;     // TRUE if waitUntilDone() has been called, but notifyDone() has not yet been called
</del><span class="cx"> 
</span><span class="cx"> static BOOL dumpAsText;
</span><span class="cx"> static BOOL dumpDOMAsWebArchive;
</span><span class="lines">@@ -164,6 +166,8 @@
</span><span class="cx"> const unsigned maxViewHeight = 600;
</span><span class="cx"> const unsigned maxViewWidth = 800;
</span><span class="cx"> 
</span><ins>+static CFMutableSetRef allWindowsRef;
+
</ins><span class="cx"> static pthread_mutex_t javaScriptThreadsMutex = PTHREAD_MUTEX_INITIALIZER;
</span><span class="cx"> static BOOL javaScriptThreadsShouldTerminate;
</span><span class="cx"> 
</span><span class="lines">@@ -433,7 +437,7 @@
</span><span class="cx">     [preferences setDefaultFixedFontSize:13];
</span><span class="cx">     [preferences setMinimumFontSize:1];
</span><span class="cx">     [preferences setJavaEnabled:NO];
</span><del>-    [preferences setJavaScriptCanOpenWindowsAutomatically:NO];
</del><ins>+    [preferences setJavaScriptCanOpenWindowsAutomatically:YES];
</ins><span class="cx">     [preferences setEditableLinkBehavior:WebKitEditableLinkOnlyLiveWithShiftKey];
</span><span class="cx">     [preferences setTabsToLinks:NO];
</span><span class="cx"> 
</span><span class="lines">@@ -1023,7 +1027,9 @@
</span><span class="cx">             || aSelector == @selector(setUserStyleSheetLocation:)
</span><span class="cx">             || aSelector == @selector(setUserStyleSheetEnabled:)
</span><span class="cx">             || aSelector == @selector(objCClassNameOf:)
</span><del>-            || aSelector == @selector(addDisallowedURL:))
</del><ins>+            || aSelector == @selector(addDisallowedURL:)    
+            || aSelector == @selector(setCanOpenWindows)
+            || aSelector == @selector(setCallCloseOnWebViews:))
</ins><span class="cx">         return NO;
</span><span class="cx">     return YES;
</span><span class="cx"> }
</span><span class="lines">@@ -1056,7 +1062,9 @@
</span><span class="cx">         return @&quot;objCClassName&quot;;
</span><span class="cx">     if (aSelector == @selector(addDisallowedURL:))
</span><span class="cx">         return @&quot;addDisallowedURL&quot;;
</span><del>-    
</del><ins>+    if (aSelector == @selector(setCallCloseOnWebViews:))
+        return @&quot;setCallCloseOnWebViews&quot;;
+
</ins><span class="cx">     return nil;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1084,6 +1092,16 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)setCallCloseOnWebViews:(BOOL)callClose
+{
+    closeWebViews = callClose;
+}
+
+- (void)setCanOpenWindows
+{
+    canOpenWindows = YES;
+}
+
</ins><span class="cx"> - (void)waitUntilDone 
</span><span class="cx"> {
</span><span class="cx">     waitToDump = YES;
</span><span class="lines">@@ -1350,6 +1368,8 @@
</span><span class="cx">     dumpTitleChanges = NO;
</span><span class="cx">     dumpBackForwardList = NO;
</span><span class="cx">     readFromWindow = NO;
</span><ins>+    canOpenWindows = NO;
+    closeWebViews = YES;
</ins><span class="cx">     testRepaint = testRepaintDefault;
</span><span class="cx">     repaintSweepHorizontally = repaintSweepHorizontallyDefault;
</span><span class="cx">     if ([WebHistory optionalSharedHistory])
</span><span class="lines">@@ -1382,6 +1402,10 @@
</span><span class="cx">     [[frame webView] setSelectedDOMRange:nil affinity:NSSelectionAffinityDownstream];
</span><span class="cx">     [pool release];
</span><span class="cx">     
</span><ins>+    // We should only have our main window left when we're done
+    assert(CFSetGetCount(allWindowsRef) == 1);
+    assert(CFSetContainsValue(allWindowsRef, [[frame webView] window]));
+    
</ins><span class="cx">     if (_shouldIgnoreWebCoreNodeLeaks)
</span><span class="cx">         [WebCoreStatistics stopIgnoringWebCoreNodeLeaks];
</span><span class="cx"> }
</span><span class="lines">@@ -1579,8 +1603,35 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+static CFSetCallBacks NonRetainingSetCallbacks = {
+    0,
+    NULL,
+    NULL,
+    CFCopyDescription,
+    CFEqual,
+    CFHash
+};
+
</ins><span class="cx"> @implementation DumpRenderTreeWindow
</span><span class="cx"> 
</span><ins>+- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
+{
+    if (!allWindowsRef)
+        allWindowsRef = CFSetCreateMutable(NULL, 0, &amp;NonRetainingSetCallbacks);
+
+    CFSetSetValue(allWindowsRef, self);
+            
+    return [super initWithContentRect:contentRect styleMask:styleMask backing:bufferingType defer:deferCreation];
+}
+
+- (void)dealloc
+{
+    assert(CFSetContainsValue(allWindowsRef, self));
+    
+    CFSetRemoveValue(allWindowsRef, self);
+    [super dealloc];
+}
+
</ins><span class="cx"> - (BOOL)isKeyWindow
</span><span class="cx"> {
</span><span class="cx">     return windowIsKey;
</span></span></pre></div>
<a id="trunkWebKitToolsDumpRenderTreeTestNetscapePlugInsubprojPluginObjectc"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c (20741 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c        2007-04-06 01:46:42 UTC (rev 20741)
+++ trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -72,14 +72,16 @@
</span><span class="cx"> #define ID_PROPERTY_EVENT_LOGGING   1
</span><span class="cx"> #define ID_PROPERTY_HAS_STREAM      2
</span><span class="cx"> #define ID_PROPERTY_TEST_OBJECT     3
</span><del>-#define NUM_PROPERTY_IDENTIFIERS    4
</del><ins>+#define ID_PROPERTY_LOG_DESTROY     4
+#define NUM_PROPERTY_IDENTIFIERS    5
</ins><span class="cx"> 
</span><span class="cx"> static NPIdentifier pluginPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS];
</span><span class="cx"> static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
</span><span class="cx">     &quot;property&quot;,
</span><span class="cx">     &quot;eventLoggingEnabled&quot;,
</span><span class="cx">     &quot;hasStream&quot;,
</span><del>-    &quot;testObject&quot;
</del><ins>+    &quot;testObject&quot;,
+    &quot;logDestroy&quot;,
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #define ID_TEST_CALLBACK_METHOD     0
</span><span class="lines">@@ -143,6 +145,9 @@
</span><span class="cx">     } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) {
</span><span class="cx">         BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)-&gt;eventLogging, *variant);
</span><span class="cx">         return true;
</span><ins>+    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) {
+        BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)-&gt;logDestroy, *variant);
+        return true;            
</ins><span class="cx">     } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_HAS_STREAM]) {
</span><span class="cx">         BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)-&gt;stream != 0, *variant);
</span><span class="cx">         return true;
</span><span class="lines">@@ -160,7 +165,11 @@
</span><span class="cx">     if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) {
</span><span class="cx">         ((PluginObject *)obj)-&gt;eventLogging = NPVARIANT_TO_BOOLEAN(*variant);
</span><span class="cx">         return true;
</span><ins>+    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) {
+        ((PluginObject *)obj)-&gt;logDestroy = NPVARIANT_TO_BOOLEAN(*variant);
+        return true;
</ins><span class="cx">     }
</span><ins>+    
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -320,6 +329,7 @@
</span><span class="cx">     newInstance-&gt;npp = npp;
</span><span class="cx">     newInstance-&gt;testObject = browser-&gt;createobject(npp, getTestClass());
</span><span class="cx">     newInstance-&gt;eventLogging = FALSE;
</span><ins>+    newInstance-&gt;logDestroy = FALSE;
</ins><span class="cx">     newInstance-&gt;stream = 0;
</span><span class="cx">     
</span><span class="cx">     return (NPObject *)newInstance;
</span></span></pre></div>
<a id="trunkWebKitToolsDumpRenderTreeTestNetscapePlugInsubprojPluginObjecth"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h (20741 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h        2007-04-06 01:46:42 UTC (rev 20741)
+++ trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx">     NPObject header;
</span><span class="cx">     NPP npp;
</span><span class="cx">     NPBool eventLogging;
</span><ins>+    NPBool logDestroy;
</ins><span class="cx">     NPObject* testObject;
</span><span class="cx">     NPStream* stream;
</span><span class="cx">     char* onStreamLoad;
</span></span></pre></div>
<a id="trunkWebKitToolsDumpRenderTreeTestNetscapePlugInsubprojmainc"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.c (20741 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.c        2007-04-06 01:46:42 UTC (rev 20741)
+++ trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.c        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -95,6 +95,9 @@
</span><span class="cx">         if (obj-&gt;onStreamLoad)
</span><span class="cx">             free(obj-&gt;onStreamLoad);
</span><span class="cx">         
</span><ins>+        if (obj-&gt;logDestroy)
+            printf(&quot;PLUGIN: NPP_Destroy\n&quot;);
+
</ins><span class="cx">         browser-&gt;releaseobject(&amp;obj-&gt;header);
</span><span class="cx">     }
</span><span class="cx">     return NPERR_NO_ERROR;
</span></span></pre></div>
<a id="trunkWebKitToolsDumpRenderTreeUIDelegatem"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/DumpRenderTree/UIDelegate.m (20741 => 20742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/DumpRenderTree/UIDelegate.m        2007-04-06 01:46:42 UTC (rev 20741)
+++ trunk/WebKitTools/DumpRenderTree/UIDelegate.m        2007-04-06 03:05:48 UTC (rev 20742)
</span><span class="lines">@@ -68,6 +68,29 @@
</span><span class="cx">         [(WebHTMLView *)documentView _updateActiveState];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request
+{
+    if (!canOpenWindows)
+        return nil;
+    
+    // Make sure that waitUntilDone has been called.
+    assert(waitToDump);
+
+    WebView *webView = createWebView();
+    
+    return [webView autorelease];
+}
+
+- (void)webViewClose:(WebView *)sender
+{
+    NSWindow* window = [sender window];

+    if (closeWebViews)
+        [sender close];
+    
+    [window close];
+}
+
</ins><span class="cx"> - (void)dealloc
</span><span class="cx"> {
</span><span class="cx">     [draggingInfo release];
</span></span></pre>
</div>
</div>

</body>
</html>