2020-02-21 Russell Epstein Cherry-pick r257077. rdar://problem/59676879 REGRESSION (r255677): Reloading tab with beforeunload prompt closes tab when asking to stay on page https://bugs.webkit.org/show_bug.cgi?id=208015 Reviewed by Geoffrey Garen. Source/WebKit: Make sure we only restart the tryClose timer after the beforeunload prompt if the timer was actually active before the prompt (i.e. tryClose was actually called). On Reload, tryClose is not called but beforeunload prompt may still happen. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::runBeforeUnloadConfirmPanel): Tools: Add API test coverage. * TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm: (TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257077 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-20 Chris Dumez REGRESSION (r255677): Reloading tab with beforeunload prompt closes tab when asking to stay on page https://bugs.webkit.org/show_bug.cgi?id=208015 Reviewed by Geoffrey Garen. Add API test coverage. * TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm: (TEST): 2020-02-19 Russell Epstein Cherry-pick r256859. rdar://problem/59576018 [macOS] Web process may crash under ServicesOverlayController::buildPotentialHighlightsIfNeeded https://bugs.webkit.org/show_bug.cgi?id=207899 Reviewed by Tim Horton and Simon Fraser. Source/WebCore: Mitigates a null pointer crash in ServicesOverlayController::buildPotentialHighlightsIfNeeded(), wherein the focused frame may not have a FrameView when the ServicesOverlayController's selection invalidation timer fires. This is possible if, while being focused, the newly focused subframe is unparented and reparented, which causes it to momentarily have a null view. During this time, if a selection change had occurred earlier in the runloop, it will schedule the page overlay controller invalidation timer, which will fire and discover that the currently focused frame no longer has a FrameView. Test: editing/selection/selection-change-in-disconnected-frame-crash.html * page/mac/ServicesOverlayController.mm: (WebCore::ServicesOverlayController::buildSelectionHighlight): Source/WebKit: Add another missing null check on iOS, for the case where FrameView is null. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::platformEditorState const): Tools: Make it possible to run tests on macOS with services controls enabled, via a new TestOptions flag. * WebKitTestRunner/TestController.cpp: (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): * WebKitTestRunner/cocoa/TestControllerCocoa.mm: (WTR::TestController::platformCreateWebView): LayoutTests: Add a new layout test to verify that we don't crash under this circumstance. * editing/selection/selection-change-in-disconnected-frame-crash-expected.txt: Added. * editing/selection/selection-change-in-disconnected-frame-crash.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256859 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-18 Wenson Hsieh [macOS] Web process may crash under ServicesOverlayController::buildPotentialHighlightsIfNeeded https://bugs.webkit.org/show_bug.cgi?id=207899 Reviewed by Tim Horton and Simon Fraser. Make it possible to run tests on macOS with services controls enabled, via a new TestOptions flag. * WebKitTestRunner/TestController.cpp: (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): * WebKitTestRunner/cocoa/TestControllerCocoa.mm: (WTR::TestController::platformCreateWebView): 2020-02-17 Alan Coon Cherry-pick r256632. rdar://problem/59478906 NetworkLoadMetrics should be shared by multiple ResourceResponse instances https://bugs.webkit.org/show_bug.cgi?id=207747 Reviewed by Keith Miller. Source/WebCore: ResourceResponse is value data, and it is copied multiple times in various places, (1) to create a new ResourceResponse which has slightly different fields, or (1) to hold ResourceResponse even after loading finishes. For example, DocumentLoader has Vector to replay response dispatching in the case of loading from BackForwardCache. The problem is that ResourceResponse is very large: 440 bytes. While we sometimes copy ResourceResponse to modify some part of it, NetworkLoadMetrics is immutable. It is set when response is created, and is never changed. And NetworkLoadMetrics is large: sizeof(NetworkLoadMetrics) is 184 bytes. Given that we have multiple copies of ResourceResponse in WebCore, we should share NetworkLoadMetrics by them. This patch puts Box in ResourceResponse to share it with all copied ResourceResponses. We do not make NetworkLoadMetrics RefCounted<> for now since some legit data structures embed NetworkLoadMetrics. This patch adds ArgumentCoder for Box so that we can encode / decode Box in ResourceResponse in IPC. To ensure NetworkLoadMetrics in ResourceResponse immutable, we add ResourceResponse::setDeprecatedNetworkLoadMetrics instead of modifying NetworkLoadMetrics already created in ResourceResponse. We also attempt to compact ResourceResponse more by using bit-fields. And removing m_isValid field in ParsedContentRange since this can be represented by the different field. These changes make sizeof(ResourceResponse) from 440 to 248. No behavior change. * inspector/agents/InspectorNetworkAgent.cpp: (WebCore::InspectorNetworkAgent::buildObjectForTiming): (WebCore::InspectorNetworkAgent::buildObjectForResourceResponse): * inspector/agents/InspectorNetworkAgent.h: * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::loadRequest): * loader/SubresourceLoader.cpp: (WebCore::SubresourceLoader::didFinishLoading): * page/PerformanceTiming.cpp: (WebCore::PerformanceTiming::domainLookupStart const): (WebCore::PerformanceTiming::domainLookupEnd const): (WebCore::PerformanceTiming::connectStart const): (WebCore::PerformanceTiming::connectEnd const): (WebCore::PerformanceTiming::secureConnectionStart const): (WebCore::PerformanceTiming::requestStart const): (WebCore::PerformanceTiming::responseStart const): * platform/network/NetworkLoadMetrics.h: * platform/network/ParsedContentRange.cpp: (WebCore::areContentRangeValuesValid): (WebCore::parseContentRange): (WebCore::ParsedContentRange::ParsedContentRange): (WebCore::ParsedContentRange::headerValue const): * platform/network/ParsedContentRange.h: (WebCore::ParsedContentRange::isValid const): (WebCore::ParsedContentRange::invalidValue): (WebCore::ParsedContentRange::MarkableTraits::isEmptyValue): (WebCore::ParsedContentRange::MarkableTraits::emptyValue): (WebCore::ParsedContentRange::ParsedContentRange): Deleted. * platform/network/ResourceHandle.h: * platform/network/ResourceResponseBase.cpp: (WebCore::ResourceResponseBase::ResourceResponseBase): (WebCore::ResourceResponseBase::crossThreadData const): (WebCore::ResourceResponseBase::fromCrossThreadData): (WebCore::ResourceResponseBase::compare): * platform/network/ResourceResponseBase.h: (WebCore::ResourceResponseBase::deprecatedNetworkLoadMetricsOrNull const): (WebCore::ResourceResponseBase::setDeprecatedNetworkLoadMetrics): (WebCore::ResourceResponseBase::encode const): (WebCore::ResourceResponseBase::decode): (WebCore::ResourceResponseBase::deprecatedNetworkLoadMetrics const): Deleted. * platform/network/cf/ResourceResponse.h: (WebCore::ResourceResponse::ResourceResponse): * platform/network/cocoa/NetworkLoadMetrics.mm: (WebCore::copyTimingData): * platform/network/curl/CurlResourceHandleDelegate.cpp: (WebCore::CurlResourceHandleDelegate::curlDidReceiveResponse): * platform/network/curl/ResourceResponse.h: * platform/network/curl/ResourceResponseCurl.cpp: (WebCore::ResourceResponse::setDeprecatedNetworkLoadMetrics): Deleted. * platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::getConnectionTimingData): * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]): Source/WebKit: Add ArgumentCoder support for Box. * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::dispatchDidReceiveResponse): * Platform/IPC/ArgumentCoders.h: (IPC::ArgumentCoder>::encode): (IPC::ArgumentCoder>::decode): Tools: * TestWebKitAPI/Tests/WebCore/ParsedContentRange.cpp: (TestWebKitAPI::TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256632 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-14 Yusuke Suzuki NetworkLoadMetrics should be shared by multiple ResourceResponse instances https://bugs.webkit.org/show_bug.cgi?id=207747 Reviewed by Keith Miller. * TestWebKitAPI/Tests/WebCore/ParsedContentRange.cpp: (TestWebKitAPI::TEST): 2020-02-17 Alan Coon Cherry-pick r256432. rdar://problem/59446974 WebSWServerConnection::registerServiceWorkerClient is not sending IPC message to UIProcess when it should https://bugs.webkit.org/show_bug.cgi?id=207537 Reviewed by Chris Dumez. Source/WebKit: Covered by added API test. * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::registerServiceWorkerClient): Fix use after move so that we can get the context connection and send the IPC message to UIProcess as expected. Tools: * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256432 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-12 Youenn Fablet WebSWServerConnection::registerServiceWorkerClient is not sending IPC message to UIProcess when it should https://bugs.webkit.org/show_bug.cgi?id=207537 Reviewed by Chris Dumez. * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: 2020-02-17 Alan Coon Cherry-pick r256383. rdar://problem/59446974 Unreviewed, rolling out r256314. https://bugs.webkit.org/show_bug.cgi?id=207594 It is breaking an API test (Requested by youenn on #webkit). Reverted changeset: "WebSWServerConnection::registerServiceWorkerClient is not sending IPC message to UIProcess when it should" https://bugs.webkit.org/show_bug.cgi?id=207537 https://trac.webkit.org/changeset/256314 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256383 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-11 Commit Queue Unreviewed, rolling out r256314. https://bugs.webkit.org/show_bug.cgi?id=207594 It is breaking an API test (Requested by youenn on #webkit). Reverted changeset: "WebSWServerConnection::registerServiceWorkerClient is not sending IPC message to UIProcess when it should" https://bugs.webkit.org/show_bug.cgi?id=207537 https://trac.webkit.org/changeset/256314 2020-02-17 Alan Coon Cherry-pick r256225. rdar://problem/59446983 [watchOS] Notification listener is never unregistered https://bugs.webkit.org/show_bug.cgi?id=207459 Source/WebKit: Reviewed by Maciej Stachowiak. On watchOS, the backlight changed notification is registered in WebProcessPool::registerNotificationObservers(), but not unregistered in WebProcessPool::unregisterNotificationObservers(). API test: WebKit.BacklightLevelNotificationCrash * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::unregisterNotificationObservers): Tools: Reviewed by Maciej Stachowiak. Add a test which tests that posting a backlight level change notification will not cause a crash. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit/BacklightLevelNotification.mm: Added. (TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256225 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-10 Per Arne Vollan [watchOS] Notification listener is never unregistered https://bugs.webkit.org/show_bug.cgi?id=207459 Reviewed by Maciej Stachowiak. Add a test which tests that posting a backlight level change notification will not cause a crash. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit/BacklightLevelNotification.mm: Added. (TEST): 2020-02-17 Alan Coon Cherry-pick r256314. rdar://problem/59446974 WebSWServerConnection::registerServiceWorkerClient is not sending IPC message to UIProcess when it should https://bugs.webkit.org/show_bug.cgi?id=207537 Reviewed by Chris Dumez. Source/WebKit: Covered by added API test. * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::registerServiceWorkerClient): Fix use after move so that we can get the context connection and send the IPC message to UIProcess as expected. Tools: * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256314 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-11 Youenn Fablet WebSWServerConnection::registerServiceWorkerClient is not sending IPC message to UIProcess when it should https://bugs.webkit.org/show_bug.cgi?id=207537 Reviewed by Chris Dumez. * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: 2020-02-17 Ryan Haddad Cherry-pick r255566. rdar://problem/59524417 Unreviewed, disable ResponsivenessTimer test in Debug / ASAN The ResponsivenessTimer is disabled for those configurations as of r255518. * TestWebKitAPI/Tests/WebKit/ResponsivenessTimerCrash.mm: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255566 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-03 Chris Dumez Unreviewed, disable ResponsivenessTimer test in Debug / ASAN The ResponsivenessTimer is disabled for those configurations as of r255518. * TestWebKitAPI/Tests/WebKit/ResponsivenessTimerCrash.mm: 2020-02-17 Ryan Haddad Unreviewed build fix. rdar://59461287 * TestWebKitAPI/Tests/WebKitCocoa/Download.mm: 2020-02-17 Alan Coon Revert r256693. rdar://problem/59478981 2020-02-14 Russell Epstein Cherry-pick r256629. rdar://problem/59478949 Allow UIDNAInfo.errors from uidna_nameToUnicode that would not cause URL parsing failures https://bugs.webkit.org/show_bug.cgi?id=207360 Patch by Alex Christensen on 2020-02-14 Reviewed by Ryosuke Niwa. Source/WTF: * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Tools: * TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm: (TestWebKitAPI::TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256629 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-14 Alex Christensen Allow UIDNAInfo.errors from uidna_nameToUnicode that would not cause URL parsing failures https://bugs.webkit.org/show_bug.cgi?id=207360 Reviewed by Ryosuke Niwa. * TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm: (TestWebKitAPI::TEST): 2020-02-14 Russell Epstein Cherry-pick r256580. rdar://problem/59478981 Dark Mode: In Notes, list item becomes invisible in dark mode after outdenting https://bugs.webkit.org/show_bug.cgi?id=207676 Reviewed by Wenson Hsieh and Timothy Hatcher. Source/WebCore: The bug was caused by EditingStyle::inverseTransformColorIfNeeded converting -apple-system-label to transparent color in ReplaceSelectionCommand when InsertListCommand invokes moveParagraphs. This patch fixes the bug in EditingStyle::inverseTransformColorIfNeeded by treating any semantic color name or semantic RGB color value as if the color was not specified. It also fixes the bug that removeStyleFromRulesAndContext was incapable of removing superflous semantic color names that appear in the inline since the context's computed style only contain RGB values by replacing the inline style's color values with that of the computed style. This fix is necessary to eliminate -apple-system-label in the pasted content, which can cause issues when such a content is sync'ed to other devices via iCloud, etc... Tests: PasteHTML.TransformColorsOfDarkContentButNotSemanticColor PasteHTML.DoesNotTransformColorsOfLightContentDuringOutdent * editing/EditingStyle.cpp: (WebCore::EditingStyle::removeStyleFromRulesAndContext): (WebCore::EditingStyle::inverseTransformColorIfNeeded): Tools: Added regression tests for pasting content with -apple-system-label and outdenting content. * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm: (PasteHTML.TransformColorsOfDarkContentButNotSemanticColor): (PasteHTML.DoesNotTransformColorsOfLightContentDuringOutdent): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256580 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-13 Ryosuke Niwa Dark Mode: In Notes, list item becomes invisible in dark mode after outdenting https://bugs.webkit.org/show_bug.cgi?id=207676 Reviewed by Wenson Hsieh and Timothy Hatcher. Added regression tests for pasting content with -apple-system-label and outdenting content. * TestWebKitAPI/Tests/WebKitCocoa/PasteHTML.mm: (PasteHTML.TransformColorsOfDarkContentButNotSemanticColor): (PasteHTML.DoesNotTransformColorsOfLightContentDuringOutdent): 2020-02-14 Russell Epstein Cherry-pick r256093. rdar://problem/59446995 [WTF] Try using 75% load factor for HashTable https://bugs.webkit.org/show_bug.cgi?id=207183 Reviewed by Mark Lam. Source/WTF: We know that hash-table is one of the most memory consuming part in WebKit. By analyzing many production hash-table implementations[1], I found that many of them are using 75% load-factor while our one is 50%. This patch changes the load-factor from 50% to 75%. But we pick 75% only for small tables which capacity is <= 1024 based on collected data by micro-benchmarking. The collected data is telling that longer probe-length affects on performance if table size gets larger. [1]: LLVM DenseMap, Abseil's, rust's, and so on. * wtf/HashTable.h: (WTF::HashTableCapacityForSize::shouldExpand): (WTF::HashTableCapacityForSize::capacityForSize): (WTF::HashTable::shouldExpand const): (WTF::KeyTraits>::computeBestTableSize): Tools: * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::testInitialCapacity): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256093 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-08 Yusuke Suzuki [WTF] Try using 75% load factor for HashTable https://bugs.webkit.org/show_bug.cgi?id=207183 Reviewed by Mark Lam. * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::testInitialCapacity): 2020-02-14 Russell Epstein Cherry-pick r256011. rdar://problem/59446995 Unreviewed, revert 75% load-factor because of JetStream2/string-unpack-code-SP regression https://bugs.webkit.org/show_bug.cgi?id=207183 Source/WTF: * wtf/HashTable.h: (WTF::HashTable::shouldExpand const): (WTF::KeyTraits>::computeBestTableSize): (WTF::HashTable::shouldExpand): Deleted. (WTF::HashTableCapacityForSize::capacityForSize): Deleted. Tools: * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::testInitialCapacity): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256011 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-07 Yusuke Suzuki Unreviewed, revert 75% load-factor because of JetStream2/string-unpack-code-SP regression https://bugs.webkit.org/show_bug.cgi?id=207183 * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::testInitialCapacity): 2020-02-14 Russell Epstein Cherry-pick r255889. rdar://problem/59446995 [WTF] Try using 75% load factor for HashTable https://bugs.webkit.org/show_bug.cgi?id=207183 Reviewed by Mark Lam. Source/WTF: We know that hash-table is one of the most memory consuming part in WebKit. By analyzing many production hash-table implementations[1], I found that many of them are using 75% load-factor while our one is 50%. A/B test shows that 75% load-factor is performance-neutral in Speedometer2 and JetStream2, while it offers 2~% improvement in Membuster. This means that we are wasting too much memory for no-performance-improvement. This patch changes the load-factor from 50% to 75%. [1]: LLVM DenseMap, Abseil's, rust's, and so on. * wtf/HashTable.h: (WTF::HashTable::shouldExpand): (WTF::HashTable::shouldExpand const): (WTF::HashTableCapacityForSize::capacityForSize): (WTF::KeyTraits>::computeBestTableSize): Tools: Fix load-factor assumption in existing tests. * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::testInitialCapacity): LayoutTests: It seems that this test is relying on hash-table's order. * http/tests/resourceLoadStatistics/aggregate-sorted-data-no-storage-access-expected.txt: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255889 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-05 Yusuke Suzuki [WTF] Try using 75% load factor for HashTable https://bugs.webkit.org/show_bug.cgi?id=207183 Reviewed by Mark Lam. Fix load-factor assumption in existing tests. * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::testInitialCapacity): 2020-02-14 Russell Epstein Cherry-pick r255611. rdar://problem/59446995 Reduce size of HashMap and HashSet https://bugs.webkit.org/show_bug.cgi?id=207138 Reviewed by Yusuke Suzuki. Source/WTF: This reduces sizeof(HashMap) and sizeof(HashSet) from 24 to 8 on 64-bit systems. I measured that the overwhelming majority of HashMaps and HashSets never see more than 0 elements, so I moved the table metadata (tableSize, tableSizeMask, keyCount, deletedCount) to inside the dynamically allocated memory. This makes another branch in size() for non-empty tables and an additional read and write when rehashing in exchange for fewer writes in the constructor and increased cache locality of everything that uses HashMap and HashSet, which is basically everything. * wtf/HashTable.h: (WTF::HashTable::~HashTable): (WTF::HashTable::end): (WTF::HashTable::end const): (WTF::HashTable::random): (WTF::HashTable::size const): (WTF::HashTable::capacity const): (WTF::HashTable::isEmpty const): (WTF::HashTable::reserveInitialCapacity): (WTF::HashTable::shouldExpand const): (WTF::HashTable::mustRehashInPlace const): (WTF::HashTable::shouldShrink const): (WTF::HashTable::shrink): (WTF::HashTable::makeIterator): (WTF::HashTable::makeConstIterator const): (WTF::HashTable::makeKnownGoodIterator): (WTF::HashTable::makeKnownGoodConstIterator const): (WTF::HashTable::tableSize const): (WTF::HashTable::setTableSize const): (WTF::HashTable::tableSizeMask const): (WTF::HashTable::setTableSizeMask): (WTF::HashTable::keyCount const): (WTF::HashTable::setKeyCount const): (WTF::HashTable::deletedCount const): (WTF::HashTable::setDeletedCount const): (WTF::KeyTraits>::HashTable): (WTF::KeyTraits>::inlineLookup): (WTF::KeyTraits>::lookupForWriting): (WTF::KeyTraits>::fullLookupForWriting): (WTF::KeyTraits>::addUniqueForInitialization): (WTF::KeyTraits>::add): (WTF::KeyTraits>::addPassingHashCode): (WTF::KeyTraits>::remove): (WTF::KeyTraits>::removeIf): (WTF::KeyTraits>::allocateTable): (WTF::KeyTraits>::deallocateTable): (WTF::KeyTraits>::expand): (WTF::KeyTraits>::shrinkToBestSize): (WTF::KeyTraits>::deleteReleasedWeakBuckets): (WTF::KeyTraits>::rehash): (WTF::KeyTraits>::clear): (WTF::KeyTraits>::swap): (WTF::KeyTraits>::checkTableConsistencyExceptSize const): Tools: * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255611 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-03 Alex Christensen Reduce size of HashMap and HashSet https://bugs.webkit.org/show_bug.cgi?id=207138 Reviewed by Yusuke Suzuki. * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::TEST): 2020-02-14 Russell Epstein Cherry-pick r256395. rdar://problem/59447024 Bug 207424: Crash in WebCore::ParsedContentType::parseContentType when parsing invalid MIME type Patch by Rob Buis and David Kilzer on 2020-02-11 Reviewed by Rob Buis. Source/WebCore: Return StringView directly rather than wrapping it in Optional, since StringView's can be null tested. Tests: TestWebKitAPI.ParsedContentType * platform/network/ParsedContentType.cpp: (WebCore::parseToken): (WebCore::parseQuotedString): (WebCore::ParsedContentType::parseContentType): Don't set type parameter if parameterName is null string. Remove unneeded `parameterName` variable; use keyRange.toString() instead. Tools: * TestWebKitAPI/Tests/WebCore/ParsedContentType.cpp: (TestWebKitAPI::TEST): Add more tests. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256395 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-11 Rob Buis Bug 207424: Crash in WebCore::ParsedContentType::parseContentType when parsing invalid MIME type Reviewed by Rob Buis. * TestWebKitAPI/Tests/WebCore/ParsedContentType.cpp: (TestWebKitAPI::TEST): Add more tests. 2020-02-14 Russell Epstein Cherry-pick r256377. rdar://problem/59446971 Regression: RTCRtpSender.getCapabilities("video") returns null on iOS 13.4 (17E5223h) https://bugs.webkit.org/show_bug.cgi?id=207325 Reviewed by Eric Carlson. Source/WebCore: Manually tested and covered by API test. * platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp: (WebCore::LibWebRTCProvider::webRTCAvailable): Return true unconditionally on iOS since libwebrtc.dylib is always available. Tools: * TestWebKitAPI/Tests/WebKit/GetUserMedia.mm: (TestWebKitAPI::TEST): Add a test validating that RTCRtpSender.getCapabilities does not return null. * TestWebKitAPI/Tests/WebKit/getUserMedia.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256377 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-11 Youenn Fablet Regression: RTCRtpSender.getCapabilities("video") returns null on iOS 13.4 (17E5223h) https://bugs.webkit.org/show_bug.cgi?id=207325 Reviewed by Eric Carlson. * TestWebKitAPI/Tests/WebKit/GetUserMedia.mm: (TestWebKitAPI::TEST): Add a test validating that RTCRtpSender.getCapabilities does not return null. * TestWebKitAPI/Tests/WebKit/getUserMedia.html: 2020-02-13 Ryan Haddad Cherry-pick r256297. rdar://problem/59442308 [iOS] Non-internal API test runners frequently crash due to Objective-C exceptions https://bugs.webkit.org/show_bug.cgi?id=207525 Reviewed by Tim Horton. After the fix for , some scroll view content offset changes will attempt to call into CoreAnalytics API to try and report data about scrolling velocities. In the iOS 13.3 simulator, this involves creating a dictionary, of which one of the keys is the bundle identifier of the application. The value is unconditionally inserted into the dictionary. Since TestWebKitAPI does not run in the context of a UIApplication, the bundle identifier (that is, `NSBundle.mainBundle.bundleIdentifier`) ends up being nil, causing us to crash upon trying to create the dictionary. While it would make things easier, we can't just swizzle -bundleIdentifier for the entirely of every test, since some tests expect the bundle identifier to be nil (or call into system frameworks that expect the bundle identifier to be nil). These tests fail or time out when -bundleIdentifier is unconditionally swizzled throughout the test run. To work around this bug for the time being, simply pretend that we have a bundle identifier when running API tests on iOS, by swizzling `-[NSBundle bundleIdentifier]` to return a string at the beginning of each API test. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/cocoa/TestWKWebView.mm: (overrideBundleIdentifier): Move this to the top of the file, so it can be shared. (+[WKWebView initialize]): At the start of each test, force UIKit to cache a fake value for `_UIMainBundleIdentifier()` by invoking an internal class method that calls into the internal helper function, with no other side effects. * TestWebKitAPI/ios/UIKitSPI.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256297 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-11 Wenson Hsieh [iOS] Non-internal API test runners frequently crash due to Objective-C exceptions https://bugs.webkit.org/show_bug.cgi?id=207525 Reviewed by Tim Horton. After the fix for , some scroll view content offset changes will attempt to call into CoreAnalytics API to try and report data about scrolling velocities. In the iOS 13.3 simulator, this involves creating a dictionary, of which one of the keys is the bundle identifier of the application. The value is unconditionally inserted into the dictionary. Since TestWebKitAPI does not run in the context of a UIApplication, the bundle identifier (that is, `NSBundle.mainBundle.bundleIdentifier`) ends up being nil, causing us to crash upon trying to create the dictionary. While it would make things easier, we can't just swizzle -bundleIdentifier for the entirely of every test, since some tests expect the bundle identifier to be nil (or call into system frameworks that expect the bundle identifier to be nil). These tests fail or time out when -bundleIdentifier is unconditionally swizzled throughout the test run. To work around this bug for the time being, simply pretend that we have a bundle identifier when running API tests on iOS, by swizzling `-[NSBundle bundleIdentifier]` to return a string at the beginning of each API test. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/cocoa/TestWKWebView.mm: (overrideBundleIdentifier): Move this to the top of the file, so it can be shared. (+[WKWebView initialize]): At the start of each test, force UIKit to cache a fake value for `_UIMainBundleIdentifier()` by invoking an internal class method that calls into the internal helper function, with no other side effects. * TestWebKitAPI/ios/UIKitSPI.h: 2020-02-13 Ryan Haddad Unreviewed attempt to fix the TestWebKitAPI build. * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewEvaluateJavaScript.mm: 2020-02-13 Russell Epstein Cherry-pick r256520. rdar://problem/59430255 [iOS] -updateSelectionWithExtentPoint:completionHandler: should work without requiring floating cursor https://bugs.webkit.org/show_bug.cgi?id=207680 Reviewed by Tim Horton. Source/WebKit: Currently, WebPage::updateSelectionWithExtentPoint consults the value of m_selectionAnchor to determine whether it should attempt to modify the current selection using the hit-tested visible position. m_selectionAnchor is only set under WebPage::beginSelectionInDirection, which is only invoked when the user begins a floating cursor gesture. When attempting to perform an out-of-band selection update (i.e. without calling beginSelectionInDirection beforehand), we will end up consulting an arbitrary value for m_selectionAnchor (::Start by default; otherwise, the last value set by beginSelectionInDirection if it was previously called). This means that the selection can often only be extended in one direction (typically forwards) when an API client attempts to use -updateSelectionWithExtentPoint:completionHandler: to extend the current selection. To fix this, make it so that we only respect the selection anchor (m_selectionAnchor) in the case where the user is currently using the floating cursor; otherwise, allow the SPI to expand the selection, such that it contains the visible position for the given location. Test: UIWKInteractionViewProtocol.UpdateSelectionWithExtentPoint * Platform/spi/ios/UIKitSPI.h: * Scripts/webkit/messages.py: * Shared/ios/GestureTypes.h: Add a new flag to tell the web process whether it should limit selection extent updates to the current selection anchor. Also, remove an existing enum type, SelectionHandlePosition, that is unused (since we no longer support block text selection). * UIProcess/WebPageProxy.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[UITextInteractionAssistant _wk_hasFloatingCursor]): Add a helper method to determine (using the text interaction assistant) whether there's an active floating cursor gesture. In the case where floating cursor is active, the text interaction assistant will be in an active gesture but its UITextInteraction will not, since the gesture recognizer belongs to the keyboard or input view rather than the first responder (in this case, WKContentView). (-[WKContentView updateSelectionWithExtentPoint:completionHandler:]): Only respect the selection anchor if we're in floating cursor mode; otherwise, allow selection updates with an extent point to extend the current selection to include the new position. * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::updateSelectionWithExtentPoint): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: Plumb the RespectsSelectionAnchor flag over to the web process. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::updateSelectionWithExtentPoint): Tools: Add a new API test to verify that calling -updateSelectionWithExtentPoint:completionHandler: with a point behind the current selection works. * TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm: (-[TestWKWebView updateSelectionWithExtentPoint:]): * TestWebKitAPI/ios/UIKitSPI.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256520 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-13 Wenson Hsieh [iOS] -updateSelectionWithExtentPoint:completionHandler: should work without requiring floating cursor https://bugs.webkit.org/show_bug.cgi?id=207680 Reviewed by Tim Horton. Add a new API test to verify that calling -updateSelectionWithExtentPoint:completionHandler: with a point behind the current selection works. * TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm: (-[TestWKWebView updateSelectionWithExtentPoint:]): * TestWebKitAPI/ios/UIKitSPI.h: 2020-02-11 Alan Coon Cherry-pick r256073. rdar://problem/59299148 Remember if we used legacy TLS in the back/forward cache like we remember if we have only secure content https://bugs.webkit.org/show_bug.cgi?id=207409 rdar://problem/59275641 Patch by Alex Christensen on 2020-02-07 Reviewed by Chris Dumez. Source/WebCore: Covered by an API test. * history/CachedFrame.cpp: (WebCore::CachedFrame::setHasInsecureContent): * history/CachedFrame.h: (WebCore::CachedFrame::usedLegacyTLS const): * loader/EmptyFrameLoaderClient.h: * loader/FrameLoader.cpp: (WebCore::FrameLoader::receivedFirstData): (WebCore::FrameLoader::commitProvisionalLoad): (WebCore::FrameLoader::dispatchDidCommitLoad): * loader/FrameLoader.h: * loader/FrameLoaderClient.h: Source/WebKit: * Scripts/webkit/messages.py: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::hasInsecureContent): * UIProcess/WebPageProxy.h: * UIProcess/WebPageProxy.messages.in: * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::dispatchDidCommitLoad): (WebKit::WebFrameLoaderClient::savePlatformDataToCachedFrame): * WebProcess/WebCoreSupport/WebFrameLoaderClient.h: Source/WebKitLegacy/mac: * WebCoreSupport/WebFrameLoaderClient.h: * WebCoreSupport/WebFrameLoaderClient.mm: (WebFrameLoaderClient::dispatchDidCommitLoad): Source/WebKitLegacy/win: * WebCoreSupport/WebFrameLoaderClient.cpp: (WebFrameLoaderClient::dispatchDidCommitLoad): * WebCoreSupport/WebFrameLoaderClient.h: Tools: * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm: (TestWebKitAPI::TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256073 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-07 Alex Christensen Remember if we used legacy TLS in the back/forward cache like we remember if we have only secure content https://bugs.webkit.org/show_bug.cgi?id=207409 rdar://problem/59275641 Reviewed by Chris Dumez. * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm: (TestWebKitAPI::TEST): 2020-02-11 Alan Coon Cherry-pick r255880. rdar://problem/59299151 Unreviewed, another build fix after r255846 * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255880 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-05 Chris Dumez Unreviewed, another build fix after r255846 * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm: 2020-02-11 Alan Coon Cherry-pick r255846. rdar://problem/59299151 Make WKWebView._negotiatedLegacyTLS accurate when loading main resouorce from network or cache https://bugs.webkit.org/show_bug.cgi?id=207207 Reviewed by Chris Dumez. Source/WebCore: * platform/network/ResourceResponseBase.cpp: (WebCore::ResourceResponseBase::includeCertificateInfo const): * platform/network/ResourceResponseBase.h: (WebCore::ResourceResponseBase::usedLegacyTLS const): (WebCore::ResourceResponseBase::encode const): (WebCore::ResourceResponseBase::decode): Source/WebKit: In PageLoadState::didCommitLoad, I was resetting the value of _negotiatedLegacyTLS to false. That created a race condition when loading the main resource because the NetworkProcess would message the UIProcess setting _negotiatedLegacyTLS to false, while the NetworkProcess would message the WebProcess which would message the UIProcess to call PageLoadState::didCommitLoad which would reset it to false. Now it resets it to the correct value, whatever it is. Updating the ResourceResponseBase serialization code has the desirable side effect that the disk cache will remember whether legacy TLS was used to fetch each resource. This will make it so _negotiatedLegacyTLS is true if we read content from the disk cache that was originally fetched using legacy TLS. In order to not increase the memory footprint of ResourceResponse, I changed m_httpStatusCode from an int to a short. It just needs to be able to cover the values 0-600 or so, which really only needs 10 bits. Covered by new API tests. * NetworkProcess/NetworkCORSPreflightChecker.cpp: (WebKit::NetworkCORSPreflightChecker::didReceiveResponse): * NetworkProcess/NetworkCORSPreflightChecker.h: * NetworkProcess/NetworkDataTask.cpp: (WebKit::NetworkDataTask::didReceiveResponse): (WebKit::NetworkDataTask::negotiatedLegacyTLS const): Deleted. * NetworkProcess/NetworkDataTask.h: (WebKit::NetworkDataTaskClient::negotiatedLegacyTLS const): Deleted. * NetworkProcess/NetworkDataTaskBlob.cpp: (WebKit::NetworkDataTaskBlob::dispatchDidReceiveResponse): * NetworkProcess/NetworkLoad.cpp: (WebKit::NetworkLoad::didReceiveResponse): (WebKit::NetworkLoad::notifyDidReceiveResponse): (WebKit::NetworkLoad::throttleDelayCompleted): (WebKit::NetworkLoad::negotiatedLegacyTLS const): Deleted. * NetworkProcess/NetworkLoad.h: * NetworkProcess/NetworkResourceLoader.h: * NetworkProcess/PingLoad.cpp: (WebKit::PingLoad::didReceiveResponse): * NetworkProcess/PingLoad.h: * NetworkProcess/cocoa/NetworkDataTaskCocoa.h: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::didReceiveResponse): * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * NetworkProcess/curl/NetworkDataTaskCurl.cpp: (WebKit::NetworkDataTaskCurl::invokeDidReceiveResponse): * NetworkProcess/soup/NetworkDataTaskSoup.cpp: (WebKit::NetworkDataTaskSoup::dispatchDidReceiveResponse): * UIProcess/PageLoadState.cpp: (WebKit::PageLoadState::didCommitLoad): * UIProcess/PageLoadState.h: * UIProcess/ProvisionalPageProxy.cpp: (WebKit::ProvisionalPageProxy::didCommitLoadForFrame): * UIProcess/ProvisionalPageProxy.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::commitProvisionalPage): (WebKit::WebPageProxy::didCommitLoadForFrame): * UIProcess/WebPageProxy.h: * UIProcess/WebPageProxy.messages.in: * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::dispatchDidCommitLoad): Source/WTF: * wtf/persistence/PersistentDecoder.cpp: (WTF::Persistence::Decoder::decode): * wtf/persistence/PersistentDecoder.h: * wtf/persistence/PersistentEncoder.cpp: (WTF::Persistence::Encoder::encode): * wtf/persistence/PersistentEncoder.h: Tools: HTTPServer now supports HTTPS. Tell your friends! * TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm: (testCertificate): (testIdentity): (credentialWithIdentity): * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm: (TestWebKitAPI::webViewWithNavigationDelegate): (TestWebKitAPI::TEST): * TestWebKitAPI/cocoa/HTTPServer.h: * TestWebKitAPI/cocoa/HTTPServer.mm: (TestWebKitAPI::HTTPServer::HTTPServer): (TestWebKitAPI::HTTPServer::request const): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255846 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-05 Alex Christensen Make WKWebView._negotiatedLegacyTLS accurate when loading main resouorce from network or cache https://bugs.webkit.org/show_bug.cgi?id=207207 Reviewed by Chris Dumez. HTTPServer now supports HTTPS. Tell your friends! * TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm: (testCertificate): (testIdentity): (credentialWithIdentity): * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm: (TestWebKitAPI::webViewWithNavigationDelegate): (TestWebKitAPI::TEST): * TestWebKitAPI/cocoa/HTTPServer.h: * TestWebKitAPI/cocoa/HTTPServer.mm: (TestWebKitAPI::HTTPServer::HTTPServer): (TestWebKitAPI::HTTPServer::request const): 2020-02-11 Alan Coon Cherry-pick r255845. rdar://problem/59298143 _WKDownload should expose the originating FrameInfo. and https://bugs.webkit.org/show_bug.cgi?id=207185 Patch by Brady Eidson on 2020-02-05 Reviewed by Geoff Garen. Source/WebKit: Covered by new API test. For the cases where a navigation is converted into a download, include the relevant WKFrameInfo on the _WKDownload object. * UIProcess/API/APIFrameInfo.h: * UIProcess/API/Cocoa/_WKDownload.h: * UIProcess/API/Cocoa/_WKDownload.mm: (-[_WKDownload originatingFrameInfo]): * UIProcess/Downloads/DownloadProxy.cpp: (WebKit::generateDownloadID): (WebKit::DownloadProxy::DownloadProxy): (WebKit::DownloadProxy::create): Deleted. (WebKit::DownloadProxy::setOriginatingPage): Deleted. * UIProcess/Downloads/DownloadProxy.h: (WebKit::DownloadProxy::create): (WebKit::DownloadProxy::frameInfo): * UIProcess/Downloads/DownloadProxyMap.cpp: (WebKit::DownloadProxyMap::createDownloadProxy): * UIProcess/Downloads/DownloadProxyMap.h: * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::createDownloadProxy): * UIProcess/Network/NetworkProcessProxy.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::receivedPolicyDecision): * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::download): (WebKit::WebProcessPool::resumeDownload): (WebKit::WebProcessPool::createDownloadProxy): * UIProcess/WebProcessPool.h: Tools: * TestWebKitAPI/Tests/WebKitCocoa/Download.mm: (-[DownloadTestSchemeDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): (-[DownloadSecurityOriginDelegate _downloadDidStart:]): (loaded): * TestWebKitAPI/cocoa/HTTPServer.mm: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255845 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-05 Brady Eidson _WKDownload should expose the originating FrameInfo. and https://bugs.webkit.org/show_bug.cgi?id=207185 Reviewed by Geoff Garen. * TestWebKitAPI/Tests/WebKitCocoa/Download.mm: (-[DownloadTestSchemeDelegate webView:decidePolicyForNavigationResponse:decisionHandler:]): (-[DownloadSecurityOriginDelegate _downloadDidStart:]): (loaded): * TestWebKitAPI/cocoa/HTTPServer.mm: 2020-02-11 Alan Coon Cherry-pick r255826. rdar://problem/59299115 REGRESSION(r255595): page not closed after beforeunload handler returns true https://bugs.webkit.org/show_bug.cgi?id=207189 Reviewed by Youenn Fablet. Add API test coverage for fix landed in r255677. * TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm: (-[SlowBeforeUnloadPromptUIDelegate _webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:]): (TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255826 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-05 Chris Dumez REGRESSION(r255595): page not closed after beforeunload handler returns true https://bugs.webkit.org/show_bug.cgi?id=207189 Reviewed by Youenn Fablet. Add API test coverage for fix landed in r255677. * TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm: (-[SlowBeforeUnloadPromptUIDelegate _webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:]): (TEST): 2020-02-11 Alan Coon Cherry-pick r255595. rdar://problem/59298183 Regression(r253224) WKUIDelegate.webViewDidClose may get called twice after calling _tryClose on the WKWebView https://bugs.webkit.org/show_bug.cgi?id=207121 Reviewed by Alex Christensen. Source/WebKit: WKUIDelegate.webViewDidClose may get called twice after calling _tryClose on the WKWebView, in case we time out while waiting for an answer from the WebProcess but the WebProcess eventually responds. Change is covered by new API test. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::tryClose): Tools: Add API test coverage. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit/beforeunload-slow.html: Added. * TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm: (-[SlowBeforeUnloadHandlerUIDelegate _webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:]): (-[SlowBeforeUnloadHandlerUIDelegate webViewDidClose:]): (TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255595 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-03 Chris Dumez Regression(r253224) WKUIDelegate.webViewDidClose may get called twice after calling _tryClose on the WKWebView https://bugs.webkit.org/show_bug.cgi?id=207121 Reviewed by Alex Christensen. Add API test coverage. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit/beforeunload-slow.html: Added. * TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm: (-[SlowBeforeUnloadHandlerUIDelegate _webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:]): (-[SlowBeforeUnloadHandlerUIDelegate webViewDidClose:]): (TEST): 2020-02-11 Alan Coon Cherry-pick r255158. rdar://problem/59298137 Throttling requestAnimationFrame should be controlled by RenderingUpdateScheduler https://bugs.webkit.org/show_bug.cgi?id=204713 Patch by Said Abou-Hallawa on 2020-01-27 Reviewed by Simon Fraser. Source/WebCore: Test: fast/animation/request-animation-frame-throttling-outside-viewport.html requestAnimationFrame is throttled by a timer although its callback are serviced by the page RenderingUpdate. This led to excessive rAF firing which makes it more than the preferred frame per seconds. The solution is to have two throttling types: 1) Page throttling (or full throttling) which slows down all the steps of RenderingUpdate for the main document and all the sub-documents. 2) Document throttling (or partial throttling) which only slows down the rAF of a certain document. * Headers.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::animationInterval const): (WebCore::DocumentTimeline::updateThrottlingState): Deleted. * animation/DocumentTimeline.h: There is no need to have DocumentTimeline throttling. It is already throttled when the page RenderingUpdate is throttled. * dom/Document.cpp: (WebCore::Document::requestAnimationFrame): (WebCore::Document::updateLastHandledUserGestureTimestamp): LowPowerMode throttling is now handled by the page. So remove its handling in the Document side. * dom/ScriptedAnimationController.cpp: (WebCore::ScriptedAnimationController::ScriptedAnimationController): (WebCore::ScriptedAnimationController::page const): (WebCore::ScriptedAnimationController::preferredScriptedAnimationInterval const): (WebCore::ScriptedAnimationController::interval const): (WebCore::ScriptedAnimationController::isThrottled const): (WebCore::ScriptedAnimationController::isThrottledRelativeToPage const): (WebCore::ScriptedAnimationController::shouldRescheduleRequestAnimationFrame const): (WebCore::ScriptedAnimationController::registerCallback): (WebCore::ScriptedAnimationController::cancelCallback): (WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks): (WebCore::ScriptedAnimationController::scheduleAnimation): (WebCore::throttlingReasonToString): Deleted. (WebCore::throttlingReasonsToString): Deleted. (WebCore::ScriptedAnimationController::addThrottlingReason): Deleted. (WebCore::ScriptedAnimationController::removeThrottlingReason): Deleted. (WebCore::ScriptedAnimationController::animationTimerFired): Deleted. * dom/ScriptedAnimationController.h: (WebCore::ScriptedAnimationController::addThrottlingReason): (WebCore::ScriptedAnimationController::removeThrottlingReason): Get rid of the rAF throttling timer. Service the rAF callback only when the period from the current time stamp till the last service time stamp is greater than the preferred rAF interval . * page/FrameView.cpp: (WebCore::FrameView::updateScriptedAnimationsAndTimersThrottlingState): ThrottlingReason is now defined outside ScriptedAnimationController. * page/Page.cpp: (WebCore::Page::renderingUpdateThrottlingEnabled const): (WebCore::Page::renderingUpdateThrottlingEnabledChanged): (WebCore::Page::isRenderingUpdateThrottled const): (WebCore::Page::preferredRenderingUpdateInterval const): Calculate the preferred RenderingUpdate interval from the throttling reasons. (WebCore::Page::setIsVisuallyIdleInternal): (WebCore::Page::handleLowModePowerChange): Call adjustRenderingUpdateFrequency() when isLowPowerModeEnabled or IsVisuallyIdle is toggled. (WebCore::updateScriptedAnimationsThrottlingReason): Deleted. * page/Page.h: * page/RenderingUpdateScheduler.cpp: (WebCore::RenderingUpdateScheduler::adjustFramesPerSecond): (WebCore::RenderingUpdateScheduler::adjustRenderingUpdateFrequency): Change the preferredFramesPerSecond of the DisplayRefreshMonitor if the throttling is not aggressive e.g. 10_s. Otherwise use the timer. (WebCore::RenderingUpdateScheduler::scheduleTimedRenderingUpdate): Call adjustFramesPerSecond() when DisplayRefreshMonitor is created. (WebCore::RenderingUpdateScheduler::startTimer): * page/RenderingUpdateScheduler.h: * page/Settings.yaml: * page/SettingsBase.cpp: (WebCore::SettingsBase::renderingUpdateThrottlingEnabledChanged): * page/SettingsBase.h: Add a setting to enable/disable RenderingUpdateThrottling. * platform/graphics/AnimationFrameRate.h: Added. (WebCore::preferredFrameInterval): (WebCore::preferredFramesPerSecond): * platform/graphics/DisplayRefreshMonitor.h: (WebCore::DisplayRefreshMonitor::setPreferredFramesPerSecond): * platform/graphics/DisplayRefreshMonitorManager.cpp: (WebCore::DisplayRefreshMonitorManager::monitorForClient): Rename createMonitorForClient() to monitorForClient() since it may return a cached DisplayRefreshMonitor. (WebCore::DisplayRefreshMonitorManager::setPreferredFramesPerSecond): (WebCore::DisplayRefreshMonitorManager::scheduleAnimation): (WebCore::DisplayRefreshMonitorManager::windowScreenDidChange): No need to call registerClient(). This function was just ensuring the DisplayRefreshMonitor is created. scheduleAnimation() does the same thing. (WebCore::DisplayRefreshMonitorManager::createMonitorForClient): Deleted. (WebCore::DisplayRefreshMonitorManager::registerClient): Deleted. * platform/graphics/DisplayRefreshMonitorManager.h: (WebCore::DisplayRefreshMonitorManager::DisplayRefreshMonitorManager): Deleted. * platform/graphics/GraphicsLayerUpdater.cpp: (WebCore::GraphicsLayerUpdater::GraphicsLayerUpdater): * platform/graphics/ios/DisplayRefreshMonitorIOS.mm: (-[WebDisplayLinkHandler setPreferredFramesPerSecond:]): Set the preferredFramesPerSecond of the CADisplayLink. Source/WebKit: Create an IPC message on the DrawingArea to send a message from the WebProcess to the UIProcess to setPreferredFramesPerSecond of the DisplayRefreshMonitor. * Shared/WebPreferences.yaml: * UIProcess/API/C/WKPreferences.cpp: (WKPreferencesSetRenderingUpdateThrottlingEnabled): (WKPreferencesGetRenderingUpdateThrottlingEnabled): * UIProcess/API/C/WKPreferencesRefPrivate.h: Add a WKPreference key for RenderingUpdateThrottlingEnabled. * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h: * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.messages.in: * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm: (-[WKOneShotDisplayLinkHandler setPreferredFramesPerSecond:]): (WebKit::RemoteLayerTreeDrawingAreaProxy::setPreferredFramesPerSecond): Set the preferredFramesPerSecond of the CADisplayLink. * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDisplayRefreshMonitor.h: * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDisplayRefreshMonitor.mm: (WebKit::RemoteLayerTreeDisplayRefreshMonitor::setPreferredFramesPerSecond): Delegate the call to RemoteLayerTreeDrawingArea. * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h: * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm: (WebKit::RemoteLayerTreeDrawingArea::setPreferredFramesPerSecond): Send the IPC message from the WebProcess to the UIProcess. Source/WebKitLegacy/mac: Add a WKPreference key for RenderingUpdateThrottling. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences renderingUpdateThrottlingEnabled]): (-[WebPreferences setRenderingUpdateThrottlingEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Add a WKPreference key for RenderingUpdateThrottling. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferenceKeysPrivate.h: * WebPreferences.cpp: (WebPreferences::initializeDefaultSettings): (WebPreferences::renderingUpdateThrottlingEnabled): (WebPreferences::setRenderingUpdateThrottlingEnabled): * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: RenderingUpdateThrottling is enabled by default. Turn it off for DRT and WTR. In some cases, the page may not get visually active while it's waiting for rAF. Throttling tests will have to explicitly turn it on. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): * DumpRenderTree/win/DumpRenderTree.cpp: (resetWebPreferencesToConsistentValues): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): LayoutTests: * fast/animation/css-animation-throttling-lowPowerMode.html: * fast/animation/request-animation-frame-throttle-subframe.html: * fast/animation/request-animation-frame-throttling-detached-iframe.html: Enable RenderingUpdateThrottling for these tests. * fast/animation/request-animation-frame-throttling-lowPowerMode-expected.txt: * fast/animation/request-animation-frame-throttling-lowPowerMode.html: Ensure the actual rAF interval is > 30ms for lowPowerMode. * fast/animation/request-animation-frame-throttling-outside-viewport-expected.txt: Added. * fast/animation/request-animation-frame-throttling-outside-viewport.html: Added. * fast/animation/resources/frame-with-animation-2.html: Added. Test the OutsideViewport throttling case. * http/tests/frame-throttling/raf-throttle-in-cross-origin-subframe.html: Enable RenderingUpdateThrottling for this test. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255158 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-27 Said Abou-Hallawa Throttling requestAnimationFrame should be controlled by RenderingUpdateScheduler https://bugs.webkit.org/show_bug.cgi?id=204713 Reviewed by Simon Fraser. RenderingUpdateThrottling is enabled by default. Turn it off for DRT and WTR. In some cases, the page may not get visually active while it's waiting for rAF. Throttling tests will have to explicitly turn it on. * DumpRenderTree/mac/DumpRenderTree.mm: (resetWebPreferencesToConsistentValues): * DumpRenderTree/win/DumpRenderTree.cpp: (resetWebPreferencesToConsistentValues): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): 2020-02-10 Kocsen Chung Cherry-pick r256000. rdar://problem/59299326 WebPage::rangeForGranularityAtPoint always returns null in the case of CharacterGranularity https://bugs.webkit.org/show_bug.cgi?id=207350 Reviewed by Tim Horton. Source/WebKit: Handle the character granularity case in `WebPage::rangeForGranularityAtPoint` by just returning a collapsed Range. Certain internal clients will have a need to place and update the text selection using character granularity; see radar for more details. Test: UIWKInteractionViewProtocol.SelectTextWithCharacterGranularity * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView supportsTextSelectionWithCharacterGranularity]): * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::rangeForGranularityAtPoint): Tools: Add a test to exercise the corner case in the SPI. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256000 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-06 Wenson Hsieh WebPage::rangeForGranularityAtPoint always returns null in the case of CharacterGranularity https://bugs.webkit.org/show_bug.cgi?id=207350 Reviewed by Tim Horton. Add a test to exercise the corner case in the SPI. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm: Added. 2020-02-10 Kocsen Chung Cherry-pick r255863. rdar://problem/59299151 Unreviewed build fix after r255846. * TestWebKitAPI/cocoa/HTTPServer.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255863 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-02-05 Chris Dumez Unreviewed build fix after r255846. * TestWebKitAPI/cocoa/HTTPServer.h: 2020-02-10 Kocsen Chung Cherry-pick r255522. rdar://problem/59299116 Add KVO SPI WKWebView._negotiatedLegacyTLS https://bugs.webkit.org/show_bug.cgi?id=207067 Patch by Alex Christensen on 2020-01-31 Reviewed by Andy Estes. Source/WebKit: Covered by API tests. * NetworkProcess/NetworkDataTask.cpp: (WebKit::NetworkDataTask::negotiatedLegacyTLS const): * NetworkProcess/NetworkDataTask.h: (WebKit::NetworkDataTaskClient::negotiatedLegacyTLS const): * NetworkProcess/NetworkLoad.cpp: (WebKit::NetworkLoad::negotiatedLegacyTLS const): * NetworkProcess/NetworkLoad.h: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]): * Shared/Authentication/AuthenticationManager.cpp: (WebKit::AuthenticationManager::negotiatedLegacyTLS const): * Shared/Authentication/AuthenticationManager.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _negotiatedLegacyTLS]): * UIProcess/API/Cocoa/WKWebViewPrivate.h: * UIProcess/Cocoa/NavigationState.h: * UIProcess/Cocoa/NavigationState.mm: (WebKit::NavigationState::willChangeNegotiatedLegacyTLS): (WebKit::NavigationState::didChangeNegotiatedLegacyTLS): * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::negotiatedLegacyTLS): * UIProcess/Network/NetworkProcessProxy.h: * UIProcess/Network/NetworkProcessProxy.messages.in: * UIProcess/PageLoadState.cpp: (WebKit::PageLoadState::commitChanges): (WebKit::PageLoadState::hasNegotiatedLegacyTLS const): (WebKit::PageLoadState::negotiatedLegacyTLS): (WebKit::PageLoadState::didCommitLoad): * UIProcess/PageLoadState.h: (WebKit::PageLoadState::Observer::willChangeNegotiatedLegacyTLS): (WebKit::PageLoadState::Observer::didChangeNegotiatedLegacyTLS): (WebKit::PageLoadState::Data::Data): Deleted. * UIProcess/WebPageProxy.cpp: * UIProcess/WebPageProxy.h: Tools: * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm: (-[TLSObserver observeValueForKeyPath:ofObject:change:context:]): (-[TLSObserver waitUntilNegotiatedLegacyTLSChanged]): (TestWebKitAPI::TEST): * TestWebKitAPI/config.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255522 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-31 Alex Christensen Add KVO SPI WKWebView._negotiatedLegacyTLS https://bugs.webkit.org/show_bug.cgi?id=207067 Reviewed by Andy Estes. * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm: (-[TLSObserver observeValueForKeyPath:ofObject:change:context:]): (-[TLSObserver waitUntilNegotiatedLegacyTLSChanged]): (TestWebKitAPI::TEST): * TestWebKitAPI/config.h: 2020-02-04 Russell Epstein Cherry-pick r255461. rdar://problem/59153618 Add WKNavigationDelegate SPI to disable TLS 1.0 and 1.1 https://bugs.webkit.org/show_bug.cgi?id=206979 Reviewed by Brady Eidson. Source/WebCore/PAL: * pal/spi/cf/CFNetworkSPI.h: Source/WebKit: * NetworkProcess/NetworkCORSPreflightChecker.cpp: (WebKit::NetworkCORSPreflightChecker::didReceiveChallenge): * NetworkProcess/NetworkCORSPreflightChecker.h: * NetworkProcess/NetworkDataTask.h: * NetworkProcess/NetworkLoad.cpp: (WebKit::NetworkLoad::didReceiveChallenge): * NetworkProcess/NetworkLoad.h: * NetworkProcess/NetworkProcessCreationParameters.cpp: (WebKit::NetworkProcessCreationParameters::encode const): (WebKit::NetworkProcessCreationParameters::decode): * NetworkProcess/NetworkProcessCreationParameters.h: * NetworkProcess/NetworkSessionCreationParameters.cpp: (WebKit::NetworkSessionCreationParameters::encode const): (WebKit::NetworkSessionCreationParameters::decode): * NetworkProcess/NetworkSessionCreationParameters.h: * NetworkProcess/PingLoad.cpp: (WebKit::PingLoad::didReceiveChallenge): * NetworkProcess/PingLoad.h: * NetworkProcess/cocoa/NetworkDataTaskCocoa.h: * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm: (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa): (WebKit::NetworkDataTaskCocoa::didReceiveChallenge): (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection): * NetworkProcess/cocoa/NetworkProcessCocoa.mm: (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa): * NetworkProcess/cocoa/NetworkSessionCocoa.h: * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (processServerTrustEvaluation): (-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]): (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): (WebKit::NetworkSessionCocoa::continueDidReceiveChallenge): * Shared/Authentication/AuthenticationManager.cpp: (WebKit::AuthenticationManager::didReceiveAuthenticationChallenge): * Shared/Authentication/AuthenticationManager.h: * UIProcess/API/APINavigationClient.h: (API::NavigationClient::shouldAllowLegacyTLS): * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h: * UIProcess/Cocoa/NavigationState.h: * UIProcess/Cocoa/NavigationState.mm: (WebKit::NavigationState::setNavigationDelegate): (WebKit::systemAllowsLegacyTLSFor): (WebKit::NavigationState::NavigationClient::shouldAllowLegacyTLS): * UIProcess/Cocoa/WebProcessPoolCocoa.mm: (WebKit::WebProcessPool::platformInitializeNetworkProcess): * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::didReceiveAuthenticationChallenge): * UIProcess/Network/NetworkProcessProxy.h: * UIProcess/Network/NetworkProcessProxy.messages.in: * UIProcess/WebPageProxy.cpp: * UIProcess/WebPageProxy.h: * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::parameters): * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h: Source/WebKitLegacy/mac: * WebView/WebView.mm: (-[WebView _commonInitializationWithFrameName:groupName:]): Tools: * MiniBrowser/mac/SettingsController.m: * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm: (-[TLSNavigationDelegate waitForDidFinishNavigation]): (-[TLSNavigationDelegate waitForDidFailProvisionalNavigation]): (-[TLSNavigationDelegate receivedShouldAllowLegacyTLS]): (-[TLSNavigationDelegate webView:didReceiveAuthenticationChallenge:completionHandler:]): (-[TLSNavigationDelegate webView:didFinishNavigation:]): (-[TLSNavigationDelegate webView:didFailProvisionalNavigation:withError:]): (-[TLSNavigationDelegate _webView:authenticationChallenge:shouldAllowLegacyTLS:]): (TestWebKitAPI::TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255461 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-30 Alex Christensen Add WKNavigationDelegate SPI to disable TLS 1.0 and 1.1 https://bugs.webkit.org/show_bug.cgi?id=206979 Reviewed by Brady Eidson. * MiniBrowser/mac/SettingsController.m: * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm: (-[TLSNavigationDelegate waitForDidFinishNavigation]): (-[TLSNavigationDelegate waitForDidFailProvisionalNavigation]): (-[TLSNavigationDelegate receivedShouldAllowLegacyTLS]): (-[TLSNavigationDelegate webView:didReceiveAuthenticationChallenge:completionHandler:]): (-[TLSNavigationDelegate webView:didFinishNavigation:]): (-[TLSNavigationDelegate webView:didFailProvisionalNavigation:withError:]): (-[TLSNavigationDelegate _webView:authenticationChallenge:shouldAllowLegacyTLS:]): (TestWebKitAPI::TEST): 2020-02-04 Russell Epstein Cherry-pick r255533. rdar://problem/59098565 REGRESSION(r252185): NetworkSessionCocoa cancels downloads that receive authentication challenges https://bugs.webkit.org/show_bug.cgi?id=206984 rdar://problem/58999654 Reviewed by Brady Eidson. Source/WebKit: r252185 changed the early return in WKNetworkSessionDelegate's -...task:didReceiveChallenge:... method from "cancel the task and return early if self has no _session" to "cancel the task and return early if we can't determine the network session for the given data task". When this method is called for an NSURLSessionDownloadTask, this early return is hit because there is no NetworkDataTaskCocoa for an active download. As a result, the download is canceled when it might have otherwise been able to proceed. Fix this by adding a code path to fetch the NetworkSession associated with the Download when an NSURLSessionDownloadTask receives an authentication challenge. This ensures we can actually handle the challenge appropriately and not just cancel the task. * NetworkProcess/Downloads/Download.h: (WebKit::Download::sessionID const): Expose the session ID so we can use it to look up the NetworkSession for a Download. * NetworkProcess/cocoa/NetworkSessionCocoa.mm: (-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]): Remove an unnecessary redeclaration of networkDataTask, and also an unneeded assertion that networkDataTask != nullptr. Even if this is the case, the code that eventually handles this task will null check it and handle the challenge as a websocket task or download task based on the taskIdentifier. Tools: Add an API test for a resumed download that receives an authentication challenge. The download delegate should be asked to handle the challenge, and the download should be able to finish. * TestWebKitAPI/Tests/WebKitCocoa/Download.mm: (-[DownloadCancelingDelegate _download:decideDestinationWithSuggestedFilename:completionHandler:]): (-[DownloadCancelingDelegate _download:didReceiveData:]): (-[DownloadCancelingDelegate _downloadDidCancel:]): (-[AuthenticationChallengeHandlingDelegate _download:didReceiveAuthenticationChallenge:completionHandler:]): (-[AuthenticationChallengeHandlingDelegate _downloadDidFinish:]): (TEST): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255533 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-31 David Quesada REGRESSION(r252185): NetworkSessionCocoa cancels downloads that receive authentication challenges https://bugs.webkit.org/show_bug.cgi?id=206984 rdar://problem/58999654 Reviewed by Brady Eidson. Add an API test for a resumed download that receives an authentication challenge. The download delegate should be asked to handle the challenge, and the download should be able to finish. * TestWebKitAPI/Tests/WebKitCocoa/Download.mm: (-[DownloadCancelingDelegate _download:decideDestinationWithSuggestedFilename:completionHandler:]): (-[DownloadCancelingDelegate _download:didReceiveData:]): (-[DownloadCancelingDelegate _downloadDidCancel:]): (-[AuthenticationChallengeHandlingDelegate _download:didReceiveAuthenticationChallenge:completionHandler:]): (-[AuthenticationChallengeHandlingDelegate _downloadDidFinish:]): (TEST): 2020-02-04 Russell Epstein Cherry-pick r255507. rdar://problem/59098088 REGRESSION: [ iPadOS ] imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements.html always fails Reviewed by Brent Fulgham. Source/WebKit: Test: imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements.html * Platform/spi/ios/UIKitSPI.h: (-[UIViewController isPerformingModalTransition]): Add SPI declaration. Tools: * WebKitTestRunner/ios/UIScriptControllerIOS.h: (WTR::UIScriptControllerIOS::waitForModalTransitionToFinish const): - Add declaration. * WebKitTestRunner/ios/UIScriptControllerIOS.mm: (WTR::UIScriptControllerIOS::waitForModalTransitionToFinish const): - Implement by waiting for -[UIViewController isPerformingModalTransition] to return NO while spinning the runloop. (WTR::UIScriptControllerIOS::singleTapAtPointWithModifiers): - Call waitForModalTransitionToFinish() to fix the test. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255507 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-31 David Kilzer REGRESSION: [ iPadOS ] imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements.html always fails Reviewed by Brent Fulgham. * WebKitTestRunner/ios/UIScriptControllerIOS.h: (WTR::UIScriptControllerIOS::waitForModalTransitionToFinish const): - Add declaration. * WebKitTestRunner/ios/UIScriptControllerIOS.mm: (WTR::UIScriptControllerIOS::waitForModalTransitionToFinish const): - Implement by waiting for -[UIViewController isPerformingModalTransition] to return NO while spinning the runloop. (WTR::UIScriptControllerIOS::singleTapAtPointWithModifiers): - Call waitForModalTransitionToFinish() to fix the test. 2020-02-04 Russell Epstein Cherry-pick r255322. rdar://problem/59097817 macCatalyst: Triple clicking to select a sentence results in an empty selection https://bugs.webkit.org/show_bug.cgi?id=206863 Reviewed by Wenson Hsieh. Source/WebCore: * editing/EditingBehavior.h: (WebCore::EditingBehavior::shouldSelectOnContextualMenuClick const): * page/ChromeClient.h: (WebCore::ChromeClient::shouldUseMouseEventsForSelection): * page/EventHandler.cpp: (WebCore::EventHandler::canMouseDownStartSelect): (WebCore::canMouseDownStartSelect): Deleted. * page/EventHandler.h: Disable WebCore's mouse-event-driven selection mechanisms on macCatalyst, where we use a UITextInteraction-driven selection instead. Otherwise, they conflict with each other in a chaotic fashion. Source/WebKit: * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: * UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _doAfterProcessingAllPendingMouseEvents:]): * UIProcess/API/mac/WKWebViewPrivateForTestingMac.h: * UIProcess/API/mac/WKWebViewTestingMac.mm: (-[WKWebView _doAfterProcessingAllPendingMouseEvents:]): Deleted. * UIProcess/Cocoa/WebViewImpl.h: * UIProcess/Cocoa/WebViewImpl.mm: (WebKit::WebViewImpl::handleProcessSwapOrExit): (WebKit::WebViewImpl::doAfterProcessingAllPendingMouseEvents): Deleted. (WebKit::WebViewImpl::didFinishProcessingAllPendingMouseEvents): Deleted. (WebKit::WebViewImpl::flushPendingMouseEventCallbacks): Deleted. * UIProcess/PageClient.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::doAfterProcessingAllPendingMouseEvents): (WebKit::WebPageProxy::didFinishProcessingAllPendingMouseEvents): (WebKit::WebPageProxy::flushPendingMouseEventCallbacks): * UIProcess/WebPageProxy.h: * UIProcess/ios/PageClientImplIOS.h: * UIProcess/mac/PageClientImplMac.h: * UIProcess/mac/PageClientImplMac.mm: (WebKit::PageClientImpl::didFinishProcessingAllPendingMouseEvents): Deleted. Move "doAfterProcessingAllPendingMouseEvents" to WebPage instead of WebViewImpl, so it can be used on all platforms. Expose it via WKWebView. * WebProcess/WebCoreSupport/WebChromeClient.h: * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm: (WebKit::WebChromeClient::shouldUseMouseEventsForSelection): Tools: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKitCocoa/MacCatalystMouseSupport.mm: Added. (-[WKTestingEvent locationInView:]): (-[WKTestingEvent _setButtonMask:]): (-[WKTestingEvent _buttonMask]): (-[WKTestingTouch locationInView:]): (-[WKTestingTouch setTapCount:]): (-[WKTestingTouch tapCount]): (mouseGesture): (TEST): Add a test ensuring that simply plumbing mouse events to WebCore does not result in a selection change in macCatalyst (because UIKit will handle the selection change itself, instead). git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255322 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-28 Tim Horton macCatalyst: Triple clicking to select a sentence results in an empty selection https://bugs.webkit.org/show_bug.cgi?id=206863 Reviewed by Wenson Hsieh. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKitCocoa/MacCatalystMouseSupport.mm: Added. (-[WKTestingEvent locationInView:]): (-[WKTestingEvent _setButtonMask:]): (-[WKTestingEvent _buttonMask]): (-[WKTestingTouch locationInView:]): (-[WKTestingTouch setTapCount:]): (-[WKTestingTouch tapCount]): (mouseGesture): (TEST): Add a test ensuring that simply plumbing mouse events to WebCore does not result in a selection change in macCatalyst (because UIKit will handle the selection change itself, instead). 2020-02-04 Russell Epstein Cherry-pick r255234. rdar://problem/59098321 [Web Animations] Make Animation.timeline read-write only if a runtime flag is enabled https://bugs.webkit.org/show_bug.cgi?id=206173 Reviewed by Dean Jackson. Source/WebCore: Make the timeline property of Animation read-write only if the new WebAnimationsMutableTimelines runtime flag is enabled. * animation/WebAnimation.idl: Make the "timeline" property conditionally read-write if WebAnimationsMutableTimelines is enabled. * bindings/js/WebCoreBuiltinNames.h: With the new RuntimeConditionallyReadWrite property used in WebAnimation.idl, it is necessary to declare the name of the affected property, in this case "timeline", in WebCoreBuiltinNames. * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setWebAnimationsMutableTimelinesEnabled): (WebCore::RuntimeEnabledFeatures::webAnimationsMutableTimelinesEnabled const): Source/WebKit: Add a new WebAnimationsMutableTimelines runtime flag. * Shared/WebPreferences.yaml: Source/WebKitLegacy/mac: Add a new WebAnimationsMutableTimelines runtime flag. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (-[WebPreferences webAnimationsMutableTimelinesEnabled]): (-[WebPreferences setWebAnimationsMutableTimelinesEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Add a new WebAnimationsMutableTimelines runtime flag. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferenceKeysPrivate.h: * WebPreferences.cpp: (WebPreferences::initializeDefaultSettings): (WebPreferences::setWebAnimationsMutableTimelinesEnabled): (WebPreferences::webAnimationsMutableTimelinesEnabled): * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Manually enable the new WebAnimationsMutableTimelines runtime flag in DumpRenderTree. * DumpRenderTree/mac/DumpRenderTree.mm: (enableExperimentalFeatures): * DumpRenderTree/win/DumpRenderTree.cpp: (enableExperimentalFeatures): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255234 268f45cc-cd09-0410-ab3c-d52691b4dbfc 2020-01-28 Antoine Quint [Web Animations] Make Animation.timeline read-write only if a runtime flag is enabled https://bugs.webkit.org/show_bug.cgi?id=206173 Reviewed by Dean Jackson. Manually enable the new WebAnimationsMutableTimelines runtime flag in DumpRenderTree. * DumpRenderTree/mac/DumpRenderTree.mm: (enableExperimentalFeatures): * DumpRenderTree/win/DumpRenderTree.cpp: (enableExperimentalFeatures): 2020-02-04 Russell Epstein Cherry-pick r254082. rdar://problem/59098088 REGRESSION: [ iOS ] imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements.html is failing https://bugs.webkit.org/show_bug.cgi?id=205458 Patch by Antoine Quint on 2020-01-06 Reviewed by Wenson Hsieh. Tools: The last sub-test in imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements.html checks on the ability to activate various form controls after disabling and re-enabling them. Two of those form controls,