@@ -32,110 +32,115 @@ void main() {
32
32
33
33
final context = TestContext (TestProject .testWithSoundNullSafety, provider);
34
34
35
- group ('Injected client' , () {
36
- setUp (() async {
37
- await context.setUp (
38
- debugSettings: TestDebugSettings .withDevTools (context),
39
- );
40
- await context.webDriver.driver.keyboard.sendChord ([Keyboard .alt, 'd' ]);
41
- // Wait for DevTools to actually open.
42
- await Future .delayed (const Duration (seconds: 2 ));
43
- });
44
-
45
- tearDown (() async {
46
- await context.tearDown ();
47
- });
48
-
49
- test (
50
- 'can launch devtools' ,
51
- () async {
52
- final windows = await context.webDriver.windows.toList ();
53
- await context.webDriver.driver.switchTo.window (windows.last);
54
- expect (await context.webDriver.pageSource, contains ('DevTools' ));
55
- expect (await context.webDriver.currentUrl, contains ('ide=Dwds' ));
56
- // TODO(https://github.com/dart-lang/webdev/issues/1888): Re-enable.
57
- },
58
- skip: Platform .isWindows,
59
- );
60
-
61
- test ('can not launch devtools for the same app in multiple tabs' , () async {
62
- final appUrl = await context.webDriver.currentUrl;
63
- // Open a new tab, select it, and navigate to the app
64
- await context.webDriver.driver
65
- .execute ("window.open('$appUrl ', '_blank');" , []);
66
- await Future .delayed (const Duration (seconds: 2 ));
67
- final newAppWindow = await context.webDriver.windows.last;
68
- await newAppWindow.setAsActive ();
35
+ group (
36
+ 'Injected client' ,
37
+ () {
38
+ setUp (() async {
39
+ await context.setUp (
40
+ debugSettings: TestDebugSettings .withDevTools (context),
41
+ );
42
+ await context.webDriver.driver.keyboard.sendChord ([Keyboard .alt, 'd' ]);
43
+ // Wait for DevTools to actually open.
44
+ await Future .delayed (const Duration (seconds: 2 ));
45
+ });
69
46
70
- // Wait for the page to be ready before trying to open DevTools again.
71
- await _waitForPageReady (context);
47
+ tearDown (() async {
48
+ await context.tearDown ();
49
+ });
72
50
73
- // Try to open devtools and check for the alert.
74
- await context.webDriver.driver.keyboard.sendChord ([Keyboard .alt, 'd' ]);
75
- await Future .delayed (const Duration (seconds: 2 ));
76
- final alert = context.webDriver.driver.switchTo.alert;
77
- expect (alert, isNotNull);
78
- expect (
79
- await alert.text,
80
- contains ('This app is already being debugged in a different tab' ),
51
+ test (
52
+ 'can launch devtools' ,
53
+ () async {
54
+ final windows = await context.webDriver.windows.toList ();
55
+ await context.webDriver.driver.switchTo.window (windows.last);
56
+ expect (await context.webDriver.pageSource, contains ('DevTools' ));
57
+ expect (await context.webDriver.currentUrl, contains ('ide=Dwds' ));
58
+ // TODO(https://github.com/dart-lang/webdev/issues/1888): Re-enable.
59
+ },
60
+ skip: Platform .isWindows,
81
61
);
82
- await alert.accept ();
83
62
84
- var windows = await context.webDriver.windows.toList ();
85
- for (final window in windows) {
86
- if (window.id != newAppWindow.id) {
87
- await window.setAsActive ();
88
- await window.close ();
89
- }
90
- }
63
+ test ('can not launch devtools for the same app in multiple tabs' ,
64
+ () async {
65
+ final appUrl = await context.webDriver.currentUrl;
66
+ // Open a new tab, select it, and navigate to the app
67
+ await context.webDriver.driver
68
+ .execute ("window.open('$appUrl ', '_blank');" , []);
69
+ await Future .delayed (const Duration (seconds: 2 ));
70
+ final newAppWindow = await context.webDriver.windows.last;
71
+ await newAppWindow.setAsActive ();
91
72
92
- await newAppWindow.setAsActive ();
93
- await context.webDriver.driver.keyboard.sendChord ([Keyboard .alt, 'd' ]);
94
- await Future .delayed (const Duration (seconds: 2 ));
95
- windows = await context.webDriver.windows.toList ();
96
- final devToolsWindow =
97
- windows.firstWhere ((window) => window != newAppWindow);
98
- await devToolsWindow.setAsActive ();
99
- expect (await context.webDriver.pageSource, contains ('DevTools' ));
100
- });
73
+ // Wait for the page to be ready before trying to open DevTools again.
74
+ await _waitForPageReady (context);
101
75
102
- test (
103
- 'destroys and recreates the isolate during a page refresh' ,
104
- () async {
105
- // This test is the same as one in reload_test, but runs here when there
106
- // is a connected client (DevTools) since it can behave differently.
107
- // https://github.com/dart-lang/webdev/pull/901#issuecomment-586438132
108
- final client = context.debugConnection.vmService;
109
- await client.streamListen ('Isolate' );
110
- context.makeEditToDartEntryFile (
111
- toReplace: 'Hello World!' ,
112
- replaceWith: 'Bonjour le monde!' ,
113
- );
114
- await context.waitForSuccessfulBuild (propagateToBrowser: true );
115
-
116
- final eventsDone = expectLater (
117
- client.onIsolateEvent,
118
- emitsThrough (
119
- emitsInOrder ([
120
- _hasKind (EventKind .kIsolateExit),
121
- _hasKind (EventKind .kIsolateStart),
122
- _hasKind (EventKind .kIsolateRunnable),
123
- ]),
124
- ),
76
+ // Try to open devtools and check for the alert.
77
+ await context.webDriver.driver.keyboard.sendChord ([Keyboard .alt, 'd' ]);
78
+ await Future .delayed (const Duration (seconds: 2 ));
79
+ final alert = context.webDriver.driver.switchTo.alert;
80
+ expect (alert, isNotNull);
81
+ expect (
82
+ await alert.text,
83
+ contains ('This app is already being debugged in a different tab' ),
125
84
);
85
+ await alert.accept ();
126
86
127
- await context.webDriver.driver.refresh ();
87
+ var windows = await context.webDriver.windows.toList ();
88
+ for (final window in windows) {
89
+ if (window.id != newAppWindow.id) {
90
+ await window.setAsActive ();
91
+ await window.close ();
92
+ }
93
+ }
128
94
129
- await eventsDone;
130
- // Re-set the edited file:
131
- context.makeEditToDartEntryFile (
132
- toReplace: 'Bonjour le monde!' ,
133
- replaceWith: 'Hello World!' ,
134
- );
135
- },
136
- skip: 'https://github.com/dart-lang/webdev/issues/1888' ,
137
- );
138
- });
95
+ await newAppWindow.setAsActive ();
96
+ await context.webDriver.driver.keyboard.sendChord ([Keyboard .alt, 'd' ]);
97
+ await Future .delayed (const Duration (seconds: 2 ));
98
+ windows = await context.webDriver.windows.toList ();
99
+ final devToolsWindow =
100
+ windows.firstWhere ((window) => window != newAppWindow);
101
+ await devToolsWindow.setAsActive ();
102
+ expect (await context.webDriver.pageSource, contains ('DevTools' ));
103
+ });
104
+
105
+ test (
106
+ 'destroys and recreates the isolate during a page refresh' ,
107
+ () async {
108
+ // This test is the same as one in reload_test, but runs here when there
109
+ // is a connected client (DevTools) since it can behave differently.
110
+ // https://github.com/dart-lang/webdev/pull/901#issuecomment-586438132
111
+ final client = context.debugConnection.vmService;
112
+ await client.streamListen ('Isolate' );
113
+ context.makeEditToDartEntryFile (
114
+ toReplace: 'Hello World!' ,
115
+ replaceWith: 'Bonjour le monde!' ,
116
+ );
117
+ await context.waitForSuccessfulBuild (propagateToBrowser: true );
118
+
119
+ final eventsDone = expectLater (
120
+ client.onIsolateEvent,
121
+ emitsThrough (
122
+ emitsInOrder ([
123
+ _hasKind (EventKind .kIsolateExit),
124
+ _hasKind (EventKind .kIsolateStart),
125
+ _hasKind (EventKind .kIsolateRunnable),
126
+ ]),
127
+ ),
128
+ );
129
+
130
+ await context.webDriver.driver.refresh ();
131
+
132
+ await eventsDone;
133
+ // Re-set the edited file:
134
+ context.makeEditToDartEntryFile (
135
+ toReplace: 'Bonjour le monde!' ,
136
+ replaceWith: 'Hello World!' ,
137
+ );
138
+ },
139
+ skip: 'https://github.com/dart-lang/webdev/issues/1888' ,
140
+ );
141
+ },
142
+ timeout: Timeout .factor (2 ),
143
+ );
139
144
140
145
group ('Injected client without a DevTools server' , () {
141
146
setUp (() async {
@@ -193,6 +198,7 @@ void main() {
193
198
},
194
199
tags: ['extension' ],
195
200
skip: 'https://github.com/dart-lang/webdev/issues/2114' ,
201
+ timeout: Timeout .factor (2 ),
196
202
);
197
203
}
198
204
0 commit comments