Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f7a3494

Browse files
committed
Add more tests.
1 parent 8e32798 commit f7a3494

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

lib/web_ui/test/canvaskit/canvaskit_api_tt_on_test.dart

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,45 @@ import 'package:ui/src/engine.dart';
99
import '../matchers.dart';
1010
import 'canvaskit_api_test.dart';
1111

12+
final bool isBlink = browserEngine == BrowserEngine.blink;
13+
14+
const String goodUrl = 'https://www.unpkg.com/blah-blah/33.x/canvaskit.js';
15+
const String badUrl = 'https://www.unpkg.com/soemthing/not-canvaskit.js';
16+
1217
// These tests need to happen in a separate file, because a Content Security
1318
// Policy cannot be relaxed once set, only made more strict.
1419
void main() {
20+
internalBootstrapBrowserTest(() => testMainWithTTOn);
21+
}
22+
23+
// Enables Trusted Types, runs all `canvaskit_api_test.dart`, then tests the
24+
// createTrustedScriptUrl function.
25+
void testMainWithTTOn() {
1526
enableTrustedTypes();
16-
internalBootstrapBrowserTest(() => () {
17-
// Run all standard canvaskit tests, with TT on...
18-
testMain();
1927

20-
test('rejects wrong canvaskit.js URL', () async {
28+
// Run all standard canvaskit tests, with TT on...
29+
testMain();
30+
31+
group('TrustedTypes API supported', () {
32+
test('createTrustedScriptUrl - returns TrustedScriptURL object', () async {
33+
final Object trusted = createTrustedScriptUrl(goodUrl);
34+
35+
expect(trusted, isA<DomTrustedScriptURL>());
36+
expect((trusted as DomTrustedScriptURL).url, goodUrl);
37+
});
38+
39+
test('createTrustedScriptUrl - rejects bad canvaskit.js URL', () async {
2140
expect(() {
22-
createTrustedScriptUrl('https://www.unpkg.com/soemthing/not-canvaskit.js');
41+
createTrustedScriptUrl(badUrl);
2342
}, throwsAssertionError);
24-
}, skip: isSafari || isFirefox);
25-
});
43+
});
44+
}, skip: !isBlink);
45+
46+
group('Trusted Types API NOT supported', () {
47+
test('createTrustedScriptUrl - returns unmodified url', () async {
48+
expect(createTrustedScriptUrl(badUrl), badUrl);
49+
});
50+
}, skip: isBlink);
2651
}
2752

2853
/// Enables Trusted Types by setting the appropriate meta tag in the DOM:

0 commit comments

Comments
 (0)