Commit Graph

5983 Commits

Author SHA1 Message Date
Adrien Destugues 0195b40b77 Merge commit 'e4390067fab9a407b0c303e04f03c77381cb2ddb' into Haiku 2021-08-30 17:59:07 +02:00
Alex Christensen ff37bd0a8d Make UIEventAttribution tests less platform dependent
https://bugs.webkit.org/show_bug.cgi?id=229323

Reviewed by John Wilander.

Source/WebKit:

This allows me to run the UIEventAttribution tests on macOS.
It also makes them not time out, which they were doing since r277447.
To accomplish this, I added more test SPI to prevent the network process
suspension message, which was causing the test to time out on the iOS simulator.

* UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
* UIProcess/API/Cocoa/WKWebViewTesting.mm:
(-[WKWebView _addEventAttributionWithSourceID:destinationURL:sourceDescription:purchaser:reportEndpoint:optionalNonce:]):
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(+[WKWebsiteDataStore _preventNetworkProcessSuspensionForTesting]):
* UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
* UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
* UIProcess/API/ios/WKWebViewTestingIOS.mm:
(-[WKWebView _setUIEventAttributionForTesting:withNonce:]): Deleted.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::preventSuspensionForTesting):
(WebKit::NetworkProcessProxy::sendPrepareToSuspend):
* UIProcess/Network/NetworkProcessProxy.h:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
(TestWebKitAPI::exampleURL):
(TestWebKitAPI::runBasicEventAttributionTest):
(TestWebKitAPI::TEST):



Canonical link: https://commits.webkit.org/240764@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281349 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-20 23:01:58 +00:00
Carlos Alberto Lopez Perez c0e9d9d1ca REGRESSION(r274166): [GTK] It broke run-javascriptcore-tests causing all tests to use lot of memory
https://bugs.webkit.org/show_bug.cgi?id=229321

Unreviewed, reverting r274166 because it caused JSC tests to use too much memory.

Reverted changeset:
        "[GTK] Reenable -fvisibility=hidden"
        https://bugs.webkit.org/show_bug.cgi?id=181916
        https://commits.webkit.org/r274166

.:

* Source/cmake/OptionsGTK.cmake:

Source/WebCore:

Covered by existing tests.

* PlatformGTK.cmake:
* dom/EventTarget.cpp:
* dom/EventTarget.h:

Tools:

* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/glib/TestExpectations.json:

Canonical link: https://commits.webkit.org/240750@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281333 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-20 20:05:57 +00:00
Megan Gardner 59d9110764 Turn on TestWebKitAPI.WKAttachmentTests.CopyAndPasteBetweenWebViews as it is now passing again.
https://bugs.webkit.org/show_bug.cgi?id=204969

Reviewed by Tim Horton.

* TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm:
(TestWebKitAPI::TEST):


Canonical link: https://commits.webkit.org/240700@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281275 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-19 22:32:47 +00:00
Adrien Destugues 9cabb795d1 Merge commit '788086b3b8ba5a5894f8cfe1094ed237351b2dea' into Haiku 2021-08-19 20:21:07 +02:00
Carlos Garcia Campos 6d32f07ec6 document.hasFocus() returns true for unfocused pages
https://bugs.webkit.org/show_bug.cgi?id=229139

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2021-08-19
Reviewed by Adrian Perez de Castro.

Source/WebCore:

We are always claiming to be focused when the document in the active window even if the page is not actually
focused.

* dom/Document.cpp:
(WebCore::Document::hasFocus const): Check also that page is focused.

Tools:

Add a unit tests to check document.hasFocus() returns false when a web view is in the active window, but not focused.

* TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
(TestWebKitAPI::TEST): Ensure web view is focused as required by credentials container.
* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
(testWebViewDocumentFocus):
(beforeAll):
* TestWebKitAPI/cocoa/TestWKWebView.h:
* TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[TestWKWebView focus]):

Canonical link: https://commits.webkit.org/240665@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281228 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-19 08:46:05 +00:00
Lauro Moura d47b4187cf REGRESSION(r281079) [GLIB] API test WebKitWebsiteData/deviceidhashsalt is not waiting for title change
https://bugs.webkit.org/show_bug.cgi?id=229174

Reviewed by Carlos Garcia Campos.

r281079 changed the helper method waitUntilTitleChangedTo to
immediately return if the current title is already the expected one.

While this is working fine in other tests, the deviceidhashsalt tries
to load the same page twice. As the title does not change, the call
returns right away, before the expected side effects of the load
happen.

This commit adds a dummy "about:blank" call between both original
calls to make sure we track the title change correctly.

* TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp:
(testWebsiteDataDeviceIdHashSalt):


Canonical link: https://commits.webkit.org/240583@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281129 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-17 06:43:39 +00:00
Ryosuke Niwa a8662ed1bf Add thread safe version of CanMakeCheckedPtr
https://bugs.webkit.org/show_bug.cgi?id=229018

Reviewed by Geoffrey Garen.

Source/WTF:

Introduce CanMakeThreadSafeCheckedPtr which is a thread safe version of CanMakeCheckedPtr.

* wtf/CheckedRef.h:
(WTF::CanMakeCheckedPtrBase): Extracted from CanMakeCheckedPtr.
(WTF::CanMakeCheckedPtrBase::~CanMakeCheckedPtrBase):
(WTF::CanMakeCheckedPtrBase::ptrCount const):
(WTF::SingleThreadIntegralWrapper): Added.
(WTF::SingleThreadIntegralWrapper::SingleThreadIntegralWrapper):
(WTF::SingleThreadIntegralWrapper::operator IntegralType const):
(WTF::SingleThreadIntegralWrapper::operator! const):
(WTF::SingleThreadIntegralWrapper::operator++):
(WTF::SingleThreadIntegralWrapper::operator--):
(WTF::SingleThreadIntegralWrapper::assertThread const):
(WTF::CanMakeCheckedPtr): Redefined using CanMakeCheckedPtrBase and SimpleNonAtomicType.
(WTF::CanMakeThreadSafeCheckedPtr): Added.

Tools:

Added a unit test for CanMakeThreadSafeCheckedPtr

* TestWebKitAPI/Tests/WTF/CheckedPtr.cpp:
(TestWebKitAPI.ThreadSafeCheckedPtrObject)
(WTF_CheckedPtr.CanMakeThreadSafeCheckedPtr): Added.


Canonical link: https://commits.webkit.org/240564@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-16 20:42:00 +00:00
Alex Christensen 953d30b139 Fix Catalyst TestWebKitAPI build
https://bugs.webkit.org/show_bug.cgi?id=229091

Patch by Alex Christensen <achristensen@webkit.org> on 2021-08-16
Reviewed by Wenson Hsieh.

* TestWebKitAPI/Configurations/Base.xcconfig:
Search the correct SDK paths.
* TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm:
(TestWebKitAPI::TEST):
Use soft linking for VisionKitCore like we do elsewyere.

Canonical link: https://commits.webkit.org/240550@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281090 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-16 16:36:12 +00:00
Philippe Normand c0b3d3ecbe [GLib] Enable mediastream setting if it's enabled at build-time
https://bugs.webkit.org/show_bug.cgi?id=229134

Patch by Philippe Normand <pnormand@igalia.com> on 2021-08-16
Reviewed by Adrian Perez de Castro.

Source/WebKit:

* UIProcess/API/glib/WebKitSettings.cpp:
(webKitSettingsConstructed):

Tools:

* TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp:
(testWebKitSettings):

Canonical link: https://commits.webkit.org/240545@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281085 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-16 16:18:46 +00:00
Carlos Garcia Campos bf6f5e5866 [GTK] Test WebKitWebView/page-visibility is a flaky timeout
https://bugs.webkit.org/show_bug.cgi?id=214804

Reviewed by Adrian Perez de Castro.

Do not wait for title change if the title already changed.

* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
(testWebViewPageVisibility):
* TestWebKitAPI/glib/TestExpectations.json:
* TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:
(WebViewTest::waitUntilTitleChangedTo):
(WebViewTest::waitUntilTitleChanged):

Canonical link: https://commits.webkit.org/240539@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281079 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-16 13:56:21 +00:00
Miguel Gomez fa52cc6b54 [GTK][WPE] Add API to pass WebKitMemoryPressureHandler parameters to the network processes
https://bugs.webkit.org/show_bug.cgi?id=228227

Reviewed by Carlos Garcia Campos.

Source/WebKit:

Added webkit_website_data_manager_set_memory_pressure_settings() API function to pass a
WebKitMemoryPressureSettings instance as the settings to use by all the network processes.

