From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- remote/cdp/CDP.sys.mjs | 147 + remote/cdp/CDPConnection.sys.mjs | 290 + remote/cdp/Error.sys.mjs | 132 + remote/cdp/JSONHandler.sys.mjs | 93 + remote/cdp/Protocol.sys.mjs | 17358 +++++++++++++++++++ remote/cdp/StreamRegistry.sys.mjs | 139 + remote/cdp/domains/ContentProcessDomain.sys.mjs | 25 + remote/cdp/domains/ContentProcessDomains.sys.mjs | 19 + remote/cdp/domains/Domain.sys.mjs | 71 + remote/cdp/domains/DomainCache.sys.mjs | 113 + remote/cdp/domains/ParentProcessDomains.sys.mjs | 19 + remote/cdp/domains/content/DOM.sys.mjs | 245 + remote/cdp/domains/content/Emulation.sys.mjs | 50 + remote/cdp/domains/content/Input.sys.mjs | 57 + remote/cdp/domains/content/Log.sys.mjs | 86 + remote/cdp/domains/content/Network.sys.mjs | 18 + remote/cdp/domains/content/Page.sys.mjs | 453 + remote/cdp/domains/content/Performance.sys.mjs | 32 + remote/cdp/domains/content/Runtime.sys.mjs | 643 + remote/cdp/domains/content/Security.sys.mjs | 32 + .../content/runtime/ExecutionContext.sys.mjs | 564 + remote/cdp/domains/parent/Browser.sys.mjs | 40 + remote/cdp/domains/parent/Emulation.sys.mjs | 177 + remote/cdp/domains/parent/Fetch.sys.mjs | 30 + remote/cdp/domains/parent/IO.sys.mjs | 103 + remote/cdp/domains/parent/Input.sys.mjs | 168 + remote/cdp/domains/parent/Network.sys.mjs | 538 + remote/cdp/domains/parent/Page.sys.mjs | 756 + remote/cdp/domains/parent/Security.sys.mjs | 58 + remote/cdp/domains/parent/SystemInfo.sys.mjs | 48 + remote/cdp/domains/parent/Target.sys.mjs | 286 + .../cdp/domains/parent/page/DialogHandler.sys.mjs | 140 + remote/cdp/jar.mn | 55 + remote/cdp/moz.build | 28 + remote/cdp/observers/ChannelEventSink.sys.mjs | 100 + remote/cdp/observers/ContextObserver.sys.mjs | 178 + remote/cdp/observers/NetworkObserver.sys.mjs | 633 + remote/cdp/observers/TargetObserver.sys.mjs | 142 + remote/cdp/sessions/ContentProcessSession.sys.mjs | 104 + remote/cdp/sessions/MainProcessSession.sys.mjs | 12 + remote/cdp/sessions/Session.sys.mjs | 80 + remote/cdp/sessions/TabSession.sys.mjs | 150 + remote/cdp/sessions/frame-script.js | 13 + remote/cdp/targets/MainProcessTarget.sys.mjs | 55 + remote/cdp/targets/TabTarget.sys.mjs | 161 + remote/cdp/targets/Target.sys.mjs | 62 + remote/cdp/targets/TargetList.sys.mjs | 159 + remote/cdp/test/browser/README.md | 11 + remote/cdp/test/browser/browser.ini | 19 + remote/cdp/test/browser/browser_agent.js | 14 + remote/cdp/test/browser/browser_cdp.js | 74 + remote/cdp/test/browser/browser_cdp_only.ini | 15 + remote/cdp/test/browser/browser_httpd.js | 138 + remote/cdp/test/browser/browser_interface.js | 20 + remote/cdp/test/browser/browser_main_target.js | 56 + remote/cdp/test/browser/browser_session.js | 22 + remote/cdp/test/browser/browser_tabs.js | 34 + remote/cdp/test/browser/chrome-remote-interface.js | 8 + remote/cdp/test/browser/dom/browser.ini | 16 + .../cdp/test/browser/dom/browser_describeNode.js | 175 + remote/cdp/test/browser/dom/browser_resolveNode.js | 99 + remote/cdp/test/browser/dom/head.js | 9 + remote/cdp/test/browser/emulation/browser.ini | 17 + .../emulation/browser_setDeviceMetricsOverride.js | 403 + .../emulation/browser_setTouchEmulationEnabled.js | 83 + .../emulation/browser_setUserAgentOverride.js | 146 + remote/cdp/test/browser/emulation/head.js | 9 + remote/cdp/test/browser/fetch/browser.ini | 15 + remote/cdp/test/browser/fetch/browser_disable.js | 11 + remote/cdp/test/browser/fetch/head.js | 9 + remote/cdp/test/browser/head.js | 638 + remote/cdp/test/browser/input/browser.ini | 22 + .../test/browser/input/browser_dispatchKeyEvent.js | 169 + .../input/browser_dispatchKeyEvent_events.js | 77 + .../browser/input/browser_dispatchKeyEvent_race.js | 92 + .../browser/input/browser_dispatchMouseEvent.js | 136 + .../browser/input/doc_dispatchKeyEvent_race.html | 28 + remote/cdp/test/browser/input/doc_events.html | 148 + remote/cdp/test/browser/input/head.js | 150 + remote/cdp/test/browser/io/browser.ini | 16 + remote/cdp/test/browser/io/browser_close.js | 46 + remote/cdp/test/browser/io/browser_read.js | 166 + remote/cdp/test/browser/io/head.js | 20 + remote/cdp/test/browser/log/browser.ini | 15 + remote/cdp/test/browser/log/browser_entryAdded.js | 138 + remote/cdp/test/browser/log/head.js | 9 + remote/cdp/test/browser/network/browser.ini | 39 + .../test/browser/network/browser_deleteCookies.js | 302 + .../network/browser_emulateNetworkConditions.js | 227 + .../test/browser/network/browser_getAllCookies.js | 231 + .../cdp/test/browser/network/browser_getCookies.js | 363 + .../browser/network/browser_navigationEvents.js | 201 + .../browser/network/browser_requestWillBeSent.js | 224 + .../browser/network/browser_responseReceived.js | 236 + .../browser/network/browser_setCacheDisabled.js | 130 + .../cdp/test/browser/network/browser_setCookie.js | 296 + .../cdp/test/browser/network/browser_setCookies.js | 70 + .../network/browser_setUserAgentOverride.js | 68 + remote/cdp/test/browser/network/doc_empty.html | 10 + remote/cdp/test/browser/network/doc_frameset.html | 11 + .../browser/network/doc_get_cookies_frame.html | 15 + .../test/browser/network/doc_get_cookies_page.html | 17 + .../test/browser/network/doc_networkEvents.html | 10 + .../test/browser/network/file_framesetEvents.js | 3 + .../cdp/test/browser/network/file_networkEvents.js | 3 + remote/cdp/test/browser/network/head.js | 99 + remote/cdp/test/browser/network/sjs-cookies.sjs | 43 + remote/cdp/test/browser/page/browser.ini | 49 + .../cdp/test/browser/page/browser_bringToFront.js | 64 + .../test/browser/page/browser_captureScreenshot.js | 557 + .../browser/page/browser_createIsolatedWorld.js | 491 + .../browser/page/browser_domContentEventFired.js | 95 + .../cdp/test/browser/page/browser_frameAttached.js | 144 + .../cdp/test/browser/page/browser_frameDetached.js | 171 + .../test/browser/page/browser_frameNavigated.js | 93 + .../browser/page/browser_frameStartedLoading.js | 104 + .../browser/page/browser_frameStoppedLoading.js | 104 + .../cdp/test/browser/page/browser_getFrameTree.js | 149 + .../test/browser/page/browser_getLayoutMetrics.js | 118 + .../browser/page/browser_getNavigationHistory.js | 65 + .../browser/page/browser_javascriptDialog_alert.js | 59 + .../page/browser_javascriptDialog_beforeunload.js | 54 + .../page/browser_javascriptDialog_confirm.js | 43 + .../page/browser_javascriptDialog_otherTarget.js | 50 + .../page/browser_javascriptDialog_prompt.js | 45 + .../test/browser/page/browser_lifecycleEvent.js | 191 + .../test/browser/page/browser_loadEventFired.js | 95 + remote/cdp/test/browser/page/browser_navigate.js | 309 + .../browser/page/browser_navigateToHistoryEntry.js | 133 + .../page/browser_navigatedWithinDocument.js | 133 + .../test/browser/page/browser_navigationEvents.js | 223 + remote/cdp/test/browser/page/browser_printToPDF.js | 53 + remote/cdp/test/browser/page/browser_reload.js | 34 + .../cdp/test/browser/page/browser_runtimeEvents.js | 118 + .../page/browser_scriptToEvaluateOnNewDocument.js | 167 + remote/cdp/test/browser/page/doc_empty.html | 9 + remote/cdp/test/browser/page/doc_frame.html | 9 + .../cdp/test/browser/page/doc_frameset_multi.html | 11 + .../cdp/test/browser/page/doc_frameset_nested.html | 10 + .../cdp/test/browser/page/doc_frameset_single.html | 10 + remote/cdp/test/browser/page/head.js | 117 + remote/cdp/test/browser/page/sjs_redirect.sjs | 7 + remote/cdp/test/browser/runtime/browser.ini | 32 + .../test/browser/runtime/browser_callFunctionOn.js | 304 + .../runtime/browser_callFunctionOn_awaitPromise.js | 181 + .../browser_callFunctionOn_returnByValue.js | 401 + .../browser/runtime/browser_consoleAPICalled.js | 380 + .../cdp/test/browser/runtime/browser_evaluate.js | 256 + .../runtime/browser_evaluate_awaitPromise.js | 169 + .../runtime/browser_evaluate_returnByValue.js | 151 + .../browser/runtime/browser_exceptionThrown.js | 121 + .../runtime/browser_executionContextEvents.js | 332 + .../test/browser/runtime/browser_getProperties.js | 184 + .../test/browser/runtime/browser_remoteObjects.js | 83 + .../browser/runtime/browser_withDefaultPrefs.js | 9 + .../browser/runtime/browser_with_default_prefs.ini | 13 + .../test/browser/runtime/doc_console_events.html | 31 + .../browser/runtime/doc_console_events_onload.html | 12 + remote/cdp/test/browser/runtime/doc_empty.html | 9 + remote/cdp/test/browser/runtime/doc_frame.html | 9 + .../test/browser/runtime/doc_frameset_single.html | 10 + remote/cdp/test/browser/runtime/head.js | 15 + remote/cdp/test/browser/security/browser.ini | 15 + .../security/browser_setIgnoreCertificateErrors.js | 159 + remote/cdp/test/browser/security/head.js | 9 + remote/cdp/test/browser/systemInfo/browser.ini | 15 + .../browser/systemInfo/browser_getProcessInfo.js | 78 + remote/cdp/test/browser/systemInfo/head.js | 9 + remote/cdp/test/browser/target/browser.ini | 28 + .../test/browser/target/browser_activateTarget.js | 78 + .../test/browser/target/browser_attachToTarget.js | 54 + .../browser/target/browser_attachedToTarget.js | 50 + .../test/browser/target/browser_browserContext.js | 72 + .../cdp/test/browser/target/browser_closeTarget.js | 43 + .../test/browser/target/browser_createTarget.js | 103 + .../cdp/test/browser/target/browser_getTargets.js | 298 + .../browser/target/browser_sendMessageToTarget.js | 41 + .../browser/target/browser_setDiscoverTargets.js | 293 + .../test/browser/target/browser_targetCreated.js | 18 + .../test/browser/target/browser_targetDestroyed.js | 21 + remote/cdp/test/browser/target/doc_test.html | 9 + remote/cdp/test/browser/target/head.js | 9 + remote/cdp/test/xpcshell/test_CDPConnection.js | 25 + remote/cdp/test/xpcshell/test_DomainCache.js | 111 + remote/cdp/test/xpcshell/test_Error.js | 104 + remote/cdp/test/xpcshell/test_Session.js | 40 + remote/cdp/test/xpcshell/test_StreamRegistry.js | 153 + remote/cdp/test/xpcshell/xpcshell.ini | 9 + 188 files changed, 39363 insertions(+) create mode 100644 remote/cdp/CDP.sys.mjs create mode 100644 remote/cdp/CDPConnection.sys.mjs create mode 100644 remote/cdp/Error.sys.mjs create mode 100644 remote/cdp/JSONHandler.sys.mjs create mode 100644 remote/cdp/Protocol.sys.mjs create mode 100644 remote/cdp/StreamRegistry.sys.mjs create mode 100644 remote/cdp/domains/ContentProcessDomain.sys.mjs create mode 100644 remote/cdp/domains/ContentProcessDomains.sys.mjs create mode 100644 remote/cdp/domains/Domain.sys.mjs create mode 100644 remote/cdp/domains/DomainCache.sys.mjs create mode 100644 remote/cdp/domains/ParentProcessDomains.sys.mjs create mode 100644 remote/cdp/domains/content/DOM.sys.mjs create mode 100644 remote/cdp/domains/content/Emulation.sys.mjs create mode 100644 remote/cdp/domains/content/Input.sys.mjs create mode 100644 remote/cdp/domains/content/Log.sys.mjs create mode 100644 remote/cdp/domains/content/Network.sys.mjs create mode 100644 remote/cdp/domains/content/Page.sys.mjs create mode 100644 remote/cdp/domains/content/Performance.sys.mjs create mode 100644 remote/cdp/domains/content/Runtime.sys.mjs create mode 100644 remote/cdp/domains/content/Security.sys.mjs create mode 100644 remote/cdp/domains/content/runtime/ExecutionContext.sys.mjs create mode 100644 remote/cdp/domains/parent/Browser.sys.mjs create mode 100644 remote/cdp/domains/parent/Emulation.sys.mjs create mode 100644 remote/cdp/domains/parent/Fetch.sys.mjs create mode 100644 remote/cdp/domains/parent/IO.sys.mjs create mode 100644 remote/cdp/domains/parent/Input.sys.mjs create mode 100644 remote/cdp/domains/parent/Network.sys.mjs create mode 100644 remote/cdp/domains/parent/Page.sys.mjs create mode 100644 remote/cdp/domains/parent/Security.sys.mjs create mode 100644 remote/cdp/domains/parent/SystemInfo.sys.mjs create mode 100644 remote/cdp/domains/parent/Target.sys.mjs create mode 100644 remote/cdp/domains/parent/page/DialogHandler.sys.mjs create mode 100644 remote/cdp/jar.mn create mode 100644 remote/cdp/moz.build create mode 100644 remote/cdp/observers/ChannelEventSink.sys.mjs create mode 100644 remote/cdp/observers/ContextObserver.sys.mjs create mode 100644 remote/cdp/observers/NetworkObserver.sys.mjs create mode 100644 remote/cdp/observers/TargetObserver.sys.mjs create mode 100644 remote/cdp/sessions/ContentProcessSession.sys.mjs create mode 100644 remote/cdp/sessions/MainProcessSession.sys.mjs create mode 100644 remote/cdp/sessions/Session.sys.mjs create mode 100644 remote/cdp/sessions/TabSession.sys.mjs create mode 100644 remote/cdp/sessions/frame-script.js create mode 100644 remote/cdp/targets/MainProcessTarget.sys.mjs create mode 100644 remote/cdp/targets/TabTarget.sys.mjs create mode 100644 remote/cdp/targets/Target.sys.mjs create mode 100644 remote/cdp/targets/TargetList.sys.mjs create mode 100644 remote/cdp/test/browser/README.md create mode 100644 remote/cdp/test/browser/browser.ini create mode 100644 remote/cdp/test/browser/browser_agent.js create mode 100644 remote/cdp/test/browser/browser_cdp.js create mode 100644 remote/cdp/test/browser/browser_cdp_only.ini create mode 100644 remote/cdp/test/browser/browser_httpd.js create mode 100644 remote/cdp/test/browser/browser_interface.js create mode 100644 remote/cdp/test/browser/browser_main_target.js create mode 100644 remote/cdp/test/browser/browser_session.js create mode 100644 remote/cdp/test/browser/browser_tabs.js create mode 100644 remote/cdp/test/browser/chrome-remote-interface.js create mode 100644 remote/cdp/test/browser/dom/browser.ini create mode 100644 remote/cdp/test/browser/dom/browser_describeNode.js create mode 100644 remote/cdp/test/browser/dom/browser_resolveNode.js create mode 100644 remote/cdp/test/browser/dom/head.js create mode 100644 remote/cdp/test/browser/emulation/browser.ini create mode 100644 remote/cdp/test/browser/emulation/browser_setDeviceMetricsOverride.js create mode 100644 remote/cdp/test/browser/emulation/browser_setTouchEmulationEnabled.js create mode 100644 remote/cdp/test/browser/emulation/browser_setUserAgentOverride.js create mode 100644 remote/cdp/test/browser/emulation/head.js create mode 100644 remote/cdp/test/browser/fetch/browser.ini create mode 100644 remote/cdp/test/browser/fetch/browser_disable.js create mode 100644 remote/cdp/test/browser/fetch/head.js create mode 100644 remote/cdp/test/browser/head.js create mode 100644 remote/cdp/test/browser/input/browser.ini create mode 100644 remote/cdp/test/browser/input/browser_dispatchKeyEvent.js create mode 100644 remote/cdp/test/browser/input/browser_dispatchKeyEvent_events.js create mode 100644 remote/cdp/test/browser/input/browser_dispatchKeyEvent_race.js create mode 100644 remote/cdp/test/browser/input/browser_dispatchMouseEvent.js create mode 100644 remote/cdp/test/browser/input/doc_dispatchKeyEvent_race.html create mode 100644 remote/cdp/test/browser/input/doc_events.html create mode 100644 remote/cdp/test/browser/input/head.js create mode 100644 remote/cdp/test/browser/io/browser.ini create mode 100644 remote/cdp/test/browser/io/browser_close.js create mode 100644 remote/cdp/test/browser/io/browser_read.js create mode 100644 remote/cdp/test/browser/io/head.js create mode 100644 remote/cdp/test/browser/log/browser.ini create mode 100644 remote/cdp/test/browser/log/browser_entryAdded.js create mode 100644 remote/cdp/test/browser/log/head.js create mode 100644 remote/cdp/test/browser/network/browser.ini create mode 100644 remote/cdp/test/browser/network/browser_deleteCookies.js create mode 100644 remote/cdp/test/browser/network/browser_emulateNetworkConditions.js create mode 100644 remote/cdp/test/browser/network/browser_getAllCookies.js create mode 100644 remote/cdp/test/browser/network/browser_getCookies.js create mode 100644 remote/cdp/test/browser/network/browser_navigationEvents.js create mode 100644 remote/cdp/test/browser/network/browser_requestWillBeSent.js create mode 100644 remote/cdp/test/browser/network/browser_responseReceived.js create mode 100644 remote/cdp/test/browser/network/browser_setCacheDisabled.js create mode 100644 remote/cdp/test/browser/network/browser_setCookie.js create mode 100644 remote/cdp/test/browser/network/browser_setCookies.js create mode 100644 remote/cdp/test/browser/network/browser_setUserAgentOverride.js create mode 100644 remote/cdp/test/browser/network/doc_empty.html create mode 100644 remote/cdp/test/browser/network/doc_frameset.html create mode 100644 remote/cdp/test/browser/network/doc_get_cookies_frame.html create mode 100644 remote/cdp/test/browser/network/doc_get_cookies_page.html create mode 100644 remote/cdp/test/browser/network/doc_networkEvents.html create mode 100644 remote/cdp/test/browser/network/file_framesetEvents.js create mode 100644 remote/cdp/test/browser/network/file_networkEvents.js create mode 100644 remote/cdp/test/browser/network/head.js create mode 100644 remote/cdp/test/browser/network/sjs-cookies.sjs create mode 100644 remote/cdp/test/browser/page/browser.ini create mode 100644 remote/cdp/test/browser/page/browser_bringToFront.js create mode 100644 remote/cdp/test/browser/page/browser_captureScreenshot.js create mode 100644 remote/cdp/test/browser/page/browser_createIsolatedWorld.js create mode 100644 remote/cdp/test/browser/page/browser_domContentEventFired.js create mode 100644 remote/cdp/test/browser/page/browser_frameAttached.js create mode 100644 remote/cdp/test/browser/page/browser_frameDetached.js create mode 100644 remote/cdp/test/browser/page/browser_frameNavigated.js create mode 100644 remote/cdp/test/browser/page/browser_frameStartedLoading.js create mode 100644 remote/cdp/test/browser/page/browser_frameStoppedLoading.js create mode 100644 remote/cdp/test/browser/page/browser_getFrameTree.js create mode 100644 remote/cdp/test/browser/page/browser_getLayoutMetrics.js create mode 100644 remote/cdp/test/browser/page/browser_getNavigationHistory.js create mode 100644 remote/cdp/test/browser/page/browser_javascriptDialog_alert.js create mode 100644 remote/cdp/test/browser/page/browser_javascriptDialog_beforeunload.js create mode 100644 remote/cdp/test/browser/page/browser_javascriptDialog_confirm.js create mode 100644 remote/cdp/test/browser/page/browser_javascriptDialog_otherTarget.js create mode 100644 remote/cdp/test/browser/page/browser_javascriptDialog_prompt.js create mode 100644 remote/cdp/test/browser/page/browser_lifecycleEvent.js create mode 100644 remote/cdp/test/browser/page/browser_loadEventFired.js create mode 100644 remote/cdp/test/browser/page/browser_navigate.js create mode 100644 remote/cdp/test/browser/page/browser_navigateToHistoryEntry.js create mode 100644 remote/cdp/test/browser/page/browser_navigatedWithinDocument.js create mode 100644 remote/cdp/test/browser/page/browser_navigationEvents.js create mode 100644 remote/cdp/test/browser/page/browser_printToPDF.js create mode 100644 remote/cdp/test/browser/page/browser_reload.js create mode 100644 remote/cdp/test/browser/page/browser_runtimeEvents.js create mode 100644 remote/cdp/test/browser/page/browser_scriptToEvaluateOnNewDocument.js create mode 100644 remote/cdp/test/browser/page/doc_empty.html create mode 100644 remote/cdp/test/browser/page/doc_frame.html create mode 100644 remote/cdp/test/browser/page/doc_frameset_multi.html create mode 100644 remote/cdp/test/browser/page/doc_frameset_nested.html create mode 100644 remote/cdp/test/browser/page/doc_frameset_single.html create mode 100644 remote/cdp/test/browser/page/head.js create mode 100644 remote/cdp/test/browser/page/sjs_redirect.sjs create mode 100644 remote/cdp/test/browser/runtime/browser.ini create mode 100644 remote/cdp/test/browser/runtime/browser_callFunctionOn.js create mode 100644 remote/cdp/test/browser/runtime/browser_callFunctionOn_awaitPromise.js create mode 100644 remote/cdp/test/browser/runtime/browser_callFunctionOn_returnByValue.js create mode 100644 remote/cdp/test/browser/runtime/browser_consoleAPICalled.js create mode 100644 remote/cdp/test/browser/runtime/browser_evaluate.js create mode 100644 remote/cdp/test/browser/runtime/browser_evaluate_awaitPromise.js create mode 100644 remote/cdp/test/browser/runtime/browser_evaluate_returnByValue.js create mode 100644 remote/cdp/test/browser/runtime/browser_exceptionThrown.js create mode 100644 remote/cdp/test/browser/runtime/browser_executionContextEvents.js create mode 100644 remote/cdp/test/browser/runtime/browser_getProperties.js create mode 100644 remote/cdp/test/browser/runtime/browser_remoteObjects.js create mode 100644 remote/cdp/test/browser/runtime/browser_withDefaultPrefs.js create mode 100644 remote/cdp/test/browser/runtime/browser_with_default_prefs.ini create mode 100644 remote/cdp/test/browser/runtime/doc_console_events.html create mode 100644 remote/cdp/test/browser/runtime/doc_console_events_onload.html create mode 100644 remote/cdp/test/browser/runtime/doc_empty.html create mode 100644 remote/cdp/test/browser/runtime/doc_frame.html create mode 100644 remote/cdp/test/browser/runtime/doc_frameset_single.html create mode 100644 remote/cdp/test/browser/runtime/head.js create mode 100644 remote/cdp/test/browser/security/browser.ini create mode 100644 remote/cdp/test/browser/security/browser_setIgnoreCertificateErrors.js create mode 100644 remote/cdp/test/browser/security/head.js create mode 100644 remote/cdp/test/browser/systemInfo/browser.ini create mode 100644 remote/cdp/test/browser/systemInfo/browser_getProcessInfo.js create mode 100644 remote/cdp/test/browser/systemInfo/head.js create mode 100644 remote/cdp/test/browser/target/browser.ini create mode 100644 remote/cdp/test/browser/target/browser_activateTarget.js create mode 100644 remote/cdp/test/browser/target/browser_attachToTarget.js create mode 100644 remote/cdp/test/browser/target/browser_attachedToTarget.js create mode 100644 remote/cdp/test/browser/target/browser_browserContext.js create mode 100644 remote/cdp/test/browser/target/browser_closeTarget.js create mode 100644 remote/cdp/test/browser/target/browser_createTarget.js create mode 100644 remote/cdp/test/browser/target/browser_getTargets.js create mode 100644 remote/cdp/test/browser/target/browser_sendMessageToTarget.js create mode 100644 remote/cdp/test/browser/target/browser_setDiscoverTargets.js create mode 100644 remote/cdp/test/browser/target/browser_targetCreated.js create mode 100644 remote/cdp/test/browser/target/browser_targetDestroyed.js create mode 100644 remote/cdp/test/browser/target/doc_test.html create mode 100644 remote/cdp/test/browser/target/head.js create mode 100644 remote/cdp/test/xpcshell/test_CDPConnection.js create mode 100644 remote/cdp/test/xpcshell/test_DomainCache.js create mode 100644 remote/cdp/test/xpcshell/test_Error.js create mode 100644 remote/cdp/test/xpcshell/test_Session.js create mode 100644 remote/cdp/test/xpcshell/test_StreamRegistry.js create mode 100644 remote/cdp/test/xpcshell/xpcshell.ini (limited to 'remote/cdp') diff --git a/remote/cdp/CDP.sys.mjs b/remote/cdp/CDP.sys.mjs new file mode 100644 index 0000000000..b8ace7efc9 --- /dev/null +++ b/remote/cdp/CDP.sys.mjs @@ -0,0 +1,147 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; + +const lazy = {}; + +ChromeUtils.defineESModuleGetters(lazy, { + JSONHandler: "chrome://remote/content/cdp/JSONHandler.sys.mjs", + Log: "chrome://remote/content/shared/Log.sys.mjs", + RecommendedPreferences: + "chrome://remote/content/shared/RecommendedPreferences.sys.mjs", + TargetList: "chrome://remote/content/cdp/targets/TargetList.sys.mjs", +}); + +XPCOMUtils.defineLazyGetter(lazy, "logger", () => + lazy.Log.get(lazy.Log.TYPES.CDP) +); +XPCOMUtils.defineLazyGetter(lazy, "textEncoder", () => new TextEncoder()); + +// Map of CDP-specific preferences that should be set via +// RecommendedPreferences. +const RECOMMENDED_PREFS = new Map([ + // Prevent various error message on the console + // jest-puppeteer asserts that no error message is emitted by the console + [ + "browser.contentblocking.features.standard", + "-tp,tpPrivate,cookieBehavior0,-cm,-fp", + ], + // Accept all cookies (see behavior definitions in nsICookieService.idl) + ["network.cookie.cookieBehavior", 0], +]); + +/** + * Entry class for the Chrome DevTools Protocol support. + * + * It holds the list of available targets (tabs, main browser), and also + * sets up the necessary handlers for the HTTP server. + * + * @see https://chromedevtools.github.io/devtools-protocol + */ +export class CDP { + /** + * Creates a new instance of the CDP class. + * + * @param {RemoteAgent} agent + * Reference to the Remote Agent instance. + */ + constructor(agent) { + this.agent = agent; + this.targetList = null; + + this._running = false; + this._activePortPath; + } + + get address() { + const mainTarget = this.targetList.getMainProcessTarget(); + return mainTarget.wsDebuggerURL; + } + + get mainTargetPath() { + const mainTarget = this.targetList.getMainProcessTarget(); + return mainTarget.path; + } + + /** + * Starts the CDP support. + */ + async start() { + if (this._running) { + return; + } + + // Note: Ideally this would only be set at the end of the method. However + // since start() is async, we prefer to set the flag early in order to + // avoid potential race conditions. + this._running = true; + + lazy.RecommendedPreferences.applyPreferences(RECOMMENDED_PREFS); + + // Starting CDP too early can cause issues with clients in not being able + // to find any available target. Also when closing the application while + // it's still starting up can cause shutdown hangs. As such CDP will be + // started when the initial application window has finished initializing. + lazy.logger.debug(`Waiting for initial application window`); + await this.agent.browserStartupFinished; + + this.agent.server.registerPrefixHandler("/", new lazy.JSONHandler(this)); + + this.targetList = new lazy.TargetList(); + this.targetList.on("target-created", (eventName, target) => { + this.agent.server.registerPathHandler(target.path, target); + }); + this.targetList.on("target-destroyed", (eventName, target) => { + this.agent.server.registerPathHandler(target.path, null); + }); + + await this.targetList.watchForTargets(); + + Cu.printStderr(`DevTools listening on ${this.address}\n`); + + // Write connection details to DevToolsActivePort file within the profile. + this._activePortPath = PathUtils.join( + PathUtils.profileDir, + "DevToolsActivePort" + ); + + const data = `${this.agent.port}\n${this.mainTargetPath}`; + try { + await IOUtils.write(this._activePortPath, lazy.textEncoder.encode(data)); + } catch (e) { + lazy.logger.warn( + `Failed to create ${this._activePortPath} (${e.message})` + ); + } + } + + /** + * Stops the CDP support. + */ + async stop() { + if (!this._running) { + return; + } + + try { + await IOUtils.remove(this._activePortPath); + } catch (e) { + lazy.logger.warn( + `Failed to remove ${this._activePortPath} (${e.message})` + ); + } + + try { + this.targetList?.destructor(); + this.targetList = null; + + lazy.RecommendedPreferences.restorePreferences(RECOMMENDED_PREFS); + } catch (e) { + lazy.logger.error("Failed to stop protocol", e); + } finally { + this._running = false; + } + } +} diff --git a/remote/cdp/CDPConnection.sys.mjs b/remote/cdp/CDPConnection.sys.mjs new file mode 100644 index 0000000000..dfbb94ee09 --- /dev/null +++ b/remote/cdp/CDPConnection.sys.mjs @@ -0,0 +1,290 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; + +import { WebSocketConnection } from "chrome://remote/content/shared/WebSocketConnection.sys.mjs"; + +const lazy = {}; + +ChromeUtils.defineESModuleGetters(lazy, { + Log: "chrome://remote/content/shared/Log.sys.mjs", + UnknownMethodError: "chrome://remote/content/cdp/Error.sys.mjs", +}); + +XPCOMUtils.defineLazyGetter(lazy, "logger", () => + lazy.Log.get(lazy.Log.TYPES.CDP) +); + +export class CDPConnection extends WebSocketConnection { + /** + * @param {WebSocket} webSocket + * The WebSocket server connection to wrap. + * @param {Connection} httpdConnection + * Reference to the httpd.js's connection needed for clean-up. + */ + constructor(webSocket, httpdConnection) { + super(webSocket, httpdConnection); + + this.sessions = new Map(); + this.defaultSession = null; + } + + /** + * Register a new Session to forward the messages to. + * + * A session without any `id` attribute will be considered to be the + * default one, to which messages without `sessionId` attribute are + * forwarded to. Only one such session can be registered. + * + * @param {Session} session + * The session to register. + */ + registerSession(session) { + // CDP is not compatible with Fission by default, check the appropriate + // preferences are set to ensure compatibility. + if ( + Services.prefs.getIntPref("fission.webContentIsolationStrategy") !== 0 || + Services.prefs.getBoolPref("fission.bfcacheInParent") + ) { + lazy.logger.warn( + `Invalid browser preferences for CDP. Set "fission.webContentIsolationStrategy"` + + `to 0 and "fission.bfcacheInParent" to false before Firefox starts.` + ); + } + + if (!session.id) { + if (this.defaultSession) { + throw new Error( + "Default session is already set on Connection, " + + "can't register another one." + ); + } + this.defaultSession = session; + } + + this.sessions.set(session.id, session); + } + + /** + * Send an error back to the CDP client. + * + * @param {number} id + * Id of the packet which lead to an error. + * @param {Error} err + * Error object with `message` and `stack` attributes. + * @param {string=} sessionId + * Id of the session used to send this packet. Falls back to the + * default session if not specified. + */ + sendError(id, err, sessionId) { + const error = { + message: err.message, + data: err.stack, + }; + + this.send({ id, error, sessionId }); + } + + /** + * Send an event coming from a Domain to the CDP client. + * + * @param {string} method + * The event name. This is composed by a domain name, a dot character + * followed by the event name, e.g. `Target.targetCreated`. + * @param {object} params + * A JSON-serializable object, which is the payload of this event. + * @param {string=} sessionId + * The sessionId from which this packet is emitted. Falls back to the + * default session if not specified. + */ + sendEvent(method, params, sessionId) { + this.send({ method, params, sessionId }); + + if (Services.profiler?.IsActive()) { + ChromeUtils.addProfilerMarker( + "CDP: Event", + { category: "Remote-Protocol" }, + method + ); + } + + // When a client attaches to a secondary target via + // `Target.attachToTarget`, we should emit an event back with the + // result including the `sessionId` attribute of this secondary target's + // session. `Target.attachToTarget` creates the secondary session and + // returns the session ID. + if (sessionId) { + // receivedMessageFromTarget is expected to send a raw CDP packet + // in the `message` property and it to be already serialized to a + // string + this.send({ + method: "Target.receivedMessageFromTarget", + params: { sessionId, message: JSON.stringify({ method, params }) }, + }); + } + } + + /** + * Interpret a given CDP packet for a given Session. + * + * @param {string} sessionId + * ID of the session for which we should execute a command. + * @param {string} message + * The stringified JSON payload of the CDP packet, which is about + * executing a Domain's function. + */ + sendMessageToTarget(sessionId, message) { + const session = this.sessions.get(sessionId); + if (!session) { + throw new Error(`Session '${sessionId}' doesn't exist.`); + } + // `message` is received from `Target.sendMessageToTarget` where the + // message attribute is a stringified JSON payload which represent a CDP + // packet. + const packet = JSON.parse(message); + + // The CDP packet sent by the client shouldn't have a sessionId attribute + // as it is passed as another argument of `Target.sendMessageToTarget`. + // Set it here in order to reuse the codepath of flatten session, where + // the client sends CDP packets with a `sessionId` attribute instead + // of going through the old and probably deprecated + // `Target.sendMessageToTarget` API. + packet.sessionId = sessionId; + this.onPacket(packet); + } + + /** + * Send the result of a call to a Domain's function back to the CDP client. + * + * @param {number} id + * The request id being sent by the client to call the domain's method. + * @param {object} result + * A JSON-serializable object, which is the actual result. + * @param {string=} sessionId + * The sessionId from which this packet is emitted. Falls back to the + * default session if not specified. + */ + sendResult(id, result, sessionId) { + result = typeof result != "undefined" ? result : {}; + this.send({ id, result, sessionId }); + + // When a client attaches to a secondary target via + // `Target.attachToTarget`, and it executes a command via + // `Target.sendMessageToTarget`, we should emit an event back with the + // result including the `sessionId` attribute of this secondary target's + // session. `Target.attachToTarget` creates the secondary session and + // returns the session ID. + if (sessionId) { + // receivedMessageFromTarget is expected to send a raw CDP packet + // in the `message` property and it to be already serialized to a + // string + this.send({ + method: "Target.receivedMessageFromTarget", + params: { sessionId, message: JSON.stringify({ id, result }) }, + }); + } + } + + // Transport hooks + + /** + * Called by the `transport` when the connection is closed. + */ + onClosed() { + // Cleanup all the registered sessions. + for (const session of this.sessions.values()) { + session.destructor(); + } + this.sessions.clear(); + + super.onClosed(); + } + + /** + * Receive a packet from the WebSocket layer. + * + * This packet is sent by a CDP client and is meant to execute + * a particular function on a given Domain. + * + * @param {object} packet + * JSON-serializable object sent by the client. + */ + async onPacket(packet) { + super.onPacket(packet); + + const { id, method, params, sessionId } = packet; + const startTime = Cu.now(); + + try { + // First check for mandatory field in the packets + if (typeof id == "undefined") { + throw new TypeError("Message missing 'id' field"); + } + if (typeof method == "undefined") { + throw new TypeError("Message missing 'method' field"); + } + + // Extract the domain name and the method name out of `method` attribute + const { domain, command } = splitMethod(method); + + // If a `sessionId` field is passed, retrieve the session to which we + // should forward this packet. Otherwise send it to the default session. + let session; + if (!sessionId) { + if (!this.defaultSession) { + throw new Error("Connection is missing a default Session."); + } + session = this.defaultSession; + } else { + session = this.sessions.get(sessionId); + if (!session) { + throw new Error(`Session '${sessionId}' doesn't exists.`); + } + } + + // Bug 1600317 - Workaround to deny internal methods to be called + if (command.startsWith("_")) { + throw new lazy.UnknownMethodError(command); + } + + // Finally, instruct the targeted session to execute the command + const result = await session.execute(id, domain, command, params); + this.sendResult(id, result, sessionId); + } catch (e) { + this.sendError(id, e, packet.sessionId); + } + + if (Services.profiler?.IsActive()) { + ChromeUtils.addProfilerMarker( + "CDP: Command", + { startTime, category: "Remote-Protocol" }, + `${method} (${id})` + ); + } + } +} + +/** + * Splits a CDP method into domain and command components. + * + * @param {string} method + * Name of the method to split, e.g. "Browser.getVersion". + * + * @returns {Object} + * Object with the domain ("Browser") and command ("getVersion") + * as properties. + */ +export function splitMethod(method) { + const parts = method.split("."); + + if (parts.length != 2 || !parts[0].length || !parts[1].length) { + throw new TypeError(`Invalid method format: '${method}'`); + } + + return { + domain: parts[0], + command: parts[1], + }; +} diff --git a/remote/cdp/Error.sys.mjs b/remote/cdp/Error.sys.mjs new file mode 100644 index 0000000000..084d8c55f2 --- /dev/null +++ b/remote/cdp/Error.sys.mjs @@ -0,0 +1,132 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; + +const lazy = {}; + +ChromeUtils.defineESModuleGetters(lazy, { + Log: "chrome://remote/content/shared/Log.sys.mjs", +}); + +XPCOMUtils.defineLazyGetter(lazy, "logger", () => + lazy.Log.get(lazy.Log.TYPES.CDP) +); + +export class RemoteAgentError extends Error { + constructor(message = "", cause = undefined) { + cause = cause || message; + super(cause); + + this.name = this.constructor.name; + this.message = message; + this.cause = cause; + + this.notify(); + } + + notify() { + console.error(this); + lazy.logger.error(this.toString({ stack: true })); + } + + toString({ stack = false } = {}) { + return RemoteAgentError.format(this, { stack }); + } + + static format(e, { stack = false } = {}) { + return formatError(e, { stack }); + } + + /** + * Takes a serialised CDP error and reconstructs it + * as a RemoteAgentError. + * + * The error must be of this form: + * + * {"message": "TypeError: foo is not a function\n + * execute@chrome://remote/content/cdp/sessions/Session.jsm:73:39\n + * onMessage@chrome://remote/content/cdp/sessions/TabSession.jsm:65:20"} + * + * This approach has the notable deficiency that it cannot deal + * with causes to errors because of the unstructured nature of CDP + * errors. A possible future improvement would be to extend the + * error serialisation to include discrete fields for each data + * property. + * + * @param {object} json + * CDP error encoded as a JSON object, which must have a + * "message" field, where the first line will make out the error + * message and the subsequent lines the stacktrace. + * + * @returns {RemoteAgentError} + */ + static fromJSON(json) { + const [message, ...stack] = json.message.split("\n"); + const err = new RemoteAgentError(); + err.message = message.slice(0, -1); + err.stack = stack.map(s => s.trim()).join("\n"); + err.cause = null; + return err; + } +} + +/** + * A fatal error that it is not possible to recover from + * or send back to the client. + * + * Constructing this error will force the application to quit. + */ +export class FatalError extends RemoteAgentError { + constructor(...args) { + super(...args); + this.quit(); + } + + notify() { + lazy.logger.fatal(this.toString({ stack: true })); + } + + quit(mode = Ci.nsIAppStartup.eForceQuit) { + Services.startup.quit(mode); + } +} + +/** When an operation is not yet implemented. */ +export class UnsupportedError extends RemoteAgentError {} + +/** The requested remote method does not exist. */ +export class UnknownMethodError extends RemoteAgentError { + constructor(domain, command = null) { + if (command) { + super(`${domain}.${command}`); + } else { + super(domain); + } + } +} + +function formatError(error, { stack = false } = {}) { + const els = []; + + els.push(error.name); + if (error.message) { + els.push(": "); + els.push(error.message); + } + + if (stack && error.stack) { + els.push(":\n"); + + const stack = error.stack.trim().split("\n"); + els.push(stack.map(line => `\t${line}`).join("\n")); + + if (error.cause) { + els.push("\n"); + els.push("caused by: " + formatError(error.cause, { stack })); + } + } + + return els.join(""); +} diff --git a/remote/cdp/JSONHandler.sys.mjs b/remote/cdp/JSONHandler.sys.mjs new file mode 100644 index 0000000000..89e7ddab7c --- /dev/null +++ b/remote/cdp/JSONHandler.sys.mjs @@ -0,0 +1,93 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; + +const lazy = {}; + +ChromeUtils.defineESModuleGetters(lazy, { + Log: "chrome://remote/content/shared/Log.sys.mjs", + Protocol: "chrome://remote/content/cdp/Protocol.sys.mjs", + RemoteAgentError: "chrome://remote/content/cdp/Error.sys.mjs", +}); + +XPCOMUtils.defineLazyModuleGetters(lazy, { + HTTP_404: "chrome://remote/content/server/HTTPD.jsm", + HTTP_505: "chrome://remote/content/server/HTTPD.jsm", +}); + +export class JSONHandler { + constructor(cdp) { + this.cdp = cdp; + this.routes = { + "/json/version": this.getVersion.bind(this), + "/json/protocol": this.getProtocol.bind(this), + "/json/list": this.getTargetList.bind(this), + "/json": this.getTargetList.bind(this), + }; + } + + getVersion() { + const mainProcessTarget = this.cdp.targetList.getMainProcessTarget(); + + const { userAgent } = Cc[ + "@mozilla.org/network/protocol;1?name=http" + ].getService(Ci.nsIHttpProtocolHandler); + + return { + Browser: `${Services.appinfo.name}/${Services.appinfo.version}`, + "Protocol-Version": "1.3", + "User-Agent": userAgent, + "V8-Version": "1.0", + "WebKit-Version": "1.0", + webSocketDebuggerUrl: mainProcessTarget.toJSON().webSocketDebuggerUrl, + }; + } + + getProtocol() { + return lazy.Protocol.Description; + } + + getTargetList() { + return [...this.cdp.targetList].filter(x => x.type !== "browser"); + } + + // nsIHttpRequestHandler + + handle(request, response) { + if (request.method != "GET") { + throw lazy.HTTP_404; + } + + // Trim trailing slashes to conform with expected routes + const path = request.path.replace(/\/+$/, ""); + + if (!(path in this.routes)) { + throw lazy.HTTP_404; + } + + try { + const body = this.routes[path](); + const payload = JSON.stringify( + body, + null, + lazy.Log.verbose ? "\t" : null + ); + + response.setStatusLine(request.httpVersion, 200, "OK"); + response.setHeader("Content-Type", "application/json"); + response.setHeader("Content-Security-Policy", "frame-ancestors 'none'"); + response.write(payload); + } catch (e) { + new lazy.RemoteAgentError(e).notify(); + throw lazy.HTTP_505; + } + } + + // XPCOM + + get QueryInterface() { + return ChromeUtils.generateQI(["nsIHttpRequestHandler"]); + } +} diff --git a/remote/cdp/Protocol.sys.mjs b/remote/cdp/Protocol.sys.mjs new file mode 100644 index 0000000000..f239c82b42 --- /dev/null +++ b/remote/cdp/Protocol.sys.mjs @@ -0,0 +1,17358 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// The `Description` below is imported from Chromium Code. + +// TODO(ato): We send back a description of the protocol +// when the user makes the initial HTTP request, +// but the following is pure fiction. +const Description = { + "domains": [ + { + "domain": "Accessibility", + "experimental": true, + "dependencies": [ + "DOM" + ], + "types": [ + { + "id": "AXNodeId", + "description": "Unique accessibility node identifier.", + "type": "string" + }, + { + "id": "AXValueType", + "description": "Enum of possible property types.", + "type": "string", + "enum": [ + "boolean", + "tristate", + "booleanOrUndefined", + "idref", + "idrefList", + "integer", + "node", + "nodeList", + "number", + "string", + "computedString", + "token", + "tokenList", + "domRelation", + "role", + "internalRole", + "valueUndefined" + ] + }, + { + "id": "AXValueSourceType", + "description": "Enum of possible property sources.", + "type": "string", + "enum": [ + "attribute", + "implicit", + "style", + "contents", + "placeholder", + "relatedElement" + ] + }, + { + "id": "AXValueNativeSourceType", + "description": "Enum of possible native property sources (as a subtype of a particular AXValueSourceType).", + "type": "string", + "enum": [ + "figcaption", + "label", + "labelfor", + "labelwrapped", + "legend", + "tablecaption", + "title", + "other" + ] + }, + { + "id": "AXValueSource", + "description": "A single source for a computed AX property.", + "type": "object", + "properties": [ + { + "name": "type", + "description": "What type of source this is.", + "$ref": "AXValueSourceType" + }, + { + "name": "value", + "description": "The value of this property source.", + "optional": true, + "$ref": "AXValue" + }, + { + "name": "attribute", + "description": "The name of the relevant attribute, if any.", + "optional": true, + "type": "string" + }, + { + "name": "attributeValue", + "description": "The value of the relevant attribute, if any.", + "optional": true, + "$ref": "AXValue" + }, + { + "name": "superseded", + "description": "Whether this source is superseded by a higher priority source.", + "optional": true, + "type": "boolean" + }, + { + "name": "nativeSource", + "description": "The native markup source for this value, e.g. a