chore: Start making use of Mozilla's linter, p=#12656

This commit is contained in:
mr. m
2026-03-07 12:15:32 +01:00
committed by GitHub
parent 7c8ccdedd4
commit 0ee960e3a3
78 changed files with 712 additions and 4842 deletions

View File

@@ -2,4 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
[DEFAULT]
["browser_compact_mode_width.js"]

View File

@@ -6,4 +6,5 @@
prefs = ["zen.workspaces.separate-essentials=true"]
["browser_container_auto_switch.js"]
["browser_container_specific_essentials.js"]
["browser_container_specific_essentials.js"]

View File

@@ -8,17 +8,28 @@ support-files = [
"head.js",
]
["browser_folder_create.js"]
["browser_folder_subfolder.js"]
["browser_folder_basic_toggle.js"]
["browser_folder_owner_tabs.js"]
["browser_folder_create.js"]
["browser_folder_density.js"]
["browser_folder_max_subfolders.js"]
["browser_folder_empty_tab.js"]
["browser_folder_multiselected.js"]
["browser_folder_visible_tabs.js"]
["browser_folder_level_checks.js"]
["browser_folder_reset_button.js"]
["browser_folder_issue_9885.js"]
["browser_folder_issue_9981.js"]
["browser_folder_level_checks.js"]
["browser_folder_max_subfolders.js"]
["browser_folder_multiselected.js"]
["browser_folder_owner_tabs.js"]
["browser_folder_reset_button.js"]
["browser_folder_subfolder.js"]
["browser_folder_visible_tabs.js"]

View File

@@ -8,9 +8,15 @@ support-files = [
]
["browser_glance_basic.js"]
["browser_glance_expand.js"]
["browser_glance_close.js"]
["browser_glance_next_tab.js"]
["browser_glance_prev_tab.js"]
["browser_glance_select_parent.js"]
["browser_glance_close_select.js"]
["browser_glance_expand.js"]
["browser_glance_next_tab.js"]
["browser_glance_prev_tab.js"]
["browser_glance_select_parent.js"]

View File

@@ -2,6 +2,10 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
["browser_live_folder.js"]
["browser_rss_live_folder.js"]
[DEFAULT]
["browser_github_live_folder.js"]
["browser_live_folder.js"]
["browser_rss_live_folder.js"]

View File

@@ -17,69 +17,69 @@ import CoreText
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
help="print verbose registration failures",
default=False,
)
parser.add_argument(
"file", nargs="*", help="font file to register or unregister", default=[]
)
parser.add_argument(
"-u",
"--unregister",
action="store_true",
help="unregister the provided fonts",
default=False,
)
parser.add_argument(
"-p",
"--persist-user",
action="store_true",
help="permanently register the font",
default=False,
)
parser = argparse.ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
action="store_true",
help="print verbose registration failures",
default=False,
)
parser.add_argument(
"file", nargs="*", help="font file to register or unregister", default=[]
)
parser.add_argument(
"-u",
"--unregister",
action="store_true",
help="unregister the provided fonts",
default=False,
)
parser.add_argument(
"-p",
"--persist-user",
action="store_true",
help="permanently register the font",
default=False,
)
args = parser.parse_args()
args = parser.parse_args()
if args.persist_user:
scope = CoreText.kCTFontManagerScopeUser
scopeDesc = "user"
else:
scope = CoreText.kCTFontManagerScopeSession
scopeDesc = "session"
failureCount = 0
for fontPath in args.file:
fontURL = Cocoa.NSURL.fileURLWithPath_(fontPath)
(result, error) = register_or_unregister_font(fontURL, args.unregister, scope)
if result:
print(
"%sregistered font %s with %s scope"
% (("un" if args.unregister else ""), fontPath, scopeDesc)
)
if args.persist_user:
scope = CoreText.kCTFontManagerScopeUser
scopeDesc = "user"
else:
print(
"Failed to %sregister font %s with %s scope"
% (("un" if args.unregister else ""), fontPath, scopeDesc)
)
if args.verbose:
print(error)
failureCount += 1
scope = CoreText.kCTFontManagerScopeSession
scopeDesc = "session"
sys.exit(failureCount)
failureCount = 0
for fontPath in args.file:
fontURL = Cocoa.NSURL.fileURLWithPath_(fontPath)
(result, error) = register_or_unregister_font(fontURL, args.unregister, scope)
if result:
print(
"%sregistered font %s with %s scope"
% (("un" if args.unregister else ""), fontPath, scopeDesc)
)
else:
print(
"Failed to %sregister font %s with %s scope"
% (("un" if args.unregister else ""), fontPath, scopeDesc)
)
if args.verbose:
print(error)
failureCount += 1
sys.exit(failureCount)
def register_or_unregister_font(fontURL, unregister, scope):
return (
CoreText.CTFontManagerUnregisterFontsForURL(fontURL, scope, None)
if unregister
else CoreText.CTFontManagerRegisterFontsForURL(fontURL, scope, None)
)
return (
CoreText.CTFontManagerUnregisterFontsForURL(fontURL, scope, None)
if unregister
else CoreText.CTFontManagerRegisterFontsForURL(fontURL, scope, None)
)
if __name__ == "__main__":
main()
main()