* NetworkProcess/NetworkProcessCreationParameters.cpp:
(WebKit::NetworkProcessCreationParameters::encode const):
(WebKit::NetworkProcessCreationParameters::decode):
* NetworkProcess/NetworkProcessCreationParameters.h:
* NetworkProcess/soup/NetworkProcessSoup.cpp:
(WebKit::NetworkProcess::platformInitializeNetworkProcess):
* UIProcess/API/glib/WebKitMemoryPressureSettings.cpp:
* UIProcess/API/glib/WebKitWebsiteDataManager.cpp:
(webkit_website_data_manager_set_memory_pressure_settings):
* UIProcess/API/gtk/WebKitWebsiteDataManager.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
* UIProcess/API/wpe/WebKitWebsiteDataManager.h:
* UIProcess/API/wpe/docs/wpe-1.0-sections.txt:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::didExceedMemoryLimit):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:
* UIProcess/WebProcessPool.h:
* UIProcess/soup/WebProcessPoolSoup.cpp:
(WebKit::memoryPressureMonitorDisabled):
(WebKit::WebProcessPool::platformInitializeNetworkProcess):

Source/WTF:

Added a new method to MemoryPressureHandler to set the configuration by copying the parameter
instead of moving it.

* wtf/MemoryPressureHandler.h:
(WTF::MemoryPressureHandler::setConfiguration):

Tools:

Added an API test for webkit_website_data_manager_set_memory_pressure_settings().

* TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp:
(MemoryPressureTest::setup):
(MemoryPressureTest::teardown):
(MemoryPressureTest::loadFailedCallback):
(MemoryPressureTest::waitUntilLoadFailed):
(testMemoryPressureSettings):
(beforeAll):


Canonical link: https://commits.webkit.org/240531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281070 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-16 06:55:58 +00:00
Lauro Moura 34f1058370 [WPE] WebExtension API test /webkit/WebKitWebView/web-process-crashed is flaky failing
https://bugs.webkit.org/show_bug.cgi?id=229067

Reviewed by Carlos Garcia Campos.

* TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp:
(testWebKitWebViewProcessCrashed): Make warnings non-fatal while waiting for the crash.
* TestWebKitAPI/glib/TestExpectations.json: Remove expectation


Canonical link: https://commits.webkit.org/240505@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-13 14:40:23 +00:00
Lauro Moura 98ed0104d8 [WPE] Gardening web-process-crashed API test failure
Unreviewed test gardening.

* TestWebKitAPI/glib/TestExpectations.json:

Canonical link: https://commits.webkit.org/240496@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281006 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-13 03:34:00 +00:00
Chris Dumez 874b3cae87 REGRESSION (iPadOS 14): [ iPadOS wk2 ] TestWebKitAPI.ServiceWorkers.SuspendNetworkProcess is a flaky failure
https://bugs.webkit.org/show_bug.cgi?id=217714
<rdar://problem/70296664>

Reviewed by Geoffrey Garen.

Give the database some time to get written out to disk before we try and suspend the network process, to try
and address the flakiness.

* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:


Canonical link: https://commits.webkit.org/240490@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-12 23:26:58 +00:00
Devin Rousso dad2a5dec4 Fix some `NSAttributedString` inconsistencies between WK1 and WK2
https://bugs.webkit.org/show_bug.cgi?id=229013
<rdar://problem/81215696>

Reviewed by Timothy Hatcher.

Source/WebCore:

`NSAttributedString` now uses WK2, which has caused us to discover some inconsistencies (and bugs).

Tests: NSAttributedStringWebKitAdditions.DefaultFontSize
       NSAttributedStringWebKitAdditions.MultipleParagraphs

* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_blockLevelElementForNode):
Check the given node before looking at the parent as it could already be a block. This
allows for sequental `<p>` to each have their own positioning instead of only the first one.
(HTMLConverter::computedAttributesForElement):
Fix typo that used `margin-right` instead of `margin-bottom` when setting `paragraphSpacing`.

Source/WebKit:

`NSAttributedString` now uses WK2, which has caused us to discover some inconsistencies (and bugs).

* UIProcess/API/Cocoa/NSAttributedString.mm:
(+[_WKAttributedStringWebViewCache configuration]):
Change the default font size to 12 to match WK1.

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/NSAttributedStringWebKitAdditions.mm: Added.
(TEST.NSAttributedStringWebKitAdditions.DefaultFontSize):
(TEST.NSAttributedStringWebKitAdditions.MultipleParagraphs):

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:


Canonical link: https://commits.webkit.org/240477@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280973 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-12 18:58:47 +00:00
Youenn Fablet 3bcf265b55 Adopt span in RTCRtpSFrameTransform
https://bugs.webkit.org/show_bug.cgi?id=229029

Reviewed by Eric Carlson.

Source/WebCore:

Transition to Span for improved readability, no change of behavior.

* Modules/mediastream/RTCEncodedFrame.cpp:
(WebCore::RTCEncodedFrame::data const):
* Modules/mediastream/RTCRtpSFrameTransform.cpp:
(WebCore::processFrame):
(WebCore::RTCRtpSFrameTransform::initializeTransformer):
(WebCore::transformFrame):
(WebCore::RTCRtpSFrameTransform::createStreams):
* Modules/mediastream/RTCRtpSFrameTransformer.cpp:
(WebCore::RTCRtpSFrameTransformer::decryptFrame):
(WebCore::RTCRtpSFrameTransformer::encryptFrame):
(WebCore::RTCRtpSFrameTransformer::transform):
* Modules/mediastream/RTCRtpSFrameTransformer.h:
* Modules/mediastream/RTCRtpScriptTransformer.cpp:
(WebCore::RTCRtpScriptTransformer::writable):
* Modules/mediastream/RTCRtpTransformableFrame.h:
(): Deleted.
* Modules/mediastream/libwebrtc/LibWebRTCRtpTransformableFrame.cpp:
(WebCore::LibWebRTCRtpTransformableFrame::data const):
(WebCore::LibWebRTCRtpTransformableFrame::setData):
* Modules/mediastream/libwebrtc/LibWebRTCRtpTransformableFrame.h:

Tools:

* TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp:
(TestWebKitAPI::TEST):


Canonical link: https://commits.webkit.org/240476@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-12 17:13:11 +00:00
Chris Dumez 5d7cb25d03 Unreviewed API test build fix with recent MacOS SDK.
* TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
(verifyCertificateAndPublicKey):

Canonical link: https://commits.webkit.org/240475@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280969 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-12 15:48:58 +00:00
Carlos Garcia Campos d757ee4433 [GTK] Simplify TestWebKitAccessibility
https://bugs.webkit.org/show_bug.cgi?id=229032

Reviewed by Michael Catanzaro.

We don't really need to have a different process to test a11y. We can remove AccessibilityTestServer and use the
same test executable. That way we don't need to spawn a process and use DBus for the communication.

* TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp: Removed.
* TestWebKitAPI/Tests/WebKitGtk/TestWebKitAccessibility.cpp:
(AccessibilityTest::findTestApplication): Find the accessible application corresponding to the test executable.
(AccessibilityTest::waitUntilChildrenRemoved): Use the WebViewTest main loop.
(testAtspiBasicHierarchy): Use WebViewTest::loadHtml.
* TestWebKitAPI/glib/PlatformGTK.cmake:
* TestWebKitAPI/glib/WebKitGLib/TestMain.cpp:
(main): Set the program name to the executable name. It helps to a11y test to find the accessible app.

Canonical link: https://commits.webkit.org/240472@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280966 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-12 13:53:44 +00:00
Youenn Fablet 830ca4f6c6 Implement SFrameTransform error handling
https://bugs.webkit.org/show_bug.cgi?id=228947

Reviewed by Eric Carlson.

Source/WebCore:

Add support for RTCRtpSFrameTransformErrorEvent.
When RTCRtpSFrameTransformer encounters an issue, dispatch a task to RTCRtpSFrameTransform context and fire a corresponding event.
This follows https://w3c.github.io/webrtc-encoded-transform/#sframe-transform-algorithm, except that:
- we are not yet exposing some fields in RTCRtpSFrameTransformErrorEvent.
- we are using errorType instead of type which should be fixed in the spec.

Test: imported/w3c/web-platform-tests/webrtc-encoded-transform/sframe-transform-error.html

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Modules/mediastream/RTCRtpSFrameTransform.cpp:
(WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform):
(WebCore::errorTypeFromInformation):
(WebCore::processFrame):
(WebCore::RTCRtpSFrameTransform::hasKey const):
(WebCore::RTCRtpSFrameTransform::initializeTransformer):
(WebCore::transformFrame):
(WebCore::RTCRtpSFrameTransform::createStreams):
(WebCore::RTCRtpSFrameTransform::writable):
(WebCore::RTCRtpSFrameTransform::virtualHasPendingActivity const):
* Modules/mediastream/RTCRtpSFrameTransform.h:
* Modules/mediastream/RTCRtpSFrameTransform.idl:
* Modules/mediastream/RTCRtpSFrameTransformErrorEvent.cpp: Added.
(WebCore::RTCRtpSFrameTransformErrorEvent::create):
(WebCore::RTCRtpSFrameTransformErrorEvent::RTCRtpSFrameTransformErrorEvent):
(WebCore::RTCRtpSFrameTransformErrorEvent::eventInterface const):
* Modules/mediastream/RTCRtpSFrameTransformErrorEvent.h: Added.
* Modules/mediastream/RTCRtpSFrameTransformErrorEvent.idl: Added.
* Modules/mediastream/RTCRtpSFrameTransformer.cpp:
(WebCore::RTCRtpSFrameTransformer::hasKey const):
(WebCore::RTCRtpSFrameTransformer::decryptFrame):
(WebCore::RTCRtpSFrameTransformer::encryptFrame):
(WebCore::RTCRtpSFrameTransformer::transform):
* Modules/mediastream/RTCRtpSFrameTransformer.h:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/WebCoreBuiltinNames.h:
* dom/EventNames.in:
* dom/EventTargetFactory.in:

