Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/css/fontfaceset-add-remove-while-loading.html | 
| diff --git a/third_party/WebKit/LayoutTests/fast/css/fontfaceset-add-remove-while-loading.html b/third_party/WebKit/LayoutTests/fast/css/fontfaceset-add-remove-while-loading.html | 
| index 3c63e88fd7e9849edfa70d3e8a07edada8072ed7..6b79dab00e6b580dff12f40c110327e936f92c32 100644 | 
| --- a/third_party/WebKit/LayoutTests/fast/css/fontfaceset-add-remove-while-loading.html | 
| +++ b/third_party/WebKit/LayoutTests/fast/css/fontfaceset-add-remove-while-loading.html | 
| @@ -1,69 +1,73 @@ | 
| <!DOCTYPE html> | 
| -<script src="../../resources/js-test.js"></script> | 
| -<script> | 
| -description('Tests that FontFaceSet is correctly updated when added or removed a FontFace while loading.'); | 
| +<script src='../../resources/testharness.js'></script> | 
| +<script src='../../resources/testharnessreport.js'></script> | 
| -window.jsTestIsAsync = true; | 
| +<script> | 
| function loadingDonePromise() { | 
| - return new Promise(function(resolve) { | 
| - function handler(e) { | 
| - document.fonts.removeEventListener('loadingdone', handler); | 
| - resolve(e); | 
| - }; | 
| - document.fonts.addEventListener('loadingdone', handler); | 
| - }); | 
| + return new Promise(function(resolve) { | 
| + function handler(e) { | 
| + document.fonts.removeEventListener('loadingdone', handler); | 
| + resolve(e); | 
| + }; | 
| + document.fonts.addEventListener('loadingdone', handler); | 
| + }); | 
| } | 
| -Promise.resolve().then(function() { | 
| - face1 = new FontFace('face1', 'url(../../resources/Ahem.ttf)', {}); | 
| - shouldBeEqualToString('face1.status', 'unloaded'); | 
| +promise_test(() => { | 
| + let face1 = new FontFace('face1', 'url(../../resources/Ahem.ttf)', {}); | 
| + assert_equals(face1.status, 'unloaded'); | 
| + | 
| + let face1Loaded = face1.load(); | 
| + assert_equals(face1.status, 'loading'); | 
| + assert_equals(document.fonts.status, 'loaded') | 
| 
 
meade_UTC10
2017/01/13 03:12:45
This is loaded, not loading, because face1 is not
 
Kunihiko Sakamoto
2017/02/07 10:13:15
That's right.
 
 | 
| - face1.load(); | 
| - shouldBeEqualToString('face1.status', 'loading'); | 
| - shouldBeEqualToString('document.fonts.status', 'loaded'); | 
| + let loadingDone = loadingDonePromise(); | 
| + document.fonts.add(face1); | 
| + assert_equals(document.fonts.status, 'loading'); | 
| - document.fonts.add(face1); | 
| - shouldBeEqualToString('document.fonts.status', 'loading'); | 
| - return document.fonts.ready; | 
| -}).then(function() { | 
| - shouldBeEqualToString('face1.status', 'loaded'); | 
| - shouldBeEqualToString('document.fonts.status', 'loaded'); | 
| + return Promise.all([face1Loaded, loadingDone]).then(() => { | 
| 
 
Kunihiko Sakamoto
2017/02/07 10:13:15
Originally this was document.fonts.ready. Didn't t
 
meade_UTC10
2017/02/09 07:42:33
Huh, it does work. Maybe I was fiddling with somet
 
 | 
| + assert_equals(document.fonts.status, 'loaded'); | 
| 
 
Kunihiko Sakamoto
2017/02/07 10:13:15
Can you also check that face1.status is 'loaded' h
 
meade_UTC10
2017/02/09 07:42:33
With this style of tests, face1 is not in scope he
 
Kunihiko Sakamoto
2017/02/09 08:18:15
Hmm, I think face1 should be accessible here?
 
meade_UTC10
2017/02/14 00:51:42
oops, I think I misread where this comment is in t
 
 | 
| + }); | 
| +}, 'document.fonts.add() called while a FontFace is loading.'); | 
| - face2 = new FontFace('face2', 'url(../../resources/Ahem.ttf)', {}); | 
| - shouldBeEqualToString('face2.status', 'unloaded'); | 
| +promise_test(() => { | 
| + assert_equals(document.fonts.status, 'loaded'); | 
| - document.fonts.add(face2); | 
| - var face2loaded = face2.load() | 
| - shouldBeEqualToString('document.fonts.status', 'loading'); | 
| + let face2 = new FontFace('face2', 'url(../../resources/Ahem.ttf)', {}); | 
| + assert_equals(face2.status, 'unloaded'); | 
| - var loadingdone = loadingDonePromise(); | 
| - document.fonts.delete(face2); | 
| - shouldBeEqualToString('document.fonts.status', 'loading'); | 
| - shouldBeEqualToString('face2.status', 'loading'); | 
| + document.fonts.add(face2); | 
| + let face2Loaded = face2.load(); | 
| + assert_equals(document.fonts.status, 'loading'); | 
| - return Promise.all([face2loaded, loadingdone]); | 
| -}).then(function() { | 
| - shouldBeEqualToString('face2.status', 'loaded'); | 
| - shouldBeEqualToString('document.fonts.status', 'loaded'); | 
| + let loadingDone = loadingDonePromise(); | 
| + document.fonts.delete(face2); | 
| + assert_equals(document.fonts.status, 'loading'); | 
| + assert_equals(face2.status, 'loading'); | 
| - face3 = new FontFace('face3', 'url(../../resources/Ahem.ttf)', {}); | 
| - shouldBeEqualToString('face3.status', 'unloaded'); | 
| + return Promise.all([face2Loaded, loadingDone]).then(() => { | 
| + assert_equals(document.fonts.status, 'loaded'); | 
| 
 
meade_UTC10
2017/01/13 03:12:45
I don't really understand the final checks in this
 
Kunihiko Sakamoto
2017/02/07 10:13:15
IIRC, these are checking that deleting face2 from
 
meade_UTC10
2017/02/09 07:42:33
Thanks for the explanation. Another thing I was wo
 
Kunihiko Sakamoto
2017/02/09 08:18:15
I don't remember why... :)
Maybe we can merge thos
 
meade_UTC10
2017/02/14 00:51:42
Done.
 
 | 
| + }); | 
| +}, 'document.fonts.delete() called while a FontFace is loading.'); | 
| + | 
| +promise_test(() => { | 
| + assert_equals(document.fonts.status, 'loaded'); | 
| + | 
| + let face3 = new FontFace('face3', 'url(../../resources/Ahem.ttf)', {}); | 
| + assert_equals(face3.status, 'unloaded'); | 
| document.fonts.add(face3); | 
| face3.load(); | 
| - shouldBeEqualToString('document.fonts.status', 'loading'); | 
| + assert_equals(document.fonts.status, 'loading'); | 
| document.fonts.clear(); | 
| - shouldBeEqualToString('document.fonts.status', 'loading'); | 
| - shouldBeEqualToString('face3.status', 'loading'); | 
| - return document.fonts.ready; | 
| -}).then(function() { | 
| - shouldBeEqualToString('document.fonts.status', 'loaded'); | 
| - finishJSTest(); | 
| -}).catch(function (err) { | 
| - testFailed('Unexpected rejection: ' + err); | 
| - finishJSTest(); | 
| -}); | 
| + assert_equals(document.fonts.status, 'loading'); | 
| + assert_equals(face3.status, 'loading'); | 
| 
 
meade_UTC10
2017/01/13 03:12:45
ditto...
 
 | 
| + | 
| + return document.fonts.ready.then(() => { | 
| + assert_equals(document.fonts.status, 'loaded'); | 
| + }); | 
| +}, 'document.fonts.clear() called while a FontFace is loading.'); | 
| </script> |