Changeset 248344 in webkit
- Timestamp:
- Aug 6, 2019, 11:52:16 PM (7 years ago)
- Location:
- branches/safari-608.1-branch
- Files:
-
- 3 added
- 10 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts-expected.txt (added)
-
LayoutTests/editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/editing/EditingStyle.cpp (modified) (4 diffs)
-
Source/WebCore/platform/graphics/FontCache.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (modified) (3 diffs)
-
Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/win/FontCacheWin.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/cocoa-writer-markup-with-system-fonts.html (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-608.1-branch/LayoutTests/ChangeLog
r248341 r248344 1 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r247720. rdar://problem/54017869 4 5 WebKit should strip away system font names from the pasted content 6 https://bugs.webkit.org/show_bug.cgi?id=199975 7 <rdar://problem/53336353> 8 9 Reviewed by Darin Adler. 10 11 Source/WebCore: 12 13 Cocoa HTML Writer sometimes generate system font names such as ".AppleSystemUIFont", ".SFUI-Regular", and ".SF UI Mono". 14 We need to strip away these font names upon paste to avoid these font names falling back to Times New Roman. 15 16 Added the code to strip these font names away in EditingStyle::mergeStyleFromRulesForSerialization, which is used by 17 StylizedMarkupAccumulator to generate HTML during copy. This works because WebContentReader::readWebArchive invokes 18 sanitizeMarkupWithArchive which inserts the pasteboard content into a temporary document then re-serializes back to HTML 19 using StylizedMarkupAccumulator before the actual pasting happens. 20 21 This approach has a few benefits over stripping away these font names in ReplaceSelectionCommand: 22 23 1. It would only affect clients that opts-in to copy & paste sanitization. e.g. it won't affect legacy WebKit clients 24 and those that opt out of pasteboard content sanitization. 25 26 2. It preserves font names such as ".SF Blah" that a website may insert as some kind of house keeping purposes if ever. 27 While we don't have any evidence that there is any such a website but it's a real risk nonetheless. The copy side fix would 28 only affect cross-site and cross-app pasting, which is rare and less likely to affect real user scenarios. 29 30 3. It avoids exposing bogus .Apple* or .SF* font names to websites that directly use event.clipboardData.getData. 31 Indeed stripping away bogus markup like this is one of the key features / benefit of using copy & paste sanitization. 32 33 Test: editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts.html 34 35 * editing/EditingStyle.cpp: 36 (WebCore::usesForbiddenSystemFontAsOnlyFontFamilyName): Added. 37 (WebCore::EditingStyle::mergeStyleFromRulesForSerialization): Added the code to remove font-family property when needed. 38 * platform/graphics/FontCache.h: 39 * platform/graphics/cocoa/FontCacheCoreText.cpp: 40 (WebCore::isSystemFont): Moved. 41 (WebCore::FontCache::isSystemFontForbiddenForEditing): Added. 42 * platform/graphics/freetype/FontCacheFreeType.cpp: 43 (WebCore::FontCache::isSystemFontForbiddenForEditing): Added. Always returns false. 44 * platform/graphics/win/FontCacheWin.cpp: 45 (WebCore::FontCache::isSystemFontForbiddenForEditing): Ditto. 46 47 Tools: 48 49 Added a test to strip away system font names such as ".AppleSystemUIFont", ".SFUI-Regular", and ".SF UI Mono". 50 51 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 52 * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm: 53 * TestWebKitAPI/Tests/WebKitCocoa/cocoa-writer-markup-with-system-fonts.html: Added. 54 55 LayoutTests: 56 57 Added a test for ClipboardData.getData returning the original markup and execCommand('insertHTML', ~) 58 not stripping away system font names. 59 60 * editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts-expected.txt: Added. 61 * editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts.html: Added. 62 63 64 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247720 268f45cc-cd09-0410-ab3c-d52691b4dbfc 65 66 2019-07-23 Ryosuke Niwa <rniwa@webkit.org> 67 68 WebKit should strip away system font names from the pasted content 69 https://bugs.webkit.org/show_bug.cgi?id=199975 70 <rdar://problem/53336353> 71 72 Reviewed by Darin Adler. 73 74 Added a test for ClipboardData.getData returning the original markup and execCommand('insertHTML', ~) 75 not stripping away system font names. 76 77 * editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts-expected.txt: Added. 78 * editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts.html: Added. 79 1 80 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 81 -
branches/safari-608.1-branch/Source/WebCore/ChangeLog
r248298 r248344 1 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r247720. rdar://problem/54017869 4 5 WebKit should strip away system font names from the pasted content 6 https://bugs.webkit.org/show_bug.cgi?id=199975 7 <rdar://problem/53336353> 8 9 Reviewed by Darin Adler. 10 11 Source/WebCore: 12 13 Cocoa HTML Writer sometimes generate system font names such as ".AppleSystemUIFont", ".SFUI-Regular", and ".SF UI Mono". 14 We need to strip away these font names upon paste to avoid these font names falling back to Times New Roman. 15 16 Added the code to strip these font names away in EditingStyle::mergeStyleFromRulesForSerialization, which is used by 17 StylizedMarkupAccumulator to generate HTML during copy. This works because WebContentReader::readWebArchive invokes 18 sanitizeMarkupWithArchive which inserts the pasteboard content into a temporary document then re-serializes back to HTML 19 using StylizedMarkupAccumulator before the actual pasting happens. 20 21 This approach has a few benefits over stripping away these font names in ReplaceSelectionCommand: 22 23 1. It would only affect clients that opts-in to copy & paste sanitization. e.g. it won't affect legacy WebKit clients 24 and those that opt out of pasteboard content sanitization. 25 26 2. It preserves font names such as ".SF Blah" that a website may insert as some kind of house keeping purposes if ever. 27 While we don't have any evidence that there is any such a website but it's a real risk nonetheless. The copy side fix would 28 only affect cross-site and cross-app pasting, which is rare and less likely to affect real user scenarios. 29 30 3. It avoids exposing bogus .Apple* or .SF* font names to websites that directly use event.clipboardData.getData. 31 Indeed stripping away bogus markup like this is one of the key features / benefit of using copy & paste sanitization. 32 33 Test: editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts.html 34 35 * editing/EditingStyle.cpp: 36 (WebCore::usesForbiddenSystemFontAsOnlyFontFamilyName): Added. 37 (WebCore::EditingStyle::mergeStyleFromRulesForSerialization): Added the code to remove font-family property when needed. 38 * platform/graphics/FontCache.h: 39 * platform/graphics/cocoa/FontCacheCoreText.cpp: 40 (WebCore::isSystemFont): Moved. 41 (WebCore::FontCache::isSystemFontForbiddenForEditing): Added. 42 * platform/graphics/freetype/FontCacheFreeType.cpp: 43 (WebCore::FontCache::isSystemFontForbiddenForEditing): Added. Always returns false. 44 * platform/graphics/win/FontCacheWin.cpp: 45 (WebCore::FontCache::isSystemFontForbiddenForEditing): Ditto. 46 47 Tools: 48 49 Added a test to strip away system font names such as ".AppleSystemUIFont", ".SFUI-Regular", and ".SF UI Mono". 50 51 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 52 * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm: 53 * TestWebKitAPI/Tests/WebKitCocoa/cocoa-writer-markup-with-system-fonts.html: Added. 54 55 LayoutTests: 56 57 Added a test for ClipboardData.getData returning the original markup and execCommand('insertHTML', ~) 58 not stripping away system font names. 59 60 * editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts-expected.txt: Added. 61 * editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts.html: Added. 62 63 64 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247720 268f45cc-cd09-0410-ab3c-d52691b4dbfc 65 66 2019-07-23 Ryosuke Niwa <rniwa@webkit.org> 67 68 WebKit should strip away system font names from the pasted content 69 https://bugs.webkit.org/show_bug.cgi?id=199975 70 <rdar://problem/53336353> 71 72 Reviewed by Darin Adler. 73 74 Cocoa HTML Writer sometimes generate system font names such as ".AppleSystemUIFont", ".SFUI-Regular", and ".SF UI Mono". 75 We need to strip away these font names upon paste to avoid these font names falling back to Times New Roman. 76 77 Added the code to strip these font names away in EditingStyle::mergeStyleFromRulesForSerialization, which is used by 78 StylizedMarkupAccumulator to generate HTML during copy. This works because WebContentReader::readWebArchive invokes 79 sanitizeMarkupWithArchive which inserts the pasteboard content into a temporary document then re-serializes back to HTML 80 using StylizedMarkupAccumulator before the actual pasting happens. 81 82 This approach has a few benefits over stripping away these font names in ReplaceSelectionCommand: 83 84 1. It would only affect clients that opts-in to copy & paste sanitization. e.g. it won't affect legacy WebKit clients 85 and those that opt out of pasteboard content sanitization. 86 87 2. It preserves font names such as ".SF Blah" that a website may insert as some kind of house keeping purposes if ever. 88 While we don't have any evidence that there is any such a website but it's a real risk nonetheless. The copy side fix would 89 only affect cross-site and cross-app pasting, which is rare and less likely to affect real user scenarios. 90 91 3. It avoids exposing bogus .Apple* or .SF* font names to websites that directly use event.clipboardData.getData. 92 Indeed stripping away bogus markup like this is one of the key features / benefit of using copy & paste sanitization. 93 94 Test: editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts.html 95 96 * editing/EditingStyle.cpp: 97 (WebCore::usesForbiddenSystemFontAsOnlyFontFamilyName): Added. 98 (WebCore::EditingStyle::mergeStyleFromRulesForSerialization): Added the code to remove font-family property when needed. 99 * platform/graphics/FontCache.h: 100 * platform/graphics/cocoa/FontCacheCoreText.cpp: 101 (WebCore::isSystemFont): Moved. 102 (WebCore::FontCache::isSystemFontForbiddenForEditing): Added. 103 * platform/graphics/freetype/FontCacheFreeType.cpp: 104 (WebCore::FontCache::isSystemFontForbiddenForEditing): Added. Always returns false. 105 * platform/graphics/win/FontCacheWin.cpp: 106 (WebCore::FontCache::isSystemFontForbiddenForEditing): Ditto. 107 1 108 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 109 -
branches/safari-608.1-branch/Source/WebCore/editing/EditingStyle.cpp
r246490 r248344 30 30 #include "ApplyStyleCommand.h" 31 31 #include "CSSComputedStyleDeclaration.h" 32 #include "CSSFontFamily.h" 32 33 #include "CSSFontStyleValue.h" 33 34 #include "CSSParser.h" … … 38 39 #include "Editing.h" 39 40 #include "Editor.h" 41 #include "FontCache.h" 42 #include "FontCascade.h" 40 43 #include "Frame.h" 41 44 #include "HTMLFontElement.h" … … 1280 1283 } 1281 1284 1285 static bool usesForbiddenSystemFontAsOnlyFontFamilyName(CSSValue& value) 1286 { 1287 if (!is<CSSValueList>(value) || downcast<CSSValueList>(value).length() != 1) 1288 return false; 1289 1290 auto& item = *downcast<CSSValueList>(value).item(0); 1291 if (!is<CSSPrimitiveValue>(item)) 1292 return false; 1293 1294 auto& primitiveValue = downcast<CSSPrimitiveValue>(item); 1295 if (!primitiveValue.isFontFamily()) 1296 return false; 1297 return FontCache::isSystemFontForbiddenForEditing(primitiveValue.fontFamily().familyName); 1298 } 1299 1282 1300 void EditingStyle::mergeStyleFromRulesForSerialization(StyledElement& element) 1283 1301 { … … 1290 1308 ComputedStyleExtractor computedStyle(&element); 1291 1309 1310 bool shouldRemoveFontFamily = false; 1292 1311 { 1293 1312 unsigned propertyCount = m_mutableStyle->propertyCount(); 1294 1313 for (unsigned i = 0; i < propertyCount; ++i) { 1295 1314 StyleProperties::PropertyReference property = m_mutableStyle->propertyAt(i); 1296 CSSValue* value = property.value(); 1297 if (!is<CSSPrimitiveValue>(*value)) 1315 CSSValue& value = *property.value(); 1316 if (property.id() == CSSPropertyFontFamily && usesForbiddenSystemFontAsOnlyFontFamilyName(value)) { 1317 shouldRemoveFontFamily = true; 1298 1318 continue; 1299 if (downcast<CSSPrimitiveValue>(*value).isPercentage()) { 1319 } 1320 if (!is<CSSPrimitiveValue>(value)) 1321 continue; 1322 if (downcast<CSSPrimitiveValue>(value).isPercentage()) { 1300 1323 if (auto computedPropertyValue = computedStyle.propertyValue(property.id())) 1301 1324 fromComputedStyle->addParsedProperty(CSSProperty(property.id(), WTFMove(computedPropertyValue))); 1302 1325 } 1303 1326 } 1327 } 1328 if (shouldRemoveFontFamily) { 1329 m_mutableStyle->removeProperty(CSSPropertyFontFamily); 1330 fromComputedStyle->removeProperty(CSSPropertyFontFamily); 1304 1331 } 1305 1332 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get()); -
branches/safari-608.1-branch/Source/WebCore/platform/graphics/FontCache.h
r247574 r248344 198 198 void platformInit(); 199 199 200 static bool isSystemFontForbiddenForEditing(const String&); 201 200 202 #if PLATFORM(COCOA) 201 203 WEBCORE_EXPORT static void setFontWhitelist(const Vector<String>&); -
branches/safari-608.1-branch/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r247632 r248344 784 784 } 785 785 786 static inline bool isSystemFont(const String& family) 787 { 788 // AtomString's operator[] handles out-of-bounds by returning 0. 789 return family[0] == '.'; 790 } 791 792 bool FontCache::isSystemFontForbiddenForEditing(const String& fontFamily) 793 { 794 return isSystemFont(fontFamily); 795 } 796 786 797 static CTFontSymbolicTraits computeTraits(const FontDescription& fontDescription) 787 798 { … … 829 840 for (auto& item : inputWhitelist) 830 841 whitelist.add(item); 831 }832 833 static inline bool isSystemFont(const AtomString& family)834 {835 // AtomString's operator[] handles out-of-bounds by returning 0.836 return family[0] == '.';837 842 } 838 843 … … 1184 1189 { 1185 1190 const auto& whitelist = fontWhitelist(); 1186 if (!isSystemFont(family ) && whitelist.size() && !whitelist.contains(family))1191 if (!isSystemFont(family.string()) && whitelist.size() && !whitelist.contains(family)) 1187 1192 return { nullptr }; 1188 1193 -
branches/safari-608.1-branch/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
r246490 r248344 187 187 } 188 188 189 bool FontCache::isSystemFontForbiddenForEditing(const String&) 190 { 191 return false; 192 } 193 189 194 Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescription) 190 195 { -
branches/safari-608.1-branch/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
r246490 r248344 329 329 } 330 330 331 bool FontCache::isSystemFontForbiddenForEditing(const String&) 332 { 333 return false; 334 } 335 331 336 RefPtr<Font> FontCache::fontFromDescriptionAndLogFont(const FontDescription& fontDescription, const LOGFONT& font, AtomString& outFontFamilyName) 332 337 { -
branches/safari-608.1-branch/Tools/ChangeLog
r248343 r248344 1 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 3 Cherry-pick r247720. rdar://problem/54017869 4 5 WebKit should strip away system font names from the pasted content 6 https://bugs.webkit.org/show_bug.cgi?id=199975 7 <rdar://problem/53336353> 8 9 Reviewed by Darin Adler. 10 11 Source/WebCore: 12 13 Cocoa HTML Writer sometimes generate system font names such as ".AppleSystemUIFont", ".SFUI-Regular", and ".SF UI Mono". 14 We need to strip away these font names upon paste to avoid these font names falling back to Times New Roman. 15 16 Added the code to strip these font names away in EditingStyle::mergeStyleFromRulesForSerialization, which is used by 17 StylizedMarkupAccumulator to generate HTML during copy. This works because WebContentReader::readWebArchive invokes 18 sanitizeMarkupWithArchive which inserts the pasteboard content into a temporary document then re-serializes back to HTML 19 using StylizedMarkupAccumulator before the actual pasting happens. 20 21 This approach has a few benefits over stripping away these font names in ReplaceSelectionCommand: 22 23 1. It would only affect clients that opts-in to copy & paste sanitization. e.g. it won't affect legacy WebKit clients 24 and those that opt out of pasteboard content sanitization. 25 26 2. It preserves font names such as ".SF Blah" that a website may insert as some kind of house keeping purposes if ever. 27 While we don't have any evidence that there is any such a website but it's a real risk nonetheless. The copy side fix would 28 only affect cross-site and cross-app pasting, which is rare and less likely to affect real user scenarios. 29 30 3. It avoids exposing bogus .Apple* or .SF* font names to websites that directly use event.clipboardData.getData. 31 Indeed stripping away bogus markup like this is one of the key features / benefit of using copy & paste sanitization. 32 33 Test: editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts.html 34 35 * editing/EditingStyle.cpp: 36 (WebCore::usesForbiddenSystemFontAsOnlyFontFamilyName): Added. 37 (WebCore::EditingStyle::mergeStyleFromRulesForSerialization): Added the code to remove font-family property when needed. 38 * platform/graphics/FontCache.h: 39 * platform/graphics/cocoa/FontCacheCoreText.cpp: 40 (WebCore::isSystemFont): Moved. 41 (WebCore::FontCache::isSystemFontForbiddenForEditing): Added. 42 * platform/graphics/freetype/FontCacheFreeType.cpp: 43 (WebCore::FontCache::isSystemFontForbiddenForEditing): Added. Always returns false. 44 * platform/graphics/win/FontCacheWin.cpp: 45 (WebCore::FontCache::isSystemFontForbiddenForEditing): Ditto. 46 47 Tools: 48 49 Added a test to strip away system font names such as ".AppleSystemUIFont", ".SFUI-Regular", and ".SF UI Mono". 50 51 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 52 * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm: 53 * TestWebKitAPI/Tests/WebKitCocoa/cocoa-writer-markup-with-system-fonts.html: Added. 54 55 LayoutTests: 56 57 Added a test for ClipboardData.getData returning the original markup and execCommand('insertHTML', ~) 58 not stripping away system font names. 59 60 * editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts-expected.txt: Added. 61 * editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts.html: Added. 62 63 64 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247720 268f45cc-cd09-0410-ab3c-d52691b4dbfc 65 66 2019-07-23 Ryosuke Niwa <rniwa@webkit.org> 67 68 WebKit should strip away system font names from the pasted content 69 https://bugs.webkit.org/show_bug.cgi?id=199975 70 <rdar://problem/53336353> 71 72 Reviewed by Darin Adler. 73 74 Added a test to strip away system font names such as ".AppleSystemUIFont", ".SFUI-Regular", and ".SF UI Mono". 75 76 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 77 * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm: 78 * TestWebKitAPI/Tests/WebKitCocoa/cocoa-writer-markup-with-system-fonts.html: Added. 79 1 80 2019-08-06 Kocsen Chung <kocsen_chung@apple.com> 2 81 -
branches/safari-608.1-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r248109 r248344 705 705 9B7D740F1F8378770006C432 /* paste-rtfd.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B7D740E1F8377E60006C432 /* paste-rtfd.html */; }; 706 706 9BAD7F3E22690F2000F8DA66 /* DeallocWebViewInEventListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9BAD7F3D22690F1400F8DA66 /* DeallocWebViewInEventListener.mm */; }; 707 9BAE177B22E2BBFB00DF3098 /* cocoa-writer-markup-with-system-fonts.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9BAE177A22E2BB6B00DF3098 /* cocoa-writer-markup-with-system-fonts.html */; }; 707 708 9BCB7C2820130600003E7C0C /* PasteHTML.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9BCB7C2620130600003E7C0C /* PasteHTML.mm */; }; 708 709 9BCD411A206DBCA3001D71BE /* mso-list-on-h4.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9BCD4119206D5ED7001D71BE /* mso-list-on-h4.html */; }; … … 1073 1074 dstSubfolderSpec = 7; 1074 1075 files = ( 1076 9BAE177B22E2BBFB00DF3098 /* cocoa-writer-markup-with-system-fonts.html in Copy Resources */, 1075 1077 55A817FF2181021A0004A39A /* 100x100-red.tga in Copy Resources */, 1076 1078 1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */, … … 2031 2033 9B7D740E1F8377E60006C432 /* paste-rtfd.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "paste-rtfd.html"; sourceTree = "<group>"; }; 2032 2034 9BAD7F3D22690F1400F8DA66 /* DeallocWebViewInEventListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeallocWebViewInEventListener.mm; sourceTree = "<group>"; }; 2035 9BAE177A22E2BB6B00DF3098 /* cocoa-writer-markup-with-system-fonts.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "cocoa-writer-markup-with-system-fonts.html"; sourceTree = "<group>"; }; 2033 2036 9BCB7C2620130600003E7C0C /* PasteHTML.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PasteHTML.mm; sourceTree = "<group>"; }; 2034 2037 9BCD4119206D5ED7001D71BE /* mso-list-on-h4.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "mso-list-on-h4.html"; sourceTree = "<group>"; }; … … 3255 3258 5120C83B1E674E350025B250 /* WebsiteDataStoreCustomPaths.html */, 3256 3259 2E131C171D83A97E001BA36C /* wide-autoplaying-video-with-audio.html */, 3260 9BAE177A22E2BB6B00DF3098 /* cocoa-writer-markup-with-system-fonts.html */, 3257 3261 ); 3258 3262 name = Resources; -
branches/safari-608.1-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm
r242339 r248344 328 328 } 329 329 330 TEST(PasteHTML, StripsSystemFontNames) 331 { 332 writeHTMLToPasteboard([NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cocoa-writer-markup-with-system-fonts" ofType:@"html" inDirectory:@"TestWebKitAPI.resources"] encoding:NSUTF8StringEncoding error:NULL]); 333 334 auto webView = createWebViewWithCustomPasteboardDataSetting(true); 335 [webView synchronouslyLoadTestPageNamed:@"paste-rtfd"]; 336 [webView paste:nil]; 337 338 EXPECT_WK_STREQ("[\"text/html\"]", [webView stringByEvaluatingJavaScript:@"JSON.stringify(clipboardData.types)"]); 339 [webView stringByEvaluatingJavaScript:@"window.htmlInDataTransfer = clipboardData.values[0]"]; 340 [webView stringByEvaluatingJavaScript:@"window.pastedHTML = editor.innerHTML"]; 341 342 EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"pastedHTML.includes('Hello Cocoa')"].boolValue); 343 EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"pastedHTML.includes('font-weight: bold')"].boolValue); 344 EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!pastedHTML.includes('.AppleSystemUIFont')"].boolValue); 345 EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!pastedHTML.includes('.SFUI')"].boolValue); 346 EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!pastedHTML.includes('.SF')"].boolValue); 347 348 EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"htmlInDataTransfer.includes('Hello Cocoa')"].boolValue); 349 EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"htmlInDataTransfer.includes('font-weight: bold')"].boolValue); 350 EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!htmlInDataTransfer.includes('.AppleSystemUIFont')"].boolValue); 351 EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!htmlInDataTransfer.includes('.SFUI')"].boolValue); 352 EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!htmlInDataTransfer.includes('.SF')"].boolValue); 353 354 EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"getComputedStyle(document.querySelector('.s2')).fontFamily"], 355 [webView stringByEvaluatingJavaScript:@"getComputedStyle(document.body).fontFamily"]); 356 EXPECT_WK_STREQ([webView stringByEvaluatingJavaScript:@"getComputedStyle(document.querySelector('.s4')).fontFamily"], 357 [webView stringByEvaluatingJavaScript:@"getComputedStyle(document.body).fontFamily"]); 358 } 330 359 331 360 #endif // PLATFORM(COCOA)
Note:
See TracChangeset
for help on using the changeset viewer.