Bug 1466723 - Fix race in dom/base/test/test_data_uri.html. r=heycam
authorJonathan Watt <jwatt@jwatt.org>
Mon, 21 May 2018 16:00:32 +0100
changeset 475601 46d845389b970ade7754694a03cb3438e6985faa
parent 475600 6d859a75b7cc5eb7ad31388889d711caaa553cda
child 475602 94409f81ab0e75db962f24b29cb8a7f1bc3a71f2
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1466723
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1466723 - Fix race in dom/base/test/test_data_uri.html. r=heycam
dom/base/test/test_data_uri.html
--- a/dom/base/test/test_data_uri.html
+++ b/dom/base/test/test_data_uri.html
@@ -140,32 +140,36 @@ function runTests()
       }
 
       resolve();
     };
     document.head.appendChild(link);
   });
 
   // Test if data:font is same-origin.
-  let p7 = new Promise(resolve => {
+  let p7 = new Promise((resolve, reject) => {
     let text = document.createElement('p');
     // Cross-domain font will not load according to [1] so we try to apply
     // data:font to this text and see if the font can be loaded.
     // [1] https://www.w3.org/TR/css-fonts-3/#same-origin-restriction
     text.style = 'font-family: DataFont';
     text.innerHTML = "This text should trigger 'TestFont' to load.";
     document.body.appendChild(text);
 
-    document.fonts.onloadingdone = function (fontFaceSetEvent) {
-      is(fontFaceSetEvent.fontfaces.length, 1);
+    document.fonts.ready.then(fontFaces => {
+      is(fontFaces.size, 1, "should FontFace entry for data:font");
+      fontFaces.forEach(fontFace => {
+        is(fontFace.status, "loaded", "data:font should be same-origin");
+      });
       resolve();
-    };
-    document.fonts.onloadingerror = function (fontFaceSetEvent) {
+    },
+    _ => {
       ok(false, "data:font is not same-origin.");
-    };
+      reject();
+    });
   });
 
   Promise.all([p1, p2, p3, p4, p5, p6, p7]).then(() => {
     SimpleTest.finish();
   }).catch((e) => {
     ok(false, "throwing " + e);
     SimpleTest.finish();
   });