summaryrefslogtreecommitdiffstats
path: root/remote/cdp/test/browser/page/browser_frameStartedLoading.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /remote/cdp/test/browser/page/browser_frameStartedLoading.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'remote/cdp/test/browser/page/browser_frameStartedLoading.js')
-rw-r--r--remote/cdp/test/browser/page/browser_frameStartedLoading.js104
1 files changed, 104 insertions, 0 deletions
diff --git a/remote/cdp/test/browser/page/browser_frameStartedLoading.js b/remote/cdp/test/browser/page/browser_frameStartedLoading.js
new file mode 100644
index 0000000000..d5bb91a952
--- /dev/null
+++ b/remote/cdp/test/browser/page/browser_frameStartedLoading.js
@@ -0,0 +1,104 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function noEventWhenPageDomainDisabled({ client }) {
+ await runFrameStartedLoadingTest(client, 0, async () => {
+ info("Navigate to a page with nested iframes");
+ await loadURL(FRAMESET_NESTED_URL);
+ });
+});
+
+add_task(async function noEventAfterPageDomainDisabled({ client }) {
+ const { Page } = client;
+
+ await Page.enable();
+ await Page.disable();
+
+ await runFrameStartedLoadingTest(client, 0, async () => {
+ info("Navigate to a page with nested iframes");
+ await loadURL(FRAMESET_NESTED_URL);
+ });
+});
+
+add_task(async function eventWhenNavigatingWithNoFrames({ client }) {
+ const { Page } = client;
+
+ await Page.enable();
+
+ await runFrameStartedLoadingTest(client, 1, async () => {
+ info("Navigate to a page with no iframes");
+ await loadURL(PAGE_URL);
+ });
+});
+
+add_task(async function eventsWhenNavigatingWithFrames({ client }) {
+ const { Page } = client;
+
+ await Page.enable();
+
+ await runFrameStartedLoadingTest(client, 3, async () => {
+ info("Navigate to a page with iframes");
+ await loadURL(FRAMESET_MULTI_URL);
+ });
+});
+
+add_task(async function eventsWhenNavigatingWithNestedFrames({ client }) {
+ const { Page } = client;
+
+ await Page.enable();
+
+ await runFrameStartedLoadingTest(client, 4, async () => {
+ info("Navigate to a page with nested iframes");
+ await loadURL(FRAMESET_NESTED_URL);
+ });
+});
+
+async function runFrameStartedLoadingTest(
+ client,
+ expectedEventCount,
+ callback
+) {
+ const { Page } = client;
+
+ const STARTED_LOADING = "Page.frameStartedLoading";
+
+ const history = new RecordEvents(expectedEventCount);
+ history.addRecorder({
+ event: Page.frameStartedLoading,
+ eventName: STARTED_LOADING,
+ messageFn: payload => {
+ return `Received ${STARTED_LOADING} for frame id ${payload.frameId}`;
+ },
+ });
+
+ await callback();
+
+ const frameStartedLoadingEvents = await history.record();
+
+ is(
+ frameStartedLoadingEvents.length,
+ expectedEventCount,
+ "Got expected amount of frameStartedLoading events"
+ );
+ if (expectedEventCount == 0) {
+ return;
+ }
+
+ const frames = await getFlattenedFrameTree(client);
+
+ frameStartedLoadingEvents.forEach(({ payload }) => {
+ const { frameId } = payload;
+
+ info(`Check frame id ${frameId}`);
+ const expectedFrame = frames.get(frameId);
+
+ ok(expectedFrame, `Found expected frame with id ${frameId}`);
+ is(
+ frameId,
+ expectedFrame.id,
+ "Got expected frame id for frameStartedLoading event"
+ );
+ });
+}