summaryrefslogtreecommitdiffstats
path: root/remote/test/browser/page/browser_frameNavigated.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /remote/test/browser/page/browser_frameNavigated.js
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'remote/test/browser/page/browser_frameNavigated.js')
-rw-r--r--remote/test/browser/page/browser_frameNavigated.js102
1 files changed, 102 insertions, 0 deletions
diff --git a/remote/test/browser/page/browser_frameNavigated.js b/remote/test/browser/page/browser_frameNavigated.js
new file mode 100644
index 0000000000..a74bb2449f
--- /dev/null
+++ b/remote/test/browser/page/browser_frameNavigated.js
@@ -0,0 +1,102 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const DOC = toDataURL("<div>foo</div>");
+const DOC_IFRAME_MULTI = toDataURL(`
+ <iframe src='data:text/html,foo'></iframe>
+ <iframe src='data:text/html,bar'></iframe>
+`);
+const DOC_IFRAME_NESTED = toDataURL(`
+ <iframe src="${DOC_IFRAME_MULTI}"></iframe>
+`);
+
+add_task(async function noEventWhenPageDomainDisabled({ client }) {
+ await runFrameNavigatedTest(client, 0, async () => {
+ info("Navigate to a page with nested iframes");
+ await loadURL(DOC_IFRAME_NESTED);
+ });
+});
+
+add_task(async function noEventAfterPageDomainDisabled({ client }) {
+ const { Page } = client;
+
+ await Page.enable();
+ await Page.disable();
+
+ await runFrameNavigatedTest(client, 0, async () => {
+ info("Navigate to a page with nested iframes");
+ await loadURL(DOC_IFRAME_NESTED);
+ });
+});
+
+add_task(async function eventWhenNavigatingWithNoFrames({ client }) {
+ const { Page } = client;
+
+ await Page.enable();
+
+ await runFrameNavigatedTest(client, 1, async () => {
+ info("Navigate to a page with no iframes");
+ await loadURL(DOC);
+ });
+});
+
+add_task(async function eventsWhenNavigatingWithFrames({ client }) {
+ const { Page } = client;
+
+ await Page.enable();
+
+ await runFrameNavigatedTest(client, 3, async () => {
+ info("Navigate to a page with iframes");
+ await loadURL(DOC_IFRAME_MULTI);
+ });
+});
+
+add_task(async function eventWhenNavigatingWithNestedFrames({ client }) {
+ const { Page } = client;
+
+ await Page.enable();
+
+ await runFrameNavigatedTest(client, 4, async () => {
+ info("Navigate to a page with nested iframes");
+ await loadURL(DOC_IFRAME_NESTED);
+ });
+});
+
+async function runFrameNavigatedTest(client, expectedEventCount, callback) {
+ const { Page } = client;
+
+ const NAVIGATED = "Page.frameNavigated";
+
+ const history = new RecordEvents(expectedEventCount);
+ history.addRecorder({
+ event: Page.frameNavigated,
+ eventName: NAVIGATED,
+ messageFn: payload => {
+ return `Received ${NAVIGATED} for frame id ${payload.frame.id}`;
+ },
+ });
+
+ await callback();
+
+ const frameNavigatedEvents = await history.record();
+
+ is(
+ frameNavigatedEvents.length,
+ expectedEventCount,
+ "Got expected amount of frameNavigated events"
+ );
+ if (expectedEventCount == 0) {
+ return;
+ }
+
+ const frames = await getFlattenedFrameTree(client);
+
+ frameNavigatedEvents.forEach(({ payload }) => {
+ const { frame } = payload;
+
+ const expectedFrame = frames.get(frame.id);
+ Assert.deepEqual(frame, expectedFrame, "Got expected frame details");
+ });
+}