Tools:

* TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp:
(TestWebKitAPI::TEST):

LayoutTests:

* http/wpt/webrtc/sframe-transform-error-worker.js: Added.
(onrtctransform.async event):
* http/wpt/webrtc/sframe-transform-error.html: Added.
* http/wpt/webrtc/sframe-transform-error-expected: Added.


Canonical link: https://commits.webkit.org/240464@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-12 09:37:05 +00:00
Chris Dumez e6c7e17d32 Add initial support for Cross-Origin-Embedder-Policy (COEP)
https://bugs.webkit.org/show_bug.cgi?id=228754

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline COEP WPT tests now that we are passing more checks.

* web-platform-tests/html/cross-origin-embedder-policy/blob.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/coep-frame-javascript.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/coep-on-response-from-service-worker.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/credentialless/iframe-coep-require-corp.tentative.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/data.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/dedicated-worker-cache-storage.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/dedicated-worker.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/header-parsing.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/javascript.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/multi-globals/workers-coep-report.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/no-secure-context-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/none-sw-from-require-corp.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/none.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/reporting-to-endpoint.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-blank-expected.txt: Removed.
* web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-blank.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-srcdoc-expected.txt: Removed.
* web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-srcdoc.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/require-corp-load-from-cache-storage.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw-from-none.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw-from-require-corp.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/require-corp.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/sandbox.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/service-worker-cache-storage.https-expected.txt:
* web-platform-tests/html/cross-origin-embedder-policy/srcdoc.https-expected.txt:

Source/WebCore:

Add initial support for Cross-Origin-Embedder-Policy (COEP) behind a runtime feature flag, off by default:
- https://html.spec.whatwg.org/multipage/origin.html#coep

The COEP header has the following impacts:
- When a document with `Cross-Origin-Embedder-Policy: require-corp` loads an iframe or a worker script, if the network
  response for that iframe doesn't also contain `Cross-Origin-Embedder-Policy: require-corp`, then we fail the load.
- When a document with `Cross-Origin-Embedder-Policy: require-corp` loads cross-origin subresources, then either CORS
  must be used or the resource response must be allowed by Cross-Origin-Resource-Policy (CORP) header.

Support is only for WK2 and checks are done in the network process for better security. Support for workers and service
workers (including cache storage) is included.

Most of the Web-Platform-Tests for COEP are passing with this patch. The exceptions are:
- Some tests relying on Blob are failing. Similarly to COOP, Blobs need to inherit COEP from their
  creator. This is currently unimplemented as the change will likely be non-trivial. I will follow-up
  to fix Blob support for both COOP and COEP.
- Tests in the credentialless/ folder are failing because we do not support `Cross-Origin-Embedder-Policy: credentialless`.
  This seems to be a fairly recent extension proposed by Google and it is not part of the HTML specification yet.
- Some tests expect violation reporting and they are failing and we do not implement reporting yet.

Note that `self.crossOriginIsolated` still returns false, even if the pages opts into both COOP & COEP, and APIs such
as SharedArrayBuffer still are not permitted to use. In order to support this, we will have to actually implement process
swapping so that we know a process is not actually shared by several origins.

Test: http/wpt/html/cross-origin-embedder-policy/require-corp.https.html

* Modules/cache/DOMCache.cpp:
(WebCore::DOMCache::queryCache):
* Modules/cache/DOMCacheEngine.cpp:
(WebCore::DOMCacheEngine::convertToException):
* Modules/cache/DOMCacheEngine.h:
* Modules/cache/RetrieveRecordsOptions.h:
(WebCore::RetrieveRecordsOptions::isolatedCopy const):
(WebCore::RetrieveRecordsOptions::encode const):
(WebCore::RetrieveRecordsOptions::decode):
* dom/Document.cpp:
(WebCore::Document::initSecurityContext):
* dom/SecurityContext.h:
(WebCore::SecurityContext::crossOriginEmbedderPolicy const):
(WebCore::SecurityContext::setCrossOriginEmbedderPolicy):
* loader/CrossOriginAccessControl.cpp:
(WebCore::shouldCrossOriginResourcePolicyCancelLoad):
(WebCore::validateCrossOriginResourcePolicy):
* loader/CrossOriginAccessControl.h:
* loader/CrossOriginEmbedderPolicy.cpp:
(WebCore::obtainCrossOriginEmbedderPolicy):
(WebCore::CrossOriginEmbedderPolicy::isolatedCopy const):
* loader/CrossOriginEmbedderPolicy.h:
(WebCore::CrossOriginEmbedderPolicy::encode const):
(WebCore::CrossOriginEmbedderPolicy::decode):
* loader/CrossOriginOpenerPolicy.cpp:
(WebCore::obtainCrossOriginOpenerPolicy):
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::loadResourceSynchronously):
(WebCore::DocumentThreadableLoader::create):
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
(WebCore::DocumentThreadableLoader::crossOriginEmbedderPolicy const):
* loader/DocumentThreadableLoader.h:
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::begin):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::didBeginDocument):
* loader/ResourceLoaderOptions.h:
* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestResource):
* page/SecurityOrigin.h:
* platform/network/HTTPParsers.cpp:
(WebCore::parseCrossOriginResourcePolicyHeader):
* platform/network/HTTPParsers.h:
* workers/Worker.cpp:
(WebCore::Worker::notifyFinished):
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::WorkerGlobalScope):
* workers/WorkerGlobalScopeProxy.h:
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
* workers/WorkerMessagingProxy.h:
* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::loadSynchronously):
(WebCore::WorkerScriptLoader::loadAsynchronously):
(WebCore::WorkerScriptLoader::didReceiveResponse):
* workers/WorkerScriptLoader.h:
(WebCore::WorkerScriptLoader::crossOriginEmbedderPolicy const):
* workers/WorkerThread.cpp:
(WebCore::WorkerParameters::isolatedCopy const):
* workers/WorkerThread.h:
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
* workers/service/ServiceWorkerContainer.h:
* workers/service/ServiceWorkerContextData.cpp:
(WebCore::ServiceWorkerContextData::isolatedCopy const):
* workers/service/ServiceWorkerContextData.h:
(WebCore::ServiceWorkerContextData::encode const):
(WebCore::ServiceWorkerContextData::decode):
* workers/service/ServiceWorkerFetchResult.h:
(WebCore::ServiceWorkerFetchResult::isolatedCopy const):
(WebCore::serviceWorkerFetchError):
(WebCore::ServiceWorkerFetchResult::encode const):
(WebCore::ServiceWorkerFetchResult::decode):
* workers/service/ServiceWorkerJob.cpp:
(WebCore::ServiceWorkerJob::notifyFinished):
* workers/service/ServiceWorkerJobClient.h:
* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::ServiceWorkerThread):
* workers/service/server/RegistrationDatabase.cpp:
(WebCore::RegistrationDatabase::doPushChanges):
(WebCore::RegistrationDatabase::importRecords):
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::addRegistrationFromStore):
(WebCore::SWServer::updateWorker):
(WebCore::SWServer::installContextData):
* workers/service/server/SWServer.h:
* workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::scriptFetchFinished):
* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::SWServerWorker):
(WebCore::SWServerWorker::contextData const):
* workers/service/server/SWServerWorker.h:

Source/WebKit:

As mentioned in the WebCore changelog, we do all the COEP checks in the network process
instead of WebCore for added security. As a result, we need to pass more information
to the network process when doing loads in order to do those checks. The checks are done
in NetworkResourceLoader for navigations & worker script loads (similarly to CSP,
X-FrameOptions) and in NetworkLoadChecker for CORP checks of subresource loads (similarly
to CORS checks).

