2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
+ import 'dart:js_util' as js_util;
6
+
5
7
import 'package:test/bootstrap/browser.dart' ;
6
8
import 'package:test/test.dart' ;
7
9
import 'package:ui/src/engine.dart' ;
@@ -141,20 +143,23 @@ void testMain() {
141
143
// Emulate WebGL context loss.
142
144
final DomCanvasElement canvas =
143
145
surface.htmlElement.children.single as DomCanvasElement ;
144
- final dynamic ctx = canvas.getContext ('webgl2' );
145
- expect (ctx, isNotNull);
146
- final dynamic loseContextExtension =
147
- ctx.getExtension ('WEBGL_lose_context' );
148
- loseContextExtension.loseContext ();
146
+ final Object ctx = canvas.getContext ('webgl2' )! ;
147
+ final Object loseContextExtension = js_util.callMethod (
148
+ ctx,
149
+ 'getExtension' ,
150
+ < String > ['WEBGL_lose_context' ],
151
+ );
152
+ js_util.callMethod (loseContextExtension, 'loseContext' , const < void > []);
149
153
150
154
// Pump a timer to allow the "lose context" event to propagate.
151
155
await Future <void >.delayed (Duration .zero);
152
156
// We don't create a new GL context until the context is restored.
153
157
expect (surface.debugContextLost, isTrue);
154
- expect (ctx.isContextLost (), isTrue);
158
+ final bool isContextLost = js_util.callMethod <bool >(ctx, 'isContextLost' , const < void > []);
159
+ expect (isContextLost, isTrue);
155
160
156
161
// Emulate WebGL context restoration.
157
- loseContextExtension. restoreContext ( );
162
+ js_util. callMethod (loseContextExtension, 'restoreContext' , const < void > [] );
158
163
159
164
// Pump a timer to allow the "restore context" event to propagate.
160
165
await Future <void >.delayed (Duration .zero);
@@ -165,9 +170,8 @@ void testMain() {
165
170
// A new context is created.
166
171
expect (afterContextLost, isNot (same (before)));
167
172
},
168
- // Firefox and Safari don't have the WEBGL_lose_context extension.
169
- // TODO(hterkelsen): https://github.com/flutter/flutter/issues/115327
170
- skip: true ,
173
+ // Firefox can't create a WebGL2 context in headless mode.
174
+ skip: isFirefox,
171
175
);
172
176
173
177
// Regression test for https://github.com/flutter/flutter/issues/75286
0 commit comments