[webkit-changes] [WebKit/WebKit] 7bd9ef: Use correct tab and frame identifiers in webNaviga...

2023-11-06 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7bd9ef4826d01039cd550fe7804291f62d0d49d1
  
https://github.com/WebKit/WebKit/commit/7bd9ef4826d01039cd550fe7804291f62d0d49d1
  Author: Brian Weinstein 
  Date:   2023-11-06 (Mon, 06 Nov 2023)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionController.h
M Source/WebKit/UIProcess/Extensions/WebExtensionController.messages.in
M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITestCocoa.mm
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationCocoa.mm
M Source/WebKit/WebProcess/Extensions/API/WebExtensionAPITest.h
M 
Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionControllerProxyCocoa.mm
M Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPITest.idl
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm

  Log Message:
  ---
  Use correct tab and frame identifiers in webNavigation events
https://bugs.webkit.org/show_bug.cgi?id=264283
rdar://102820594

Reviewed by Timothy Hatcher.

With this change, we now pass WebExtensionTabIdentifiers and 
WebExtensionFrameIdentifiers to the webNavigation event
handlers.

With this change, we can get rid of the test function to fire a webNavigation 
event, and actually use a local HTTP server to
load content and verify that webNavigation events are being fired.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::didStartProvisionalLoadForFrame): Continue 
early if we don't have a tab, and pass the tab's identifier.
(WebKit::WebExtensionController::didCommitLoadForFrame): Ditto.
(WebKit::WebExtensionController::didFinishLoadForFrame): Ditto.
(WebKit::WebExtensionController::didFailLoadForFrame): Ditto.
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionController.messages.in:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITestCocoa.mm:
(WebKit::WebExtensionAPITest::testWebNavigationEvent): Deleted.
(WebKit::WebExtensionAPITest::fireTestWebNavigationEvent): Deleted.
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationCocoa.mm:
(WebKit::WebExtensionContextProxy::dispatchWebNavigationEvent): Update for the 
correct identifiers.
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPITest.h:
* Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionControllerProxyCocoa.mm:
(WebKit::WebExtensionControllerProxy::didStartProvisionalLoadForFrame): Pass a 
WebExtensionFrameIdentifier.
(WebKit::WebExtensionControllerProxy::didCommitLoadForFrame): Ditto.
(WebKit::WebExtensionControllerProxy::didFinishLoadForFrame): Ditto.
(WebKit::WebExtensionControllerProxy::didFailLoadForFrame): Ditto.
* Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPITest.idl:
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h:
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm:
(TestWebKitAPI::TEST): Update the tests to use actual HTTP servers and remove 
any use of the test Web Navigation event code.

Canonical link: https://commits.webkit.org/270297@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] dabbc7: Pass parent frame ID and timestamp to webNavigatio...

2023-11-07 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: dabbc74d29e07c7a33ceb0373d72e7ea107f178a
  
https://github.com/WebKit/WebKit/commit/dabbc74d29e07c7a33ceb0373d72e7ea107f178a
  Author: Brian Weinstein 
  Date:   2023-11-07 (Tue, 07 Nov 2023)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionController.h
M Source/WebKit/UIProcess/Extensions/WebExtensionController.messages.in
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationCocoa.mm
M 
Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionControllerProxyCocoa.mm
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm

  Log Message:
  ---
  Pass parent frame ID and timestamp to webNavigation handlers
https://bugs.webkit.org/show_bug.cgi?id=264345
rdar://102820594

Reviewed by Timothy Hatcher.

When firing the webNavigation events - make sure that we include additional 
information for parity with Safari. This includes:
- The parent frame ID (or none if the event is being fired for a main frame)
- The timestamp of the event

This information is all sent from WebExtensionControllerProxyCocoa -> 
WebExtensionControllerCocoa -> WebExtensionAPIWebNavigationCocoa.

This PR also fixes a bug where we were firing the wrong event (completed 
instead of committed in didCommitLoadForFrame).

It also fixes an issue with the web navigation tests (where we weren't spinning 
the run loop after loading a URL), and adding a test
verifying that all web navigation events are fired in a page load.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::didStartProvisionalLoadForFrame): Pass the 
parent frame ID and timestamp along.
(WebKit::WebExtensionController::didCommitLoadForFrame): Ditto (and make sure 
we send the correct event!)
(WebKit::WebExtensionController::didFinishLoadForFrame): Ditto.
(WebKit::WebExtensionController::didFailLoadForFrame): Ditto.
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionController.messages.in:
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationCocoa.mm:
(WebKit::WebExtensionContextProxy::dispatchWebNavigationEvent): Include the 
parent frame ID and timestamp in the details dictionary.
* Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionControllerProxyCocoa.mm:
(WebKit::WebExtensionControllerProxy::didStartProvisionalLoadForFrame): Pass 
the parent frame ID and timestamp along.
(WebKit::WebExtensionControllerProxy::didCommitLoadForFrame): Ditto.
(WebKit::WebExtensionControllerProxy::didFinishLoadForFrame): Ditto.
(WebKit::WebExtensionControllerProxy::didFailLoadForFrame): Ditto.
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h:
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm:
(TestWebKitAPI::TEST): Fix the tests by spinning the run loop, and add some new 
tests.

Canonical link: https://commits.webkit.org/270345@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 6b250d: Check for webNavigation permission before dispatch...

2023-11-09 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6b250d82f6e831eaca7af1f86aa296746ecdbda6
  
https://github.com/WebKit/WebKit/commit/6b250d82f6e831eaca7af1f86aa296746ecdbda6
  Author: Brian Weinstein 
  Date:   2023-11-09 (Thu, 09 Nov 2023)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm

  Log Message:
  ---
  Check for webNavigation permission before dispatching events
https://bugs.webkit.org/show_bug.cgi?id=264542
rdar://102820594

Reviewed by Timothy Hatcher.

This PR also updates the webNavigation tests so they to continue working.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::didStartProvisionalLoadForFrame):
(WebKit::WebExtensionController::didCommitLoadForFrame):
(WebKit::WebExtensionController::didFinishLoadForFrame):
(WebKit::WebExtensionController::didFailLoadForFrame):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/270503@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 0575d0: Hook up IPC for webNavigation APIs

2023-11-10 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0575d062092c09d95db62b0064342021dc06366f
  
https://github.com/WebKit/WebKit/commit/0575d062092c09d95db62b0064342021dc06366f
  Author: Brian Weinstein 
  Date:   2023-11-10 (Fri, 10 Nov 2023)

  Changed paths:
M Source/WebKit/DerivedSources-input.xcfilelist
M Source/WebKit/DerivedSources.make
M Source/WebKit/Scripts/webkit/messages.py
A Source/WebKit/Shared/Extensions/WebExtensionFrameParameters.h
A 
Source/WebKit/Shared/Extensions/WebExtensionFrameParameters.serialization.in
A 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWebNavigationCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationCocoa.mm

  Log Message:
  ---
  Hook up IPC for webNavigation APIs
https://bugs.webkit.org/show_bug.cgi?id=264595
rdar://118237023

Reviewed by Timothy Hatcher.

This patch creates a new WebExtensionFrameParameters and adopts it to pass 
frame data from the UI process
back to the Web process.

* Source/WebKit/DerivedSources-input.xcfilelist: Add the new file.
* Source/WebKit/DerivedSources.make: Ditto.
* Source/WebKit/Scripts/webkit/messages.py:
(types_that_cannot_be_forward_declared): Ditto.
* Source/WebKit/Shared/Extensions/WebExtensionFrameParameters.h: Added.
* Source/WebKit/Shared/Extensions/WebExtensionFrameParameters.serialization.in: 
Added.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWebNavigationCocoa.mm:
 Added.
(WebKit::WebExtensionContext::webNavigationGetFrame): Call into the UI process 
and generate Objective-C objects based on the return value.
(WebKit::WebExtensionContext::webNavigationGetAllFrames): Ditto.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: Add the message 
handling methods.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: Ditto.
* Source/WebKit/WebKit.xcodeproj/project.pbxproj: Add the new files.
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationCocoa.mm:
(WebKit::toWebAPI): Turn the passed in arguments into NS types.
(WebKit::WebExtensionAPIWebNavigation::getAllFrames): Call into the UI process 
to perform the work.
(WebKit::WebExtensionAPIWebNavigation::getFrame): Ditto.

Canonical link: https://commits.webkit.org/270564@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] d2610d: Route the rest of the WebNavigation events from We...

2023-01-06 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d2610dc0dedb035d810463243743ee6c12136d2e
  
https://github.com/WebKit/WebKit/commit/d2610dc0dedb035d810463243743ee6c12136d2e
  Author: Brian Weinstein 
  Date:   2023-01-06 (Fri, 06 Jan 2023)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionController.h
M Source/WebKit/UIProcess/Extensions/WebExtensionController.messages.in
M Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionContextProxyCocoa.mm
M 
Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionControllerProxyCocoa.mm
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in
M Source/WebKit/WebProcess/Extensions/WebExtensionControllerProxy.h
M Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

  Log Message:
  ---
  Route the rest of the WebNavigation events from WebFrameLoaderClient to the 
extension event listeners.
https://bugs.webkit.org/show_bug.cgi?id=249683
rdar://102820594

Reviewed by Timothy Hatcher.

This patch allows WebFrameLoaderClient to tell web extensions code about the 
various stages of frame loading.

The flow is:
- WebFrameLoaderClient sends a message to the WebExtensionController using IPC.
- WebExtensionController iterates over all the WebExtensionContexts and:
- Sends a message to their WebExtensionContextProxy using IPC.

WebFrameLoaderClient::dispatchDidCommitLoad -> onCommitted and 
onDOMContentLoaded
WebFrameLoaderClient::dispatchDidFinishLoad -> onCompleted
WebFrameLoaderClient::dispatchDidFailLoad -> onErrorOccurred

And then the WebExtensionContextProxy will fire the event on the extension 
pages that listen to it.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::didCommitLoadForFrame): Call into the 
WebExtensionContextProxy.
(WebKit::WebExtensionController::didFinishLoadForFrame): Ditto.
(WebKit::WebExtensionController::didFailLoadForFrame): Ditto.
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionController.messages.in:
* Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionContextProxyCocoa.mm:
(WebKit::WebExtensionContextProxy::dispatchWebNavigationOnCommittedEvent): 
Iterate the namespace objects and call the
relevant listeners.
(WebKit::WebExtensionContextProxy::dispatchWebNavigationOnDOMContentLoadedEvent):
 Ditto.
(WebKit::WebExtensionContextProxy::dispatchWebNavigationOnCompletedEvent): 
Ditto.
(WebKit::WebExtensionContextProxy::dispatchWebNavigationOnErrorOccurredEvent): 
Ditto.
* Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionControllerProxyCocoa.mm:
(WebKit::WebExtensionControllerProxy::didCommitLoadForFrame): Send a message to 
the WebExtensionController in the UI process.
(WebKit::WebExtensionControllerProxy::didFinishLoadForFrame): Ditto.
(WebKit::WebExtensionControllerProxy::didFailLoadForFrame): Ditto.
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h:
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in:
* Source/WebKit/WebProcess/Extensions/WebExtensionControllerProxy.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidCommitLoad): Call into 
WebExtensionControllerProxy.
(WebKit::WebFrameLoaderClient::dispatchDidFailLoad): Ditto.
(WebKit::WebFrameLoaderClient::dispatchDidFinishLoad): Ditto.

Canonical link: https://commits.webkit.org/258594@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 753015: Add tests for _WKWebExtensionUtilities validateCon...

2022-12-16 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 753015b17a828ee7e9e453915d08d7b22704c9fd
  
https://github.com/WebKit/WebKit/commit/753015b17a828ee7e9e453915d08d7b22704c9fd
  Author: Brian Weinstein 
  Date:   2022-12-16 (Fri, 16 Dec 2022)

  Changed paths:
M Source/WebKit/Shared/Extensions/_WKWebExtensionUtilities.h
M Source/WebKit/Shared/Extensions/_WKWebExtensionUtilities.mm
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M Tools/TestWebKitAPI/SourcesCocoa.txt
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionUtilities.mm

  Log Message:
  ---
  Add tests for _WKWebExtensionUtilities validateContentsOfDictionary:.