* NetworkProcess/NetworkLoadChecker.cpp:
(WebKit::NetworkLoadChecker::NetworkLoadChecker):
(WebKit::NetworkLoadChecker::validateResponse):
* NetworkProcess/NetworkLoadChecker.h:
(WebKit::NetworkLoadChecker::setParentCrossOriginEmbedderPolicy):
(WebKit::NetworkLoadChecker::setCrossOriginEmbedderPolicy):
* NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::parentOrigin const):
(WebKit::NetworkResourceLoadParameters::encode const):
(WebKit::NetworkResourceLoadParameters::decode):
* NetworkProcess/NetworkResourceLoadParameters.h:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::shouldInterruptLoadForCSPFrameAncestorsOrXFrameOptions):
(WebKit::NetworkResourceLoader::shouldInterruptNavigationForCrossOriginEmbedderPolicy):
(WebKit::NetworkResourceLoader::shouldInterruptWorkerLoadForCrossOriginEmbedderPolicy):
(WebKit::NetworkResourceLoader::didReceiveResponse):
(WebKit::NetworkResourceLoader::willSendRedirectedRequest):
* NetworkProcess/NetworkResourceLoader.h:
* NetworkProcess/PingLoad.cpp:
(WebKit::PingLoad::PingLoad):
(WebKit::PingLoad::initialize):
* NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:
(WebKit::ServiceWorkerFetchTask::didReceiveResponse):
* NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp:
(WebKit::ServiceWorkerSoftUpdateLoader::processResponse):
(WebKit::ServiceWorkerSoftUpdateLoader::didFinishLoading):
* NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.h:
* NetworkProcess/cache/CacheStorageEngineCache.cpp:
(WebKit::CacheStorage::Cache::retrieveRecords):
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::addParametersShared):
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):

Source/WTF:

Add experimental feature flag for Cross-Origin-Embedder-Policy (COEP), off by default.

* Scripts/Preferences/WebPreferencesExperimental.yaml:

LayoutTests:

Update test expectations now that we support COEP on WK2.

* TestExpectations:
* http/wpt/html/cross-origin-embedder-policy/require-corp.https-expected.txt: Added.
* http/wpt/html/cross-origin-embedder-policy/require-corp.https.html: Added.
* http/wpt/html/cross-origin-embedder-policy/require-corp.https.html.headers: Added.
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:


Canonical link: https://commits.webkit.org/240459@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280953 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-12 02:43:53 +00:00
Peng Liu 66b1d7c8b0 [ BigSur Debug ] TestWebKitAPI.GPUProcess.CrashWhilePlayingAudioViaCreateMediaElementSource is flaky, hitting ASSERTION FAILED: !isInRoutingArbitrationForToken(token)
https://bugs.webkit.org/show_bug.cgi?id=227728
<rdar://problem/80237464>

Reviewed by Jer Noble.

Source/WebKit:

After the GPU process crashes, the UI process will clean up the
`SharedRoutingArbitrator`, while a WebContent process might be resuming
the media playback and setup `AudioSessionRoutingArbitrator`.
There is a race condition here. If the WebContent process runs faster,
`SharedRoutingArbitrator` in the UI process will try to begin a duplicated
routing arbitration and lead to an assertion failure.

No new tests. Fixed following two API test failures:
- TestWebKitAPI.WebKit2.CrashGPUProcessWhileCapturing
- TestWebKitAPI.GPUProcess.CrashWhilePlayingAudioViaCreateMediaElementSource

* UIProcess/Media/cocoa/AudioSessionRoutingArbitratorProxyCocoa.mm:
(WebKit::AudioSessionRoutingArbitratorProxy::processDidTerminate):
* WebProcess/GPU/GPUProcessConnection.cpp:
(WebKit::GPUProcessConnection::didClose):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm:
(TEST):


Canonical link: https://commits.webkit.org/240457@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280951 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-12 01:11:15 +00:00
Youenn Fablet 95faabf3b3 Media element is not always autoplaying when going from background to foreground if it is initially not in viewport
https://bugs.webkit.org/show_bug.cgi?id=228955
Source/WebCore:

Reviewed by Eric Carlson.

In case video element is autoplayable but is paused, we should try to autoplay even if we are not interrupted due to invisible autoplay.
Covered by API test.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateShouldAutoplay):

Tools:

rdar://81751653

Reviewed by Eric Carlson.

* TestWebKitAPI/Tests/WebKit/GetUserMedia.mm:


Canonical link: https://commits.webkit.org/240440@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280920 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-11 18:08:49 +00:00
Devin Rousso 2c6dee95cc [macOS] REGRESSION(r278850): modifying `playbackRate` via JS on a TouchBar mac only sometimes works and also causes the `defaultPlaybackRate` to change
https://bugs.webkit.org/show_bug.cgi?id=228939
<rdar://problem/80427578>

Reviewed by Eric Carlson.

Source/WebCore:

Test: VideoControlsManager.VideoControlsManagerDoesNotChangeValuesExposedToJavaScript

* platform/mac/PlaybackSessionInterfaceMac.mm:
(WebCore::PlaybackSessionInterfaceMac::rateChanged):
Make sure to change the `defaultPlaybackRate` before the `rate` as otherwise the former will
override changes made to the latter (see r278850 (and r277203) for details as to why).

* platform/mac/WebPlaybackControlsManager.h:
* platform/mac/WebPlaybackControlsManager.mm:
(-[WebPlaybackControlsManager setDefaultPlaybackRate:]):
(-[WebPlaybackControlsManager setDefaultPlaybackRate:fromJavaScript:]): Added.
(-[WebPlaybackControlsManager setRate:]):
(-[WebPlaybackControlsManager setRate:fromJavaScript:]): Added.
Add a way to distinguish whether the change to the `rate`/`defaultPlaybackRate` came from JS
or some native call (e.g. AVKit). If the former, don't propagate the change to the playback
model (which eventually is the `HTMLMediaElement` in the WebProcess) as that's where the
value came from in the first place. Note that we still want to propagate the `rate` to the
`defaultPlaybackRate` (and vice versa when `isPlaying`) in the UIProcess for the reasons
described in r278850 (and r277203), but we don't want to expose it to JS.

* platform/ios/PlaybackSessionInterfaceAVKit.mm:
(WebCore::PlaybackSessionInterfaceAVKit::rateChanged):
* platform/ios/WebAVPlayerController.h:
* platform/ios/WebAVPlayerController.mm:
(-[WebAVPlayerController setDefaultPlaybackRate:]):
(-[WebAVPlayerController setDefaultPlaybackRate:fromJavaScript:]): Added.
(-[WebAVPlayerController setRate:]):
(-[WebAVPlayerController setRate:fromJavaScript:]): Added.
Drive-by: r278850 was based r277203 (which added the above), so fix that code now too.

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/VideoControlsManager.mm:
(TestWebKitAPI::TEST.VideoControlsManager.VideoControlsManagerDoesNotChangeValuesExposedToJavaScript): Added.


Canonical link: https://commits.webkit.org/240391@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280840 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-10 14:31:51 +00:00
Adrien Destugues d6974a01e1 Merge commit '4c93d7c924a050bdef974543bb03c118cf962acc' into Haiku 2021-08-08 14:31:09 +02:00
Youenn Fablet 81d5631f01 [GPUP] Test WebKit2.CrashGPUProcessAfterApplyingConstraints fails when Media in GPU Process is enabled
https://bugs.webkit.org/show_bug.cgi?id=228759
<rdar://problem/81529641>

Reviewed by Geoffrey Garen.

Source/WebCore:

Revert part of https://trac.webkit.org/changeset/279940/webkit.

* platform/mediastream/RealtimeVideoSource.cpp:
(WebCore::RealtimeVideoSource::sourceSettingsChanged):
Covered by API test.

Tools:

* TestWebKitAPI/Tests/WebKit/GetUserMedia.mm:
Reenable test.


Canonical link: https://commits.webkit.org/240319@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280732 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-06 19:06:15 +00:00
Ryan Haddad dce5ab7fad REGRESSION (r279855): TestWebKitAPI.AppleLanguagesTest.UpdateAppleLanguages is failing
https://bugs.webkit.org/show_bug.cgi?id=228309

Unreviewed test gardening.

This test has been skipped on Apple Silicon because of timeouts, and
now it is a flaky failure on Intel machines. Disable it outright for
the time being.

* TestWebKitAPI/Tests/WebKit/OverrideAppleLanguagesPreference.mm:
(TEST_F):

Canonical link: https://commits.webkit.org/240305@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280713 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-06 01:01:32 +00:00
Kate Cheney 2d946d4217 LoadWebArchive.FailNavigation1 test is a false positive
https://bugs.webkit.org/show_bug.cgi?id=228848
<rdar://problem/81587448>

Reviewed by Brent Fulgham.

Source/WebKit:

Drive by logging fix.

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::fetchWebsiteData):
(WebKit::WebProcessProxy::deleteWebsiteData):

Tools:

Update LoadWebArchive.FailNavigation1 to test the case of a webarchive
being loaded with a host for better test coverage.

* TestWebKitAPI/Tests/mac/load-web-archive-1.html:


Canonical link: https://commits.webkit.org/240302@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280706 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-05 23:47:09 +00:00
Peng Liu fb68cd3c6b [Catalina][GPUP] Some API tests fail after GPU Process features are enabled
https://bugs.webkit.org/show_bug.cgi?id=228589

Reviewed by Jer Noble.

Source/WebCore:

When "Media in GPU Process" is enabled, `AudioSession[IOS|Mac]` runs in
the GPU process. `HTMLMediaElement`, which is an observer of audio session,
runs in a WebContent process. It cannot get its AudioSession's configuration
directly. We need a mechanism to "push" the latest audio session configuration
from the GPU process to the WebContent process.

