Files
sdk/tests/lib_2/html/fontface_loaded_test.dart
T
Terry Lucas 8611852b81 Migrated Block 199 to Dart 2.0
R=bkonyi@google.com

Change-Id: Ic52e7afb489b15b2f2e45f5ad9191cf5e441c047
Reviewed-on: https://dart-review.googlesource.com/11342
Commit-Queue: Terry Lucas <terry@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2017-10-10 13:53:24 +00:00

54 lines
1.3 KiB
Dart

library fontface_loaded_test;
import 'package:unittest/unittest.dart';
import 'package:unittest/html_config.dart';
import 'dart:async';
import 'dart:isolate';
import 'dart:html';
class NullTreeSanitizer implements NodeTreeSanitizer {
void sanitizeTree(Node node) {}
}
main() {
useHtmlConfiguration();
var style = new Element.html(
'''
<style>
@font-face {
font-family: 'Ahem';
src: url(/root_dart/tests/html/Ahem.ttf);
font-style: italic;
font-weight: 300;
unicode-range: U+0-3FF;
font-variant: small-caps;
-webkit-font-feature-settings: "dlig" 1;
/* font-stretch property is not supported */
}
</style>
''',
treeSanitizer: new NullTreeSanitizer());
document.head.append(style);
test('document fonts - temporary', () {
var atLeastOneFont = false;
var loaded = <Future>[];
document.fonts.forEach((FontFace fontFace, _, __) {
atLeastOneFont = true;
Future f1 = fontFace.loaded;
Future f2 = fontFace.loaded;
loaded.add(fontFace.load());
loaded.add(f1);
loaded.add(f2);
});
expect(atLeastOneFont, isTrue);
return Future.wait(loaded).then(expectAsync((_) {
document.fonts.forEach((fontFace, _, __) {
expect(fontFace.status, 'loaded');
});
}));
});
}