https://bugs.webkit.org/show_bug.cgi?id=249425
rdar://102820594

Reviewed by Timothy Hatcher.

This also requires _WKWebExtensionUtilities to be made a private header, which 
requires the ENABLE flags to be removed from the header,
so a stub implementation is needed.

* Source/WebKit/Shared/Extensions/_WKWebExtensionUtilities.h:
* Source/WebKit/Shared/Extensions/_WKWebExtensionUtilities.mm:
(+[_WKWebExtensionUtilities 
validateContentsOfDictionary:requiredKeys:optionalKeys:keyToExpectedValueType:outExceptionString:]):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionUtilities.mm: Added.
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/258003@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 2f58e3: Add tests for _WKWebExtensionWebNavigationURLFilter.

2022-12-15 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2f58e32a4f45913c77437207f04d2addd7acc571
  
https://github.com/WebKit/WebKit/commit/2f58e32a4f45913c77437207f04d2addd7acc571
  Author: Brian Weinstein 
  Date:   2022-12-15 (Thu, 15 Dec 2022)

  Changed paths:
M Source/WebKit/Shared/Extensions/_WKWebExtensionUtilities.h
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.h
M 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm

  Log Message:
  ---
  Add tests for _WKWebExtensionWebNavigationURLFilter.
https://bugs.webkit.org/show_bug.cgi?id=249365
rdar://102820594

Reviewed by Timothy Hatcher.

* Source/WebKit/Shared/Extensions/_WKWebExtensionUtilities.h:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.h:
* 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.mm:
(-[_WKWebExtensionWebNavigationURLFilter initWithDictionary:outErrorMessage:]):
(-[_WKWebExtensionWebNavigationURLFilter matchesURL:]):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/257950@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 0b8cd1: Add filtering for WebNavigation events.

2022-12-14 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0b8cd1e53947aed4b0679d330162f563f190b828
  
https://github.com/WebKit/WebKit/commit/0b8cd1e53947aed4b0679d330162f563f190b828
  Author: Brian Weinstein 
  Date:   2022-12-14 (Wed, 14 Dec 2022)

  Changed paths:
A Source/WebKit/Shared/Extensions/_WKWebExtensionUtilities.h
A Source/WebKit/Shared/Extensions/_WKWebExtensionUtilities.mm
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationEventCocoa.mm
M 
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIWebNavigationEvent.h
A 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.h
A 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm

  Log Message:
  ---
  Add filtering for WebNavigation events.
https://bugs.webkit.org/show_bug.cgi?id=249258
rdar://102820594

Reviewed by Timothy Hatcher.

When a webNavigation event listener is added, parse and save the filter that 
was included with the listener.

When attempting to fire a webNavigation event, check the given URL and see if 
it passes the included filter.

The filter parsing + managing code is written in Objective-C, and more tests 
are coming in upcoming patches.

* Source/WebKit/Shared/Extensions/_WKWebExtensionUtilities.h: Added.
* Source/WebKit/Shared/Extensions/_WKWebExtensionUtilities.mm: Added.
(classToClassString):
(+[_WKWebExtensionUtilities 
validateContentsOfDictionary:requiredKeys:optionalKeys:keyToExpectedValueType:outExceptionString:]):
 Validates
the contents of the given dictionary, checking for the presence of required 
keys, possible optional keys, and type checking.
* Source/WebKit/WebKit.xcodeproj/project.pbxproj: Add new files.
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationEventCocoa.mm:
(WebKit::WebExtensionAPIWebNavigationEvent::invokeListenersWithArgument): If 
the listener has a filter, only invoke the listener if the filter
matches the target URL.
(WebKit::WebExtensionAPIWebNavigationEvent::addListener): Handle the filter.
(WebKit::WebExtensionAPIWebNavigationEvent::removeListener): Ditto.
(WebKit::WebExtensionAPIWebNavigationEvent::hasListener): Ditto.
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIWebNavigationEvent.h: 
Change the listener vector to a vector of pairs.
* 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.h:
 Copied from 
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIWebNavigationEvent.h.
* 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.mm:
 Added.
(-[_WKWebExtensionWebNavigationURLPredicate 
initWithTypeString:value:outErrorMessage:]):
(-[_WKWebExtensionWebNavigationURLPredicate matchesURL:]):
(-[_WKWebExtensionWebNavigationURLFilter initWithDictionary:outErrorMessage:]):
(-[_WKWebExtensionWebNavigationURLFilter matchesURL:]):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm:
(TestWebKitAPI::TEST): Add some basic tests around filtering.

Canonical link: https://commits.webkit.org/257875@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 6896e9: Make sendToProcessesForEvent compile correctly whe...

2022-12-20 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6896e90a42a4d8ba60aabdbdbed0aa275a328cf9
  
https://github.com/WebKit/WebKit/commit/6896e90a42a4d8ba60aabdbdbed0aa275a328cf9
  Author: Brian Weinstein 
  Date:   2022-12-20 (Tue, 20 Dec 2022)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionController.h
M Source/WebKit/UIProcess/Extensions/WebExtensionController.messages.in
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
A Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionContextProxyCocoa.mm
M 
Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionControllerProxyCocoa.mm
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in
M Source/WebKit/WebProcess/Extensions/WebExtensionControllerProxy.h
M Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

  Log Message:
  ---
  Make sendToProcessesForEvent compile correctly when used.
https://bugs.webkit.org/show_bug.cgi?id=249514


Reviewed by Timothy Hatcher.

* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
(WebKit::WebExtensionContext::sendToProcessesForEvent):

Fire the onBeforeNavigateEvent when a frame starts to load content.
https://bugs.webkit.org/show_bug.cgi?id=249514
rdar://102820594

Reviewed by Timothy Hatcher.

When a frame begins navigation, WebKit tells all extensions about it using the 
following flow.
- WebFrameLoaderClient sends a message to the WebExtensionController using IPC.
- WebExtensionController iterates over all the WebExtensionContexts and:
- Sends a message to their WebExtensionContextProxy using IPC.

The WebExtensionContextProxy then handles this call by firing the 
onBeforeNavigate event on the extension.

There are some loose ends here:
1) We are firing events for some pages we shouldn't
2) The tab and frame IDs that we are vending to the listener aren't correct 
(they are identifiers, but not ones that have been
normalized for the required context)
3) We should be passing more information in the details dictionary.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::didStartProvisionalLoadForFrame): Tell every 
extension context about the event.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionController.messages.in:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionContextProxyCocoa.mm: 
Copied from 
Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in.
(WebKit::WebExtensionContextProxy::dispatchWebNavigationOnBeforeNavigateEvent): 
Create a details dictionary and
fire the "onBeforeNavigate" event.
* Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionControllerProxyCocoa.mm:
(WebKit::WebExtensionControllerProxy::didStartProvisionalLoadForFrame): Tell 
the UIProcess about this.
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h:
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in:
* Source/WebKit/WebProcess/Extensions/WebExtensionControllerProxy.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidStartProvisionalLoad): Tell the 
extensions controller about this.

Canonical link: https://commits.webkit.org/258163@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 355ce0: Safari Content Blocker doesn't support :has() sele...

2023-01-18 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 355ce06ba535bdf2ce87a0f130d67ff866930649
  
https://github.com/WebKit/WebKit/commit/355ce06ba535bdf2ce87a0f130d67ff866930649
  Author: Brian Weinstein 
  Date:   2023-01-18 (Wed, 18 Jan 2023)

  Changed paths:
M LayoutTests/http/tests/contentextensions/css-display-none.html
M LayoutTests/http/tests/contentextensions/css-display-none.html.json
M Source/WebCore/contentextensions/ContentExtension.cpp
M Source/WebCore/contentextensions/ContentExtensionParser.cpp
M Source/WebCore/contentextensions/ContentExtensionParser.h
M Source/WebCore/contentextensions/ContentExtensionStyleSheet.cpp
M Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp

  Log Message:
  ---
  Safari Content Blocker doesn't support :has() selector
https://bugs.webkit.org/show_bug.cgi?id=250609
rdar://103976010

Reviewed by Antti Koivisto and Alex Christensen.

When creating the CSSParsers for content blocker parsing and compilation, make 
sure to opt
into hasPseudoClassEnabled so selectors like :has work. The places this was 
needed were:
- ContentExtensionParser (for parsing the rules)
- ContentExtension (for the global display none rules)
- ContentExtensionStyleSheet (for the other display none rules)

Also update the contentextensions css-display-none test to test this 
functionality.

* Source/WebCore/contentextensions/ContentExtension.cpp:
(WebCore::ContentExtensions::ContentExtension::compileGlobalDisplayNoneStyleSheet):
* Source/WebCore/contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::isValidCSSSelector):

Canonical link: https://commits.webkit.org/259068@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] a423cd: Expose WebCore::ContentExtensions::parseRuleList a...

2023-02-01 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a423cde6af09afbcb38784951a94ff40a28fac6e
  
https://github.com/WebKit/WebKit/commit/a423cde6af09afbcb38784951a94ff40a28fac6e
  Author: Brian Weinstein 
  Date:   2023-02-01 (Wed, 01 Feb 2023)

  Changed paths:
M Source/WebKit/UIProcess/API/APIContentRuleList.cpp
M Source/WebKit/UIProcess/API/APIContentRuleList.h
M Source/WebKit/UIProcess/API/Cocoa/WKContentRuleList.mm
M Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListPrivate.h
M Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentRuleListNotification.mm

  Log Message:
  ---
  Expose WebCore::ContentExtensions::parseRuleList as WebKit SPI
https://bugs.webkit.org/show_bug.cgi?id=251465


Reviewed by Alex Christensen.

This patch also adds tests for passing and failing rule parsing.

* Source/WebKit/UIProcess/API/APIContentRuleList.cpp:
(API::ContentRuleList::parseRuleList): Call into 
WebCore::ContentExtensions::parseRuleList and return the error code if it 
exists.
* Source/WebKit/UIProcess/API/APIContentRuleList.h:
* Source/WebKit/UIProcess/API/Cocoa/WKContentRuleList.mm:
(+[WKContentRuleList _parseRuleList:]): Call into 
API::ContentRuleList::parseRuleList and wrap the error code in an NSError if 
necessary.
* Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListPrivate.h:

Canonical link: https://commits.webkit.org/259706@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 6f913a: Content Blocker API ignores some CSS Selectors wit...

2023-02-21 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6f913a33098ba2633d5cb251e002637e50fcffc7
  
https://github.com/WebKit/WebKit/commit/6f913a33098ba2633d5cb251e002637e50fcffc7
  Author: Brian Weinstein 
  Date:   2023-02-21 (Tue, 21 Feb 2023)

  Changed paths:
M LayoutTests/http/tests/contentextensions/css-display-none.html
M LayoutTests/http/tests/contentextensions/css-display-none.html.json
M Source/WebCore/contentextensions/ContentExtensionParser.cpp

  Log Message:
  ---
  Content Blocker API ignores some CSS Selectors with uppercase letters.
https://bugs.webkit.org/show_bug.cgi?id=252677
rdar://105648971

Reviewed by Antti Koivisto.

The fix for https://bugs.webkit.org/show_bug.cgi?id=250609 caused us to use 
Quirks mode when both
parsing content blocker rules and applying them.

That caused this regression, since rules like .SomeCLass stopped working in 
Quirks mode.

To fix this, make us use Quirks mode when actually parsing the rules, but 
standard mode when
applying them, to match how the behavior was before 
https://bugs.webkit.org/show_bug.cgi?id=250609.

* LayoutTests/http/tests/contentextensions/css-display-none.html:
* LayoutTests/http/tests/contentextensions/css-display-none.html.json:
* Source/WebCore/contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::isValidCSSSelector):
(WebCore::ContentExtensions::contentExtensionCSSParserContext):

Canonical link: https://commits.webkit.org/260638@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 2afc03: Pass information about resource loads from WebPage...

2024-01-22 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2afc03180fc116298060b5b592282c471f29225b
  
https://github.com/WebKit/WebKit/commit/2afc03180fc116298060b5b592282c471f29225b
  Author: Brian Weinstein 
  Date:   2024-01-22 (Mon, 22 Jan 2024)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.cpp
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionController.h
M Source/WebKit/UIProcess/WebPageProxy.cpp
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebRequestCocoa.mm
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in

  Log Message:
  ---
  Pass information about resource loads from WebPageProxy through the 