This patch replaces the `MutedStateObserver` with an audio session configuration
change observer interface, so that an audio session will notify its observers
after changing its configurations, including buffer size, muted state, sample rate.
Currently, this observer interface is used on macOS only.

No new tests. Fix an API test failure.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::initializeMediaSession):
(WebCore::HTMLMediaElement::~HTMLMediaElement):
(WebCore::HTMLMediaElement::hardwareMutedStateDidChange):
* html/HTMLMediaElement.h:

* platform/audio/AudioSession.cpp:
(WebCore::AudioSession::addConfigurationChangeObserver):
(WebCore::AudioSession::removeConfigurationChangeObserver):
* platform/audio/AudioSession.h:
* platform/audio/ios/AudioSessionIOS.h:
Move `m_interruptionObservers` to this class because only `AudioSessionIOS`
supports interruption observers.
* platform/audio/mac/AudioSessionMac.h:
* platform/audio/mac/AudioSessionMac.mm:
(WebCore::AudioSessionMac::handleSampleRateChange):
(WebCore::AudioSessionMac::handleSampleRateChange const):
(WebCore::AudioSessionMac::handleBufferSizeChange):
(WebCore::AudioSessionMac::handleBufferSizeChange const):
(WebCore::AudioSessionMac::sampleRate const):
(WebCore::AudioSessionMac::setPreferredBufferSize):
(WebCore::AudioSessionMac::handleMutedStateChange):
(WebCore::AudioSessionMac::addConfigurationChangeObserver):
(WebCore::AudioSessionMac::removeConfigurationChangeObserver):
(WebCore::AudioSessionMac::addMutedStateObserver): Deleted.
(WebCore::AudioSessionMac::removeMutedStateObserver): Deleted.

Source/WebKit:

When an audio session's configuration changes, let `RemoteAudioSessionProxy`
in the GPU process send the latest audio session configuration to `RemoteAudioSession`
in the WebContent process through an IPC message (`RemoteAudioSession::ConfigurationChanged`).

* GPUProcess/media/RemoteAudioSessionProxy.cpp:
(WebKit::RemoteAudioSessionProxy::configurationChanged):
* GPUProcess/media/RemoteAudioSessionProxy.h:

* GPUProcess/media/RemoteAudioSessionProxyManager.cpp:
(WebKit::RemoteAudioSessionProxyManager::RemoteAudioSessionProxyManager):
(WebKit::RemoteAudioSessionProxyManager::~RemoteAudioSessionProxyManager):
(WebKit::RemoteAudioSessionProxyManager::beginAudioSessionInterruption):
(WebKit::RemoteAudioSessionProxyManager::endAudioSessionInterruption):
(WebKit::RemoteAudioSessionProxyManager::hardwareMutedStateDidChange):
(WebKit::RemoteAudioSessionProxyManager::bufferSizeDidChange):
(WebKit::RemoteAudioSessionProxyManager::sampleRateDidChange):
(WebKit::RemoteAudioSessionProxyManager::configurationDidChange):

* GPUProcess/media/RemoteAudioSessionProxyManager.h:
* WebProcess/GPU/media/RemoteAudioSession.cpp:
(WebKit::RemoteAudioSession::addConfigurationChangeObserver):
(WebKit::RemoteAudioSession::removeConfigurationChangeObserver):
(WebKit::RemoteAudioSession::configurationChanged):
* WebProcess/GPU/media/RemoteAudioSession.h:
* WebProcess/GPU/media/RemoteAudioSession.messages.in:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/AudioBufferSize.mm:
(TestWebKitAPI::TEST):


Canonical link: https://commits.webkit.org/240270@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-04 21:36:38 +00:00
Myles C. Maxfield f512d3569c [Cocoa] Tweak the formatting for passing NSArrays to TextStreams
https://bugs.webkit.org/show_bug.cgi?id=228766

Reviewed by Simon Fraser.

Source/WTF:

Instead of using -[NSArray description], which puts its output on multiple lines,
instead use the same formatting as WTF::Vector, which puts its output on a single line.

We can also use this opportunity to tweak the implementation of operator<<(id) to
allow it to be called with Core Foundation types in raw C++ code.

* wtf/text/TextStream.h:
* wtf/text/cocoa/TextStreamCocoa.mm:
(WTF::TextStream::operator<<):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.cpp: Added.
(TEST):
* TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.mm: Added.
(TEST):

Canonical link: https://commits.webkit.org/240262@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280651 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-04 19:37:35 +00:00
Risul Islam b3a64fcc34 Add functions for parsing URL query string
https://bugs.webkit.org/show_bug.cgi?id=228122

Patch by Risul Islam <risul_islam@apple.com> on 2021-08-03
Reviewed by Darin Adler.

Source/WTF:

Added parsing of URL query strings.

* wtf/KeyValuePair.h:
(WTF::operator== const):
* wtf/URL.cpp:
(WTF::URL::differingQueryParameters):
(WTF::lengthOfURLIgnoringQueryAndFragments):
(WTF::URL::isEqualIgnoringQueryAndFragments):
(WTF::URL::removeQueryParameters):
* wtf/URL.h:

Tools:

Added the test functions required for parsing URL query string.

* TestWebKitAPI/Tests/WTF/URL.cpp:
(TestWebKitAPI::TEST_F):

Canonical link: https://commits.webkit.org/240239@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-04 01:37:22 +00:00
Peng Liu 7f632b6b12 [GPUP] RemoteAudioSession::setPreferredBufferSize() does not change its preferredBufferSize
https://bugs.webkit.org/show_bug.cgi?id=228720

Reviewed by Jer Noble.

Source/WebKit:

`RemoteAudioSession` should update its `preferredBufferSize` in
`setPreferredBufferSize()`. Otherwise, the `preferredBufferSize`
will become inconsistent with the value in the GPU process.

No new tests. Fix API test failures.

* WebProcess/GPU/media/RemoteAudioSession.cpp:
(WebKit::RemoteAudioSession::setPreferredBufferSize):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/PreferredAudioBufferSize.mm:
(TEST_F):


Canonical link: https://commits.webkit.org/240198@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-03 01:05:39 +00:00
Alex Christensen 663fcb94cb Don't change invalid baseURLs from loadData or loadHTMLString to about:blank
https://bugs.webkit.org/show_bug.cgi?id=228717
<rdar://79909343>

Reviewed by Chris Dumez.

Source/WebKit:

r278737 fixed a compatibility bug from r272469 but introduced a crash when the base URL does not successfully parse.
r279450 fixed that crash but introduced a new behavior change that changes the URL to about:blank.  This didn't seem
to change anything because window.location is about:blank with and without the change, but WKWebView.URL did change,
which broke at least one app.  This undoes the functionality change from r279450 and keeps the crash fix, which are
both covered by API tests.  I also manually verified this fixes the app in the radar.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::loadData):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/LoadAlternateHTMLString.mm:
(TEST):



Canonical link: https://commits.webkit.org/240186@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280562 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-02 22:04:46 +00:00
Ryosuke Niwa 42242af49f Add CheckedRef
https://bugs.webkit.org/show_bug.cgi?id=227164

Reviewed by Geoffrey Garen.

Source/WTF:

Like r278344, this patch introduces a new type of smart pointer, CheckedRef,
which lets each object keep track of pointers pointing to the object.

As with CheckedPtr, the purpose of the internal counter for CheckedRef is
to release assert that there is no outstanding pointer at the time of destruction
instead of keeping the object alive when there is one.

This patch also removes makeCheckedPtr in favor of using CheckedPtr with
template argument deduction in C++17.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/CheckedPtr.h:
(WTF::CheckedPtr::CheckedPtr): Added variants which take CheckedRef as arguments.
(WTF::makeCheckedPtr): Deleted.
(WTF::CanMakeCheckedPtr): Moved to CheckedRef.h
* wtf/CheckedRef.h: Added.
(WTF::CheckedRef::~CheckedRef): Added.
(WTF::CheckedRef::CheckedRef): Added.
(WTF::CheckedRef::isHashTableDeletedValue const): Added.
(WTF::CheckedRef::isHashTableEmptyValue const): Added.
(WTF::CheckedRef::hashTableEmptyValue): Added.
(WTF::CheckedRef::ptrAllowingHashTableEmptyValue const): Added.
(WTF::CheckedRef::ptrAllowingHashTableEmptyValue): Added.
(WTF::CheckedRef::ptr const): Added.
(WTF::CheckedRef::ptr): Added.
(WTF::CheckedRef::get const): Added.
(WTF::CheckedRef::get): Added.
(WTF::CheckedRef::operator-> const): Added.
(WTF::CheckedRef::operator->): Added.
(WTF::CheckedRef::operator const T& const): Added.
(WTF::CheckedRef::operator T&): Added.
(WTF::CheckedRef::operator! const): Added.
(WTF::CheckedRef::operator=): Added.
(WTF::CheckedRef::releasePtr): Added. Returns m_ptr without calling decrementPtrCount.
This is equivalent of leakPtr in Ref but we don't call this that since CheckedRef or
CheckedPtr is generally not used to manage the object lifetime.
(WTF::CheckedRef::poison): Added.
(WTF::CheckedRef::unpoison): Added.
(WTF::is): Added.
(WTF::CheckedRefHashTraits): Added.
(WTF::CheckedRefHashTraits::emptyValue): Added.
(WTF::CheckedRefHashTraits::constructEmptyValue): Added.
(WTF::CheckedRefHashTraits::isEmptyValue): Added.
(WTF::CheckedRefHashTraits::peek): Added.
(WTF::CheckedRefHashTraits::take): Added.
(WTF::CanMakeCheckedPtr): Moved from CheckedPtr.h
* wtf/Forward.h:

