3 <script src=
"../../resources/js-test.js"></script>
21 description('Tests Set operations of FontFaceSet.');
24 nonCssConnectedFace
= new FontFace("MyFont", "local(Arial)", {});
26 shouldBe('document.fonts.size', '3');
30 document
.fonts
.forEach(function(face
, faceAgain
, set) {
31 if (faces
.length
== 0) {
32 callbackArgs
= arguments
;
34 shouldBeTrue('callbackArgs[0] === callbackArgs[1]');
35 shouldBeTrue('callbackArgs[2] === document.fonts');
36 shouldBeTrue('thisValue === thisArg');
40 shouldBe('faces.length', '3');
42 shouldBeEqualToString('faces[0].family', 'Font1');
43 shouldBeEqualToString('faces[1].family', 'Font2');
44 shouldBeEqualToString('faces[2].family', 'Font3');
46 shouldBeTrue('document.fonts.has(faces[0])');
47 shouldBeTrue('document.fonts.has(faces[1])');
48 shouldBeTrue('document.fonts.has(faces[2])');
49 shouldBeFalse('document.fonts.has(nonCssConnectedFace)');
50 shouldThrow('document.fonts.has("Font1")', '"TypeError: Failed to execute \'has\' on \'FontFaceSet\': The argument is not a FontFace."');
52 shouldThrow('document.fonts.add(faces[0])', '"InvalidModificationError: Failed to execute \'add\' on \'FontFaceSet\': Cannot add a CSS-connected FontFace."');
53 shouldThrow('document.fonts.delete(faces[0])', '"InvalidModificationError: Failed to execute \'delete\' on \'FontFaceSet\': Cannot delete a CSS-connected FontFace."');
55 document
.fonts
.add(nonCssConnectedFace
);
56 shouldBe('document.fonts.size', '4');
57 shouldBeTrue('document.fonts.has(nonCssConnectedFace)');
58 document
.fonts
.add(nonCssConnectedFace
);
59 shouldBe('document.fonts.size', '4');
60 document
.fonts
.delete(nonCssConnectedFace
);
61 shouldBe('document.fonts.size', '3');
62 shouldBeFalse('document.fonts.has(nonCssConnectedFace)');
63 document
.fonts
.delete(nonCssConnectedFace
);
64 shouldBe('document.fonts.size', '3');
66 document
.fonts
.add(nonCssConnectedFace
);
67 shouldBe('document.fonts.size', '4');
68 document
.fonts
.clear();
69 shouldBe('document.fonts.size', '3');
75 testFailed('document.fonts does not exist');