extensions controller machinery (needed for webRequest support)
https://bugs.webkit.org/show_bug.cgi?id=267882
rdar://114823223

Reviewed by Timothy Hatcher.

The events still aren't fired in the extensions' web process yet, but they will 
be in the next PR.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::hasPermissionToSendWebRequestEvent): Check that:
- The extension can see the tab
- The extension has access to the page URL
- The extension has access to the resource URL
- The extension has access to the URL specified in the ResourceLoadInfo object
(WebKit::WebExtensionContext::resourceLoadDidSendRequest): Send a message to 
the WebExtensionContextProxy.
(WebKit::WebExtensionContext::resourceLoadDidPerformHTTPRedirection): Ditto.
(WebKit::WebExtensionContext::resourceLoadDidReceiveChallenge): Ditto.
(WebKit::WebExtensionContext::resourceLoadDidReceiveResponse): Ditto.
(WebKit::WebExtensionContext::resourceLoadDidCompleteWithError): Ditto.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::resourceLoadDidSendRequest): Call into each 
WebExtensionContext.
(WebKit::WebExtensionController::resourceLoadDidPerformHTTPRedirection): Ditto.
(WebKit::WebExtensionController::resourceLoadDidReceiveChallenge): Ditto.
(WebKit::WebExtensionController::resourceLoadDidReceiveResponse): Ditto.
(WebKit::WebExtensionController::resourceLoadDidCompleteWithError): Ditto.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.cpp:
(WebKit::WebExtensionContext::processes const): Update the method to get all 
processes for an event to take a set
of events.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
(WebKit::WebExtensionContext::sendToProcessesForEvents):
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resourceLoadDidSendRequest): Call into the 
WebExtensionController if it exists.
(WebKit::WebPageProxy::resourceLoadDidPerformHTTPRedirection): Ditto.
(WebKit::WebPageProxy::resourceLoadDidReceiveChallenge): Ditto.
(WebKit::WebPageProxy::resourceLoadDidReceiveResponse): Ditto.
(WebKit::WebPageProxy::resourceLoadDidCompleteWithError): Ditto.
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebRequestCocoa.mm:
(WebKit::WebExtensionContextProxy::resourceLoadDidSendRequest): Add a FIXME to 
implement this.
(WebKit::WebExtensionContextProxy::resourceLoadDidPerformHTTPRedirection): 
Ditto.
(WebKit::WebExtensionContextProxy::resourceLoadDidReceiveChallenge): Ditto.
(WebKit::WebExtensionContextProxy::resourceLoadDidReceiveResponse): Ditto.
(WebKit::WebExtensionContextProxy::resourceLoadDidCompleteWithError): Ditto.
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h:
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in:

Canonical link: https://commits.webkit.org/273335@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 0c0655: Implement event firing from the web process for we...

2024-01-23 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0c0655a175613f58168c7f30652e989cc0fe2736
  
https://github.com/WebKit/WebKit/commit/0c0655a175613f58168c7f30652e989cc0fe2736
  Author: Brian Weinstein 
  Date:   2024-01-23 (Tue, 23 Jan 2024)

  Changed paths:
M Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp
M Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h
M 
Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.serialization.in
M Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
M Source/WebKit/NetworkProcess/NetworkResourceLoader.h
M Source/WebKit/Shared/Extensions/WebExtensionFrameIdentifier.h
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebRequestCocoa.mm
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebRequestEventCocoa.mm
M Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIWebRequestEvent.h
M 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebRequestFilter.h
M 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebRequestFilter.mm
M 
Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIWebRequestEvent.idl
M Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebRequest.mm

  Log Message:
  ---
  Implement event firing from the web process for webRequest events and add 
tests
https://bugs.webkit.org/show_bug.cgi?id=267963
rdar://114823223

Reviewed by Timothy Hatcher.

The tests exposed a few issues that were also fixed here:
1) The network process wasn't calling into WebPageProxy when running the tests 
because the
page didn't have a resource load delegate. To fix this, also call into the 
WebPageProxy when
the page has an extension controller.
2) There was a copy/paste-o in 
WebExtensionContext::resourceLoadDidPerformHTTPRedirection where
the wrong events were being sent.
3) When just a filter was being passed to webRequest.event.addListener, it was 
being treated as the extraInfoSpec because
we weren't being specific enough about the type.

This PR also changed _WKWebExtensionWebRequestFilter to deal with 
WebKit::ResourceLoadInfo instead of _WKResourceLoadInfo.

* Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters): Add a 
new pageHasExtensionController parameter.
* Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h:
* Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.serialization.in:
* Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::shouldSendResourceLoadMessages const): Check 
both pageHasResourceLoadClient and pageHasExtensionController.
(WebKit::NetworkResourceLoader::startNetworkLoad): Adopt 
shouldSendResourceLoadMessages.
(WebKit::NetworkResourceLoader::didReceiveResponse): Ditto.
(WebKit::NetworkResourceLoader::didFinishLoading): Ditto.
(WebKit::NetworkResourceLoader::didFailLoading): Ditto.
(WebKit::NetworkResourceLoader::didReceiveChallenge): Ditto.
(WebKit::NetworkResourceLoader::continueWillSendRequest): Ditto.
* Source/WebKit/NetworkProcess/NetworkResourceLoader.h:
* Source/WebKit/Shared/Extensions/WebExtensionFrameIdentifier.h:
(WebKit::toWebExtensionFrameIdentifier): Add a new flavor of this method.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::resourceLoadDidPerformHTTPRedirection): Make sure 
we are calling the correct events here.
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebRequestCocoa.mm:
(WebKit::convertRequestBodyToWebExtensionFormat): Convert the request body to 
the format extensions expect.
(WebKit::webRequestDetailsForResourceLoad): Generate a dictionary of 
information about the resource load conforming to the webRequest spec.
(WebKit::convertHeaderFieldsToWebExtensionFormat): Convert the header fields to 
an array of dictionaries.
(WebKit::headersReceivedDetails): Convert the NSHTTPURLResponse information 
into a dictionary conforming to the webRequest spec.
(WebKit::WebExtensionContextProxy::resourceLoadDidSendRequest): Call the 
correct events.
(WebKit::WebExtensionContextProxy::resourceLoadDidPerformHTTPRedirection): 
Ditto.
(WebKit::WebExtensionContextProxy::resourceLoadDidReceiveChallenge): Ditto.
(WebKit::WebExtensionContextProxy::resourceLoadDidReceiveResponse): Ditto.
(WebKit::WebExtensionContextProxy::resourceLoadDidCompleteWithError): Ditto.
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebRequestEventCocoa.mm:
(WebKit::WebExtensionAPIWebRequestEvent::invokeListenersWithArgument): Check 
the filter and invoke the correct listeners.
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIWebRequestEvent.h:
* Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebRequestFilter.h:
* Source

[webkit-changes] [WebKit/WebKit] 1d5e98: Only run webRequest tests on macOS that allow pers...

2024-01-24 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1d5e9822affd75ce7440bf15a7f9917613cd9718
  
https://github.com/WebKit/WebKit/commit/1d5e9822affd75ce7440bf15a7f9917613cd9718
  Author: Brian Weinstein 
  Date:   2024-01-24 (Wed, 24 Jan 2024)

  Changed paths:
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebRequest.mm

  Log Message:
  ---
  Only run webRequest tests on macOS that allow persistent background pages
https://bugs.webkit.org/show_bug.cgi?id=268012


Reviewed by Timothy Hatcher.

The filter tests are still run on every platform, but the tests that involve 
the webRequest JavaScript API are only
run on Mac, since that is the only platform that supports persistent background 
pages (and therefore webRequest).

* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebRequest.mm:

Canonical link: https://commits.webkit.org/273438@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] baf3ea: Implement errorOccured in webNavigation.getFrame/g...

2023-12-19 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: baf3eae87da202e1ab9d7ccb2dff883fe503e2bc
  
https://github.com/WebKit/WebKit/commit/baf3eae87da202e1ab9d7ccb2dff883fe503e2bc
  Author: Brian Weinstein 
  Date:   2023-12-19 (Tue, 19 Dec 2023)

  Changed paths:
M Source/WebCore/loader/FrameLoader.cpp
M Source/WebCore/loader/FrameLoader.h
M Source/WebKit/Shared/FrameInfoData.h
M Source/WebKit/Shared/FrameInfoData.serialization.in
M Source/WebKit/UIProcess/API/APIFrameInfo.h
M Source/WebKit/UIProcess/API/Cocoa/WKFrameInfo.mm
M Source/WebKit/UIProcess/API/Cocoa/WKFrameInfoPrivate.h
M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWebNavigationCocoa.mm
M Source/WebKit/WebProcess/WebPage/WebFrame.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm

  Log Message:
  ---
  Implement errorOccured in webNavigation.getFrame/getAllFrames
https://bugs.webkit.org/show_bug.cgi?id=266499
rdar://118340990

Reviewed by Alex Christensen and Timothy Hatcher.

Before this change, there was no way to determine if an error occurred in the 
load of a frame given a WKFrameInfo.

This patch pipes that information from the FrameLoader -> WebFrame -> 
WKFrameInfo, and exposes it as SPI on the WKFrameInfo.

This patch also adds some tests for both the new WKFrameInfo SPI and how it is 
exposed to extensions.

* Source/WebCore/loader/FrameLoader.cpp: Clear m_errorOccurredInLoading in all 
of the places that load start.
(WebCore::FrameLoader::dispatchDidFailProvisionalLoad): Set 
m_errorOccurredInLoading to true.
(WebCore::FrameLoader::checkLoadCompleteForThisFrame): Set 
m_errorOccurredInLoading to true if necessary.
* Source/WebCore/loader/FrameLoader.h:
* Source/WebKit/Shared/FrameInfoData.h: Add the new parameter.
* Source/WebKit/Shared/FrameInfoData.serialization.in: Ditto.
* Source/WebKit/UIProcess/API/APIFrameInfo.h:
* Source/WebKit/UIProcess/API/Cocoa/WKFrameInfo.mm:
(-[WKFrameInfo _errorOccurred]):
* Source/WebKit/UIProcess/API/Cocoa/WKFrameInfoPrivate.h:
* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWebNavigationCocoa.mm:
(WebKit::frameParametersForFrame): Include whether or not an error occurred.
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::info const): Include whether or not an error occurred.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm:
(TestWebKitAPI::TEST): Add a test that when a frame load fails with an error, 
errorOccurred is set in the getFrame call. There
are two flavors of this test, one with a failed provisional load, the other 
with a failed load after it had been committed.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm: Enhance the Frames test 
to:
1) Make sure the WKFrameInfo _errorOccurred SPI value is correct when loads 
fail and complete.
2) Perform an additional load after the failed load to make sure the error 
occurred state is reset.

Canonical link: https://commits.webkit.org/272303@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] cb966f: Notify the WebExtensionsController when a provisio...

2023-12-14 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: cb966fb5714c81e8ee1cf2c7128f7aebaed507e5
  
https://github.com/WebKit/WebKit/commit/cb966fb5714c81e8ee1cf2c7128f7aebaed507e5
  Author: Brian Weinstein 
  Date:   2023-12-14 (Thu, 14 Dec 2023)

  Changed paths:
M Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm

  Log Message:
  ---
  Notify the WebExtensionsController when a provisional load fails for a frame
https://bugs.webkit.org/show_bug.cgi?id=266444


Reviewed by Alex Christensen.

This patch also adds a test verifying this behavior.

* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::dispatchDidFailProvisionalLoad):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/272086@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] b14b70: Change behavior of webNavigation.getFrame/getAllFr...

2023-12-12 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b14b70f5eff5dd4c67e9f53f598382a8cf0fb91b
  
https://github.com/WebKit/WebKit/commit/b14b70f5eff5dd4c67e9f53f598382a8cf0fb91b
  Author: Brian Weinstein 
  Date:   2023-12-12 (Tue, 12 Dec 2023)

  Changed paths:
M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWebNavigationCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationCocoa.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm

  Log Message:
  ---
  Change behavior of webNavigation.getFrame/getAllFrames to better match spec
