mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1144450 - Part 5: Fix/add tests for not firing loadingdone/loadingerror when adding an already-loaded/error FontFace to a FontFaceSet. r=jdaggett
This commit is contained in:
parent
561da6f5c3
commit
1b8d1d5203
@ -615,7 +615,8 @@ function runTest() {
|
||||
}).then(function() {
|
||||
|
||||
// (TEST 29) Test that a loadingdone and a loadingerror event is dispatched
|
||||
// when a FontFace with status "error" is added to the FontFaceSet.
|
||||
// when a FontFace that eventually becomes status "error" is added to the
|
||||
// FontFaceSet.
|
||||
var face;
|
||||
var awaitEvents = new Promise(function(aResolve, aReject) {
|
||||
|
||||
@ -657,14 +658,16 @@ function runTest() {
|
||||
};
|
||||
});
|
||||
|
||||
face = new FontFace("test", new ArrayBuffer(0));
|
||||
face = new FontFace("test", "url(x)");
|
||||
face.load();
|
||||
is(face.status, "loading", "FontFace should have status \"loading\" (TEST 29)");
|
||||
document.fonts.add(face);
|
||||
|
||||
return face.loaded
|
||||
.then(function() {
|
||||
ok(false, "the FontFace should not load (TEST 29)");
|
||||
}, function(aError) {
|
||||
is(face.status, "error", "FontFace should have status \"error\" (TEST 29)");
|
||||
document.fonts.add(face);
|
||||
return awaitEvents;
|
||||
})
|
||||
.then(function() {
|
||||
@ -675,7 +678,7 @@ function runTest() {
|
||||
}).then(function() {
|
||||
|
||||
// (TEST 30) Test that a loadingdone event is dispatched when a FontFace
|
||||
// with status "loaded" is added to the FontFaceSet.
|
||||
// that eventually becomes status "loaded" is added to the FontFaceSet.
|
||||
var face;
|
||||
var awaitEvents = new Promise(function(aResolve, aReject) {
|
||||
|
||||
@ -701,12 +704,14 @@ function runTest() {
|
||||
};
|
||||
});
|
||||
|
||||
face = new FontFace("test", fontData);
|
||||
face = new FontFace("test", "url(BitPattern.woff)");
|
||||
face.load();
|
||||
is(face.status, "loading", "FontFace should have status \"loading\" (TEST 30)");
|
||||
document.fonts.add(face);
|
||||
|
||||
return face.loaded
|
||||
.then(function() {
|
||||
is(face.status, "loaded", "FontFace should have status \"loaded\" (TEST 30)");
|
||||
document.fonts.add(face);
|
||||
return awaitEvents;
|
||||
})
|
||||
.then(function() {
|
||||
@ -744,14 +749,15 @@ function runTest() {
|
||||
});
|
||||
|
||||
face = new FontFace("test", "url(BitPattern.woff)");
|
||||
is(face.status, "unloaded", "FontFace should have status \"unloaded\" (TEST 31)");
|
||||
document.fonts.add(face);
|
||||
|
||||
return face.load()
|
||||
.then(function() {
|
||||
is(face.status, "loaded", "FontFace should have status \"loaded\" (TEST 31)");
|
||||
document.fonts.add(face);
|
||||
return awaitEvents;
|
||||
})
|
||||
.then(function() {
|
||||
is(face.status, "loaded", "FontFace should have status \"loaded\" (TEST 31)");
|
||||
document.fonts.clear();
|
||||
return document.fonts.ready;
|
||||
});
|
||||
@ -863,6 +869,63 @@ function runTest() {
|
||||
|
||||
style.textContent = "";
|
||||
|
||||
}).then(function() {
|
||||
|
||||
// (TEST 35) Test that no loadingdone event is dispatched when a FontFace
|
||||
// with "loaded" status is added to a "loaded" FontFaceSet.
|
||||
var gotLoadingDone = false;
|
||||
document.fonts.onloadingdone = function(aEvent) {
|
||||
gotLoadingDone = true;
|
||||
};
|
||||
|
||||
is(document.fonts.status, "loaded", "document.fonts.status should have status \"loaded\" (TEST 35)");
|
||||
var face = new FontFace("test", fontData);
|
||||
|
||||
return face.loaded
|
||||
.then(function() {
|
||||
is(face.status, "loaded", "FontFace should have status \"loaded\" (TEST 35)");
|
||||
document.fonts.add(face);
|
||||
is(document.fonts.status, "loaded", "document.fonts.status should still have status \"loaded\" (TEST 35)");
|
||||
return document.fonts.ready;
|
||||
})
|
||||
.then(function() {
|
||||
ok(!gotLoadingDone, "loadingdone event should not be dispatched (TEST 35)");
|
||||
document.fonts.onloadingdone = null;
|
||||
document.fonts.clear();
|
||||
});
|
||||
|
||||
}).then(function() {
|
||||
|
||||
// (TEST 36) Test that no loadingdone or loadingerror event is dispatched
|
||||
// when a FontFace with "error" status is added to a "loaded" FontFaceSet.
|
||||
var gotLoadingDone = false, gotLoadingError = false;
|
||||
document.fonts.onloadingdone = function(aEvent) {
|
||||
gotLoadingDone = true;
|
||||
};
|
||||
document.fonts.onloadingerror = function(aEvent) {
|
||||
gotLoadingError = true;
|
||||
};
|
||||
|
||||
is(document.fonts.status, "loaded", "document.fonts.status should have status \"loaded\" (TEST 36)");
|
||||
var face = new FontFace("test", new ArrayBuffer(0));
|
||||
|
||||
return face.loaded
|
||||
.then(function() {
|
||||
ok(false, "FontFace should not have loaded (TEST 36)");
|
||||
}, function() {
|
||||
is(face.status, "error", "FontFace should have status \"error\" (TEST 36)");
|
||||
document.fonts.add(face);
|
||||
is(document.fonts.status, "loaded", "document.fonts.status should still have status \"loaded\" (TEST 36)");
|
||||
return document.fonts.ready;
|
||||
})
|
||||
.then(function() {
|
||||
ok(!gotLoadingDone, "loadingdone event should not be dispatched (TEST 36)");
|
||||
ok(!gotLoadingError, "loadingerror event should not be dispatched (TEST 36)");
|
||||
document.fonts.onloadingdone = null;
|
||||
document.fonts.onloadingerror = null;
|
||||
document.fonts.clear();
|
||||
});
|
||||
|
||||
}).then(function() {
|
||||
|
||||
// (TEST LAST) Test that a pending style sheet load prevents
|
||||
|
Loading…
Reference in New Issue
Block a user