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_ignore_same_page_navigation.js | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 browser/base/content/test/siteIdentity/browser_ignore_same_page_navigation.js (limited to 'browser/base/content/test/siteIdentity/browser_ignore_same_page_navigation.js') diff --git a/browser/base/content/test/siteIdentity/browser_ignore_same_page_navigation.js b/browser/base/content/test/siteIdentity/browser_ignore_same_page_navigation.js new file mode 100644 index 0000000000..86ec70a0cf --- /dev/null +++ b/browser/base/content/test/siteIdentity/browser_ignore_same_page_navigation.js @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test that the nsISecureBrowserUI implementation doesn't send extraneous OnSecurityChange events +// when it receives OnLocationChange events with the LOCATION_CHANGE_SAME_DOCUMENT flag set. + +add_task(async function () { + await BrowserTestUtils.withNewTab("about:blank", async browser => { + let onLocationChangeCount = 0; + let onSecurityChangeCount = 0; + let progressListener = { + onStateChange() {}, + onLocationChange() { + onLocationChangeCount++; + }, + onSecurityChange() { + onSecurityChangeCount++; + }, + onProgressChange() {}, + onStatusChange() {}, + + QueryInterface: ChromeUtils.generateQI([ + "nsIWebProgressListener", + "nsISupportsWeakReference", + ]), + }; + browser.addProgressListener(progressListener, Ci.nsIWebProgress.NOTIFY_ALL); + + let uri = + getRootDirectory(gTestPath).replace( + "chrome://mochitests/content", + "https://example.com" + ) + "dummy_page.html"; + BrowserTestUtils.loadURIString(browser, uri); + await BrowserTestUtils.browserLoaded(browser, false, uri); + is(onLocationChangeCount, 1, "should have 1 onLocationChange event"); + is(onSecurityChangeCount, 1, "should have 1 onSecurityChange event"); + await SpecialPowers.spawn(browser, [], async () => { + content.history.pushState({}, "", "https://example.com"); + }); + is(onLocationChangeCount, 2, "should have 2 onLocationChange events"); + is( + onSecurityChangeCount, + 1, + "should still have only 1 onSecurityChange event" + ); + }); +}); -- cgit v1.2.3