https://bugs.webkit.org/show_bug.cgi?id=266305
rdar://118340990

Reviewed by Timothy Hatcher.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webNavigation/getFrame
 states:
"If the specified tab or frame ID could not be found, or some other error 
occurs, the promise will be rejected with an error message."

Before this change, we weren't doing that - we were just vending an empty 
object.

This PR also adds a couple tests for this behavior.

* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWebNavigationCocoa.mm:
(WebKit::WebExtensionContext::webNavigationGetFrame):
(WebKit::WebExtensionContext::webNavigationGetAllFrames):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationCocoa.mm:
(WebKit::WebExtensionAPIWebNavigation::getAllFrames):
(WebKit::WebExtensionAPIWebNavigation::getFrame):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/271961@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] b09450: DNR content rule list notifications aren't being d...

2023-12-08 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b09450296bb71cd5a926c1b63b72fbea324a9a70
  
https://github.com/WebKit/WebKit/commit/b09450296bb71cd5a926c1b63b72fbea324a9a70
  Author: Brian Weinstein 
  Date:   2023-12-08 (Fri, 08 Dec 2023)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm

  Log Message:
  ---
  DNR content rule list notifications aren't being delivered to the correct 
extension
https://bugs.webkit.org/show_bug.cgi?id=266099


Reviewed by Timothy Hatcher.

When notifying an extension that a DNR rule was matched (for getMatchedRules or 
setExtensionActionOptions), we need a way
to match the content rule list notification to the extension. After the change 
of the name of the content rule list to be the
same across all extensions, there was no way to do this anymore.

It's a bit silly to require the unique name of the extension in an already 
unique directory, but ContentRuleListResults only
has the identifier of the content rule list that performed the action, not the 
store it came from.

While I'm here, a few more changes were made:
1) Clear out some DNR ivars when an extension context is unloaded
2) Enhance the DynamicRules test to unload and reload the extension context, 
and verify that the rules are still loaded and applied
upon unload/reload of the context.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::unload):
(WebKit::WebExtensionContext::addDeclarativeNetRequestRulesToPrivateUserContentControllers):
(WebKit::WebExtensionContext::compileDeclarativeNetRequestRules):
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRules):
* 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/271762@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] eb8ff9: Add support for WebExtensionAPIWebRequestEvent and...

2024-01-18 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: eb8ff94d64827d261308f3c3e98fb19ae87a60a1
  
https://github.com/WebKit/WebKit/commit/eb8ff94d64827d261308f3c3e98fb19ae87a60a1
  Author: Brian Weinstein 
  Date:   2024-01-18 (Thu, 18 Jan 2024)

  Changed paths:
M Source/WebKit/DerivedSources-input.xcfilelist
M Source/WebKit/DerivedSources-output.xcfilelist
M Source/WebKit/DerivedSources.make
M Source/WebKit/Modules/OSX_Private.modulemap
M Source/WebKit/Modules/iOS_Private.modulemap
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
A 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebRequestEventCocoa.mm
A Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIWebRequestEvent.h
A 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebRequestFilter.h
A 
Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebRequestFilter.mm
A 
Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIWebRequestEvent.idl
M Tools/TestWebKitAPI/SourcesCocoa.txt
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebRequest.mm

  Log Message:
  ---
  Add support for WebExtensionAPIWebRequestEvent and filter code
https://bugs.webkit.org/show_bug.cgi?id=267718
rdar://114823223

Reviewed by Timothy Hatcher.

* Source/WebKit/DerivedSources-input.xcfilelist: Add the new files.
* Source/WebKit/DerivedSources-output.xcfilelist: Ditto.
* Source/WebKit/DerivedSources.make: Ditto.
* Source/WebKit/Modules/OSX_Private.modulemap: Add 
_WKWebExtensionWebRequestFilter here, it is Private due to being needed in 
TestWebKitAPI.
* Source/WebKit/Modules/iOS_Private.modulemap: Ditto.
* Source/WebKit/WebKit.xcodeproj/project.pbxproj: Add the new files.
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebRequestEventCocoa.mm:
 Added.
(WebKit::WebExtensionAPIWebRequestEvent::addListener): Add the listener to 
m_listeners.
(WebKit::WebExtensionAPIWebRequestEvent::removeListener): Remove it from 
m_listeners.
(WebKit::WebExtensionAPIWebRequestEvent::hasListener): Check for the listener 
in m_listeners.
(WebKit::WebExtensionAPIWebRequestEvent::removeAllListeners): Clear m_listeners.
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIWebRequestEvent.h: 
Added.
(WebKit::WebExtensionAPIWebRequestEvent::listeners const):
(WebKit::WebExtensionAPIWebRequestEvent::~WebExtensionAPIWebRequestEvent):
(WebKit::WebExtensionAPIWebRequestEvent::WebExtensionAPIWebRequestEvent):
* Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebRequestFilter.h: 
Added.
* Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebRequestFilter.mm: 
Added.
(_WKWebExtensionWebRequestResourceTypeFromWKResourceLoadInfo): Get the resource 
type from the resource load info.
(-[_WKWebExtensionWebRequestFilter initWithDictionary:outErrorMessage:]): 
Validate the dictionary and create a filter if the dictionary is valid.
(toResourceType): Convert the string to a resource type.
(toTabID): Convert the given double to a 
std::optional
(toWindowID): Convert the given double to a 
std::optional
(-[_WKWebExtensionWebRequestFilter _initializeWithDictionary:]):
(-[_WKWebExtensionWebRequestFilter 
matchesRequestForResourceOfType:URL:tabID:windowID:]): Perform the matching - 
making sure URL, tab, window, and resource type match.
* 
Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIWebRequestEvent.idl:
 Added.
* Tools/TestWebKitAPI/SourcesCocoa.txt: Add the new test file.
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Ditto.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebRequest.mm: Added.
(TestWebKitAPI::TEST):
(TestWebKitAPI::filterWithDictionary):

Canonical link: https://commits.webkit.org/273194@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 10ce6a: Avoid compiling rules every time the extension is ...

2023-11-28 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 10ce6abfd3467908a62bf2d8ab1e57ac4b356a28
  
https://github.com/WebKit/WebKit/commit/10ce6abfd3467908a62bf2d8ab1e57ac4b356a28
  Author: Brian Weinstein 
  Date:   2023-11-28 (Tue, 28 Nov 2023)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h

  Log Message:
  ---
  Avoid compiling rules every time the extension is loaded if the rules haven't 
changed
https://bugs.webkit.org/show_bug.cgi?id=265473
rdar://118839289

Reviewed by Timothy Hatcher.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::declarativeNetRequestRuleStore):
(WebKit::computeStringHashForContentBlockerRules): Compute the hash for these 
content blocker rules, making sure to
append the current version of the rule translator, so when it is updated, rules 
will be re-compiled.
(WebKit::WebExtensionContext::compileDeclarativeNetRequestRules): Before 
compiling the rule, perform a lookup and check
the hash.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:

Canonical link: https://commits.webkit.org/271248@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] e270f8: Support declarativeNetRequest.getMatchedRules

2023-12-05 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e270f83dd685dc0262a6ab8a12bedf26a0560049
  
https://github.com/WebKit/WebKit/commit/e270f83dd685dc0262a6ab8a12bedf26a0560049
  Author: Brian Weinstein 
  Date:   2023-12-05 (Tue, 05 Dec 2023)

  Changed paths:
M Source/WebKit/DerivedSources-input.xcfilelist
M Source/WebKit/DerivedSources.make
A Source/WebKit/Shared/Extensions/WebExtensionMatchedRuleParameters.h
A 
Source/WebKit/Shared/Extensions/WebExtensionMatchedRuleParameters.serialization.in
M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationCocoa.mm
M 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm

  Log Message:
  ---
  Support declarativeNetRequest.getMatchedRules
https://bugs.webkit.org/show_bug.cgi?id=265917
rdar://118940129

Reviewed by Timothy Hatcher.

This patch keeps track of the content rule list actions that each extension has 
performed and
exposes them through declarativeNetRequest.getMatchedRules().

These can be filtered on tabId and timeStamp, and are limited to only vending 
information about
URLs that the extension has access to.

* Source/WebKit/DerivedSources-input.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/Shared/Extensions/WebExtensionMatchedRuleParameters.h: Added.
* 
Source/WebKit/Shared/Extensions/WebExtensionMatchedRuleParameters.serialization.in:
 Added.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionContext::declarativeNetRequestGetMatchedRules): Iterate 
over the matched rules and
filter them. Also check to make sure we have permission to access the URLs 
before vending them.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::unload): Clear the matched rules.
(WebKit::WebExtensionContext::handleContentRuleListNotificationForTab): 
Increment the blocked resource count
and add the blocked resource to the list of matched rules.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::handleContentRuleListNotification):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
(WebKit::WebExtensionContext::matchedRules): Keep track of the matched rules.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
(WebKit::extensionHasPermission): Add a helper method.
(WebKit::toWebAPI): Ditto.
(WebKit::WebExtensionAPIDeclarativeNetRequest::getMatchedRules):
* 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm:
(TestWebKitAPI::TEST): Add a test that getMatchedRules returns a match that the 
frame was blocked.

Canonical link: https://commits.webkit.org/271593@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] c26e66: Implement declarativeNetRequest.setExtensionAction...

2023-12-05 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c26e66feb2aa3ac2cb62f6a15ea66c0dacef644e
  
https://github.com/WebKit/WebKit/commit/c26e66feb2aa3ac2cb62f6a15ea66c0dacef644e
  Author: Brian Weinstein 
  Date:   2023-12-05 (Tue, 05 Dec 2023)

  Changed paths:
M Source/WebKit/UIProcess/Cocoa/NavigationState.mm
M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionAction.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in
M Source/WebKit/UIProcess/Extensions/WebExtensionController.h
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm
M 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm

  Log Message:
  ---
  Implement declarativeNetRequest.setExtensionActionOptions
https://bugs.webkit.org/show_bug.cgi?id=265829
rdar://118476776

Reviewed by Timothy Hatcher.

This API has two use cases:
1) To opt an extension into a behavior where the extension's action shows the 
number of blocked resources on the current page
2) To manually increment or decrement this badged number

It's a bit unfortunate that these two disparate behaviors are combined into one 
API, but here we are. This PR implements both of
them and adds tests for them.

* Source/WebKit/UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::contentRuleListNotification): Call 
into the WebExtensionController.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionContext::shouldDisplayBlockedResourceCountAsBadgeText): 
Returns whether or not the blocked resource count should be the badge text.
(WebKit::WebExtensionContext::saveShouldDisplayBlockedResourceCountAsBadgeText):
 Sets whether or not the blocked resource count should be the badge
text, and saves to disk.
(WebKit::WebExtensionContext::incrementActionCountForTab): Get the action for 
the tab and increment the blocked resource count.
(WebKit::WebExtensionContext::declarativeNetRequestDisplayActionCountAsBadgeText):
 Call saveShouldDisplayBlockedResourceCountAsBadgeText with the new value, and
clear any blocked resource counts if the flag is turned off.
(WebKit::WebExtensionContext::declarativeNetRequestIncrementActionCount): Call 
into incrementActionCountForTab after finding the tab.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm:
(WebKit::WebExtensionAction::clearCustomizations): Clear the blocked resource 
count.
(WebKit::WebExtensionAction::clearBlockedResourceCount): Ditto.
(WebKit::WebExtensionAction::badgeText const): If we have a blocked resource 
count - use it as the badge text.
(WebKit::WebExtensionAction::incrementBlockedResourceCount): Modify the blocked 
resource count member variable.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::handleContentRuleListNotification): Iterate 
over all of the actions, find the extension if it exists, and call 
incrementActionCountForTab.
* Source/WebKit/UIProcess/Extensions/WebExtensionAction.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionAPIDeclarativeNetRequest::setExtensionActionOptions): 
Perform object validation and call into the UI process based on if flavor (1) 
or (2) was called.
* 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/271561@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 4d126d: Add stub declarativeNetRequest JavaScript bindings

2023-11-29 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4d126d6c1ea62328b7c04b01959880441b420412
  