Tools:

Added some unit tests for CheckedRef and updated the unit tests
for CheckedPtr per the removal of makeCheckedPtr.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/CheckedPtr.cpp:
(WTF_CheckedPtr.CheckedRef): Added
* TestWebKitAPI/Tests/WTF/CheckedRef.cpp: Added.
(TestWebKitAPI..CheckedObject): Added.
(TestWebKitAPI..DerivedCheckedObject): Added.
(WTF_CheckedRef.Basic): Added.
(WTF_CheckedRef.DerivedClass): Added.
(WTF_CheckedRef.HashSet): Added.


Canonical link: https://commits.webkit.org/240183@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-02 21:46:29 +00:00
Lauro Moura fcc106a8c1 [GLIB] Make CORS allowlist test wait for promise resolution
https://bugs.webkit.org/show_bug.cgi?id=228695

Reviewed by Michael Catanzaro.

r278456 introduced a CORS allow list test that tries to fetch a
resource using the fetch() function, which returns a promise. This is
working on GTK but in WPE the test fails as the promise is not yet
resolved by the time the test variable is checked.

This commit changes the test to actually report the promise failure
through catch() and wait for its resolution before checking the values.

* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
(testWebViewCORSAllowlist):


Canonical link: https://commits.webkit.org/240160@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280528 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-02 14:30:24 +00:00
Adrien Destugues 3c03b69045 Merge commit 'e09283eaa2c87b3bb00c5380c76ccc1292a165c2' into Haiku branch 2021-08-01 10:58:52 +02:00
Peng Liu 9831356769 [Catalina][GPUP] Some API tests fail after GPU Process features are enabled
https://bugs.webkit.org/show_bug.cgi?id=228589

Reviewed by Aakash Jain.

Disable a few API tests while the investigation is ongoing.

* TestWebKitAPI/Tests/WebKit/GetUserMedia.mm:
* TestWebKitAPI/Tests/WebKitCocoa/AudioBufferSize.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKitCocoa/NowPlaying.mm:
(TEST_F):
* TestWebKitAPI/Tests/WebKitCocoa/PreferredAudioBufferSize.mm:
(TEST_F):


Canonical link: https://commits.webkit.org/240077@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280439 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-29 19:04:52 +00:00
Michael Catanzaro 7a28765d57 [WPE][GTK] .asc file extension is appended to filename of text/plain downloads
https://bugs.webkit.org/show_bug.cgi?id=228566

Patch by Michael Catanzaro <mcatanzaro@gnome.org> on 2021-07-29
Reviewed by Adrian Perez de Castro.

Source/WebCore:

Our MIMETypeRegistry::preferredExtensionForMIMEType returns "asc" for text/plain, possibly
because "asc" sorts alphabetically ahead of all other possible file extensions for
text/plain, and we just pick the first one. So if the text file does not contain any file
extension, we give it a file extension for a GPG signature. Ouch.

I don't know how to fix it, but we don't need to, because we don't really want to append any
file extension for text/plain anyway. That's just annoying. If I download a file named
"backtrace" then I don't want it renamed to "backtrace.txt". That would be expected on
Windows, but certainly not from WebKitGTK. So I think it's reasonable to have a special case
for text/plain.

* platform/xdg/MIMETypeRegistryXdg.cpp:
(WebCore::MIMETypeRegistry::preferredExtensionForMIMEType):

Tools:

* TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp:
(serverCallback):
(testDownloadTextPlainMIMEType):
(beforeAll):
* TestWebKitAPI/Tests/WebKitGLib/resources/text: Added.

Canonical link: https://commits.webkit.org/240062@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280422 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-29 14:56:22 +00:00
Ryosuke Niwa 4b00bd3d8f makeWeakPtr should support Ref and RefPtr as the argument
https://bugs.webkit.org/show_bug.cgi?id=228574

Reviewed by Wenson Hsieh.

Source/WTF:

This patch adds variants of makeWeakPtr<T> which take Ref<T> and RefPtr<T>.

Tests: TestWebKitAPI.WTF_WeakPtr.MakeWeakPtrTakesRef
       TestWebKitAPI.WTF_WeakPtr.MakeWeakPtrTakesRefPtr

* wtf/WeakPtr.h:
(WTF::makeWeakPtr):

Tools:

Added unit tests for makeWeakPtr<T> on Ref<T> and RefPtr<T>.

* TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
(TestWebKitAPI::BaseObjectWithRefAndWeakPtr): Added.
(TestWebKitAPI::BaseObjectWithRefAndWeakPtr::create): Added.
(TestWebKitAPI::BaseObjectWithRefAndWeakPtr::someFunction):
(TestWebKitAPI::DerivedObjectWithRefAndWeakPtr): Added.
(TestWebKitAPI::DerivedObjectWithRefAndWeakPtr::create):
(WTF_WeakPtr.MakeWeakPtrTakesRef): Added.
(WTF_WeakPtr.MakeWeakPtrTakesRefPtr): Added.


Canonical link: https://commits.webkit.org/240054@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280414 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-29 02:33:05 +00:00
Alex Christensen 172f26c099 WebSocket: Safari on iOS 15 beta 3 is sending invalid close frame
https://bugs.webkit.org/show_bug.cgi?id=228329

Patch by Alex Christensen <achristensen@webkit.org> on 2021-07-28
Reviewed by Youenn Fablet.

Source/WebKit:

Our NSURLSession WebSocket implementation had two bugs:
1. It was sending 1005 as the close code if none was specified.
   It now sends no close code, which matches Chrome and Firefox.
2. It was not sending a close code before the close reason when a WebSocket is closed due to navigation.
   It now sends the close code in 2 bytes before the reason, which matches Chrome and Firefox.
   Side note: our CFReadStream/CFWriteStream implementation sent neither the code nor the reason
   in this case, which matches no other browser.

Covered by an API test.

* NetworkProcess/cocoa/WebSocketTaskCocoa.mm:
(WebKit::WebSocketTask::close):
* WebProcess/Network/WebSocketChannel.cpp:
(WebKit::WebSocketChannel::fail):
(WebKit::WebSocketChannel::disconnect):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/WebSocket.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/240028@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280385 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-28 15:57:49 +00:00
Wenson Hsieh a767112d28 [macOS Monterey] Pressing Fn+E should present the emoji picker when editing
https://bugs.webkit.org/show_bug.cgi?id=228300
rdar://77558672

Reviewed by Tim Horton.

Source/WebCore/PAL:

Add a new SPI declaration on NSMenu. See WebKit and WebKitLegacy changes for more information.

* pal/spi/mac/NSMenuSPI.h:

Source/WebKit:

In macOS Monterey, the system-wide Fn+E key command presents the Emoji & Symbols UI as a popover. However, this
new key command currently does not work in editable contexts in both WebKit1 and WebKit2 views on macOS, where
we end up just inserting the character "e".

This is because, on both ports, we attempt to interpret NSEvents by calling back into AppKit to handle the
event, recording the selectors that *would've* been performed, and then using this information to build up a
list of WebCore::KeyCommand for the event (which are later converted into editing commands). In WebKit2, we
call into `-[NSTextInputContext handleEventByKeyboardLayout:]` to handle the event, and capture the resulting
calls back into `WKWebView` by storing entries in `m_collectedKeypressCommands` (something similar happens in
WebKit1). In the case of these new Fn commands, they are handled by the system before entering
NSTextInputContext, so NSTextInputContext ends up handling them as regular text insertion.

As an aside, the reason the meta (⌘) key doesn't encounter this problem is because meta, option, control and
shift are considered valid key bindings in NSKeyBindingManager, whereas the function key mask is specifically
excluded from this list for compability reasons. NSTextInputContext consults NSKeyBindingManager in order to
check whether the given NSEvent is a known key binding in `-handleEventByKeyboardLayout:`, so it fails to
acknowledge Fn+E as a key binding.

To work around this, we adopt new AppKit SPI added in rdar://81123724 to determine whether an NSEvent maps to
any main menu items and avoid handling "Fn-*" key events as text insertion if they already map to items in the
main menu.

Test: KeyboardEventTests.FunctionKeyCommand

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::collectKeyboardLayoutCommandsForEvent):

Source/WebKitLegacy/mac:

Apply a similar fix, this time for WebKit1 on macOS.

* WebView/WebHTMLView.mm:
(-[WebHTMLView insertText:]):

