Title: [281951] trunk
Revision
281951
Author
mmaxfi...@apple.com
Date
2021-09-02 13:41:18 -0700 (Thu, 02 Sep 2021)

Log Message

FontFaceSet.add() needs to throw when called on a CSS-connected font
https://bugs.webkit.org/show_bug.cgi?id=229641

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-font-loading/fontfaceset-add-css-connected-expected.txt:

Source/WebCore:

https://drafts.csswg.org/css-font-loading-3/#dom-fontfaceset-add
"2. If font is CSS-connected, throw an InvalidModificationError exception and exit this algorithm immediately."

Test: imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-add-css-connected.html

* css/FontFaceSet.cpp:
(WebCore::FontFaceSet::add): Deleted.
* css/FontFaceSet.h:

LayoutTests:

* fast/text/font-face-set-document-expected.txt:
* fast/text/font-face-set-document.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (281950 => 281951)


--- trunk/LayoutTests/ChangeLog	2021-09-02 20:31:32 UTC (rev 281950)
+++ trunk/LayoutTests/ChangeLog	2021-09-02 20:41:18 UTC (rev 281951)
@@ -1,3 +1,13 @@
+2021-09-02  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        FontFaceSet.add() needs to throw when called on a CSS-connected font
+        https://bugs.webkit.org/show_bug.cgi?id=229641
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/font-face-set-document-expected.txt:
+        * fast/text/font-face-set-document.html:
+
 2021-09-02  Peng Liu  <peng.l...@apple.com>
 
         [MSE][GPUP] SourceBufferPrivateAVFObjC does not work properly when audio and video exchange their track IDs

Modified: trunk/LayoutTests/fast/text/font-face-set-document-expected.txt (281950 => 281951)


--- trunk/LayoutTests/fast/text/font-face-set-document-expected.txt	2021-09-02 20:31:32 UTC (rev 281950)
+++ trunk/LayoutTests/fast/text/font-face-set-document-expected.txt	2021-09-02 20:41:18 UTC (rev 281951)
@@ -4,10 +4,9 @@
 PASS object.done is false
 PASS object.value.family is "MyFont2"
 PASS object.done is true
-PASS fontFaceSet.size is 2
+PASS fontFaceSet.add(document.fonts.keys().next().value) threw exception InvalidModificationError:  The object can not be modified in this way..
+PASS fontFaceSet.size is 1
 PASS object.done is false
-PASS object.value.family is "MyFont1"
-PASS object.done is false
 PASS object.value.family is "MyFont2"
 PASS object.done is true
 PASS document.getElementById("testElement").offsetWidth is not originalWidth

Modified: trunk/LayoutTests/fast/text/font-face-set-document.html (281950 => 281951)


--- trunk/LayoutTests/fast/text/font-face-set-document.html	2021-09-02 20:31:32 UTC (rev 281950)
+++ trunk/LayoutTests/fast/text/font-face-set-document.html	2021-09-02 20:41:18 UTC (rev 281951)
@@ -35,14 +35,11 @@
 
 var fontFaceSet = new FontFaceSet([]);
 fontFaceSet.add(new FontFace("MyFont2", "url(\"asdf\")", {}));
-fontFaceSet.add(document.fonts.keys().next().value);
-shouldBe("fontFaceSet.size", "2");
+shouldThrow("fontFaceSet.add(document.fonts.keys().next().value)");
+shouldBe("fontFaceSet.size", "1");
 iterator = fontFaceSet.keys();
 object = iterator.next();
 shouldBeFalse("object.done");
-shouldBeEqualToString("object.value.family", "MyFont1");
-object = iterator.next();
-shouldBeFalse("object.done");
 shouldBeEqualToString("object.value.family", "MyFont2");
 object = iterator.next();
 shouldBeTrue("object.done");
@@ -101,4 +98,4 @@
 </script>
 <script src=""
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (281950 => 281951)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-02 20:31:32 UTC (rev 281950)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-02 20:41:18 UTC (rev 281951)
@@ -1,3 +1,12 @@
+2021-09-02  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        FontFaceSet.add() needs to throw when called on a CSS-connected font
+        https://bugs.webkit.org/show_bug.cgi?id=229641
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/css/css-font-loading/fontfaceset-add-css-connected-expected.txt:
+
 2021-09-02  Chris Dumez  <cdu...@apple.com>
 
         [COOP] html/cross-origin-opener-policy/coop-navigate-same-origin-csp-sandbox.html WPT test is failing

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-add-css-connected-expected.txt (281950 => 281951)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-add-css-connected-expected.txt	2021-09-02 20:31:32 UTC (rev 281950)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-add-css-connected-expected.txt	2021-09-02 20:41:18 UTC (rev 281951)
@@ -1,3 +1,3 @@
 
-FAIL fontfaceset-add-css-connected assert_throws_dom: function "function () { fontFaceSet.add(font); }" did not throw
+PASS fontfaceset-add-css-connected
 

Modified: trunk/Source/WebCore/ChangeLog (281950 => 281951)


--- trunk/Source/WebCore/ChangeLog	2021-09-02 20:31:32 UTC (rev 281950)
+++ trunk/Source/WebCore/ChangeLog	2021-09-02 20:41:18 UTC (rev 281951)
@@ -1,3 +1,19 @@
+2021-09-02  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        FontFaceSet.add() needs to throw when called on a CSS-connected font
+        https://bugs.webkit.org/show_bug.cgi?id=229641
+
+        Reviewed by Simon Fraser.
+
+        https://drafts.csswg.org/css-font-loading-3/#dom-fontfaceset-add
+        "2. If font is CSS-connected, throw an InvalidModificationError exception and exit this algorithm immediately."
+
+        Test: imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-add-css-connected.html
+
+        * css/FontFaceSet.cpp:
+        (WebCore::FontFaceSet::add): Deleted.
+        * css/FontFaceSet.h:
+
 2021-09-02  David Kilzer  <ddkil...@apple.com>
 
         Leak of VTImageRotationSessionRef (176 bytes) in com.apple.WebKit.GPU.Development process

Modified: trunk/Source/WebCore/css/FontFaceSet.cpp (281950 => 281951)


--- trunk/Source/WebCore/css/FontFaceSet.cpp	2021-09-02 20:31:32 UTC (rev 281950)
+++ trunk/Source/WebCore/css/FontFaceSet.cpp	2021-09-02 20:41:18 UTC (rev 281951)
@@ -117,10 +117,13 @@
     return protect->faceCount();
 }
 
-FontFaceSet& FontFaceSet::add(FontFace& face)
+ExceptionOr<FontFaceSet&> FontFaceSet::add(FontFace& face)
 {
-    if (!m_backing->hasFace(face.backing()))
-        m_backing->add(face.backing());
+    if (m_backing->hasFace(face.backing()))
+        return *this;
+    if (face.backing().cssConnection())
+        return Exception(InvalidModificationError);
+    m_backing->add(face.backing());
     return *this;
 }
 

Modified: trunk/Source/WebCore/css/FontFaceSet.h (281950 => 281951)


--- trunk/Source/WebCore/css/FontFaceSet.h	2021-09-02 20:31:32 UTC (rev 281950)
+++ trunk/Source/WebCore/css/FontFaceSet.h	2021-09-02 20:41:18 UTC (rev 281951)
@@ -47,7 +47,7 @@
 
     bool has(FontFace&) const;
     size_t size();
-    FontFaceSet& add(FontFace&);
+    ExceptionOr<FontFaceSet&> add(FontFace&);
     bool remove(FontFace&);
     void clear();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to