Changeset 268497 in webkit
- Timestamp:
- Oct 14, 2020 4:14:55 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r268492 r268497 1 2020-10-14 Ryosuke Niwa <rniwa@webkit.org> 2 3 Enabling IPC testing API should prevent the termination of WebContent process which sends an invalid IPC 4 https://bugs.webkit.org/show_bug.cgi?id=217698 5 6 Reviewed by Geoffrey Garen. 7 8 A part of this was landed in r268431 but this patch formally disables UI process' default behavior 9 to terminate a Web process upon receiving an invalid message from it. 10 11 Tests: IPCTestingAPI.CanSendInvalidAsyncMessageWithoutTermination 12 IPCTestingAPI.CanSendInvalidMessageWithoutTermination 13 14 * Platform/IPC/Connection.cpp: 15 (IPC::Connection::dispatchSyncMessage): Disable the debug assertion if the IPC testing API is enabled. 16 * Platform/IPC/Connection.h: 17 (IPC::Connection::setIgnoreInvalidMessageForTesting): Added. 18 (IPC::Connection::ignoreInvalidMessageForTesting const): Added. 19 (IPC::Connection::m_ignoreInvalidMessageForTesting): Added. 20 * UIProcess/WebPageProxy.cpp: 21 (WebKit::WebPageProxy::WebPageProxy): Set the flag on WebProcessProxy to trigger the behavior. 22 (WebKit::WebPageProxy::launchProcess): Ditto. 23 * UIProcess/WebProcessProxy.cpp: 24 (WebKit::WebProcessProxy::didReceiveInvalidMessage): Use the flag on Connection instead of reaching 25 out to the default page group. 26 (WebKit::WebProcessProxy::setIgnoreInvalidMessageForTesting): Added. Remember the fact we've enabled IPC 27 testing API in a member variable and propagate the flag to Connection if a Web process is already running. 28 (WebKit::WebProcessProxy::didFinishLaunching): Propagte the flag to the newly launched Web process. 29 * UIProcess/WebProcessProxy.h: 30 (WebKit::WebProcessProxy::m_ignoreInvalidMessageForTesting): Added. 31 1 32 2020-10-14 Per Arne Vollan <pvollan@apple.com> 2 33 -
trunk/Source/WebKit/Platform/IPC/Connection.cpp
r268423 r268497 929 929 930 930 // FIXME: If the message was invalid, we should send back a SyncMessageError. 931 ASSERT(decoder.isValid() );931 ASSERT(decoder.isValid() || m_ignoreInvalidMessageForTesting); 932 932 933 933 if (replyEncoder) -
trunk/Source/WebKit/Platform/IPC/Connection.h
r268423 r268497 288 288 void enableIncomingMessagesThrottling(); 289 289 290 #if ENABLE(IPC_TESTING_API) 291 void setIgnoreInvalidMessageForTesting() { m_ignoreInvalidMessageForTesting = true; } 292 bool ignoreInvalidMessageForTesting() const { return m_ignoreInvalidMessageForTesting; } 293 #endif 294 290 295 private: 291 296 Connection(Identifier, bool isServer, Client&); … … 409 414 RefPtr<WorkQueue> m_incomingSyncMessageCallbackQueue; 410 415 uint64_t m_nextIncomingSyncMessageCallbackID { 0 }; 416 417 #if ENABLE(IPC_TESTING_API) 418 bool m_ignoreInvalidMessageForTesting { false }; 419 #endif 411 420 412 421 #if HAVE(QOS_CLASSES) -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r268492 r268497 571 571 #endif 572 572 m_inspectorController->init(); 573 574 #if ENABLE(IPC_TESTING_API) 575 if (m_preferences->store().getBoolValueForKey(WebPreferencesKey::ipcTestingAPIEnabledKey())) 576 process.setIgnoreInvalidMessageForTesting(); 577 #endif 578 573 579 } 574 580 … … 839 845 m_process->addExistingWebPage(*this, WebProcessProxy::BeginsUsingDataStore::Yes); 840 846 m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_webPageID, *this); 847 848 #if ENABLE(IPC_TESTING_API) 849 if (m_preferences->store().getBoolValueForKey(WebPreferencesKey::ipcTestingAPIEnabledKey())) 850 m_process->setIgnoreInvalidMessageForTesting(); 851 #endif 841 852 842 853 finishAttachingToWebProcess(reason); -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r268486 r268497 881 881 WebProcessPool::didReceiveInvalidMessage(messageName); 882 882 883 #if ENABLE(IPC_TESTING_API) 884 if (connection.ignoreInvalidMessageForTesting()) 885 return; 886 #endif 887 883 888 // Terminate the WebContent process. 884 889 terminate(); … … 956 961 } 957 962 963 #if ENABLE(IPC_TESTING_API) 964 void WebProcessProxy::setIgnoreInvalidMessageForTesting() 965 { 966 if (state() == State::Running) 967 connection()->setIgnoreInvalidMessageForTesting(); 968 m_ignoreInvalidMessageForTesting = true; 969 } 970 #endif 971 958 972 void WebProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connection::Identifier connectionIdentifier) 959 973 { … … 979 993 m_processPool->processDidFinishLaunching(this); 980 994 m_backgroundResponsivenessTimer.updateState(); 995 996 #if ENABLE(IPC_TESTING_API) 997 if (m_ignoreInvalidMessageForTesting) 998 connection()->setIgnoreInvalidMessageForTesting(); 999 #endif 981 1000 982 1001 #if PLATFORM(IOS_FAMILY) -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r268458 r268497 391 391 #endif 392 392 393 #if ENABLE(IPC_TESTING_API) 394 void setIgnoreInvalidMessageForTesting(); 395 #endif 396 393 397 protected: 394 398 WebProcessProxy(WebProcessPool&, WebsiteDataStore*, IsPrewarmed); … … 621 625 622 626 ShutdownPreventingScopeCounter m_shutdownPreventingScopeCounter; 627 628 #if ENABLE(IPC_TESTING_API) 629 bool m_ignoreInvalidMessageForTesting { false }; 630 #endif 623 631 }; 624 632 -
trunk/Tools/ChangeLog
r268496 r268497 1 2020-10-14 Ryosuke Niwa <rniwa@webkit.org> 2 3 Enabling IPC testing API should prevent the termination of WebContent process which sends an invalid IPC 4 https://bugs.webkit.org/show_bug.cgi?id=217698 5 6 Reviewed by Geoffrey Garen. 7 8 Added regression tests. 9 10 * TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm: 11 (IPCTestingAPI.CanSendInvalidAsyncMessageWithoutTermination): 12 (IPCTestingAPI.CanSendInvalidMessageWithoutTermination): 13 1 14 2020-10-14 Aakash Jain <aakash_jain@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm
r268486 r268497 88 88 } 89 89 90 TEST(IPCTestingAPI, CanSendInvalidAsyncMessageWithoutTermination) 91 { 92 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 93 for (_WKInternalDebugFeature *feature in [WKPreferences _internalDebugFeatures]) { 94 if ([feature.key isEqualToString:@"IPCTestingAPIEnabled"]) { 95 [[configuration preferences] _setEnabled:YES forInternalDebugFeature:feature]; 96 break; 97 } 98 } 99 RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get()]); 100 101 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]); 102 [webView setUIDelegate:delegate.get()]; 103 104 done = false; 105 [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>" 106 "IPC.sendMessage('UI', IPC.webPageProxyID, IPC.messages.WebPageProxy_ShowShareSheet.name, []);" 107 "alert('hi')</script>"]; 108 TestWebKitAPI::Util::run(&done); 109 110 EXPECT_STREQ([alertMessage UTF8String], "hi"); 111 } 112 113 TEST(IPCTestingAPI, CanSendInvalidMessageWithoutTermination) 114 { 115 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 116 for (_WKInternalDebugFeature *feature in [WKPreferences _internalDebugFeatures]) { 117 if ([feature.key isEqualToString:@"IPCTestingAPIEnabled"]) { 118 [[configuration preferences] _setEnabled:YES forInternalDebugFeature:feature]; 119 break; 120 } 121 } 122 RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get()]); 123 124 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]); 125 [webView setUIDelegate:delegate.get()]; 126 127 done = false; 128 [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>" 129 "IPC.sendSyncMessage('UI', IPC.webPageProxyID, IPC.messages.WebPageProxy_RunJavaScriptAlert.name, 100, [{type: 'uint64_t', value: IPC.frameID}]);" 130 "alert('hi')</script>"]; 131 TestWebKitAPI::Util::run(&done); 132 133 EXPECT_STREQ([alertMessage UTF8String], "hi"); 134 } 135 90 136 #endif
Note: See TracChangeset
for help on using the changeset viewer.