Only append "insertText:" for a corresponding NSEvent with the Function key held down if it doesn't also map
to a item in the main menu.

Tools:

Add a new API test that simulates a keypress for "Fn+E" with a main menu that contains a system menu item for
that key binding; the test then verifies that text was not inserted into the page as a result.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/KeyboardEventTests.mm: Added.
(-[KeyboardTestMenu _containsItemMatchingEvent:includingDisabledItems:]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/cocoa/TestWKWebView.h:
* TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[TestWKWebView typeCharacter:]):
(-[TestWKWebView typeCharacter:modifiers:]):


Canonical link: https://commits.webkit.org/239983@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-27 02:21:15 +00:00
Yusuke Suzuki 8c35105dc6 Unreviewed, speculative revert of r280193
https://bugs.webkit.org/show_bug.cgi?id=228142

Source/WebCore:

* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::insertTextNode):
* html/parser/HTMLConstructionSite.h:
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::pumpTokenizerLoop):
* html/parser/HTMLMetaCharsetParser.cpp:
(WebCore::HTMLMetaCharsetParser::checkForMetaCharset):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::HTMLPreloadScanner::scan):
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::clear):
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::shrinkToBestFit): Deleted.
* html/parser/HTMLTokenizer.h:
(WebCore::HTMLTokenizer::shrinkToBestFit): Deleted.
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::characterPredicate):
(WebCore::HTMLTreeBuilder::processFakeCharacters):
(WebCore::HTMLTreeBuilder::insertPhoneNumberLink):
(WebCore::HTMLTreeBuilder::linkifyPhoneNumbers):
(WebCore::HTMLTreeBuilder::processCharacterBuffer):
(WebCore::HTMLTreeBuilder::processCharacterBufferForInBody):
(WebCore::HTMLTreeBuilder::defaultForInTableText):
(WebCore::HTMLTreeBuilder::processTokenInForeignContent):
* html/parser/HTMLTreeBuilder.h:

Source/WTF:

* wtf/Vector.h:
(WTF::Malloc>::shrinkCapacity):
(WTF::Malloc>::shrinkToBestFit): Deleted.
* wtf/text/AtomStringImpl.cpp:
(WTF::UCharBufferTranslator::equal):
(WTF::LCharBufferTranslator::equal):
(WTF::BufferFromStaticDataTranslator::equal):
* wtf/text/StringView.h:
(WTF::StringView::stripLeadingMatchedCharacters): Deleted.

Tools:

* TestWebKitAPI/Tests/WTF/StringView.cpp:
* TestWebKitAPI/Tests/WTF/Vector.cpp:

Canonical link: https://commits.webkit.org/239982@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280335 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-27 01:43:33 +00:00
Alex Christensen 03854abcde WKUserContentController.removeAllScriptMessageHandlers() doesn't release the message handlers
https://bugs.webkit.org/show_bug.cgi?id=228271

Patch by Alex Christensen <achristensen@webkit.org> on 2021-07-26
Reviewed by Sihui Liu.

Source/WebKit:

Covered by an API test.

* UIProcess/UserContent/WebUserContentControllerProxy.cpp:
(WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:
(TEST):

Canonical link: https://commits.webkit.org/239972@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280325 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-26 23:58:23 +00:00
Kate Cheney 307e38a81e ServiceWorkerRegistration.unregister method fails in WKWebView
https://bugs.webkit.org/show_bug.cgi?id=227524
<rdar://problem/80264108>

Reviewed by Youenn Fablet.

Source/WebCore:

We should only check the app-bound domain list when registering a new
worker. Unregistering or updating an existing registration is fine because
we know that every registration has already gone through this check.

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::addRegistrationFromStore):
(WebCore::SWServer::validateRegistrationDomain):
(WebCore::SWServer::scheduleJob):
* workers/service/server/SWServer.h:

Tools:

API test coverage. Drive-by fix to remove unnecessary WKWebView
configuration flags from tests that don't need them.

Note this will also fix https://bugs.webkit.org/show_bug.cgi?id=227531
where updating an existing worker fails after registering 3 domains,
but writing a test for that would require registering service workers
on 3 domains that are not localhost or a loopback IP address, which
we currently do not have infrastructure for.

Testing unregister was only possible because the script URL passed in
during the unregister job is null, so it does not get caught in the
localhost/loopback IP address check, unlike the update case.

* TestWebKitAPI/Tests/WebKitCocoa/InAppBrowserPrivacy.mm:
(TEST):
(-[SWInAppBrowserPrivacyMessageHandler userContentController:didReceiveScriptMessage:]):


Canonical link: https://commits.webkit.org/239967@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280319 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-26 22:09:27 +00:00
Devin Rousso c68f241ca9 [iOS] REGRESSION(r277505): `-[WKWebView underPageBackgroundColor]` also changes the scroll bar color
https://bugs.webkit.org/show_bug.cgi?id=228259
<rdar://problem/80116822>

Reviewed by Tim Horton.

Source/WebKit:

If an application overrides the `-underPageBackgroundColor` with a dark color on a page that
has a light background color, the scroll bar will appear light to match the overridden value
of `-underPageBackgroundColor` instead of dark to match the page's background color.

Test: WKWebViewUnderPageBackgroundColor.MatchesScrollView

