Changeset 188844 in webkit
- Timestamp:
- Aug 23, 2015 3:31:32 PM (9 years ago)
- Location:
- trunk/Tools
- Files:
-
- 6 added
- 4 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r188840 r188844 1 2015-08-22 Andy Estes <aestes@apple.com> 2 3 [Cocoa] API tests using the Modern WebKit API should be able to create web process plug-ins 4 https://bugs.webkit.org/show_bug.cgi?id=148317 5 6 Reviewed by Dan Bernstein. 7 8 Added the ability for Modern WebKit API tests to create WKWebProcessPlugIns. A test can create a plug-in by 9 creating a class that conforms to WKWebProcessPlugIn, adding it to the WebProcessPlugIn target, and using the 10 WKWebViewConfiguration returned by +[WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:] 11 when creating WKWebViews. 12 13 Since TestWebKitAPI relies on a bundle parameter to know which test class to instantiate in the plug-in, I also 14 added a new API test for bundle parameters. 15 16 * TestWebKitAPI/Configurations/WebProcessPlugIn.xcconfig: Added. Named the bundle TestWebKitAPI.wkbundle and 17 named its executable TestWebKitAPI.bundle. 18 * TestWebKitAPI/PlatformUtilities.h: Declared TestPlugInClassNameParameter. 19 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added the WebProcessPlugIn target. 20 * TestWebKitAPI/Tests/WebKit2Cocoa/BundleParameters.mm: Added. 21 (TEST): Tested bundle parameters by verifying that parameter changes in the UI process are observed in the bundle. 22 * TestWebKitAPI/Tests/WebKit2Cocoa/BundleParametersPlugIn.mm: Added. 23 (-[BundleParametersPlugIn webProcessPlugIn:didCreateBrowserContextController:]): Started observing changes to a 24 bundle parameter and asked for an initial notification. 25 (-[BundleParametersPlugIn dealloc]): Stopped observing changes to a bundle parameter. 26 (-[BundleParametersPlugIn observeValueForKeyPath:ofObject:change:context:]): When a bundle parameter changes, 27 mirror its value in the main frame's JSContext. 28 * TestWebKitAPI/WKWebViewConfigurationExtras.h: Added. 29 * TestWebKitAPI/WKWebViewConfigurationExtras.mm: Added. 30 (+[WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:]): Created a configuration with 31 TestWebKitAPI's bundle URL and set a bundle parameter indicating the test plug-in's class name. 32 * TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm: Defined TestPlugInClassNameParameter. 33 * TestWebKitAPI/cocoa/WebProcessPlugIn/Info.plist: Added. Set the principal class to WebProcessPlugIn. 34 * TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugIn.mm: Added. 35 (-[WebProcessPlugIn webProcessPlugIn:initializeWithObject:]): Forwarded to a newly-created test class instance. 36 (-[WebProcessPlugIn respondsToSelector:]): Returned YES if the test class instance response. 37 (-[WebProcessPlugIn forwardingTargetForSelector:]): Forwarded unimplemented methods to the test class instance. 38 1 39 2015-08-23 Csaba Osztrogonác <ossy@webkit.org> 2 40 -
trunk/Tools/TestWebKitAPI/PlatformUtilities.h
r177506 r188844 76 76 EXPECT_PRED_FORMAT2(TestWebKitAPI::Util::assertWKStringEqual, expected, actual) 77 77 78 #if WK_API_ENABLED 79 extern NSString * const TestPlugInClassNameParameter; 80 #endif 81 78 82 } // namespace Util 79 83 } // namespace TestWebKitAPI -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r188400 r188844 265 265 9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */; }; 266 266 9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */; }; 267 A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */; }; 268 A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */; }; 269 A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */; }; 270 A13EBBB11B87438000097110 /* BundleParameters.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBAC1B87436F00097110 /* BundleParameters.mm */; }; 271 A14FC5851B89739100D107EB /* WKWebViewConfigurationExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */; }; 267 272 A57A34F216AF6B2B00C2501F /* PageVisibilityStateWithWindowChanges.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */; }; 268 273 A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; }; … … 324 329 remoteGlobalIDString = 7CCE7E8B1A41144E00447C4C; 325 330 remoteInfo = TestWebKitAPILibrary; 331 }; 332 A13EBBB21B87441900097110 /* PBXContainerItemProxy */ = { 333 isa = PBXContainerItemProxy; 334 containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; 335 proxyType = 1; 336 remoteGlobalIDString = A13EBB481B87339E00097110; 337 remoteInfo = WebProcessPlugIn; 326 338 }; 327 339 BC575A95126E74E7006F0F12 /* PBXContainerItemProxy */ = { … … 620 632 9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLCollectionNamedItem.mm; sourceTree = "<group>"; }; 621 633 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLCollectionNamedItem.html; sourceTree = "<group>"; }; 634 A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestWebKitAPI.wkbundle; sourceTree = BUILT_PRODUCTS_DIR; }; 635 A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebProcessPlugIn.xcconfig; sourceTree = "<group>"; }; 636 A13EBB541B8734E000097110 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 637 A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessPlugIn.mm; sourceTree = "<group>"; }; 638 A13EBBAC1B87436F00097110 /* BundleParameters.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleParameters.mm; sourceTree = "<group>"; }; 639 A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleParametersPlugIn.mm; sourceTree = "<group>"; }; 640 A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewConfigurationExtras.mm; sourceTree = "<group>"; }; 641 A14FC5841B89739100D107EB /* WKWebViewConfigurationExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewConfigurationExtras.h; sourceTree = "<group>"; }; 622 642 A1A4FE5D18DD3DB700B5EA8A /* Download.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Download.mm; sourceTree = "<group>"; }; 623 643 A1FDFD2E19C288BB005148A4 /* WKImageCreateCGImageCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKImageCreateCGImageCrash.cpp; sourceTree = "<group>"; }; … … 837 857 isa = PBXGroup; 838 858 children = ( 859 A13EBB441B87332B00097110 /* WebProcessPlugIn */, 839 860 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */, 861 A14FC5841B89739100D107EB /* WKWebViewConfigurationExtras.h */, 862 A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */, 840 863 ); 841 864 name = cocoa; … … 856 879 BC575980126E74AF006F0F12 /* InjectedBundleTestWebKitAPI.bundle */, 857 880 7CCE7E8C1A41144E00447C4C /* libTestWebKitAPI.a */, 881 A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */, 858 882 ); 859 883 name = Products; … … 864 888 children = ( 865 889 7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */, 890 A13EBBAC1B87436F00097110 /* BundleParameters.mm */, 891 A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */, 866 892 A1A4FE5D18DD3DB700B5EA8A /* Download.mm */, 867 893 2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */, … … 932 958 sourceTree = "<group>"; 933 959 }; 960 A13EBB441B87332B00097110 /* WebProcessPlugIn */ = { 961 isa = PBXGroup; 962 children = ( 963 A13EBB541B8734E000097110 /* Info.plist */, 964 A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */, 965 ); 966 name = WebProcessPlugIn; 967 path = cocoa/WebProcessPlugIn; 968 sourceTree = "<group>"; 969 }; 934 970 BC029B1A1486B23800817DA9 /* ns */ = { 935 971 isa = PBXGroup; … … 976 1012 BC90958012554CF900083756 /* TestWebKitAPI.xcconfig */, 977 1013 7CCE7EA31A4115CB00447C4C /* TestWebKitAPILibrary.xcconfig */, 1014 A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */, 978 1015 ); 979 1016 path = Configurations; … … 1379 1416 ); 1380 1417 dependencies = ( 1418 A13EBBB31B87441900097110 /* PBXTargetDependency */, 1381 1419 BC575A96126E74E7006F0F12 /* PBXTargetDependency */, 1382 1420 7CCE7F511A4124DB00447C4C /* PBXTargetDependency */, … … 1387 1425 productReference = 8DD76FA10486AA7600D96B5E /* TestWebKitAPI */; 1388 1426 productType = "com.apple.product-type.tool"; 1427 }; 1428 A13EBB481B87339E00097110 /* WebProcessPlugIn */ = { 1429 isa = PBXNativeTarget; 1430 buildConfigurationList = A13EBB4C1B87339E00097110 /* Build configuration list for PBXNativeTarget "WebProcessPlugIn" */; 1431 buildPhases = ( 1432 A13EBB451B87339E00097110 /* Sources */, 1433 ); 1434 buildRules = ( 1435 ); 1436 dependencies = ( 1437 ); 1438 name = WebProcessPlugIn; 1439 productName = WebProcessPlugIn; 1440 productReference = A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */; 1441 productType = "com.apple.product-type.bundle"; 1389 1442 }; 1390 1443 BC57597F126E74AF006F0F12 /* InjectedBundleTestWebKitAPI */ = { … … 1417 1470 CreatedOnToolsVersion = 6.3; 1418 1471 }; 1472 A13EBB481B87339E00097110 = { 1473 CreatedOnToolsVersion = 7.0; 1474 }; 1419 1475 }; 1420 1476 }; … … 1436 1492 BC57597F126E74AF006F0F12 /* InjectedBundleTestWebKitAPI */, 1437 1493 7CCE7E8B1A41144E00447C4C /* TestWebKitAPILibrary */, 1494 A13EBB481B87339E00097110 /* WebProcessPlugIn */, 1438 1495 ); 1439 1496 }; … … 1531 1588 7CCE7F061A411AE600447C4C /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */, 1532 1589 7CCE7EDF1A411A9200447C4C /* LayoutUnit.cpp in Sources */, 1590 A13EBBB11B87438000097110 /* BundleParameters.mm in Sources */, 1533 1591 7CCE7F381A411B8E00447C4C /* ListHashSet.cpp in Sources */, 1534 1592 37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */, … … 1599 1657 7CCE7ECF1A411A7E00447C4C /* StopLoadingFromDidReceiveResponse.mm in Sources */, 1600 1658 7CCE7F441A411B8E00447C4C /* StringBuilder.cpp in Sources */, 1659 A14FC5851B89739100D107EB /* WKWebViewConfigurationExtras.mm in Sources */, 1601 1660 7CB184C61AA3F2100066EDFD /* ContentExtensions.cpp in Sources */, 1602 1661 7CCE7ED01A411A7E00447C4C /* StringByEvaluatingJavaScriptFromString.mm in Sources */, … … 1671 1730 runOnlyForDeploymentPostprocessing = 0; 1672 1731 }; 1732 A13EBB451B87339E00097110 /* Sources */ = { 1733 isa = PBXSourcesBuildPhase; 1734 buildActionMask = 2147483647; 1735 files = ( 1736 A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */, 1737 A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */, 1738 A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */, 1739 ); 1740 runOnlyForDeploymentPostprocessing = 0; 1741 }; 1673 1742 BC57597D126E74AF006F0F12 /* Sources */ = { 1674 1743 isa = PBXSourcesBuildPhase; … … 1722 1791 targetProxy = 7CCE7F501A4124DB00447C4C /* PBXContainerItemProxy */; 1723 1792 }; 1793 A13EBBB31B87441900097110 /* PBXTargetDependency */ = { 1794 isa = PBXTargetDependency; 1795 target = A13EBB481B87339E00097110 /* WebProcessPlugIn */; 1796 targetProxy = A13EBBB21B87441900097110 /* PBXContainerItemProxy */; 1797 }; 1724 1798 BC575A96126E74E7006F0F12 /* PBXTargetDependency */ = { 1725 1799 isa = PBXTargetDependency; … … 1774 1848 name = Release; 1775 1849 }; 1850 A13EBB4D1B87339E00097110 /* Debug */ = { 1851 isa = XCBuildConfiguration; 1852 baseConfigurationReference = A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */; 1853 buildSettings = { 1854 }; 1855 name = Debug; 1856 }; 1857 A13EBB4E1B87339E00097110 /* Release */ = { 1858 isa = XCBuildConfiguration; 1859 baseConfigurationReference = A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */; 1860 buildSettings = { 1861 }; 1862 name = Release; 1863 }; 1776 1864 BC575984126E74AF006F0F12 /* Debug */ = { 1777 1865 isa = XCBuildConfiguration; … … 1818 1906 defaultConfigurationName = Release; 1819 1907 }; 1908 A13EBB4C1B87339E00097110 /* Build configuration list for PBXNativeTarget "WebProcessPlugIn" */ = { 1909 isa = XCConfigurationList; 1910 buildConfigurations = ( 1911 A13EBB4D1B87339E00097110 /* Debug */, 1912 A13EBB4E1B87339E00097110 /* Release */, 1913 ); 1914 defaultConfigurationIsVisible = 0; 1915 defaultConfigurationName = Release; 1916 }; 1820 1917 BC575986126E74AF006F0F12 /* Build configuration list for PBXNativeTarget "InjectedBundleTestWebKitAPI" */ = { 1821 1918 isa = XCConfigurationList; -
trunk/Tools/TestWebKitAPI/WKWebViewConfigurationExtras.h
r188843 r188844 1 1 /* 2 * Copyright (C) 201 4Apple Inc. All rights reserved.2 * Copyright (C) 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #include "config.h" 27 #include "PlatformUtilities.h" 28 29 #include <wtf/RetainPtr.h> 30 #include <wtf/StdLibExtras.h> 31 32 namespace TestWebKitAPI { 33 namespace Util { 34 35 void run(bool* done) 36 { 37 while (!*done) 38 [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]]; 39 } 40 41 void sleep(double seconds) 42 { 43 usleep(seconds * 1000000); 44 } 45 46 std::string toSTD(NSString *string) 47 { 48 if (!string) 49 return std::string(); 50 51 size_t bufferSize = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; 52 auto buffer = std::make_unique<char[]>(bufferSize); 53 NSUInteger stringLength; 54 [string getBytes:buffer.get() maxLength:bufferSize usedLength:&stringLength encoding:NSUTF8StringEncoding options:0 range:NSMakeRange(0, [string length]) remainingRange:0]; 55 return std::string(buffer.get(), stringLength); 56 } 57 58 } // namespace Util 59 } // namespace TestWebKitAPI 26 @interface WKWebViewConfiguration (TestWebKitAPIExtras) 27 + (instancetype)testwebkitapi_configurationWithTestPlugInClassName:(NSString *)className; 28 @end -
trunk/Tools/TestWebKitAPI/WKWebViewConfigurationExtras.mm
r188843 r188844 1 1 /* 2 * Copyright (C) 201 4Apple Inc. All rights reserved.2 * Copyright (C) 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #i nclude"config.h"27 #i nclude "PlatformUtilities.h"26 #import "config.h" 27 #import "WKWebViewConfigurationExtras.h" 28 28 29 #include <wtf/RetainPtr.h> 30 #include <wtf/StdLibExtras.h> 29 #if WK_API_ENABLED 31 30 32 namespace TestWebKitAPI { 33 namespace Util { 31 #import "PlatformUtilities.h" 32 #import <WebKit/WKProcessPoolPrivate.h> 33 #import <WebKit/WKWebViewConfiguration.h> 34 #import <WebKit/_WKProcessPoolConfiguration.h> 35 #import <wtf/RetainPtr.h> 34 36 35 void run(bool* done) 37 @implementation WKWebViewConfiguration (TestWebKitAPIExtras) 38 39 + (instancetype)testwebkitapi_configurationWithTestPlugInClassName:(NSString *)className 36 40 { 37 while (!*done) 38 [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]]; 41 auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]); 42 [processPoolConfiguration setInjectedBundleURL:[[NSBundle mainBundle] URLForResource:@"TestWebKitAPI" withExtension:@"wkbundle"]]; 43 44 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 45 [processPool _setObject:className forBundleParameter:TestWebKitAPI::Util::TestPlugInClassNameParameter]; 46 47 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 48 [webViewConfiguration setProcessPool:processPool.get()]; 49 50 return webViewConfiguration.autorelease(); 39 51 } 40 52 41 void sleep(double seconds) 42 { 43 usleep(seconds * 1000000); 44 } 53 @end 45 54 46 std::string toSTD(NSString *string) 47 { 48 if (!string) 49 return std::string(); 50 51 size_t bufferSize = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; 52 auto buffer = std::make_unique<char[]>(bufferSize); 53 NSUInteger stringLength; 54 [string getBytes:buffer.get() maxLength:bufferSize usedLength:&stringLength encoding:NSUTF8StringEncoding options:0 range:NSMakeRange(0, [string length]) remainingRange:0]; 55 return std::string(buffer.get(), stringLength); 56 } 57 58 } // namespace Util 59 } // namespace TestWebKitAPI 55 #endif // WK_API_ENABLED -
trunk/Tools/TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm
r177506 r188844 56 56 } 57 57 58 #if WK_API_ENABLED 59 NSString * const TestPlugInClassNameParameter = @"TestPlugInPrincipalClassName"; 60 #endif 58 61 } // namespace Util 59 62 } // namespace TestWebKitAPI
Note: See TracChangeset
for help on using the changeset viewer.