diff --git a/lib/web_ui/test/canvaskit/surface_test.dart b/lib/web_ui/test/canvaskit/surface_test.dart index 178fd5f762c06..f3d7e26ddb044 100644 --- a/lib/web_ui/test/canvaskit/surface_test.dart +++ b/lib/web_ui/test/canvaskit/surface_test.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:js_util' as js_util; + import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; @@ -141,20 +143,23 @@ void testMain() { // Emulate WebGL context loss. final DomCanvasElement canvas = surface.htmlElement.children.single as DomCanvasElement; - final dynamic ctx = canvas.getContext('webgl2'); - expect(ctx, isNotNull); - final dynamic loseContextExtension = - ctx.getExtension('WEBGL_lose_context'); - loseContextExtension.loseContext(); + final Object ctx = canvas.getContext('webgl2')!; + final Object loseContextExtension = js_util.callMethod( + ctx, + 'getExtension', + ['WEBGL_lose_context'], + ); + js_util.callMethod(loseContextExtension, 'loseContext', const []); // Pump a timer to allow the "lose context" event to propagate. await Future.delayed(Duration.zero); // We don't create a new GL context until the context is restored. expect(surface.debugContextLost, isTrue); - expect(ctx.isContextLost(), isTrue); + final bool isContextLost = js_util.callMethod(ctx, 'isContextLost', const []); + expect(isContextLost, isTrue); // Emulate WebGL context restoration. - loseContextExtension.restoreContext(); + js_util.callMethod(loseContextExtension, 'restoreContext', const []); // Pump a timer to allow the "restore context" event to propagate. await Future.delayed(Duration.zero); @@ -165,9 +170,8 @@ void testMain() { // A new context is created. expect(afterContextLost, isNot(same(before))); }, - // Firefox and Safari don't have the WEBGL_lose_context extension. - // TODO(hterkelsen): https://github.com/flutter/flutter/issues/115327 - skip: true, + // Firefox can't create a WebGL2 context in headless mode. + skip: isFirefox, ); // Regression test for https://github.com/flutter/flutter/issues/75286