* UIProcess/API/ios/WKWebViewIOS.mm:
(baseScrollViewBackgroundColor):
(scrollViewBackgroundColor):
(-[WKWebView _updateScrollViewBackground]):
Add a flag to indicate whether the `underPageBackgroundColor` (which can be overridden by
API) or `pageExtendedBackgroundColor` should be used when calculating the value provided to
`-[UIScrollView setBackgroundColor:]` and `-[UIScrollView setIndicatorStyle:]`. The former
uses the `underPageBackgroundColor` since that is why that API exists and the latter uses
the ``pageExtendedBackgroundColor` since it is based on what is shown in the page, which is
what the scroll bar is drawn on top of.

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/WKWebViewUnderPageBackgroundColor.mm:
(TEST.WKWebViewUnderPageBackgroundColor.MatchesScrollView):


Canonical link: https://commits.webkit.org/239941@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280283 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-24 08:20:05 +00:00
Alex Christensen 041a23a848 Make WKContentRuleListStore respond to same selectors as _WKUserContentExtensionStore
https://bugs.webkit.org/show_bug.cgi?id=228253
Source/WebKit:

<rdar://81038849>

Patch by Alex Christensen <achristensen@webkit.org> on 2021-07-23
Reviewed by Brian Weinstein.

We have an unfortunate situation where an old framework is calling code in a new framework that is giving it a WKContentRuleListStore
where it expects a _WKUserContentExtensionStore.  As one of several mitigations for this problem, make the selectors able to be called.
Luckily it doesn't do much with the results.  It just checks if they're null or not, and it passes any errors along.  I added tests that do this.

* UIProcess/API/Cocoa/WKContentRuleListStore.mm:
(-[WKContentRuleListStore compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]):
(-[WKContentRuleListStore lookupContentExtensionForIdentifier:completionHandler:]):
(-[WKContentRuleListStore removeContentExtensionForIdentifier:completionHandler:]):

Tools:

Patch by Alex Christensen <achristensen@webkit.org> on 2021-07-23
Reviewed by Brian Weinstein.

* TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm:
(TEST_F):

Canonical link: https://commits.webkit.org/239936@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280274 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-24 00:39:15 +00:00
Yusuke Suzuki 609bede062 Micro-optimize innerHTML
https://bugs.webkit.org/show_bug.cgi?id=228142

Reviewed by Simon Fraser.

Source/WebCore:

No behavior change.

This patch does some micro optimizations revealed by the profiler when running some of Speedometer2 tests which intensively use innerHTML.
This offers improvement in jQuery-TodoMVC and Vanilla-ES2015-Babel-Webpack-TodoMVC since both are super innerHTML heavy benchmarks.

----------------------------------------------------------------------------------------------------------------------------------
|               subtest                |     ms      |     ms      |  b / a   | pValue (significance using False Discovery Rate) |
----------------------------------------------------------------------------------------------------------------------------------
| Elm-TodoMVC                          |126.862500   |126.687500   |0.998621  | 0.673462                                         |
| VueJS-TodoMVC                        |27.775000    |27.645833    |0.995350  | 0.741588                                         |
| EmberJS-TodoMVC                      |129.350000   |129.129167   |0.998293  | 0.624196                                         |
| BackboneJS-TodoMVC                   |51.129167    |51.204167    |1.001467  | 0.716622                                         |
| Preact-TodoMVC                       |21.870833    |21.337500    |0.975614  | 0.217771                                         |
| AngularJS-TodoMVC                    |139.854167   |140.266667   |1.002950  | 0.489838                                         |
| Vanilla-ES2015-TodoMVC               |69.229167    |68.895833    |0.995185  | 0.238772                                         |
| Inferno-TodoMVC                      |68.391667    |68.266667    |0.998172  | 0.762281                                         |
| Flight-TodoMVC                       |77.979167    |78.166667    |1.002404  | 0.710324                                         |
| Angular2-TypeScript-TodoMVC          |39.741667    |39.966667    |1.005662  | 0.524123                                         |
| VanillaJS-TodoMVC                    |55.416667    |55.512500    |1.001729  | 0.781447                                         |
| jQuery-TodoMVC                       |268.812500   |266.966667   |0.993133  | 0.003384 (significant)                           |
| EmberJS-Debug-TodoMVC                |345.383333   |345.662500   |1.000808  | 0.695259                                         |
| React-TodoMVC                        |90.679167    |90.179167    |0.994486  | 0.067477                                         |
| React-Redux-TodoMVC                  |152.691667   |152.687500   |0.999973  | 0.991207                                         |
| Vanilla-ES2015-Babel-Webpack-TodoMVC |66.487500    |65.729167    |0.988594  | 0.000118 (significant)                           |
----------------------------------------------------------------------------------------------------------------------------------

a mean = 242.12319
b mean = 242.80485
pValue = 0.1992654128
(Bigger means are better.)
1.003 times better
Results ARE NOT significant

* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::insertTextNode):
* html/parser/HTMLConstructionSite.h:
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::pumpTokenizerLoop): We do not need to call `shrinkToBestFit` in fragment parsing case since
we will discard HTMLToken soon.
* html/parser/HTMLMetaCharsetParser.cpp:
(WebCore::HTMLMetaCharsetParser::checkForMetaCharset):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::HTMLPreloadScanner::scan):
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::clear): We found that these `clear` calls cause performance problem according to the Instruments: we
repeatedly use this Vector, and we repeatedly allocate and deallocate this Vector unnecessarily. We use `resize(0)` instead
to avoid this allocation and deallocation.
(WebCore::HTMLToken::shrinkToBestFit): But HTMLToken is kept so long, so at some point, we would like to make backing storage
small. So, we add shrinkToBestFit and we call it only after finishing batching of HTMLToken processing.
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
* html/parser/HTMLTokenizer.h:
(WebCore::HTMLTokenizer::shrinkToBestFit):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::characterPredicate):
(WebCore::HTMLTreeBuilder::insertPhoneNumberLink):
(WebCore::HTMLTreeBuilder::linkifyPhoneNumbers):
(WebCore::HTMLTreeBuilder::processCharacterBuffer):
(WebCore::HTMLTreeBuilder::processCharacterBufferForInBody):
(WebCore::HTMLTreeBuilder::defaultForInTableText):
(WebCore::HTMLTreeBuilder::processTokenInForeignContent):
(WebCore::HTMLTreeBuilder::processFakeCharacters): Deleted. It is dead code before this patch.
* html/parser/HTMLTreeBuilder.h:

Source/WTF:

* wtf/Vector.h:
(WTF::Malloc>::shrinkToBestFit): This shrinks the backing storage to "appropriate for the living Vector".
* wtf/text/AtomStringImpl.cpp:
(WTF::UCharBufferTranslator::equal): WTF::equal for String does not check hash. This is because computing hash is expensive
and we would like to avoid that if it is not necessary. But when inserting string into AtomStringTable, we can use hash value
since they must be already computed because of HashMap's requirement. So let's use it before calling WTF::equal.
(WTF::LCharBufferTranslator::equal):
(WTF::BufferFromStaticDataTranslator::equal):
* wtf/text/StringView.h:
(WTF::StringView::stripLeadingMatchedCharacters): Add this and use it in HTMLTreeBuilder.

Tools:

* TestWebKitAPI/Tests/WTF/StringView.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/Vector.cpp:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/239881@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280193 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-22 19:18:45 +00:00
Peng Liu 73e9618f0c [ BigSur Debug ] TestWebKitAPI.GPUProcess.CrashWhilePlayingAudioViaCreateMediaElementSource is flaky, hitting ASSERTION FAILED: !isInRoutingArbitrationForToken(token)
https://bugs.webkit.org/show_bug.cgi?id=227728

Unreviewed API test gardening.


* TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm:
(TEST):


Canonical link: https://commits.webkit.org/239874@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280180 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-22 17:28:57 +00:00
commit-queue@webkit.org cae366dd92 nullptr crash in ApplyStyleCommand::applyRelativeFontStyleChange
https://bugs.webkit.org/show_bug.cgi?id=223974

Patch by Frédéric Wang <fwang@igalia.com> on 2021-07-22
Reviewed by Darin Adler.

Source/WebCore:

WebCore::documentOrder does not handle well elements like <summary> that contains a
shadow substree. This is causing assertion failures in debug build when setting start/end
selection and nullptr crashes in release build when trying to browse selection between these
start and end nodes. This patch fixes that issue by switching to shadow including tree order
for these particular cases. It introduces a generic treeOrder<TreeType>(a, b) function that
can be used for TreeType = ShadowIncludingTree as well as by WebCore::documentOrder.

* dom/Node.cpp: Explicitly instantiate commonInclusiveAncestor<ShadowIncludingTree> so that it can be used
by WebCore::treeOrder.
* dom/Position.cpp: Explicitly instantiate templates.
(WebCore::treeOrder): Convert documentOrder to a template parametrized by TreeType.
(WebCore::documentOrder): Implement it with treeOrder<ComposedTree>.
* dom/Position.h: Delcare new template.
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::updateStartEnd): Use treeOrder<ShadowIncludingTree>.
(WebCore::ApplyStyleCommand::removeInlineStyle): Ditto.
* editing/VisiblePosition.cpp:
(WebCore::documentOrder): Use treeOrder<ShadowIncludingTree>.
* editing/VisibleSelection.cpp:
(WebCore::VisibleSelection::setBaseAndExtentToDeepEquivalents): Use treeOrder<ShadowIncludingTree>.
(WebCore::VisibleSelection::setWithoutValidation): Ditto.

Tools:

* TestWebKitAPI/Tests/WebCore/DocumentOrder.cpp: Update FIXME.

Canonical link: https://commits.webkit.org/239869@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280174 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-22 16:27:33 +00:00
Philippe Normand 07b445fd44 [GLib] Expose API to access/modify capture devices states
https://bugs.webkit.org/show_bug.cgi?id=227902

Reviewed by Carlos Garcia Campos.

Source/WebKit:

Introduce new GLib API (and corresponding GObject properties):

webkit_web_view_get_camera_capture_state
webkit_web_view_get_microphone_capture_state
webkit_web_view_set_camera_capture_state
webkit_web_view_set_microphone_capture_state
webkit_web_view_get_display_capture_state
webkit_web_view_set_display_capture_state
webkit_user_media_permission_is_for_display_device

This can be useful in Web browsers willing to indicate the status of the capture devices
currently in use by the WebView.

Covered by API tests.

* UIProcess/API/glib/WebKitUIClient.cpp:
* UIProcess/API/glib/WebKitUserMediaPermissionRequest.cpp:
(webkit_user_media_permission_is_for_display_device):
* UIProcess/API/glib/WebKitWebView.cpp:
(webkitWebViewMediaCaptureStateDidChange):
(webkitWebViewSetProperty):
(webkitWebViewGetProperty):
(webkit_web_view_class_init):
(webkitWebViewConfigureMediaCapture):
(webkit_web_view_get_camera_capture_state):
(webkit_web_view_set_camera_capture_state):
(webkit_web_view_get_microphone_capture_state):
(webkit_web_view_set_microphone_capture_state):
(webkit_web_view_get_display_capture_state):
(webkit_web_view_set_display_capture_state):
* UIProcess/API/glib/WebKitWebViewPrivate.h:
* UIProcess/API/gtk/WebKitUserMediaPermissionRequest.h:
* UIProcess/API/gtk/WebKitWebView.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
* UIProcess/API/wpe/WebKitUserMediaPermissionRequest.h:
* UIProcess/API/wpe/WebKitWebView.h:
* UIProcess/API/wpe/docs/wpe-1.0-sections.txt:

Tools:

The GTK MiniBrowser is now able to show media capture indicators, through the URI entry. A
new API test was added, checking support for getDisplayMedia().

* MiniBrowser/gtk/BrowserTab.c:
(decidePermissionRequest):
* MiniBrowser/gtk/BrowserWindow.c:
(webViewMediaCaptureStateChanged):
(webViewUriEntryIconPressed):
(browserWindowSwitchTab):
* TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
(testWebViewUserMediaPermissionRequests):
(testWebViewAudioOnlyUserMediaPermissionRequests):
(testWebViewDisplayUserMediaPermissionRequests):
(beforeAll):
* TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:
(displayCaptureChanged):
(WebViewTest::waitUntilDisplayCaptureStateChangedTo):
(microphoneCaptureChanged):
(WebViewTest::waitUntilMicrophoneCaptureStateChangedTo):
(cameraCaptureChanged):
(WebViewTest::waitUntilCameraCaptureStateChangedTo):
* TestWebKitAPI/glib/WebKitGLib/WebViewTest.h:
* flatpak/flatpakutils.py:
(WebkitFlatpak.run_in_sandbox):

Canonical link: https://commits.webkit.org/239867@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280172 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-22 10:54:07 +00:00