https://github.com/WebKit/WebKit/commit/4d126d6c1ea62328b7c04b01959880441b420412
  Author: Brian Weinstein 
  Date:   2023-11-29 (Wed, 29 Nov 2023)

  Changed paths:
M Source/WebKit/DerivedSources-input.xcfilelist
M Source/WebKit/DerivedSources-output.xcfilelist
M Source/WebKit/DerivedSources.make
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
A 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPINamespaceCocoa.mm
A 
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIDeclarativeNetRequest.h
M Source/WebKit/WebProcess/Extensions/API/WebExtensionAPINamespace.h
A 
Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIDeclarativeNetRequest.idl
M 
Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPINamespace.idl

  Log Message:
  ---
  Add stub declarativeNetRequest JavaScript bindings
https://bugs.webkit.org/show_bug.cgi?id=265532


Reviewed by Timothy Hatcher.

* Source/WebKit/DerivedSources-input.xcfilelist:
* Source/WebKit/DerivedSources-output.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
 Added.
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateEnabledRulesets):
(WebKit::WebExtensionAPIDeclarativeNetRequest::getEnabledRulesets):
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateDynamicRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::getDynamicRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateSessionRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::getSessionRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::getMatchedRules):
(WebKit::WebExtensionAPIDeclarativeNetRequest::isRegexSupported):
(WebKit::WebExtensionAPIDeclarativeNetRequest::setExtensionActionOptions):
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPINamespaceCocoa.mm:
(WebKit::WebExtensionAPINamespace::declarativeNetRequest):
* 
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIDeclarativeNetRequest.h: 
Added.
(WebKit::WebExtensionAPIDeclarativeNetRequest::maxNumberOfStaticRulesets const):
(WebKit::WebExtensionAPIDeclarativeNetRequest::maxNumberOfEnabledRulesets 
const):
(WebKit::WebExtensionAPIDeclarativeNetRequest::maxNumberOfDynamicAndSessionRules
 const):
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPINamespace.h:
* 
Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIDeclarativeNetRequest.idl:
 Added.
* Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPINamespace.idl:

Canonical link: https://commits.webkit.org/271294@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 8942ad: Implement declarativeNetRequest.getEnabledRulesets

2023-11-29 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8942add3e1d86bfc2ad5e8c71b9bdb005f3bed30
  
https://github.com/WebKit/WebKit/commit/8942add3e1d86bfc2ad5e8c71b9bdb005f3bed30
  Author: Brian Weinstein 
  Date:   2023-11-29 (Wed, 29 Nov 2023)

  Changed paths:
A 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm

  Log Message:
  ---
  Implement declarativeNetRequest.getEnabledRulesets
https://bugs.webkit.org/show_bug.cgi?id=265539
rdar://118940027

Reviewed by Timothy Hatcher.

* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm:
 Added.
(WebKit::WebExtensionContext::declarativeNetRequestGetEnabledRulesets):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionAPIDeclarativeNetRequest::getEnabledRulesets):

Canonical link: https://commits.webkit.org/271313@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] dc8ef5: Implement declarativeNetRequest.updateEnabledRulesets

2023-12-01 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: dc8ef58782b8f08276f8731a52ebbdb54d08ac9d
  
https://github.com/WebKit/WebKit/commit/dc8ef58782b8f08276f8731a52ebbdb54d08ac9d
  Author: Brian Weinstein 
  Date:   2023-12-01 (Fri, 01 Dec 2023)

  Changed paths:
A 
Source/WebKit/Shared/Extensions/WebExtensionDeclarativeNetRequestConstants.h
M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtension.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm
M 
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIDeclarativeNetRequest.h
M 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm

  Log Message:
  ---
  Implement declarativeNetRequest.updateEnabledRulesets
https://bugs.webkit.org/show_bug.cgi?id=265616
rdar://118940027

Reviewed by Timothy Hatcher.

When an extension calls updateEnabledRulesets - the following happens:
1) We validate the arguments in the WebProcess to make sure they are of the 
correct format
2) We call into the UI process to perform the work
3) The UI process makes sure all of the passed identifiers exist, and if they 
do, we attempt to perform the update

To do this, we modify the enabled state of the given rulesets, and attempt to 
load the declarativeNetRequest rules again.

If this succeeds, we write the updated state to disk. If it fails, we revert 
the changes that were made (and will continue to use
the old DNR rules).

This patch also adds tests for getEnabledRulesets and updateEnabledRulesets.

* Source/WebKit/Shared/Extensions/WebExtensionDeclarativeNetRequestConstants.h: 
Copied from 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRulesetStateFromStorage):
 Read the modified state of rulesets from State.plist
and apply it.
(WebKit::WebExtensionContext::saveDeclarativeNetRequestRulesetStateToStorage): 
Merge the given dictionary with the existing one and
save it to disk.
(WebKit::WebExtensionContext::declarativeNetRequestValidateRulesetIdentifiers): 
Make sure all of the ruleset identifiers exist and throw
an error if any don't.
(WebKit::WebExtensionContext::declarativeNetRequestEnabledRulesetCount): Get 
the count of enabled rulesets.
(WebKit::WebExtensionContext::declarativeNetRequestToggleRulesets): Set the 
state of the given rulesets.
(WebKit::WebExtensionContext::declarativeNetRequestUpdateEnabledRulesets): 
Perform the logic described in steps 3+ earlier in the commit message.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
(WebKit::WebExtension::populateDeclarativeNetRequestPropertiesIfNeeded): Adopt 
a few constants.
(WebKit::WebExtension::declarativeNetRequestRulesets): These ruleset objects 
can be changed, so don't return const.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::load): Call 
loadDeclarativeNetRequestRulesetStateFromStorage at startup. We don't want to 
call this each time that the
loadDeclarativeNetRequestRules is called, because we might be attempting to 
update the enabled rulesets and in that case we don't want to consult storage
yet.
(WebKit::WebExtensionContext::queueStartupAndInstallEventsForExtensionIfNecessary):
 Clear any customized rulesets upon update.
(WebKit::WebExtensionContext::compileDeclarativeNetRequestRules): Add a 
completion handler.
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRules): Ditto.
* Source/WebKit/UIProcess/Extensions/WebExtension.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateEnabledRulesets): Perform 
argument validation.
* 
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIDeclarativeNetRequest.h:
(WebKit::WebExtensionAPIDeclarativeNetRequest::maxNumberOfStaticRulesets 
const): Use a constant.
(WebKit::WebExtensionAPIDeclarativeNetRequest::maxNumberOfEnabledRulesets 
const): Ditto.
(WebKit::WebExtensionAPIDeclarativeNetRequest::maxNumberOfDynamicAndSessionRules
 const): Ditto.

Canonical link: https://commits.webkit.org/271410@main


___
webkit-changes

[webkit-changes] [WebKit/WebKit] ded506: Implement declarativeNetRequest.isRegexSupported

2023-12-01 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ded5062ffb2601dac60ce1cfc4e3e1b99ae1fb34
  
https://github.com/WebKit/WebKit/commit/ded5062ffb2601dac60ce1cfc4e3e1b99ae1fb34
  Author: Brian Weinstein 
  Date:   2023-12-01 (Fri, 01 Dec 2023)

  Changed paths:
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm
M 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm

  Log Message:
  ---
  Implement declarativeNetRequest.isRegexSupported
https://bugs.webkit.org/show_bug.cgi?id=265701
rdar://118940110

Reviewed by Timothy Hatcher.

* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionAPIDeclarativeNetRequest::isRegexSupported):
* 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/271414@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 14bd8a: Implement declarativeNetRequest dynamic and sessio...

2023-12-07 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 14bd8a42717a351ebe92101b83d757311d20a07e
  
https://github.com/WebKit/WebKit/commit/14bd8a42717a351ebe92101b83d757311d20a07e
  Author: Brian Weinstein 
  Date:   2023-12-07 (Thu, 07 Dec 2023)

  Changed paths:
M Source/WebCore/en.lproj/Localizable.strings
M Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
M Source/WebKit/Shared/Extensions/_WKWebExtensionSQLiteStore.h
M Source/WebKit/Shared/Extensions/_WKWebExtensionSQLiteStore.mm
M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestSQLiteStore.h
M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestSQLiteStore.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm
M 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm

  Log Message:
  ---
  Implement declarativeNetRequest dynamic and session rules APIs
https://bugs.webkit.org/show_bug.cgi?id=266016
rdar://118476702&118476774

Reviewed by Timothy Hatcher.

This patch implements:
- declarativeNetRequest.getSessionRules()
- declarativeNetRequest.updateSessionRules()
- declarativeNetRequest.getDynamicRules()
- declarativeNetRequest.updateDynamicRules()

The big difference between these two APIs is that dynamic rules are persisted 
to disk and will be loaded across
quitting and relaunching the browser. Session rules will go away.

Also, while we are here, fix a typo in an error message and update the 
localizable strings.

* Source/WebKit/Shared/Extensions/_WKWebExtensionSQLiteStore.h:
* Source/WebKit/Shared/Extensions/_WKWebExtensionSQLiteStore.mm:
(-[_WKWebExtensionSQLiteStore _savepointNameFromUUID:]): Generate a savepoint 
name based on the UUID.
(-[_WKWebExtensionSQLiteStore createSavepointWithCompletionHandler:]): Create a 
savepoint in the database.
(-[_WKWebExtensionSQLiteStore commitSavepoint:completionHandler:]): Commit the 
savepoint to the database.
(-[_WKWebExtensionSQLiteStore rollbackToSavepoint:completionHandler:]): 
Rollback the database to a given savepoint.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionContext::declarativeNetRequestDynamicRulesStore): Create 
and return a _WKWebExtensionDeclarativeNetRequestSQLiteStore for the
dynamic rules. This will only use the in memory database if storage isn't 
persistent for the extension context.
(WebKit::WebExtensionContext::declarativeNetRequestSessionRulesStore): Create 
and return a _WKWebExtensionDeclarativeNetRequestSQLiteStore for the
session rules. This will always use the in memory database.
(WebKit::WebExtensionContext::updateDeclarativeNetRequestRulesInStorage): 
Attempt to perform the given updates to the rules in the database. The flow is:
- Create a savepoint
- Update the rules by removing and adding rules.
- If this fails, perform a rollback
- If this succeeds, attempt to load the new rules
- If this fails, perform a rollback, and attempt to load the old rules
- If this succeeds, commit the savepoint
(WebKit::WebExtensionContext::declarativeNetRequestGetDynamicRules): Get the 
rules from the dynamic rules store.
(WebKit::WebExtensionContext::declarativeNetRequestUpdateDynamicRules): Call 
into updateDeclarativeNetRequestRulesInStorage.
(WebKit::WebExtensionContext::declarativeNetRequestGetSessionRules): Get the 
rules from the session rules store.
(WebKit::WebExtensionContext::declarativeNetRequestUpdateSessionRules): Call 
into updateDeclarativeNetRequestRulesInStorage.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRules): Chain together 
loading rules from the various sources, the order is:
- Session rules
- Dynamic rules
- Static rules
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateDynamicRules): Call into 
the UI process after performing argument validation.
(WebKit::WebExtensionAPIDeclarativeNetRequest::getDynamicRules): Call into the 
UI process.
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateSessionRules): Call into 
the UI process after performing argument validation.
(WebKit::WebExtensionAPIDeclarativeNetRequest::getSessionRules): Call into the 
UI process.
* 
Tools/TestWebKi

[webkit-changes] [WebKit/WebKit] 62dc25: Make sure declarativeNetRequest APIs don't attempt...

2023-12-08 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 62dc259e4805b0be63e51658163800381cfa4e3f
  
https://github.com/WebKit/WebKit/commit/62dc259e4805b0be63e51658163800381cfa4e3f
  Author: Brian Weinstein 
  Date:   2023-12-08 (Fri, 08 Dec 2023)

  Changed paths:
M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h

  Log Message:
  ---
  Make sure declarativeNetRequest APIs don't attempt to create too many 
dynamic/session rules
https://bugs.webkit.org/show_bug.cgi?id=266088


Reviewed by Timothy Hatcher.

* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionContext::declarativeNetRequestUpdateDynamicRules): Filter 
out any rule IDs that don't match, and make sure
adding any rules doesn't take us over the limit.
(WebKit::WebExtensionContext::declarativeNetRequestUpdateSessionRules): Ditto.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRules): Keep track of 
the session and dynamic rule IDs that have been loaded.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:

Canonical link: https://commits.webkit.org/271756@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] f23885: Compile declarativeNetRequest rules and load them ...

2023-11-27 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f23885142bfbfa43aa5ccecaffd0b094b3bb7611
  
https://github.com/WebKit/WebKit/commit/f23885142bfbfa43aa5ccecaffd0b094b3bb7611
  Author: Brian Weinstein 
  Date:   2023-11-27 (Mon, 27 Nov 2023)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M 
Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerConfigurationCocoa.mm
M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionControllerConfiguration.h
M 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm

  Log Message:
  ---
  Compile declarativeNetRequest rules and load them into the proper user 
content controllers
https://bugs.webkit.org/show_bug.cgi?id=265399


Reviewed by Timothy Hatcher.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::unload): Remove the compiled rules from all 
userContentControllers.
(WebKit::WebExtensionContext::setHasAccessInPrivateBrowsing): Add or remove 
declarativeNetRequest rules from private browsing
user content controllers.
(WebKit::WebExtensionContext::declarativeNetRequestRuleStore): Returns the rule 
store.
(WebKit::WebExtensionContext::removeDeclarativeNetRequestRules): Removes the 
compiled rules for this extension from all userContentControllers.
(WebKit::WebExtensionContext::addDeclarativeNetRequestRulesToPrivateUserContentControllers):
 Adds the compiled rules for this extension to all
private browsing userContentControllers.
(WebKit::WebExtensionContext::compileDeclarativeNetRequestRules): Translate the 
NSData given to us into rules in the WebKit content blocker format
and compile them. When the compilation finishes, add the compiled content rule 
lists to the needed userContentControllers.
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRules): Add a bug number 
to a FIXME.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerConfigurationCocoa.mm:
(WebKit::WebExtensionControllerConfiguration::declarativeNetRequestStoreDirectory):
 Generate the directory to store these content blockers in.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm:
(+[_WKWebExtensionDeclarativeNetRequestTranslator 
jsonObjectsFromData:errorStrings:]): Allow fragments when parsing the JSON. 
This is needed
because the top level object of a DNR rule set is an array. We also make sure 
we were given an array.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionControllerConfiguration.h:
* 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm:
(TestWebKitAPI::TEST): Add tests that DNR rules are blocking content in both 
regular and private browsing.

Canonical link: https://commits.webkit.org/271177@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] b6d625: Add a subclass of _WKWebExtensionSQLiteStore respo...

2023-12-06 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b6d6257f11d5e8e9602ee2ac6de5ad3bece290ba
  
https://github.com/WebKit/WebKit/commit/b6d6257f11d5e8e9602ee2ac6de5ad3bece290ba
  Author: Brian Weinstein 
  Date:   2023-12-06 (Wed, 06 Dec 2023)

  Changed paths:
A 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestSQLiteStore.h
A 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestSQLiteStore.mm
M Source/WebKit/WebKit.xcodeproj/project.pbxproj

  Log Message:
  ---
  Add a subclass of _WKWebExtensionSQLiteStore responsible for managing dynamic 
and session DNR rules
https://bugs.webkit.org/show_bug.cgi?id=265965


Reviewed by Timothy Hatcher.

This will be used for dynamic and session rules in the WebKit Web Extensions 
implementation. It was ported from
existing code in Safari.

* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestSQLiteStore.h:
 Added.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestSQLiteStore.mm:
 Added.
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore 
initWithUniqueIdentifier:directory:usesInMemoryDatabase:]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore 
updateRulesByRemovingIDs:addRules:completionHandler:]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore 
addRules:completionHandler:]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore 
deleteRules:completionHandler:]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore 
getRulesWithCompletionHandler:]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore 
_getRulesWithOutErrorMessage:]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore 
_getKeysAndValuesFromRowEnumerator:]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore _insertRule:inDatabase:]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore 
_currentDatabaseSchemaVersion]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore _databaseURL]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore _createFreshDatabaseSchema]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore _resetDatabaseSchema]):
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore _isDatabaseEmpty]):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/271647@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 5a1eb5: Use a timer to purged old matched rules

2023-12-06 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5a1eb5d9c5cec2c7f696dc953963f56f246dc699
  
https://github.com/WebKit/WebKit/commit/5a1eb5d9c5cec2c7f696dc953963f56f246dc699
  Author: Brian Weinstein 
  Date:   2023-12-06 (Wed, 06 Dec 2023)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionController.h
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm

  Log Message:
  ---
  Use a timer to purged old matched rules
https://bugs.webkit.org/show_bug.cgi?id=265950
rdar://118940129

Reviewed by Timothy Hatcher.

When a content rule list notification is saved as a matched rule by an 
extension, start a repeating 5 minute timer to purge
any rules that are older than 5 minutes.

If after the purge there aren't any remaining saved rules, stop the timer.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::handleContentRuleListNotificationForTab): This 
now returns a bool representing if the
notification was saved as a matched rule.
(WebKit::WebExtensionContext::purgeMatchedRulesFromBefore): Iterate over the 
rules and remove any that were from before the given
start time.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::handleContentRuleListNotification): Start a 
timer if the action was saved and there wasn't a timer
started already.
(WebKit::WebExtensionController::purgeOldMatchedRules): Iterate over all of the 
extensions and call purgeMatchedRulesFromBefore.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionAPIDeclarativeNetRequest::getMatchedRules): Remove an 
extra newline.

Canonical link: https://commits.webkit.org/271629@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 63b67f: WebExtensionContext::handleContentRuleListNotifica...

2024-02-02 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 63b67f18d2d22d8100972ddccb5602d2a0700fd9
  
https://github.com/WebKit/WebKit/commit/63b67f18d2d22d8100972ddccb5602d2a0700fd9
  Author: Brian Weinstein 
  Date:   2024-02-02 (Fri, 02 Feb 2024)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm

  Log Message:
  ---
  WebExtensionContext::handleContentRuleListNotificationForTab activeTab 
permission check is wrong
https://bugs.webkit.org/show_bug.cgi?id=268645
rdar://122197589

Reviewed by Timothy Hatcher.

Make sure the extension actually has access to the tab instead of just 
searching for the activeTab permission.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::handleContentRuleListNotificationForTab):

Canonical link: https://commits.webkit.org/274030@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] cff46c: New Tests(273949@main): [ ReleaseĀ ] API tests Test...

2024-02-02 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: cff46c9c95c74960edbc58afafe190e0f9078401
  
https://github.com/WebKit/WebKit/commit/cff46c9c95c74960edbc58afafe190e0f9078401
  Author: Brian Weinstein 
  Date:   2024-02-02 (Fri, 02 Feb 2024)

  Changed paths:
M Source/WebKit/Shared/Extensions/WebExtensionUtilities.mm

  Log Message:
  ---
  New Tests(273949@main): [ ReleaseĀ ] API tests 
TestWebKitAPI.WKWebExtensionAPIStorage.* are constantly timing out or failing.
https://bugs.webkit.org/show_bug.cgi?id=268659
rdar://122202826

Reviewed by Timothy Hatcher.

Make sure itemExceededQuota and are initialized. The test failures indicate 
that the `sizeOfCurrentItem > quota` block was never being
hit, but `itemExceededQuota` was true due to the initial value of its memory.

* Source/WebKit/Shared/Extensions/WebExtensionUtilities.mm:
(WebKit::anyItemsExceedQuota):

Canonical link: https://commits.webkit.org/274018@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] d37336: Add a delegate method to let clients opt out of gr...

2024-02-02 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d3733674e19a6b2a0f181736faefa896f3223a2d
  
https://github.com/WebKit/WebKit/commit/d3733674e19a6b2a0f181736faefa896f3223a2d
  Author: Brian Weinstein 
  Date:   2024-02-02 (Fri, 02 Feb 2024)

  Changed paths:
M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionTab.h
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionTabCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionTab.h

  Log Message:
  ---
  Add a delegate method to let clients opt out of granting activeTab from a 
user gesture
https://bugs.webkit.org/show_bug.cgi?id=268652
rdar://122129916

Reviewed by Timothy Hatcher.

This PR also fixes a place where checking the permission state wasn't exactly 
correct.

* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionTab.h:
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::permissionState):
(WebKit::WebExtensionContext::userGesturePerformed):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionTabCocoa.mm:
(WebKit::WebExtensionTab::WebExtensionTab):
(WebKit::WebExtensionTab::shouldGrantTabPermissionsOnUserGesture const):
* Source/WebKit/UIProcess/Extensions/WebExtensionTab.h:

Canonical link: https://commits.webkit.org/274021@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] f808a2: Add webRequest event listener bindings and a basic...

2024-01-19 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f808a2b2b9e3ac58ffa028da52c07dd3441cd7a8
  
https://github.com/WebKit/WebKit/commit/f808a2b2b9e3ac58ffa028da52c07dd3441cd7a8
  Author: Brian Weinstein 
  Date:   2024-01-19 (Fri, 19 Jan 2024)

  Changed paths:
M Source/WebKit/DerivedSources-input.xcfilelist
M Source/WebKit/DerivedSources-output.xcfilelist
M Source/WebKit/DerivedSources.make
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPINamespaceCocoa.mm
A 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebRequestCocoa.mm
M Source/WebKit/WebProcess/Extensions/API/WebExtensionAPINamespace.h
A Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIWebRequest.h
M 
Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPINamespace.idl
A 
Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIWebRequest.idl
M 
Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIWebRequestEvent.idl
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebRequest.mm

  Log Message:
  ---
  Add webRequest event listener bindings and a basic test for them
https://bugs.webkit.org/show_bug.cgi?id=267747
rdar://114823223

Reviewed by Timothy Hatcher.

* Source/WebKit/DerivedSources-input.xcfilelist: Add new files.
* Source/WebKit/DerivedSources-output.xcfilelist: Ditto.
* Source/WebKit/DerivedSources.make: Add the new idl file.
* Source/WebKit/WebKit.xcodeproj/project.pbxproj: Add new files.
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPINamespaceCocoa.mm:
(WebKit::WebExtensionAPINamespace::webRequest): Create the 
WebExtensionAPIWebRequest object and return it.
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebRequestCocoa.mm:
 Added.
(WebKit::WebExtensionAPIWebRequest::onBeforeRequest): Create the listener and 
return it.
(WebKit::WebExtensionAPIWebRequest::onBeforeSendHeaders): Ditto.
(WebKit::WebExtensionAPIWebRequest::onSendHeaders): Ditto.
(WebKit::WebExtensionAPIWebRequest::onHeadersReceived): Ditto.
(WebKit::WebExtensionAPIWebRequest::onAuthRequired): Ditto.
(WebKit::WebExtensionAPIWebRequest::onBeforeRedirect): Ditto.
(WebKit::WebExtensionAPIWebRequest::onResponseStarted): Ditto.
(WebKit::WebExtensionAPIWebRequest::onCompleted): Ditto.
(WebKit::WebExtensionAPIWebRequest::onErrorOccurred): Ditto.
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPINamespace.h:
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIWebRequest.h: Added.
* Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPINamespace.idl: 
Add the webRequest binding on the browser object.
* Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIWebRequest.idl: 
Copied from 
Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIWebRequestEvent.idl.
* 
Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIWebRequestEvent.idl:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebRequest.mm:
(TestWebKitAPI::TEST): Add a test around the basic 
addListener/removeListener/hasListener functionality.

Canonical link: https://commits.webkit.org/273223@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 3a2ef9: Start adding code to load/compile content modifica...

2023-11-16 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3a2ef94d0a264425936aaad7aa40f7947ba87fd4
  
https://github.com/WebKit/WebKit/commit/3a2ef94d0a264425936aaad7aa40f7947ba87fd4
  Author: Brian Weinstein 
  Date:   2023-11-16 (Thu, 16 Nov 2023)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h

  Log Message:
  ---
  Start adding code to load/compile content modification rules
https://bugs.webkit.org/show_bug.cgi?id=264959


Reviewed by Timothy Hatcher.

