diff --git a/browser/base/content/sanitizeDialog.js b/browser/base/content/sanitizeDialog.js index d46780fd6fc6..38d5f1a1a7d5 100644 --- a/browser/base/content/sanitizeDialog.js +++ b/browser/base/content/sanitizeDialog.js @@ -34,10 +34,17 @@ var gSanitizePromptDialog = { // This is used by selectByTimespan() to determine if the window has loaded. this._inited = true; this._dialog = document.querySelector("dialog"); - let { inBrowserWindow = false } = window.arguments?.[0] || {}; - if (inBrowserWindow) { + let arg = window.arguments?.[0] || {}; + if (arg.inBrowserWindow) { this._dialog.setAttribute("inbrowserwindow", "true"); this._observeTitleForChanges(); + } else if (arg.wrappedJSObject?.needNativeUI) { + document + .getElementById("sanitizeDurationChoice") + .setAttribute("native", "true"); + for (let cb of document.querySelectorAll("checkbox")) { + cb.setAttribute("native", "true"); + } } let OKButton = this._dialog.getButton("accept"); diff --git a/browser/modules/Sanitizer.jsm b/browser/modules/Sanitizer.jsm index 635447c7cbf4..c8cd0e55f139 100644 --- a/browser/modules/Sanitizer.jsm +++ b/browser/modules/Sanitizer.jsm @@ -107,13 +107,31 @@ var Sanitizer = { * @throws if parentWindow is undefined or doesn't have a gDialogBox. */ showUI(parentWindow) { - if (!parentWindow?.gDialogBox) { - throw new Error("Sanitizer.showUI expected a browser window argument."); + // Treat the hidden window as not being a parent window: + if ( + parentWindow?.document.documentURI == + "chrome://browser/content/hiddenWindowMac.xhtml" + ) { + parentWindow = null; + } + if (parentWindow?.gDialogBox) { + parentWindow.gDialogBox.open("chrome://browser/content/sanitize.xhtml", { + inBrowserWindow: true, + }); + } else { + let arg = { + needNativeUI: true, + QueryInterface: ChromeUtils.generateQI([]), + }; + arg.wrappedJSObject = arg; + Services.ww.openWindow( + parentWindow, + "chrome://browser/content/sanitize.xhtml", + "Sanitize", + "chrome,titlebar,dialog,centerscreen,modal", + arg + ); } - - parentWindow.gDialogBox.open("chrome://browser/content/sanitize.xhtml", { - inBrowserWindow: true, - }); }, /**