diff options
Diffstat (limited to 'remote/cdp/test/browser/browser_main_target.js')
-rw-r--r-- | remote/cdp/test/browser/browser_main_target.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/remote/cdp/test/browser/browser_main_target.js b/remote/cdp/test/browser/browser_main_target.js new file mode 100644 index 0000000000..b3b18b4c0c --- /dev/null +++ b/remote/cdp/test/browser/browser_main_target.js @@ -0,0 +1,56 @@ +/* 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 ({ CDP }) { + const { mainProcessTarget } = RemoteAgent.cdp.targetList; + ok( + mainProcessTarget, + "The main process target is instantiated after the call to `listen`" + ); + + const targetURL = mainProcessTarget.wsDebuggerURL; + + const client = await CDP({ target: targetURL }); + info("CDP client has been instantiated"); + + try { + const { Browser, Target } = client; + ok(Browser, "The main process target exposes Browser domain"); + ok(Target, "The main process target exposes Target domain"); + + const version = await Browser.getVersion(); + + const { isHeadless } = Cc["@mozilla.org/gfx/info;1"].getService( + Ci.nsIGfxInfo + ); + const expectedProduct = + (isHeadless ? "Headless" : "") + + `${Services.appinfo.name}/${Services.appinfo.version}`; + is(version.product, expectedProduct, "Browser.getVersion works"); + + is( + version.revision, + Services.appinfo.sourceURL.split("/").pop(), + "Browser.getVersion().revision is correct" + ); + + is( + version.jsVersion, + Services.appinfo.version, + "Browser.getVersion().jsVersion is correct" + ); + + const { webSocketDebuggerUrl } = await CDP.Version(); + is( + webSocketDebuggerUrl, + targetURL, + "Version endpoint refers to the same Main process target" + ); + } finally { + await client.close(); + } +}); |