Future PRs will add logic to translate DNR rules to the WebKit content blocker 
format, and
actually compile/load the rule lists using WebKit API.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::load):
(WebKit::WebExtensionContext::compileDeclarativeNetRequestRules):
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRules):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:

Canonical link: https://commits.webkit.org/270844@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] f3d8de: Add logic to convert declarativeNetRequest rules t...

2023-11-16 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f3d8deeacd7258224aacd25276f66e9d1d8e242a
  
https://github.com/WebKit/WebKit/commit/f3d8deeacd7258224aacd25276f66e9d1d8e242a
  Author: Brian Weinstein 
  Date:   2023-11-16 (Thu, 16 Nov 2023)

  Changed paths:
M Source/WebKit/Platform/cocoa/CocoaHelpers.h
M Source/WebKit/Platform/cocoa/CocoaHelpers.mm
A 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.h
A 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm
A 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.h
A 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm
M Source/WebKit/WebKit.xcodeproj/project.pbxproj

  Log Message:
  ---
  Add logic to convert declarativeNetRequest rules to WebKit content blocker 
rules
https://bugs.webkit.org/show_bug.cgi?id=264982
rdar://118528800

Reviewed by Timothy Hatcher.

This PR also gets rid of all of the `__kindof`s in the CocoaHelpers template 
functions. It is causing compile errors
on older OSes.

* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.h:
 Added.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm:
 Added.
(-[_WKWebExtensionDeclarativeNetRequestRule _validateHeaderInfoDictionary:]): 
Validates the header info dictionary.
(isHeaderNameValid): Checks the name of the header against a list of known 
headers.
(isArrayOfDomainsValid): Makes sure there are domains and they can all be 
converted to ASCII.
(isArrayOfExcludedDomainsValid): Makes sure all domains can be converted to 
ASCII.
(-[_WKWebExtensionDeclarativeNetRequestRule 
removeInvalidResourceTypesForKey:]): Remove any resource types WebKit can't 
handle.
(-[_WKWebExtensionDeclarativeNetRequestRule ruleInWebKitFormat]): Convert the 
rule to WebKit format.
(-[_WKWebExtensionDeclarativeNetRequestRule 
_convertedRulesForWebKitActionType:chromeActionType:]): Convert action type 
from Chrome
to WebKit format.
(-[_WKWebExtensionDeclarativeNetRequestRule 
_webKitRuleWithWebKitActionType:chromeActionType:chromeResourceTypes:]): Create 
a content blocking
rule with the given parameters.
(-[_WKWebExtensionDeclarativeNetRequestRule 
_chromeResourceTypeToWebKitLoadContext]): Convert a resource type to a load 
context.
(-[_WKWebExtensionDeclarativeNetRequestRule 
_chromeDomainTypeToWebKitDomainType]): Convert a Chrome domain type to a WebKit 
domain type.
(-[_WKWebExtensionDeclarativeNetRequestRule 
_chromeResourceTypeToWebKitResourceType]): Convert resource types.
(-[_WKWebExtensionDeclarativeNetRequestRule 
_resourcesToTargetWhenNoneAreSpecifiedInRule]):
(-[_WKWebExtensionDeclarativeNetRequestRule _allChromeResourceTypes]):
(-[_WKWebExtensionDeclarativeNetRequestRule 
_convertedResourceTypesForChromeResourceTypes:]):
(-[_WKWebExtensionDeclarativeNetRequestRule 
_regexURLFilterForChromeURLFilter:]):
(-[_WKWebExtensionDeclarativeNetRequestRule compare:]): Compare two rules.
(priorityForRuleType):
(-[_WKWebExtensionDeclarativeNetRequestRule description]): Print out 
information about the rule.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.h:
 Added.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm:
 Added.
(+[_WKWebExtensionDeclarativeNetRequestTranslator 
translateRules:errorStrings:]): Translate the rules.
(+[_WKWebExtensionDeclarativeNetRequestTranslator 
jsonObjectsFromData:errorStrings:]): Perform JSON parsing.
(+[_WKWebExtensionDeclarativeNetRequestTranslator jsonStringForJSONObject:]): 
Ditto.
* Source/WebKit/WebKit.xcodeproj/project.pbxproj: Add the new files.

Canonical link: https://commits.webkit.org/270861@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 4fbab9: Add tests for _WKWebExtensionDeclarativeNetRequest...

2023-11-17 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4fbab99095d1b31f272aab6d5e74d7788c9fb60a
  
https://github.com/WebKit/WebKit/commit/4fbab99095d1b31f272aab6d5e74d7788c9fb60a
  Author: Brian Weinstein 
  Date:   2023-11-17 (Fri, 17 Nov 2023)

  Changed paths:
M Source/WebKit/Modules/OSX_Private.modulemap
M Source/WebKit/Modules/iOS_Private.modulemap
M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.h
M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm
M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.h
M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M Tools/TestWebKitAPI/SourcesCocoa.txt
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIExtension.mm

  Log Message:
  ---
  Add tests for _WKWebExtensionDeclarativeNetRequestRule and 
_WKWebExtensionDeclarativeNetRequestTranslator and make them SPI to use in 
TestWebKitAPI
https://bugs.webkit.org/show_bug.cgi?id=265049
rdar://118570291

Reviewed by Timothy Hatcher.

To add tests for these classes in TestWebKitAPI, the headers need to become 
private headers in the WebKit project. To do this, I needed to
get rid of all ENABLE flags and implement a version of the classes when 
WK_WEB_EXTENSIONS is off.

Doing this lets us add a lot of tests of the rule translator code into 
TestWebKitAPI.

Adding this new file showed a latent compilation error in 
WKWebExtensionAPIExtension, so fix that while we are here.

* Source/WebKit/Modules/OSX_Private.modulemap:
* Source/WebKit/Modules/iOS_Private.modulemap:
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.h:
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm:
(WebKit::if):
(-[_WKWebExtensionDeclarativeNetRequestRule initWithDictionary:errorString:]):
(-[_WKWebExtensionDeclarativeNetRequestRule compare:]):
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.h:
* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm:
(+[_WKWebExtensionDeclarativeNetRequestTranslator 
jsonObjectsFromData:errorStrings:]):
(+[_WKWebExtensionDeclarativeNetRequestTranslator 
translateRules:errorStrings:]):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* 
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm:
 Added.
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIExtension.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/270926@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 1093d6: Parse web extension manifest for declarativeNetReq...

2023-11-14 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1093d6012bcfd5c17dbd4710264729b559612699
  
https://github.com/WebKit/WebKit/commit/1093d6012bcfd5c17dbd4710264729b559612699
  Author: Brian Weinstein 
  Date:   2023-11-14 (Tue, 14 Nov 2023)

  Changed paths:
M Source/WebCore/en.lproj/Localizable.strings
M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.h
M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtension.h
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm

  Log Message:
  ---
  Parse web extension manifest for declarativeNetRequest rulesets
https://bugs.webkit.org/show_bug.cgi?id=264836
rdar://118415584

Reviewed by Timothy Hatcher.

This patch hooks up basic manifest parsing for declarativeNetRequest rule sets.

* Source/WebCore/en.lproj/Localizable.strings:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.mm:
(-[_WKWebExtension hasDeclarativeNetRequestRules]): Mostly added for testing at 
this point. Returns if there were any correctly parsed rulesets.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
(WebKit::WebExtension::errors): Call 
parseDeclarativeNetRequestRulesetDictionary.
(WebKit::WebExtension::declarativeNetRequestRulesets): Call 
populateDeclarativeNetRequestPropertiesIfNeeded and return the vector of 
rulesets.
(WebKit::WebExtension::parseDeclarativeNetRequestRulesetDictionary): Takes in a 
dictionary and returns an optional DeclarativeNetRequestRulesetData. This method
does argument type checking and makes sure the string arguments aren't nil or 
empty.
(WebKit::WebExtension::populateDeclarativeNetRequestPropertiesIfNeeded): Read 
the manifest and turn the JSON into a vector of 
DeclarativeNetRequestRulesetData. This
PR makes sure the extension doesn't specify too many rulesets, too many enabled 
rulesets, or multiple rulesets with the same id.
* Source/WebKit/UIProcess/Extensions/WebExtension.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm:
(TestWebKitAPI::TEST): Add some tests for the manifest parsing.

Canonical link: https://commits.webkit.org/270751@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 69414c: Implement UI process side of getFrame and getAllFr...

2023-11-11 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 69414c30375b5099697bf2b350d7c8f3576a5d58
  
https://github.com/WebKit/WebKit/commit/69414c30375b5099697bf2b350d7c8f3576a5d58
  Author: Brian Weinstein 
  Date:   2023-11-11 (Sat, 11 Nov 2023)

  Changed paths:
M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWebNavigationCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm

  Log Message:
  ---
  Implement UI process side of getFrame and getAllFrames
https://bugs.webkit.org/show_bug.cgi?id=264686
rdar://118278958

Reviewed by Timothy Hatcher.

This patch sets up basic frame traversal APIs to:
1) Iterate all frames, adding their WebExtensionFrameParameters to a vector
2) Find a frame in a subtree

* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWebNavigationCocoa.mm:
(WebKit::frameParametersForFrame): Set up the various parts of the 
WebExtensionFrameParameters object.
(WebKit::WebExtensionContext::webNavigationTraverseFrameTreeForFrame): Traverse 
the frame and subframes recursively.
(WebKit::WebExtensionContext::webNavigationFindFrameIdentifierInFrameTree): 
Find the frame with the given identifier recursively.
(WebKit::WebExtensionContext::webNavigationGetFrame): Call into 
webNavigationFindFrameIdentifierInFrameTree.
(WebKit::WebExtensionContext::webNavigationGetAllFrames): Call into 
webNavigationTraverseFrameTreeForFrame.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm:
(TestWebKitAPI::TEST): Add tests for webNavigation.getAllFrames and 
webNavigation.getFrame (for both the main frame and subframes).

Canonical link: https://commits.webkit.org/270608@main


___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 619674: Add more fallback logic for the name of a browser ...

2024-02-23 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6196748e4b8469493d488992d5dd1f38e6312624
  
https://github.com/WebKit/WebKit/commit/6196748e4b8469493d488992d5dd1f38e6312624
  Author: Brian Weinstein 
  Date:   2024-02-23 (Fri, 23 Feb 2024)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCommandCocoa.mm

  Log Message:
  ---
  Add more fallback logic for the name of a browser action keyboard shortcut
https://bugs.webkit.org/show_bug.cgi?id=269997
rdar://123455683

Reviewed by Timothy Hatcher.

This change:
1) Makes it so we don't crash if a command has an empty name or description
2) Falls back to the display name for _execute_browser_action if no action 
title is specified

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
(WebKit::WebExtension::populateCommandsIfNeeded):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCommandCocoa.mm:
(+[_WKWebExtensionKeyCommand 
commandWithTitle:image:input:modifierFlags:handler:]):

Canonical link: https://commits.webkit.org/275248@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 688f48: permissionState should be requested if an extensio...

2024-04-10 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 688f484337ef854b86bc20cef43677e6ba82dec7
  
https://github.com/WebKit/WebKit/commit/688f484337ef854b86bc20cef43677e6ba82dec7
  Author: Brian Weinstein 
  Date:   2024-04-10 (Wed, 10 Apr 2024)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm

  Log Message:
  ---
  permissionState should be requested if an extension has the webNavigation 
permission
https://bugs.webkit.org/show_bug.cgi?id=272466
rdar://126212951

Reviewed by Timothy Hatcher.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::permissionState):

Canonical link: https://commits.webkit.org/277308@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 5e8c33: Check both browser and chrome objects in enumerate...

2024-03-07 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5e8c33f6e1ce4b6f4f7d3fadbdd34ea40b2ce8f5
  
https://github.com/WebKit/WebKit/commit/5e8c33f6e1ce4b6f4f7d3fadbdd34ea40b2ce8f5
  Author: Brian Weinstein 
  Date:   2024-03-07 (Thu, 07 Mar 2024)

  Changed paths:
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.cpp

  Log Message:
  ---
  Check both browser and chrome objects in enumerateFramesAndNamespaceObjects
https://bugs.webkit.org/show_bug.cgi?id=270657
rdar://123409359

Reviewed by Timothy Hatcher.

