Hi.
For my Safari Web Extension, using getMatchedRules() from declarativeNetRequest does not seem to work.
I've declared the permission for declarativeNetRequestFeedback in my manifest.json file and tried the activeTab permission too.
getMatchedRules() was added in a previous Safari release and was adjusted in Safari 16.4. I'm using Safari 16.5.
It only returns an empty array when it's called.
I know the rules are there and they're being applied from the static rules json, it's just that getMatchedRules() is not showing them for some reason.
I'm using:
const rules = await browser.declarativeNetRequest.getMatchedRules();
But it only ever returns:
{rulesMatchedInfo: []}
Can anyone tell me what I'm doing wrong please? The same code works fine in Chromium based browsers.
Thank you.
General
RSS for tagExplore the integration of web technologies within your app. Discuss building web-based apps, leveraging Safari functionalities, and integrating with web services.
Post
Replies
Boosts
Views
Activity
I created an application with the com.apple.developer.web-browser (set default browser) function, but when I want to add the Universal link function to this application, I found that the Universal link function is invalid. I searched for this problem for a long time, until finally I found that it has something to do with com.apple.developer.web-browser settings, when I turn off com.apple.developer.web-browser, Universal link works again. But my app needs to have both, has anyone encountered such a problem? Can you provide some solutions?Thanks anyway.
Hello,
We're testing our app using iOS 17 beta to see if there's any problem, and we encountered an issue with an image rendered using HTML5 canvas having the alpha layer turning to white (See screenshot below) This happens not just our website but to other website as well. Both in UIWebView and Safari Browser.
Is this going to be fixed before the actual release of iOS 17? or do we have to tweak our code somewhere in order to fix this?
Thanks!
Regards,
Byron Bautista
Hello, I'm trying to learn swift and making the Landmarks tutorial I found a problem with the map view. The error read as follow: "'init(coordinateRegion:interactionModes:showsUserLocation:userTrackingMode:)' was deprecated in iOS 17.0: Use Map initializers that take a MapContentBuilder instead."
My code is:
import MapKit
struct MapView: View {
@State private var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 34.011_286, longitude: -116.166_868),
span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2)
)
// The error happens here!
var body: some View {
Map(coordinateRegion: $region)
}
}
#Preview {
MapView()
}
Any suggestions about hot to solve this will be appreciate it.
Thanks,
BR
Skalex
Apparently WebXR is gonna be available on the visionOS Webkit: https://developer.apple.com/videos/play/wwdc2023/10279
So I guess we are still many to wonder if WebXR experimental features will ever be testable on Safari for iOS?
https://bugs.webkit.org/show_bug.cgi?id=208988
Declarative net Request modify header rule is not working for safari. Works fine on all other browsers (chrome, edge , FF etc)
Error: [Error] Error: Invalid call to declarativeNetRequest.updateDynamicRules(). Error with rule at index 0: Rule with id 100 is invalid. The header x-source is not recognized.
> > let x = [{ "id": 100, "priority": 1, "action": { "type": "modifyHeaders", "requestHeaders": [ { "header": "x-source", "operation": "set", "value": "test" } ] }, "condition": { "urlFilter": "https://*/*" } }]
await browser.declarativeNetRequest.updateDynamicRules({ addRules: x });
However, if I change the header name to "Origin" it works. Is there a restriction on which all header names are supported?
Code to print
self.airPrintWebView.loadHTMLString(html, baseURL: nil)
self.view.add(subView:self.airPrintWebView)
let formatter = self.airPrintWebView.viewPrintFormatter()
//1.5" margins for the page
formatter.perPageContentInsets = UIEdgeInsets(top: HALF_INCH_INSET, left: ONE_INCH_INSET, bottom: ONEHALF_INCH_INSET, right: ONE_INCH_INSET)
let activityVC = UIActivityViewController(activityItems: [formatter], applicationActivities: nil)
// Prevents iBook and PDF from being options
activityVC.excludedActivityTypes = [.openInIBooks, .markupAsPDF]
activityVC.completionWithItemsHandler = { (activity, success, items, error) in
self.airPrintWebView.removeFromSuperview()
if shouldRemoveSenderButton {
sender.removeFromSuperview()
}
PredictSpringApplication.sharedInstance.psAlertBlockView?.isHidden = false
}
if PSUtil.isIpad() {
activityVC.popoverPresentationController?.sourceView = self.airPrintWebView
activityVC.popoverPresentationController?.sourceRect = sender.frame
}
self.present(activityVC, animated: true, completion: nil)
Crash
Crashed: com.apple.main-thread
0 CoreGraphics 0x107e6c CGPDFDocumentIsEncrypted + 12
1 PrintKitUI 0x586b0 -[UIPrintPreviewPageFetcher redrawQuicklookPDF:] + 104
2 PrintKitUI 0x28f4c -[UIPrintPreviewViewController updateQuicklookPDF] + 148
3 Foundation 0xa6f14 NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 24
4 Foundation 0x7b020 -[NSBlockOperation main] + 104
5 Foundation 0x7afb0 NSOPERATION_IS_INVOKING_MAIN + 16
6 Foundation 0x3c4d8 -[NSOperation start] + 708
7 Foundation 0x3c20c NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION + 16
8 Foundation 0x4189c __NSOQSchedule_f + 172
9 libdispatch.dylib 0x12fc4 _dispatch_block_async_invoke2 + 148
10 libdispatch.dylib 0x3eac _dispatch_client_callout + 20
11 libdispatch.dylib 0x126a4 _dispatch_main_queue_drain + 928
12 libdispatch.dylib 0x122f4 _dispatch_main_queue_callback_4CF + 44
13 CoreFoundation 0x98c28 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16
14 CoreFoundation 0x7a560 __CFRunLoopRun + 1992
15 CoreFoundation 0x7f3ec CFRunLoopRunSpecific + 612
16 GraphicsServices 0x135c GSEventRunModal + 164
17 UIKitCore 0x39d6e8 -[UIApplication _run] + 888
18 UIKitCore 0x39d34c UIApplicationMain + 340
19 PSStore 0xbaa0 main + 2 (main.swift:2)
20 ??? 0x1b94fedec (Missing)
Any body able to solve this random crash ?
Sometimes Safari is rendering the icon for an active extension in its original provided colored representation, other times Safari is applying an overlay color in line with the system's highlight color.
This difference can even be seen seen on the Safari Extensions Developer home page: https://developer.apple.com/safari/extensions/images/extensions-hero-large_2x.png
You will notice that Grammarly's icon is shown in it's original color format, while the others aren't.
Example of extensions where the icon is shown in color:
Bitwarden
Grammarly
1Password
Consent-O-Matic
I've compared the source code of Bitwarden and Consent-o-Matic with my own extension and cannot find any differences in the settings or image properties (resolution, DPI, file type, color profile). If I take the exact PNG source files from said open source extensions and replace them in my own source code, these icons show up in full color.
Does this perhaps mean there is a bug in Safari's processing of the icons where it fails to overlay the icon with the highlight color in some cases?
I and I assume many developers with me would like to understand what determines this difference. Ideally, there is a consistent UX where the end user has the choice between icons in color or highlight color overlay.
Hi
From the video, Safari will pop up a banner for these enabled app extension, which can let user set per-site option, when upgrade to Safari17(MacOS14). Such as following:
For enterprise, there are too many users install app extensions. We want to set these by management tools. We have following questions:
For upgrade users, Is there any way or tools to disable this banner or grant "ALLOW" for user automatically? Such as MDM tools.
For fresh install user, is there any way to grant per-site permission automatically by MDM tools or others?
Thanks.
Best wishes
eric_wang_mac
I have an html file embedded in my app that renders as expected (and has for years) on iOS versions up to 16.2 (not sure about 16.3 - haven't tried that yet). Now on iOS 16.4, the background color of one of my html elements is not being rendered.
It can't only be me, this is very normal css:
#bizAndClientContact {
margin-top: 40px;
background-color: #EEEEEE;
padding: 25px;
}
I'm really at a loss. Is this a known issue?
Hi all,
For months I've been trying to change the order of my Safari’s tab groups on my Mac and my IPad to no avail. I would change the order with the most important tab groups at the top and they would always come back to the previous order, the order in which they were created. Today I discovered that I could do this also at my iPhone’s Safari. And to my surprise I could see the orders of my tab groups on my Mac’s Safari being updated as I changed them on my iPhone’s Safari. So, problem solved as long as I understand that iPhone is the boss. Well, I would never choose iPhone the preferred device to read Safari’s web pages given that I have a Mac and an iPad.
Regards,
Johel
iOS 17.0 (21A5277j)
iPadOS 17.0 (21A5277j)
macOS 14.0 Beta (23A5286i)
macOS 10.15.7 (19H2026) and their related official Safaris
When trying to compile a rule list via WKContentRuleListStore's -compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler: method I'm getting the following error:
** Rule list compilation failed Too many rules in JSON array.**
The max number of rules allowed in a WKContentRuleList doesn't seem to be documented (or I couldn't find it). Does anyone know what the limit is?
Thanks
Hi everyone,
I am having a problem that only happens in Safari that is really weird. I tried to google it but I didn't find any information regarding this so I was hoping that someone could help me here.
I have a site that supports dark and light theme, and when I switch from dark to light or vise versa the background-color on the body doesn't change. I saw on the dev tools that the rgb on the computed changes but on the screen it stays with the previous color and needs a refresh to change to the correct color.
Can somebody help me?
Thank you in advance!
Hi,
I am trying to override some properties on iPad Air 5 with media query. I am using Safari, but the query should work with Chrome also.
I have tried several combinations, but it seems that nothing works. For example I have tried this queries:
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 2) {
body {
font-size: 20px;
}
}
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
body {
font-size: 20px;
}
}
@media only screen
and (-webkit-min-device-pixel-ratio: 2) {
body {
font-size: 20px;
}
}
Does anyone know what is the problem?
Best regards!
I see in the documentation that it is possible to hide elements on a page using a CSS selector by setting the action type to css-display-none and then providing a selector.
But this is kind of limited. You have to know every selector for every style sheet ahead of time. It's possible to block loading of a style sheet using a block rule.
"trigger" : {
"load-type" : [
"third-party"
],
"url-filter" : "REGEX_FOR_STYLESHEET_OF_KNOWN_NASTY_CONTENT_PROVIDER",
"resource-type" : [
"style-sheet"
],
"url-filter-is-case-sensitive" : true
},
"action" : {
"type" : "block"
}
Is is my understanding that the above rule will block loading of a stylesheet that matches the url-filter but all elements will still be displayed by WKWebView using the default style provided by the browser. Am I misunderstanding?
Ideally I'd like to be able to set display:none; for every selector in the evil style sheet. I of course can look at the style sheet and make css-display-none rules for every selector manually but that's pretty much impossible to maintain for rule lists with thousands of entires and will break when the author of the nasty stylesheet makes any changes.
Is there a way to accomplish what I'm after using WKContentRuleList?
I see WKContentRuleListStore saves compile lists by identifier. It's nice that I don't have to recompile the WKContentRuleListStore on every app launch but is there ever an event where the system discards compiled lists (other than me calling -removeContentRuleListForIdentifier:completionHandler:)?
The reason I ask is should I be writing a version number with my compiled list? If I change the JSON code on an app update do I need to manually remove compiled lists after an app update before recompiling the new JSON?
Hello,
According to MDN, Safari v15.4+ should fully support declarativeNetRequest.Redirect, including regexSubstitution, but when I use it in a rule I get this:
Rule:
EXT_PAGE = '/hello.html';
RULES = [{
id: 1,
action: {
type: 'redirect',
redirect: {
regexSubstitution: EXT_PAGE + '#\\0'
},
},
condition: {
requestDomains: ['example.com'],
regexFilter: '^.+$',
resourceTypes: ['main_frame', 'sub_frame'],
},
}];
browser.declarativeNetRequest.updateDynamicRules({
removeRuleIds: RULES.map(r => r.id),
addRules: RULES,
});
Error: Invalid call to declarativeNetRequest.updateDynamicRules(). Error with rule at index 0: Rule with id 1 is invalid. redirect is missing either a url, extensionPath, or transform key.
We have been testing universal links and detected the following: Assuming there is an HTML with embedded JS that redirects to the universal link.
**Direct redirection --> WORKS OK **
window.location.href = "https://my-universal-link?data=abc";
Redirection with timeOut or Interval --> NOT WORKING (go to default WEB)
setTimeout(function () {
window.location.href = "https://my-universal-link?data=abc";
}, 2000);
setInterval(function () {
window.location.href = "https://my-universal-link?data=abc";
}, 2000);
I am currently utilizing local servers to facilitate interactions with local resources. However, I am exploring if there are solutions that would enable direct file access through the file:// protocol.
I cannot access the developer tools and feature flags. Specifically, the option "Show features for web developers" seems to be deactivated.
This is happening within the ASan WebKit build. I am running this using Tools/Scripts/run-safari. Any insights or potential solutions to these issues would be greatly appreciated.
You used to be able to create custom Widgets using Safari to view a section of a website. The "open in dashboard" option is no longer there. what is the process to do this now?