summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/font-face-add-same-family-later.html
blob: 253fed962aae28e9b0ecda54ef1649b12c4de04c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<style>
@font-face {
    font-family: Test;
    font-weight: 400;
    src: local(Times);
}
</style>
<span id="text" style="font-family: Test; font-weight: 700;">Test Text</span>
<script>
description('Tests that adding a FontFace to existing family triggers font update.');

window.jsTestIsAsync = true;

var widthBeforeLoad, widthAfterLoad;

document.fonts.ready.then(function() {
    widthBeforeLoad = document.getElementById('text').offsetWidth;
    var face = new FontFace('Test', 'url(../../resources/Ahem.ttf)', { weight: 700 });
    document.fonts.add(face);
    return face.loaded;
}).then(function() {
    widthAfterLoad = document.getElementById('text').offsetWidth;
    shouldBeTrue('widthBeforeLoad != widthAfterLoad');
    finishJSTest();
});
</script>