Bug 1958350 - Part 2: Add test for subframe content area clicks, r=Gijs,frontend-codestyle-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D244445
This commit is contained in:
Nika Layzell
2025-05-15 16:18:03 +00:00
committed by nlayzell@mozilla.com
parent 77a5fc0c85
commit 8ae5b9e858
5 changed files with 53 additions and 0 deletions

View File

@@ -93,6 +93,7 @@ const extraBrowserTestPaths = [
"browser/base/content/test/gesture/",
"browser/base/content/test/historySwipeAnimation/",
"browser/base/content/test/keyboard/",
"browser/base/content/test/linkHandling/",
"browser/base/content/test/menubar/",
"browser/base/content/test/metaTags/",
"browser/base/content/test/notificationbox/",

View File

@@ -0,0 +1,4 @@
["browser_contentAreaClick_subframe_javascript.js"]
support-files = [
"file_contentAreaClick_subframe_javascript.html"
]

View File

@@ -0,0 +1,45 @@
const gExampleComRoot = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content/",
"https://example.com/"
);
const IFRAME_FILE = "file_contentAreaClick_subframe_javascript.html";
add_task(async function () {
await BrowserTestUtils.withNewTab(
`data:text/html,<iframe src="${gExampleComRoot + IFRAME_FILE}"></iframe>`,
async browser => {
let newTabPromise = BrowserTestUtils.waitForNewTab(
gBrowser,
"about:blank"
);
let javascriptRanPromise = TestUtils.topicObserved(
"contentAreaClick-javascriptRan"
);
// ctrl/cmd-click the link in the subframe. This should cause it to be
// loaded in a new tab.
info("Clicking link");
let expectedRemoteType =
browser.browsingContext.children[0].currentRemoteType;
await BrowserTestUtils.synthesizeMouseAtCenter(
"a",
{ ctrlKey: true, metaKey: true },
browser.browsingContext.children[0]
);
info("Waiting for new tab");
let newTab = await newTabPromise;
info("Waiting to be notified that the javascript ran");
await javascriptRanPromise;
is(
newTab.linkedBrowser.remoteType,
expectedRemoteType,
"new tab was loaded in expected process"
);
info("Removing the tab");
BrowserTestUtils.removeTab(newTab);
}
);
});

View File

@@ -0,0 +1,2 @@
<!DOCTYPE html>
<a href="javascript:SpecialPowers.notifyObserversInParentProcess(null, 'contentAreaClick-javascriptRan');">link</a>

View File

@@ -33,6 +33,7 @@ BROWSER_CHROME_MANIFESTS += [
"content/test/historySwipeAnimation/browser.toml",
"content/test/keyboard/browser.toml",
"content/test/keyboard/browserSidebarRevamp.toml",
"content/test/linkHandling/browser.toml",
"content/test/menubar/browser.toml",
"content/test/metaTags/browser.toml",
"content/test/notificationbox/browser.toml",