View File

@@ -31,138 +31,138 @@ from Cocoa import NSURL
def main():
parser = argparse.ArgumentParser(
description="Utility to print, set, or "
+ "check the path to image being used as "
+ "the desktop background image. By "
+ "default, prints the path to the "
+ "current desktop background image."
)
parser.add_argument(
"-v",
"--verbose",
action="store_true",
help="print verbose debugging information",
default=False,
)
group = parser.add_mutually_exclusive_group()
group.add_argument(
"-s",
"--set-background-image",
dest="newBackgroundImagePath",
required=False,
help="path to the new background image to set. A zero "
+ "exit code indicates no errors occurred.",
default=None,
)
group.add_argument(
"-c",
"--check-background-image",
dest="checkBackgroundImagePath",
required=False,
help="check if the provided background image path "
+ "matches the provided path. A zero exit code "
+ "indicates the paths match.",
default=None,
)
args = parser.parse_args()
# Using logging for verbose output
if args.verbose:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.CRITICAL)
logger = logging.getLogger("desktopImage")
# Print what we're going to do
if args.checkBackgroundImagePath is not None:
logger.debug(
"checking provided desktop image %s matches current "
"image" % args.checkBackgroundImagePath
parser = argparse.ArgumentParser(
description="Utility to print, set, or "
+ "check the path to image being used as "
+ "the desktop background image. By "
+ "default, prints the path to the "
+ "current desktop background image."
)
elif args.newBackgroundImagePath is not None:
logger.debug("setting image to %s " % args.newBackgroundImagePath)
else:
logger.debug("retrieving desktop image path")
focussedScreen = NSScreen.mainScreen()
if not focussedScreen:
raise RuntimeError("mainScreen error")
ws = NSWorkspace.sharedWorkspace()
if not ws:
raise RuntimeError("sharedWorkspace error")
# If we're just checking the image path, check it and then return.
# A successful exit code (0) indicates the paths match.
if args.checkBackgroundImagePath is not None:
# Get existing desktop image path and resolve it
existingImageURL = getCurrentDesktopImageURL(focussedScreen, ws, logger)
existingImagePath = existingImageURL.path()
existingImagePathReal = os.path.realpath(existingImagePath)
logger.debug("existing desktop image: %s" % existingImagePath)
logger.debug("existing desktop image realpath: %s" % existingImagePath)
# Resolve the path we're going to check
checkImagePathReal = os.path.realpath(args.checkBackgroundImagePath)
logger.debug("check desktop image: %s" % args.checkBackgroundImagePath)
logger.debug("check desktop image realpath: %s" % checkImagePathReal)
if existingImagePathReal == checkImagePathReal:
print("desktop image path matches provided path")
return True
print("desktop image path does NOT match provided path")
return False
# Log the current desktop image
if args.verbose:
existingImageURL = getCurrentDesktopImageURL(focussedScreen, ws, logger)
logger.debug("existing desktop image: %s" % existingImageURL.path())
# Set the desktop image
if args.newBackgroundImagePath is not None:
newImagePath = args.newBackgroundImagePath
if not os.path.exists(newImagePath):
logger.critical("%s does not exist" % newImagePath)
return False
if not os.access(newImagePath, os.R_OK):
logger.critical("%s is not readable" % newImagePath)
return False
logger.debug("new desktop image to set: %s" % newImagePath)
newImageURL = NSURL.fileURLWithPath_(newImagePath)
logger.debug("new desktop image URL to set: %s" % newImageURL)
status = False
(status, error) = ws.setDesktopImageURL_forScreen_options_error_(
newImageURL, focussedScreen, None, None
parser.add_argument(
"-v",
"--verbose",
action="store_true",
help="print verbose debugging information",
default=False,
)
if not status:
raise RuntimeError("setDesktopImageURL error")
group = parser.add_mutually_exclusive_group()
group.add_argument(
"-s",
"--set-background-image",
dest="newBackgroundImagePath",
required=False,
help="path to the new background image to set. A zero "
+ "exit code indicates no errors occurred.",
default=None,
)
group.add_argument(
"-c",
"--check-background-image",
dest="checkBackgroundImagePath",
required=False,
help="check if the provided background image path "
+ "matches the provided path. A zero exit code "
+ "indicates the paths match.",
default=None,
)
args = parser.parse_args()
# Print the current desktop image
imageURL = getCurrentDesktopImageURL(focussedScreen, ws, logger)
imagePath = imageURL.path()
imagePathReal = os.path.realpath(imagePath)
logger.debug("updated desktop image URL: %s" % imageURL)
logger.debug("updated desktop image path: %s" % imagePath)
logger.debug("updated desktop image path (resolved): %s" % imagePathReal)
print(imagePathReal)
return True
# Using logging for verbose output
if args.verbose:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.CRITICAL)
logger = logging.getLogger("desktopImage")
# Print what we're going to do
if args.checkBackgroundImagePath is not None:
logger.debug(
"checking provided desktop image %s matches current "
"image" % args.checkBackgroundImagePath
)
elif args.newBackgroundImagePath is not None:
logger.debug("setting image to %s " % args.newBackgroundImagePath)
else:
logger.debug("retrieving desktop image path")
focussedScreen = NSScreen.mainScreen()
if not focussedScreen:
raise RuntimeError("mainScreen error")
ws = NSWorkspace.sharedWorkspace()
if not ws:
raise RuntimeError("sharedWorkspace error")
# If we're just checking the image path, check it and then return.
# A successful exit code (0) indicates the paths match.
if args.checkBackgroundImagePath is not None:
# Get existing desktop image path and resolve it
existingImageURL = getCurrentDesktopImageURL(focussedScreen, ws, logger)
existingImagePath = existingImageURL.path()
existingImagePathReal = os.path.realpath(existingImagePath)
logger.debug("existing desktop image: %s" % existingImagePath)
logger.debug("existing desktop image realpath: %s" % existingImagePath)
# Resolve the path we're going to check
checkImagePathReal = os.path.realpath(args.checkBackgroundImagePath)
logger.debug("check desktop image: %s" % args.checkBackgroundImagePath)
logger.debug("check desktop image realpath: %s" % checkImagePathReal)
if existingImagePathReal == checkImagePathReal:
print("desktop image path matches provided path")
return True
print("desktop image path does NOT match provided path")
return False
# Log the current desktop image
if args.verbose:
existingImageURL = getCurrentDesktopImageURL(focussedScreen, ws, logger)
logger.debug("existing desktop image: %s" % existingImageURL.path())
# Set the desktop image
if args.newBackgroundImagePath is not None:
newImagePath = args.newBackgroundImagePath
if not os.path.exists(newImagePath):
logger.critical("%s does not exist" % newImagePath)
return False
if not os.access(newImagePath, os.R_OK):
logger.critical("%s is not readable" % newImagePath)
return False
logger.debug("new desktop image to set: %s" % newImagePath)
newImageURL = NSURL.fileURLWithPath_(newImagePath)
logger.debug("new desktop image URL to set: %s" % newImageURL)
status = False
(status, error) = ws.setDesktopImageURL_forScreen_options_error_(
newImageURL, focussedScreen, None, None
)
if not status:
raise RuntimeError("setDesktopImageURL error")
# Print the current desktop image
imageURL = getCurrentDesktopImageURL(focussedScreen, ws, logger)
imagePath = imageURL.path()
imagePathReal = os.path.realpath(imagePath)
logger.debug("updated desktop image URL: %s" % imageURL)
logger.debug("updated desktop image path: %s" % imagePath)
logger.debug("updated desktop image path (resolved): %s" % imagePathReal)
print(imagePathReal)
return True
def getCurrentDesktopImageURL(focussedScreen, workspace, logger):
imageURL = workspace.desktopImageURLForScreen_(focussedScreen)
if not imageURL:
raise RuntimeError("desktopImageURLForScreen returned invalid URL")
if not imageURL.isFileURL():
logger.warning("desktop image URL is not a file URL")
return imageURL
imageURL = workspace.desktopImageURLForScreen_(focussedScreen)
if not imageURL:
raise RuntimeError("desktopImageURLForScreen returned invalid URL")
if not imageURL.isFileURL():
logger.warning("desktop image URL is not a file URL")
return imageURL
if __name__ == "__main__":
if not main():
sys.exit(1)
else:
sys.exit(0)
if not main():
sys.exit(1)
else:
sys.exit(0)

View File

@@ -5,14 +5,22 @@
[DEFAULT]
prefs = ["zen.workspaces.separate-essentials=false"]
["browser_pinned_unload_changed.js"]
["browser_pinned_unload_noreset.js"]
["browser_pinned_nounload_reset.js"]
["browser_pinned_switch.js"]
["browser_pinned_reset_noswitch.js"]
["browser_pinned_close.js"]
["browser_issue_8726.js"]
["browser_pinned_changed.js"]
["browser_pinned_close.js"]
["browser_pinned_created.js"]
["browser_pinned_nounload_reset.js"]
["browser_pinned_reset_noswitch.js"]
["browser_pinned_switch.js"]
["browser_pinned_to_essential.js"]
["browser_issue_8726.js"]
["browser_pinned_unload_changed.js"]
["browser_pinned_unload_noreset.js"]

View File

@@ -9,9 +9,15 @@ support-files = [
]
["browser_basic_split_view.js"]
["browser_split_inset_checks.js"]
["browser_split_groups.js"]
["browser_split_browser_duplication.js"]
["browser_split_view_with_glance.js"]
["browser_split_view_with_folders.js"]
["browser_split_groups.js"]
["browser_split_inset_checks.js"]
["browser_split_view_empty.js"]
["browser_split_view_with_folders.js"]
["browser_split_view_with_glance.js"]

View File

@@ -7,12 +7,16 @@ support-files = [
"head.js",
]
["browser_tabs_empty_checks.js"]
["browser_tabs_close_recently.js"]
["browser_tabs_fetch_checks.js"]
["browser_tabs_cycle_by_attribute.js"]
["browser_drag_drop_vertical.js"]
tags = [
"drag-drop",
"vertical-tabs"
]
["browser_tabs_close_recently.js"]
["browser_tabs_cycle_by_attribute.js"]
["browser_tabs_empty_checks.js"]
["browser_tabs_fetch_checks.js"]

View File

@@ -2,4 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
["browser_ub_actions_search.js"]
[DEFAULT]
["browser_ub_actions_search.js"]

View File

@@ -9,4 +9,5 @@ support-files = [
]
["browser_floating_urlbar.js"]
["browser_issue_7385.js"]

View File

@@ -8,5 +8,6 @@ support-files = [
"head.js",
]
["browser_sync_tab_open.js"]
["browser_sync_tab_label.js"]
["browser_sync_tab_open.js"]

View File

@@ -9,13 +9,19 @@ support-files = [
]
["browser_basic_workspaces.js"]
["browser_workspace_bookmarks.js"]
["browser_double_click_newtab.js"]
["browser_overflow_scrollbox.js"]
["browser_issue_8699.js"]
["browser_issue_9900.js"]
["browser_double_click_newtab.js"]
["browser_issue_10455.js"]
["browser_issue_8699.js"]
["browser_issue_9900.js"]
["browser_overflow_scrollbox.js"]
["browser_private_mode.js"]
["browser_private_mode_startup.js"]
["browser_workspace_bookmarks.js"]