@@ -38,6 +38,23 @@ final context = TestContext();
38
38
final devToolsLoadTime = const Duration (seconds: 4 );
39
39
40
40
void main () async {
41
+ Future <void > waitForDartDevToolsWithRetry ({
42
+ int retryCount = 6 ,
43
+ Duration retryWait = const Duration (seconds: 1 ),
44
+ }) async {
45
+ if (retryCount == 0 ) return ;
46
+ var windows = await context.webDriver.windows.toList ();
47
+ await context.webDriver.driver.switchTo.window (windows.last);
48
+ final title = await context.webDriver.title;
49
+ if (title == 'Dart DevTools' ) return ;
50
+
51
+ await Future .delayed (retryWait);
52
+ return waitForDartDevToolsWithRetry (
53
+ retryCount: retryCount-- ,
54
+ retryWait: retryWait,
55
+ );
56
+ }
57
+
41
58
for (var useSse in [true , false ]) {
42
59
group (useSse ? 'SSE' : 'WebSockets' , () {
43
60
group ('Without encoding' , () {
@@ -76,11 +93,9 @@ void main() async {
76
93
await context.extensionConnection.sendCommand ('Runtime.evaluate' , {
77
94
'expression' : 'fakeClick()' ,
78
95
});
79
- await Future .delayed (devToolsLoadTime);
80
- var windows = await context.webDriver.windows.toList ();
81
- await context.webDriver.driver.switchTo.window (windows.last);
96
+ await waitForDartDevToolsWithRetry ();
82
97
expect (await context.webDriver.title, 'Dart DevTools' );
83
- }, skip : 'https://github.com/dart-lang/webdev/issues/1512' );
98
+ });
84
99
});
85
100
86
101
group ('With a sharded Dart app' , () {
@@ -154,11 +169,9 @@ void main() async {
154
169
await context.extensionConnection.sendCommand ('Runtime.evaluate' , {
155
170
'expression' : 'fakeClick()' ,
156
171
});
157
- await Future .delayed (devToolsLoadTime);
158
- var windows = await context.webDriver.windows.toList ();
159
- await context.webDriver.driver.switchTo.window (windows.last);
172
+ await waitForDartDevToolsWithRetry ();
160
173
expect (await context.webDriver.title, 'Dart DevTools' );
161
- }, skip : 'https://github.com/dart-lang/webdev/issues/1512' );
174
+ });
162
175
});
163
176
});
164
177
}
0 commit comments