@@ -137,7 +137,6 @@ private void testLogAppend(String msg) {
137137 static List <String > initialOpenedDescriptors = new ArrayList <>();
138138
139139 List <Browser > createdBroswers = new ArrayList <>();
140- boolean ignoreNonDisposedShells ;
141140 static List <String > descriptors = new ArrayList <>();
142141
143142 private final int swtBrowserSettings ;
@@ -165,7 +164,6 @@ public Test_org_eclipse_swt_browser_Browser(int swtBrowserSettings) {
165164public void setUp () {
166165 super .setUp ();
167166 testNumber ++;
168- ignoreNonDisposedShells = false ;
169167 secondsToWaitTillFail = Math .max (15 , debug_show_browser_timeout_seconds );
170168
171169 // If webkit crashes, it's very hard to tell which jUnit caused the JVM crash.
@@ -207,14 +205,21 @@ protected void afterDispose(Display display) {
207205 Shell [] shells = Display .getDefault ().getShells ();
208206 int disposedShells = 0 ;
209207 for (Shell shell : shells ) {
208+
209+ if (shell .getParent () == null // top-level shell
210+ || shell .getText () != null && shell .getText ().contains ("limbo" )) {
211+ // Skip the check for the top-level and the "limbo" shell since they are disposed
212+ // after all tests are finished
213+ continue ;
214+ }
215+
210216 if (!shell .isDisposed ()) {
211217 System .out .println ("Not disposed shell: " + shell );
212- shell .dispose ();
213218 disposedShells ++;
214219 }
215220 }
216- if (! ignoreNonDisposedShells ) {
217- assertEquals ("Found " + disposedShells + " not disposed shells!" , 0 , disposedShells );
221+ if (disposedShells > 0 ) {
222+ throw new RuntimeException ("Found " + disposedShells + " not disposed shells!" );
218223 }
219224
220225 int disposedBrowsers = 0 ;
@@ -2151,8 +2156,6 @@ public void test_evaluate_array_mixedTypes () {
21512156 */
21522157@ Test
21532158public void test_BrowserFunction_callback () {
2154- // There are shells left opened after this test
2155- ignoreNonDisposedShells = true ;
21562159 AtomicBoolean javaCallbackExecuted = new AtomicBoolean (false );
21572160
21582161 class JavascriptCallback extends BrowserFunction { // Note: Local class defined inside method.
0 commit comments