Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnsgn committed Mar 17, 2019
1 parent 4c6e59c commit 4b15e3f
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 68 deletions.
2 changes: 1 addition & 1 deletion dist/fontfaceobserver.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 7 additions & 9 deletions dist/fontfaceobserver.esm.js
Expand Up @@ -400,32 +400,30 @@ var FontFaceObserver = function () {
var now = that.getTime();

if (now - start >= timeoutValue) {
reject();
reject(new Error("" + timeoutValue + "ms timeout exceeded"));
} else {
document.fonts.load(that.getStyle('"' + that["family"] + '"'), testString).then(function (fonts) {
if (fonts.length >= 1) {
resolve();
} else {
setTimeout(check, 25);
}
}, function () {
reject();
});
}, reject);
}
};
check();
});

var timer = new Promise(function (resolve, reject) {
timeoutId = setTimeout(reject, timeoutValue);
timeoutId = setTimeout(function () {
reject(new Error("" + timeoutValue + "ms timeout exceeded"));
}, timeoutValue);
});

Promise.race([timer, loader]).then(function () {
clearTimeout(timeoutId);
resolve(that);
}, function () {
reject(that);
});
}, reject);
} else {
onReady(function () {
var rulerA = new Ruler(testString);
Expand Down Expand Up @@ -516,7 +514,7 @@ var FontFaceObserver = function () {

if (now - start >= timeoutValue) {
removeContainer();
reject(that);
reject(new Error("" + timeoutValue + "ms timeout exceeded"));
} else {
var hidden = document["hidden"];
if (hidden === true || hidden === undefined) {
Expand Down

0 comments on commit 4b15e3f

Please sign in to comment.