Bug 1152647 - Part 1: Test. r=jdaggett
authorCameron McCormack <cam@mcc.id.au>
Sat, 09 May 2015 14:46:22 +1000
changeset 274456 e7cb51e17cc081e4e056e70f560bcd19046bad11
parent 274455 083d678bb7fd7a4a057eb74ee86d1824188b7700
child 274457 e96956b4da3364e6aaf36e711c61a6edfae093ff
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs1152647
milestone40.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 1152647 - Part 1: Test. r=jdaggett
layout/style/test/test_font_loading_api.html
--- a/layout/style/test/test_font_loading_api.html
+++ b/layout/style/test/test_font_loading_api.html
@@ -825,23 +825,17 @@ function runTest() {
     });
 
     is(document.fonts.status, "loaded", "document.fonts.status should still be loaded (TEST 33)");
     is(face.status, "unloaded", "FontFace.status should be unloaded (TEST 33)");
 
     document.fonts.clear();
     ok(document.fonts.has(face), "CSS-connected FontFace should not be removed from document.fonts when clear is called (TEST 33)");
 
-    var exceptionName = "";
-    try {
-      document.fonts.delete(face);
-    } catch (ex) {
-      exceptionName = ex.name;
-    }
-    ok(exceptionName == "InvalidModificationError", "attempting to remove CSS-connected FontFace from document.fonts should throw an InvalidModificationError (TEST 33)");
+    is(document.fonts.delete(face), false, "attempting to remove CSS-connected FontFace from document.fonts should return false (TEST 33)");
     ok(document.fonts.has(face), "CSS-connected FontFace should not be removed from document.fonts when delete is called (TEST 33)");
 
     style.textContent = "";
 
     ok(!document.fonts.has(face), "CSS-connected FontFace should be removed from document.fonts once the rule has been removed (TEST 33)");
 
     is(document.fonts.status, "loaded", "document.fonts.status should still be loaded after rule is removed (TEST 33)");
     is(face.status, "unloaded", "FontFace.status should still be unloaded after rule is removed (TEST 33)");
@@ -1085,24 +1079,69 @@ function runTest() {
         is(events[0].type, "loadingdone", "first event should be \"loadingdone\" (TEST 39)");
         is(events[0].fontfaces.length, 1, "first event should have 1 FontFace (TEST 39)");
         is(events[0].fontfaces[0], all[0], "first event should have the first FontFace");
 
         is(events[1].type, "loadingdone", "second event should be \"loadingdone\" (TEST 39)");
         is(events[1].fontfaces.length, 1, "second event should only have 1 FontFace (TEST 39)");
         is(events[1].fontfaces[0], all[1], "second event should have the second FontFace (TEST 39)");
 
+        style.textContent = "";
+
         document.fonts.onloadingdone = null;
         document.fonts.onloadingerror = null;
         document.fonts.clear();
         return document.fonts.ready;
       });
 
   }).then(function() {
 
+    // (TEST 40) Test that an attempt to add the same FontFace object a second
+    // time to a FontFaceSet will be ignored.
+
+    // First set up a @font-face rule.
+    var style = document.querySelector("style");
+    style.textContent = "@font-face { font-family: something; src: url(x); }";
+
+    // Then add a couple of non-connected FontFace objects.
+    var f1 = new FontFace("test1", "url(x)");
+    var f2 = new FontFace("test2", "url(x)");
+
+    document.fonts.add(f1);
+    document.fonts.add(f2);
+
+    var all = Array.from(document.fonts);
+    var ruleFontFace = all[0];
+
+    is(all.length, 3, "number of FontFace objects in the FontFaceSet before duplicate add (TEST 40)");
+    is(all[1], f1, "first non-connected FontFace object in the FontFaceSet before duplicate add (TEST 40)");
+    is(all[2], f2, "second non-connected FontFace object in the FontFaceSet before duplicate add (TEST 40)");
+
+    document.fonts.add(f1);
+
+    all = Array.from(document.fonts);
+    is(all.length, 3, "number of FontFace objects in the FontFaceSet after duplicate add #1 (TEST 40)");
+    is(all[0], ruleFontFace, "rule-based FontFace object in the FontFaceSEt after duplicate add #1 (TEST 40)");
+    is(all[1], f1, "first non-connected FontFace object in the FontFaceSet after duplicate add #1 (TEST 40)");
+    is(all[2], f2, "second non-connected FontFace object in the FontFaceSet after duplicate add #1 (TEST 40)");
+
+    document.fonts.add(ruleFontFace);
+
+    all = Array.from(document.fonts);
+    is(all.length, 3, "number of FontFace objects in the FontFaceSet after duplicate add #2 (TEST 40)");
+    is(all[0], ruleFontFace, "rule-based FontFace object in the FontFaceSEt after duplicate add #2 (TEST 40)");
+    is(all[1], f1, "first non-connected FontFace object in the FontFaceSet after duplicate add #2 (TEST 40)");
+    is(all[2], f2, "second non-connected FontFace object in the FontFaceSet after duplicate add #2 (TEST 40)");
+
+    style.textContent = "";
+
+    document.fonts.clear();
+
+  }).then(function() {
+
     // (TEST LAST) Test that a pending style sheet load prevents
     // document.fonts.status from being set to "loaded".
 
     // First, add a FontFace to document.fonts that will load soon.
     var face = new FontFace("test", "url(BitPattern.woff?testlast)");
     face.load();
     document.fonts.add(face);