chromium/third_party/blink/web_tests/fast/css/fontfaceset-ready.html

<!DOCTYPE html>
<title>FontFaceSet.ready attribute</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<div style="font-family: ahem">A</div>
<script>

promise_test(function(t) {
    assert_equals(document.fonts.ready, document.fonts.ready,
                  'FontFaceSet.ready should return the same promise');

    var face = new FontFace('test', 'url(../../resources/Ahem.ttf)');

    return document.fonts.ready
        .then(function(fonts) {
            assert_equals(fonts, document.fonts,
                          'FontFaceSet.ready should be resolved with the FontFaceSet');

            var oldReady = document.fonts.ready;
            document.fonts.add(face);
            assert_equals(document.fonts.ready, oldReady,
                          'FontFaceSet.ready should not be replaced when FontFace added to it is not loading');
            assert_equals(document.fonts.status, 'loaded',
                          'FontFaceSet.status after adding unloaded FontFace');
            face.load();
            var newReady = document.fonts.ready;
            assert_not_equals(newReady, oldReady,
                              'FontFaceSet.ready should be replaced when a FontFace in it started loading');
            assert_equals(document.fonts.status, 'loading',
                          'FontFaceSet.status after calling load() on a FontFace in it');
            return newReady;
        }).then(function(fonts) {
            assert_equals(face.status, 'loaded',
                          'FontFaceSet.ready should be resolved after all fonts have been loaded');
            assert_equals(document.fonts.status, 'loaded',
                          'FontFaceSet.status after FontFaceSet.ready is resolved');
        });
}, 'FontFaceSet.ready attribute');

promise_test(function(t) {
    var face = new FontFace('ahem', 'url(../../resources/Ahem.ttf)');

    return document.fonts.ready
        .then(function(fonts) {
            document.fonts.add(face);
            return document.fonts.ready;
        }).then(function(fonts) {
            assert_equals(face.status, 'loaded');
        });
}, 'FontFaceSet.ready should be resolved after layout operations which may cause font loads.');

</script>