Changeset 268239 in webkit
- Timestamp:
- Oct 8, 2020, 5:48:35 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r268170 r268239 1 2020-10-08 Ryosuke Niwa <rniwa@webkit.org> 2 3 Make it possible to send an arbitrary IPC message from JavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=217423 5 <rdar://problem/69969351> 6 7 Reviewed by Geoffrey Garen. 8 9 Added a helper function to get uint64_t out of BigInt. 10 11 * runtime/JSBigInt.cpp: 12 (JSC::JSBigInt::toUint64Heap): Added. 13 * runtime/JSBigInt.h: 14 (JSC::JSBigInt::toUint64): Added. 15 1 16 2020-10-07 Yusuke Suzuki <ysuzuki@apple.com> 2 17 -
trunk/Source/JavaScriptCore/runtime/JSBigInt.cpp
r267373 r268239 3050 3050 #endif 3051 3051 3052 Optional<uint64_t> JSBigInt::toUint64Heap(JSBigInt* bigInt) 3053 { 3054 auto length = bigInt->length(); 3055 if (!length) 3056 return 0; 3057 if (bigInt->sign()) 3058 return WTF::nullopt; 3059 3060 static_assert(sizeof(uint64_t) == sizeof(Digit) || sizeof(uint64_t) == sizeof(Digit) * 2, "Digit must be either 32-bit or 64-bit"); 3061 if (sizeof(uint64_t) == sizeof(Digit)) { 3062 if (length > 1) 3063 return WTF::nullopt; 3064 return bigInt->digit(0); 3065 } 3066 3067 if (length > 2) 3068 return WTF::nullopt; 3069 uint64_t result = bigInt->digit(0); 3070 if (length == 1) 3071 result += static_cast<uint64_t>(bigInt->digit(0)) << 32; 3072 return result; 3073 } 3074 3052 3075 static ALWAYS_INLINE unsigned computeHash(JSBigInt::Digit* digits, unsigned length, bool sign) 3053 3076 { -
trunk/Source/JavaScriptCore/runtime/JSBigInt.h
r267373 r268239 74 74 static JSBigInt* createFrom(JSGlobalObject*, uint32_t value); 75 75 static JSBigInt* createFrom(JSGlobalObject*, int64_t value); 76 static JSBigInt* createFrom(JSGlobalObject*, uint64_t value);76 JS_EXPORT_PRIVATE static JSBigInt* createFrom(JSGlobalObject*, uint64_t value); 77 77 static JSBigInt* createFrom(JSGlobalObject*, bool value); 78 78 static JSBigInt* createFrom(JSGlobalObject*, double value); … … 422 422 static JSValue asUintN(JSGlobalObject*, uint64_t numberOfBits, int32_t bigIntAsInt32); 423 423 #endif 424 425 static Optional<uint64_t> toUint64(JSValue bigInt) 426 { 427 ASSERT(bigInt.isBigInt()); 428 #if USE(BIGINT32) 429 if (bigInt.isBigInt32()) { 430 auto value = bigInt.bigInt32AsInt32(); 431 if (value < 0) 432 return WTF::nullopt; 433 return value; 434 } 435 #endif 436 return toUint64Heap(jsCast<JSBigInt*>(bigInt)); 437 } 424 438 425 439 Digit digit(unsigned); … … 577 591 static ImplResult truncateAndSubFromPowerOfTwo(JSGlobalObject*, int32_t, BigIntImpl, bool resultSign); 578 592 593 JS_EXPORT_PRIVATE static Optional<uint64_t> toUint64Heap(JSBigInt*); 594 579 595 inline static size_t offsetOfData() 580 596 { -
trunk/Source/WTF/ChangeLog
r268214 r268239 1 2020-10-08 Ryosuke Niwa <rniwa@webkit.org> 2 3 Make it possible to send an arbitrary IPC message from JavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=217423 5 <rdar://problem/69969351> 6 7 Reviewed by Geoffrey Garen. 8 9 Added a compile time flag (ENABLE_IPC_TESTING_API) and a runtime flag (IPCTestingAPIEnabled) 10 for the JavaScript API to test IPC. 11 12 * Scripts/GeneratePreferences.rb: 13 (Preference::nameLower): Keep IPC uppercase. 14 * Scripts/Preferences/WebPreferencesInternal.yaml: Added IPCTestingAPIEnabled. 15 * wtf/PlatformEnable.h: Added ENABLE_IPC_TESTING_API. 16 1 17 2020-10-08 Alex Christensen <achristensen@webkit.org> 2 18 -
trunk/Source/WTF/Scripts/GeneratePreferences.rb
r268163 r268239 121 121 elsif @name.start_with?("VP") 122 122 @name[0..1].downcase + @name[2..@name.length] 123 elsif @name.start_with?("CSS", " XSS", "FTP", "DOM", "DNS", "PDF", "ICE")123 elsif @name.start_with?("CSS", "DOM", "DNS", "FTP", "ICE", "IPC", "PDF", "XSS") 124 124 @name[0..2].downcase + @name[3..@name.length] 125 125 elsif @name.start_with?("HTTP") -
trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml
r268123 r268239 280 280 default: true 281 281 282 IPCTestingAPIEnabled: 283 type: bool 284 humanReadableName: "IPC Testing API" 285 humanReadableDescription: "Enable IPC Testing API for JavaScript" 286 webcoreBinding: none 287 condition: ENABLE(IPC_TESTING_API) 288 exposed: [ WebKit ] 289 defaultValue: 290 WebKit: 291 default: false 292 282 293 InputTypeColorEnabled: 283 294 type: bool -
trunk/Source/WTF/wtf/PlatformEnable.h
r267938 r268239 316 316 #endif 317 317 318 #if !defined(ENABLE_IPC_TESTING_API) 319 /* Enable IPC testing on all ASAN builds and debug builds. */ 320 #if ASAN_ENABLED || !defined(NDEBUG) 321 #define ENABLE_IPC_TESTING_API 1 322 #endif 323 #endif 324 318 325 #if ENABLE(INPUT_TYPE_DATE) || ENABLE(INPUT_TYPE_DATETIMELOCAL) || ENABLE(INPUT_TYPE_MONTH) || ENABLE(INPUT_TYPE_TIME) || ENABLE(INPUT_TYPE_WEEK) 319 326 #if !defined(ENABLE_DATE_AND_TIME_INPUT_TYPES) -
trunk/Source/WebKit/ChangeLog
r268231 r268239 1 2020-10-08 Ryosuke Niwa <rniwa@webkit.org> 2 3 Make it possible to send an arbitrary IPC message from JavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=217423 5 <rdar://problem/69969351> 6 7 Reviewed by Geoffrey Garen. 8 9 This patch introduces the JavaScript API (window.IPC) to send IPC out of WebContent process. 10 The feature is compiled in under ASAN and Debug builds and can be enabled at runtime. 11 12 window.IPC has two methods: sendMessage and sendSyncMessage which sends an async and sync IPC respectively. 13 It takes the destination process name (UI, GPU, or Networking), the destination ID (e.g. WebPageProxy ID), 14 message ID, timeout for sendSyncMessage, and optionally IPC message arguments. The message arguments can be 15 passed in as a TypedArray or ArrayBuffer, or a JavaScript array that recursively describes encoded objects. 16 17 Each object can be either a TypedArray or ArrayBuffer, which will be treated as encoded message, an array 18 which will be encoded as a Vector with each item within the array encoded recursively, or a dictionary which 19 describes a specific type. 20 21 When a specific type is described via a dictionary, "value" is encoed based on "type" as follows: 22 - When "type" is "String", "value" is encoded as a WTF::String, treating null or undefined as a null string. 23 - When "type" is "bool", "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", 24 or "uint64_t", "value" (which can be BigInt or a number) is encoded as the respective C++ type. 25 - When "type" is "RGBA", "value" is used as PackedColor::RGBA to construct WebCore::Color to be encoded. 26 - When "type" is "IntRect" or "FloatRect", "x", "y", "width", and "height" are treated as respective values 27 of IntRect or FloatRect C++ objects, and the constructed *Rect is encoded. 28 - When "type" is "FrameInfoData", the context object's WebFrame's FrameInfoData is encoded. 29 30 The list of IPC messages are exposed on window.IPC.messages, and VisitedLinkStore ID, WebPageProxy ID, 31 and frame identifiers are also exposed as static variables on window.IPC. 32 33 * Sources.txt: 34 * WebKit.xcodeproj/project.pbxproj: 35 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: 36 (WebKit::WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld): Inject the API if enabled. 37 * WebProcess/WebPage/IPCTestingAPI.cpp: Added. 38 (WebKit::IPCTestingAPI::JSIPC::create): Added. 39 (WebKit::IPCTestingAPI::JSIPC::webFrame): Added. 40 (WebKit::IPCTestingAPI::JSIPC::JSIPC): Added. 41 (WebKit::IPCTestingAPI::JSIPC::wrapperClass): Added. 42 (WebKit::IPCTestingAPI::JSIPC::unwrap): Added. 43 (WebKit::IPCTestingAPI::JSIPC::toWrapped): Added. 44 (WebKit::IPCTestingAPI::JSIPC::initialize): Added. 45 (WebKit::IPCTestingAPI::JSIPC::finalize): Added. 46 (WebKit::IPCTestingAPI::JSIPC::staticFunctions): Added. 47 (WebKit::IPCTestingAPI::JSIPC::staticValues): Added. 48 (WebKit::IPCTestingAPI::convertToUint64): Added. 49 (WebKit::IPCTestingAPI::processTargetFromArgument): Added. 50 (WebKit::IPCTestingAPI::destinationIDFromArgument): Added. 51 (WebKit::IPCTestingAPI::messageIDFromArgument): Added. 52 (WebKit::IPCTestingAPI::encodeTypedArray): Added. 53 (WebKit::IPCTestingAPI::createTypeError): Added. 54 (WebKit::IPCTestingAPI::encodeRectType): Added. 55 (WebKit::IPCTestingAPI::encodeIntegralType): Added. 56 (WebKit::IPCTestingAPI::VectorEncodeHelper::encode const): Added. 57 (WebKit::IPCTestingAPI::encodeArgument): Added. 58 (WebKit::IPCTestingAPI::JSIPC::sendMessage): Added. 59 (WebKit::IPCTestingAPI::JSIPC::sendSyncMessage): Added. 60 (WebKit::IPCTestingAPI::JSIPC::visitedLinkStoreID): Added. 61 (WebKit::IPCTestingAPI::JSIPC::webPageProxyID): Added. 62 (WebKit::IPCTestingAPI::JSIPC::frameIdentifier): Added. 63 (WebKit::IPCTestingAPI::JSIPC::retrieveID): Added. 64 (WebKit::IPCTestingAPI::JSIPC::messages): Added. 65 (WebKit::IPCTestingAPI::inject): 66 * WebProcess/WebPage/IPCTestingAPI.h: Added. 67 * WebProcess/WebPage/WebFrame.h: 68 * WebProcess/WebPage/WebPage.cpp: 69 (WebKit::m_limitsNavigationsToAppBoundDomains): 70 (WebKit::WebPage::updatePreferences): 71 * WebProcess/WebPage/WebPage.h: 72 (WebKit::WebPage::ipcTestingAPIEnabled const): 73 (WebKit::WebPage::webPageProxyID const): 74 (WebKit::WebPage::visitedLinkTableID const): 75 1 76 2020-10-08 Peng Liu <peng.liu6@apple.com> 2 77 -
trunk/Source/WebKit/Sources.txt
r267938 r268239 653 653 WebProcess/WebPage/EventDispatcher.cpp 654 654 WebProcess/WebPage/FindController.cpp 655 WebProcess/WebPage/IPCTestingAPI.cpp 655 656 WebProcess/WebPage/PageBanner.cpp 656 657 WebProcess/WebPage/VisitedLinkTableController.cpp -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r268217 r268239 4488 4488 9B02E0CE235EBB14004044B2 /* _WKTextManipulationToken.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKTextManipulationToken.mm; sourceTree = "<group>"; }; 4489 4489 9B02E0D0235EBCCA004044B2 /* _WKTextManipulationItem.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKTextManipulationItem.mm; sourceTree = "<group>"; }; 4490 9B033E71252580F300501071 /* IPCTestingAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IPCTestingAPI.h; sourceTree = "<group>"; }; 4491 9B033E72252580F300501071 /* IPCTestingAPI.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IPCTestingAPI.cpp; sourceTree = "<group>"; }; 4490 4492 9B1229CB23FF25F2008CA751 /* RemoteAudioDestinationManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioDestinationManager.h; sourceTree = "<group>"; }; 4491 4493 9B1229CC23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteAudioDestinationManager.cpp; sourceTree = "<group>"; }; … … 8867 8869 1A90C1F31264FD71003E44D4 /* FindController.cpp */, 8868 8870 1A90C1F21264FD71003E44D4 /* FindController.h */, 8871 9B033E72252580F300501071 /* IPCTestingAPI.cpp */, 8872 9B033E71252580F300501071 /* IPCTestingAPI.h */, 8869 8873 7C387433172F5615001BD88A /* PageBanner.cpp */, 8870 8874 7CF47FF917275C57008ACB91 /* PageBanner.h */, -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r266829 r268239 33 33 #include "FormDataReference.h" 34 34 #include "FrameInfoData.h" 35 #include "IPCTestingAPI.h" 35 36 #include "InjectedBundle.h" 36 37 #include "InjectedBundleDOMWindowExtension.h" … … 1744 1745 return; 1745 1746 1747 #if ENABLE(IPC_TESTING_API) 1748 if (world.isNormal() && webPage->ipcTestingAPIEnabled()) 1749 IPCTestingAPI::inject(*webPage, m_frame.get(), world); 1750 #endif 1751 1746 1752 webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(*webPage, m_frame, world); 1747 1753 -
trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h
r268017 r268239 64 64 struct WebsitePoliciesData; 65 65 66 class WebFrame : public API::ObjectImpl<API::Object::Type::BundleFrame> {66 class WebFrame : public API::ObjectImpl<API::Object::Type::BundleFrame>, public CanMakeWeakPtr<WebFrame> { 67 67 public: 68 68 static Ref<WebFrame> create() { return adoptRef(*new WebFrame); } -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r268074 r268239 790 790 #endif 791 791 792 #if ENABLE(IPC_TESTING_API) 793 m_visitedLinkTableID = parameters.visitedLinkTableID; 794 #endif 795 792 796 #if ENABLE(VP9) 793 797 if (parameters.shouldEnableVP9Decoder) … … 3785 3789 WebProcess::singleton().setUseGPUProcessForMedia(settings.useGPUProcessForMediaEnabled()); 3786 3790 #endif 3791 3792 #if ENABLE(IPC_TESTING_API) 3793 m_ipcTestingAPIEnabled = store.getBoolValueForKey(WebPreferencesKey::ipcTestingAPIEnabledKey()); 3794 #endif 3787 3795 } 3788 3796 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r268116 r268239 1340 1340 void updateCORSDisablingPatterns(Vector<String>&&); 1341 1341 1342 #if ENABLE(IPC_TESTING_API) 1343 bool ipcTestingAPIEnabled() const { return m_ipcTestingAPIEnabled; } 1344 uint64_t webPageProxyID() const { return messageSenderDestinationID(); } 1345 uint64_t visitedLinkTableID() const { return m_visitedLinkTableID; } 1346 #endif 1347 1342 1348 void getProcessDisplayName(CompletionHandler<void(String&&)>&&); 1343 1349 … … 2172 2178 2173 2179 Vector<String> m_corsDisablingPatterns; 2180 2181 #if ENABLE(IPC_TESTING_API) 2182 bool m_ipcTestingAPIEnabled { false }; 2183 uint64_t m_visitedLinkTableID; 2184 #endif 2174 2185 }; 2175 2186 -
trunk/Tools/ChangeLog
r268238 r268239 1 2020-10-08 Ryosuke Niwa <rniwa@webkit.org> 2 3 Make it possible to send an arbitrary IPC message from JavaScript 4 https://bugs.webkit.org/show_bug.cgi?id=217423 5 <rdar://problem/69969351> 6 7 Reviewed by Geoffrey Garen. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm: Added. 11 (-[IPCTestingAPIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): 12 (TEST): 13 1 14 2020-10-08 Sam Weinig <weinig@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r268192 r268239 848 848 9B59F12A2034086F009E63D5 /* mso-list-compat-mode.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B59F12920340854009E63D5 /* mso-list-compat-mode.html */; }; 849 849 9B62630C1F8C25C8007EE29B /* copy-url.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B62630B1F8C2510007EE29B /* copy-url.html */; }; 850 9B6D9FF9252EFDE500A51640 /* IPCTestingAPI.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B6D9FF8252EFDE500A51640 /* IPCTestingAPI.mm */; }; 850 851 9B7A37C41F8AEBA5004AA228 /* CopyURL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B7A37C21F8AEBA5004AA228 /* CopyURL.mm */; }; 851 852 9B7D740F1F8378770006C432 /* paste-rtfd.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B7D740E1F8377E60006C432 /* paste-rtfd.html */; }; … … 2460 2461 9B59F12920340854009E63D5 /* mso-list-compat-mode.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "mso-list-compat-mode.html"; sourceTree = "<group>"; }; 2461 2462 9B62630B1F8C2510007EE29B /* copy-url.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "copy-url.html"; sourceTree = "<group>"; }; 2463 9B6D9FF8252EFDE500A51640 /* IPCTestingAPI.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = IPCTestingAPI.mm; sourceTree = "<group>"; }; 2462 2464 9B79164F1BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FirstResponderScrollingPosition.mm; sourceTree = "<group>"; }; 2463 2465 9B7A37C21F8AEBA5004AA228 /* CopyURL.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CopyURL.mm; sourceTree = "<group>"; }; … … 3271 3273 2DB0232E1E4E871800707123 /* InteractionDeadlockAfterCrash.mm */, 3272 3274 2D116E1223E0CB3900208900 /* iOSMouseSupport.mm */, 3275 9B6D9FF8252EFDE500A51640 /* IPCTestingAPI.mm */, 3273 3276 5C69BDD41F82A7EB000F4F4B /* JavaScriptDuringNavigation.mm */, 3274 3277 5C0160C021A132320077FA32 /* JITEnabled.mm */, … … 5227 5230 7A909A831D877480007E10F8 /* IntSizeTests.cpp in Sources */, 5228 5231 2D116E1323E0CB3A00208900 /* iOSMouseSupport.mm in Sources */, 5232 9B6D9FF9252EFDE500A51640 /* IPCTestingAPI.mm in Sources */, 5229 5233 5C0BF8931DD599BD00B00328 /* IsNavigationActionTrusted.mm in Sources */, 5230 5234 CD5FF49F2162E943004BD86F /* ISOBox.cpp in Sources */,
Note:
See TracChangeset
for help on using the changeset viewer.