From 99e4dc450cecfad09e5c1f7e561f5a905186b629 Mon Sep 17 00:00:00 2001 From: wuggy Date: Sat, 19 Sep 2026 15:11:02 -0700 Subject: [PATCH] AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA --- .../en-US/chrome/browser/browser.properties | 2 ++ browser/modules/PermissionUI.jsm | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties index 76ceaa4e7d..b8dfb11739 100644 --- a/browser/locales/en-US/chrome/browser/browser.properties +++ b/browser/locales/en-US/chrome/browser/browser.properties @@ -368,6 +368,8 @@ geolocation.shareWithSite2=Would you like to share your location with this site? geolocation.shareWithFile2=Would you like to share your location with this file? webUSB.connectToSite=Would you like to let this site access USB devices? +webUSB.selectDeviceTitle=Select USB device +webUSB.selectDevice=Choose a USB device to access: webUSB.allow=Allow USB Devices webUSB.allow.accesskey=A webUSB.block=Block USB Devices diff --git a/browser/modules/PermissionUI.jsm b/browser/modules/PermissionUI.jsm index 238b64a605..3486e787af 100644 --- a/browser/modules/PermissionUI.jsm +++ b/browser/modules/PermissionUI.jsm @@ -550,6 +550,35 @@ USBPermissionPrompt.prototype = { return "web-usb"; }, + // PopupNotifications in older UXP builds cannot reliably render a + // permission request that contains a variable list of USB devices. Use + // the native prompt service so the chooser is always visible and the + // selected device can be returned to the content request. + prompt() { + let choices = getUSBDeviceChoices(this.request); + if (!choices.length) { + this.cancel(); + return; + } + + let browser = this.browser; + let parent = browser && browser.ownerGlobal ? browser.ownerGlobal : null; + let selected = { value: 0 }; + let accepted = Services.prompt.select( + parent, + getUSBString("webUSB.selectDeviceTitle", "Select USB device"), + getUSBString("webUSB.selectDevice", "Choose a USB device to access:"), + choices.length, + choices, + selected); + + if (accepted && selected.value >= 0 && selected.value < choices.length) { + this.request.allow({usb: choices[selected.value]}); + } else { + this.cancel(); + } + }, + get anchorID() { return "default-notification-icon"; },