Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / css / fontfaceset-add-remove-while-loading.html
blob3c63e88fd7e9849edfa70d3e8a07edada8072ed7
1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script>
4 description('Tests that FontFaceSet is correctly updated when added or removed a FontFace while loading.');
6 window.jsTestIsAsync = true;
8 function loadingDonePromise() {
9 return new Promise(function(resolve) {
10 function handler(e) {
11 document.fonts.removeEventListener('loadingdone', handler);
12 resolve(e);
14 document.fonts.addEventListener('loadingdone', handler);
15 });
18 Promise.resolve().then(function() {
19 face1 = new FontFace('face1', 'url(../../resources/Ahem.ttf)', {});
20 shouldBeEqualToString('face1.status', 'unloaded');
22 face1.load();
23 shouldBeEqualToString('face1.status', 'loading');
24 shouldBeEqualToString('document.fonts.status', 'loaded');
26 document.fonts.add(face1);
27 shouldBeEqualToString('document.fonts.status', 'loading');
28 return document.fonts.ready;
29 }).then(function() {
30 shouldBeEqualToString('face1.status', 'loaded');
31 shouldBeEqualToString('document.fonts.status', 'loaded');
33 face2 = new FontFace('face2', 'url(../../resources/Ahem.ttf)', {});
34 shouldBeEqualToString('face2.status', 'unloaded');
36 document.fonts.add(face2);
37 var face2loaded = face2.load()
38 shouldBeEqualToString('document.fonts.status', 'loading');
40 var loadingdone = loadingDonePromise();
41 document.fonts.delete(face2);
42 shouldBeEqualToString('document.fonts.status', 'loading');
43 shouldBeEqualToString('face2.status', 'loading');
45 return Promise.all([face2loaded, loadingdone]);
46 }).then(function() {
47 shouldBeEqualToString('face2.status', 'loaded');
48 shouldBeEqualToString('document.fonts.status', 'loaded');
50 face3 = new FontFace('face3', 'url(../../resources/Ahem.ttf)', {});
51 shouldBeEqualToString('face3.status', 'unloaded');
53 document.fonts.add(face3);
54 face3.load();
55 shouldBeEqualToString('document.fonts.status', 'loading');
57 document.fonts.clear();
58 shouldBeEqualToString('document.fonts.status', 'loading');
59 shouldBeEqualToString('face3.status', 'loading');
60 return document.fonts.ready;
61 }).then(function() {
62 shouldBeEqualToString('document.fonts.status', 'loaded');
63 finishJSTest();
64 }).catch(function (err) {
65 testFailed('Unexpected rejection: ' + err);
66 finishJSTest();
67 });
69 </script>