From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- remote/cdp/test/browser/browser_cdp.js | 74 ++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 remote/cdp/test/browser/browser_cdp.js (limited to 'remote/cdp/test/browser/browser_cdp.js') diff --git a/remote/cdp/test/browser/browser_cdp.js b/remote/cdp/test/browser/browser_cdp.js new file mode 100644 index 0000000000..bbc593c39e --- /dev/null +++ b/remote/cdp/test/browser/browser_cdp.js @@ -0,0 +1,74 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test very basic CDP features. +add_task(async function testCDP({ client }) { + const { Browser, Log, Page } = client; + + ok("Browser" in client, "Browser domain is available"); + ok("Log" in client, "Log domain is available"); + ok("Page" in client, "Page domain is available"); + + const version = await Browser.getVersion(); + const { isHeadless } = Cc["@mozilla.org/gfx/info;1"].getService( + Ci.nsIGfxInfo + ); + is( + version.product, + (isHeadless ? "Headless" : "") + + `${Services.appinfo.name}/${Services.appinfo.version}`, + "Browser.getVersion works and depends on headless mode" + ); + is( + version.userAgent, + window.navigator.userAgent, + "Browser.getVersion().userAgent is correct" + ); + + is( + version.revision, + Services.appinfo.sourceURL.split("/").pop(), + "Browser.getVersion().revision is correct" + ); + + is( + version.jsVersion, + Services.appinfo.version, + "Browser.getVersion().jsVersion is correct" + ); + + // receive console.log messages and print them + let result = await Log.enable(); + info("Log domain has been enabled"); + Assert.deepEqual(result, {}, "Got expected result value"); + + Log.entryAdded(({ entry }) => { + const { timestamp, level, text, args } = entry; + const msg = text || args.join(" "); + console.log(`${new Date(timestamp)}\t${level.toUpperCase()}\t${msg}`); + }); + + // turn on navigation related events, such as DOMContentLoaded et al. + result = await Page.enable(); + info("Page domain has been enabled"); + Assert.deepEqual(result, {}, "Got expected result value"); + + const frameStoppedLoading = Page.frameStoppedLoading(); + const frameNavigated = Page.frameNavigated(); + const loadEventFired = Page.loadEventFired(); + await Page.navigate({ + url: toDataURL(``), + }); + info("A new page has been requested"); + + await loadEventFired; + info("`Page.loadEventFired` fired"); + + await frameStoppedLoading; + info("`Page.frameStoppedLoading` fired"); + + await frameNavigated; + info("`Page.frameNavigated` fired"); +}); -- cgit v1.2.3