From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../browser_privatebrowsing_certexceptionsui.js | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 browser/components/privatebrowsing/test/browser/browser_privatebrowsing_certexceptionsui.js (limited to 'browser/components/privatebrowsing/test/browser/browser_privatebrowsing_certexceptionsui.js') diff --git a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_certexceptionsui.js b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_certexceptionsui.js new file mode 100644 index 0000000000..9b796613a9 --- /dev/null +++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_certexceptionsui.js @@ -0,0 +1,65 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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/. */ + +// This test makes sure that certificate exceptions UI behaves correctly +// in private browsing windows, based on whether it's opened from the prefs +// window or from the SSL error page (see bug 461627). + +function test() { + const EXCEPTIONS_DLG_URL = "chrome://pippki/content/exceptionDialog.xhtml"; + const EXCEPTIONS_DLG_FEATURES = "chrome,centerscreen"; + const INVALID_CERT_LOCATION = "https://nocert.example.com/"; + waitForExplicitFinish(); + + // open a private browsing window + var pbWin = OpenBrowserWindow({ private: true }); + pbWin.addEventListener( + "load", + function () { + doTest(); + }, + { once: true } + ); + + // Test the certificate exceptions dialog + function doTest() { + let params = { + exceptionAdded: false, + location: INVALID_CERT_LOCATION, + prefetchCert: true, + }; + function testCheckbox() { + win.removeEventListener("load", testCheckbox); + Services.obs.addObserver(function onCertUI(aSubject, aTopic, aData) { + Services.obs.removeObserver(onCertUI, "cert-exception-ui-ready"); + ok(win.gCert, "The certificate information should be available now"); + + let checkbox = win.document.getElementById("permanent"); + ok( + checkbox.hasAttribute("disabled"), + "the permanent checkbox should be disabled when handling the private browsing mode" + ); + ok( + !checkbox.hasAttribute("checked"), + "the permanent checkbox should not be checked when handling the private browsing mode" + ); + win.close(); + cleanup(); + }, "cert-exception-ui-ready"); + } + var win = pbWin.openDialog( + EXCEPTIONS_DLG_URL, + "", + EXCEPTIONS_DLG_FEATURES, + params + ); + win.addEventListener("load", testCheckbox); + } + + function cleanup() { + // close the private browsing window + pbWin.close(); + finish(); + } +} -- cgit v1.2.3