@@ -137,7 +137,6 @@ private void testLogAppend(String msg) {
137
137
static List <String > initialOpenedDescriptors = new ArrayList <>();
138
138
139
139
List <Browser > createdBroswers = new ArrayList <>();
140
- boolean ignoreNonDisposedShells ;
141
140
static List <String > descriptors = new ArrayList <>();
142
141
143
142
private final int swtBrowserSettings ;
@@ -165,7 +164,6 @@ public Test_org_eclipse_swt_browser_Browser(int swtBrowserSettings) {
165
164
public void setUp () {
166
165
super .setUp ();
167
166
testNumber ++;
168
- ignoreNonDisposedShells = false ;
169
167
secondsToWaitTillFail = Math .max (15 , debug_show_browser_timeout_seconds );
170
168
171
169
// If webkit crashes, it's very hard to tell which jUnit caused the JVM crash.
@@ -207,14 +205,21 @@ protected void afterDispose(Display display) {
207
205
Shell [] shells = Display .getDefault ().getShells ();
208
206
int disposedShells = 0 ;
209
207
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
+
210
216
if (!shell .isDisposed ()) {
211
217
System .out .println ("Not disposed shell: " + shell );
212
- shell .dispose ();
213
218
disposedShells ++;
214
219
}
215
220
}
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!" );
218
223
}
219
224
220
225
int disposedBrowsers = 0 ;
@@ -2151,8 +2156,6 @@ public void test_evaluate_array_mixedTypes () {
2151
2156
*/
2152
2157
@ Test
2153
2158
public void test_BrowserFunction_callback () {
2154
- // There are shells left opened after this test
2155
- ignoreNonDisposedShells = true ;
2156
2159
AtomicBoolean javaCallbackExecuted = new AtomicBoolean (false );
2157
2160
2158
2161
class JavascriptCallback extends BrowserFunction { // Note: Local class defined inside method.
0 commit comments