Some extensions use a polyfill to overwrite the browser object with their own 
proxy. The Blue Canoe extension was doing this,
and it led to WebExtensionContextProxy::enumerateFramesAndNamespaceObjects not 
being able to find the namespace object for the extension,
since we were only checking the `browser` object.

To fix this, check both `browser` and `chrome`, and use whichever one is valid.

* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.cpp:
(WebKit::WebExtensionContextProxy::enumerateFramesAndNamespaceObjects):

Canonical link: https://commits.webkit.org/275809@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 5e785e: Fix flaky WKWebExtensionAPIWebRequest tests

2024-03-11 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5e785e867f363d114dcce1fc32056b63005c163e
  
https://github.com/WebKit/WebKit/commit/5e785e867f363d114dcce1fc32056b63005c163e
  Author: Brian Weinstein 
  Date:   2024-03-11 (Mon, 11 Mar 2024)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebRequest.mm

  Log Message:
  ---
  Fix flaky WKWebExtensionAPIWebRequest tests
https://bugs.webkit.org/show_bug.cgi?id=270824
rdar://124401551

Reviewed by Timothy Hatcher.

There were a few cascading issues here.

1) For webRequest, we were trying to create a persistent background page with 
manifest v3. This is not a supported
configuration, so it was being forced into being non-persistent.

This meant that the background page could sometimes unload, leading to the 
flakiness described in the bug.

2) After making this change, I discovered that we were attempting to load the 
background page before it was safe (before
moveLocalStorageIfNeeded was called).

To fix this, add a new variable tracking if it's safe to load the background 
view. This is set to true in loadBackgroundWebViewDuringLoad,
and checked in loadBackgroundWebViewIfNeeded before attempting to load the 
background web view.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::loadBackgroundWebViewDuringLoad):
(WebKit::WebExtensionContext::loadBackgroundWebViewIfNeeded):
(WebKit::WebExtensionContext::loadBackgroundWebView):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
(WebKit::WebExtensionContext::safeToLoadBackgroundContent const):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebRequest.mm:

Canonical link: https://commits.webkit.org/275955@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 349c5a: Use the rule type as a prefix for the DNR database...

2024-03-13 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 349c5a3059a9047c7d9939deab1e2bbd4dc08e10
  
https://github.com/WebKit/WebKit/commit/349c5a3059a9047c7d9939deab1e2bbd4dc08e10
  Author: Brian Weinstein 
  Date:   2024-03-13 (Wed, 13 Mar 2024)

  Changed paths:
M 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestSQLiteStore.mm

  Log Message:
  ---
  Use the rule type as a prefix for the DNR database table
https://bugs.webkit.org/show_bug.cgi?id=270911
rdar://121455049

Reviewed by Timothy Hatcher.

This matches the current database format in Safari, and having these formats 
match will help us migrate existing extension data
over to WebKit's new file structure.

While we're here, we are changing the name of the database file on disk. 
Without this, we would need to bump the schema version, which
would lead to issues when performing the previously described migration.

* 
Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestSQLiteStore.mm:
(-[_WKWebExtensionDeclarativeNetRequestSQLiteStore 
initWithUniqueIdentifier:storageType:directory:usesInMemoryDatabase:]):

Canonical link: https://commits.webkit.org/276033@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 2a19d0: Fix flaky Web Extension exception tests on debug

2024-03-14 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2a19d0288716ba319aaa3d50ffca58ac30975286
  
https://github.com/WebKit/WebKit/commit/2a19d0288716ba319aaa3d50ffca58ac30975286
  Author: Brian Weinstein 
  Date:   2024-03-14 (Thu, 14 Mar 2024)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPICookies.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIScripting.mm

  Log Message:
  ---
  Fix flaky Web Extension exception tests on debug
https://bugs.webkit.org/show_bug.cgi?id=270997
rdar://124632659

Reviewed by Timothy Hatcher.

It appears that these error tests were timing out on the bots. This PR fixes 
them in two ways:
1) Upping the timeout on debug builds to 6 seconds (since debug builds are 
slower to run these tests)
2) Splitting the tests that are timing out into separate tests

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::scheduleBackgroundContentToUnload):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPICookies.mm:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIScripting.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/276126@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 7f19d5: Handle the case where an extension could be unload...

2024-03-22 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7f19d5a29be35074f1b14a16a768786d64fa95d9
  
https://github.com/WebKit/WebKit/commit/7f19d5a29be35074f1b14a16a768786d64fa95d9
  Author: Brian Weinstein 
  Date:   2024-03-22 (Fri, 22 Mar 2024)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm

  Log Message:
  ---
  Handle the case where an extension could be unloaded after compiling DNR rules
https://bugs.webkit.org/show_bug.cgi?id=271493
rdar://123900589

Reviewed by Timothy Hatcher.

If the extension has been unloaded, iterating the user content controllers will 
lead to a crash.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::addDeclarativeNetRequestRulesToPrivateUserContentControllers):
(WebKit::WebExtensionContext::compileDeclarativeNetRequestRules):

Canonical link: https://commits.webkit.org/276578@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 3b08a5: Fix an issue with the background page trying to me...

2024-04-09 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3b08a55102c5ec79db58f6aec9d18056b86c5425
  
https://github.com/WebKit/WebKit/commit/3b08a55102c5ec79db58f6aec9d18056b86c5425
  Author: Brian Weinstein 
  Date:   2024-04-09 (Tue, 09 Apr 2024)

  Changed paths:
M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionTabCocoa.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITabs.mm

  Log Message:
  ---
  Fix an issue with the background page trying to message full page extension 
content
https://bugs.webkit.org/show_bug.cgi?id=272362
rdar://125996453

Reviewed by Timothy Hatcher.

When an extension was trying to send a message from a background page to a tab 
with full page extension content, we were treating
the message as going to a content script and sending it to a non-main world, 
which led to a crash.

Additionally, we want to block an extension from sending a message to a tab 
showing full page content for a different extension. One
extension should have no idea about another's content.

* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm:
(WebKit::WebExtensionContext::tabsSendMessage):
(WebKit::WebExtensionContext::tabsConnect):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionTabCocoa.mm:
(WebKit::WebExtensionTab::extensionHasPermission const):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITabs.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPITabs, 
SendMessageFromBackgroundPageToFullPageExtensionContent)):

Canonical link: https://commits.webkit.org/277240@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 5e245a: Allow tabs.update to be called without a tabID

2024-02-22 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5e245ad06c697f9fd4b06a7592744ebb51a67d2d
  
https://github.com/WebKit/WebKit/commit/5e245ad06c697f9fd4b06a7592744ebb51a67d2d
  Author: Brian Weinstein 
  Date:   2024-02-22 (Thu, 22 Feb 2024)

  Changed paths:
M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in
M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITabsCocoa.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIAction.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITabs.mm

  Log Message:
  ---
  Allow tabs.update to be called without a tabID
https://bugs.webkit.org/show_bug.cgi?id=269934
rdar://123407828

Reviewed by Timothy Hatcher.

The tabID is an optional argument to tabs.update. We were always attempting to 
get the value of the optional.

If it isn't passed, then it is meant to fall back to the active tab of the 
current context, which means:
- If this was called from a popup, then the active tab of the popup's window
- If this was called from the background page, then the active tab of the 
active window

This required some refactoring to WebExtensionContext::getTab and 
WebExtensionContext::getCurrentTab to support this,
and some tests were added calling this method without a tab ID from both 
contexts.

* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm:
(WebKit::WebExtensionContext::tabsUpdate):
(WebKit::WebExtensionContext::tabsReload):
(WebKit::WebExtensionContext::tabsGoBack):
(WebKit::WebExtensionContext::tabsGoForward):
(WebKit::WebExtensionContext::tabsDetectLanguage):
(WebKit::WebExtensionContext::tabsToggleReaderMode):
(WebKit::WebExtensionContext::tabsGetZoom):
(WebKit::WebExtensionContext::tabsSetZoom):
(WebKit::WebExtensionContext::tabsExecuteScript):
(WebKit::WebExtensionContext::tabsInsertCSS):
(WebKit::WebExtensionContext::tabsRemoveCSS):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::getWindow const):
(WebKit::WebExtensionContext::getTab const):
(WebKit::WebExtensionContext::getCurrentTab const):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITabsCocoa.mm:
(WebKit::WebExtensionAPITabs::update):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIAction.mm:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITabs.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/275204@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] eeef2a: Close extension popup web views when the web conte...

2024-02-26 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: eeef2a286027af94c7d9117260bbb72142545569
  
https://github.com/WebKit/WebKit/commit/eeef2a286027af94c7d9117260bbb72142545569
  Author: Brian Weinstein 
  Date:   2024-02-26 (Mon, 26 Feb 2024)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm

  Log Message:
  ---
  Close extension popup web views when the web content process terminates or 
window.close is called
https://bugs.webkit.org/show_bug.cgi?id=270130
rdar://123468009

Reviewed by Timothy Hatcher.

On iOS, this will lead to the UIViewController being closed, which leads to a 
better experience for the client.

On Mac, if the web view lives in an NSPanel, WebKit will close the window that 
the web view is in.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm:
(-[_WKWebExtensionActionWebViewDelegate webViewWebContentProcessDidTerminate:]):
(-[_WKWebExtensionActionWebViewDelegate webViewDidClose:]):

Canonical link: https://commits.webkit.org/275360@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 247ec3: Create a faster cache of _WKWebExtensionTabs

2024-03-05 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 247ec3b89c5405e9dd3c3ef431513b64d38136c0
  
https://github.com/WebKit/WebKit/commit/247ec3b89c5405e9dd3c3ef431513b64d38136c0
  Author: Brian Weinstein 
  Date:   2024-03-05 (Tue, 05 Mar 2024)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h

  Log Message:
  ---
  Create a faster cache of _WKWebExtensionTabs
https://bugs.webkit.org/show_bug.cgi?id=270488
rdar://123959934

Reviewed by Timothy Hatcher.

Instead of iterating over all of the tabs in m_tabMap and checking to see if 
their delegates match, create a new
data structure that is a map table from the delegate to the identifier.

This way, we can just do one O(1) lookup instead of an O(n) iteration.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::WebExtensionContext):
(WebKit::WebExtensionContext::getOrCreateTab const):
(WebKit::WebExtensionContext::forgetTab const):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:

Canonical link: https://commits.webkit.org/275692@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 7b1151: activeTab extension has access to page after turni...

2024-03-04 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7b1151eb72481d791968bce427be4775ff616789
  
https://github.com/WebKit/WebKit/commit/7b1151eb72481d791968bce427be4775ff616789
  Author: Brian Weinstein 
  Date:   2024-03-04 (Mon, 04 Mar 2024)

  Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm

  Log Message:
  ---
  activeTab extension has access to page after turning the extension off, then 
back on
https://bugs.webkit.org/show_bug.cgi?id=270454
rdar://124016968

Reviewed by Timothy Hatcher.

When an extension is unloaded, clear the map of open tabs and windows. That 
will clear any active tab permissions,
and lead to new window and tab IDs getting created if the extension is turned 
back on.

While we're here, clear a bunch more extension state that should be refreshed 
if the extension is loaded again.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::unload):

Canonical link: https://commits.webkit.org/275651@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes


[webkit-changes] [WebKit/WebKit] 237b90: Add an early return if loading updated DNR rules f...

2024-05-28 Thread Brian Weinstein
  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 237b90c1c756967c60ca644f02dcc13084364628
  
https://github.com/WebKit/WebKit/commit/237b90c1c756967c60ca644f02dcc13084364628
  Author: Brian Weinstein 
  Date:   2024-05-28 (Tue, 28 May 2024)

  Changed paths:
M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm

  Log Message:
  ---
  Add an early return if loading updated DNR rules fails
https://bugs.webkit.org/show_bug.cgi?id=274785
rdar://128749905

Reviewed by Timothy Hatcher.

Without this early return, we were both trying to roll back to a savepoint and 
commit the same savepoint,
and then we would call the completion handler more than once, leading to this 
crash.

These code paths should be mutually exclusive, so make sure to add an early 
return.

* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionContext::updateDeclarativeNetRequestRulesInStorage):

Canonical link: https://commits.webkit.org/279426@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
___
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes