summaryrefslogtreecommitdiffstats
path: root/dom/media/test/rdd_process_xpcom
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /dom/media/test/rdd_process_xpcom
parentInitial commit. (diff)
downloadfirefox-esr-upstream/115.8.0esr.tar.xz
firefox-esr-upstream/115.8.0esr.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/test/rdd_process_xpcom')
-rw-r--r--dom/media/test/rdd_process_xpcom/RddProcessTest.cpp69
-rw-r--r--dom/media/test/rdd_process_xpcom/RddProcessTest.h28
-rw-r--r--dom/media/test/rdd_process_xpcom/components.conf15
-rw-r--r--dom/media/test/rdd_process_xpcom/moz.build21
-rw-r--r--dom/media/test/rdd_process_xpcom/nsIRddProcessTest.idl25
5 files changed, 158 insertions, 0 deletions
diff --git a/dom/media/test/rdd_process_xpcom/RddProcessTest.cpp b/dom/media/test/rdd_process_xpcom/RddProcessTest.cpp
new file mode 100644
index 0000000000..fad7d6ee2e
--- /dev/null
+++ b/dom/media/test/rdd_process_xpcom/RddProcessTest.cpp
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#if defined(ENABLE_TESTS)
+# include "mozilla/RDDProcessManager.h"
+# include "mozilla/RDDChild.h"
+# include "mozilla/RddProcessTest.h"
+# include "mozilla/dom/Promise.h"
+
+namespace mozilla {
+
+NS_IMETHODIMP
+RddProcessTest::TestTelemetryProbes(JSContext* aCx,
+ mozilla::dom::Promise** aOutPromise) {
+ NS_ENSURE_ARG(aOutPromise);
+ *aOutPromise = nullptr;
+ nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx);
+ if (NS_WARN_IF(!global)) {
+ return NS_ERROR_FAILURE;
+ }
+
+ ErrorResult erv;
+ RefPtr<dom::Promise> promise = dom::Promise::Create(global, erv);
+ if (NS_WARN_IF(erv.Failed())) {
+ return erv.StealNSResult();
+ }
+
+ RDDProcessManager* rddProc = RDDProcessManager::Get();
+ MOZ_ASSERT(rddProc, "No RddProcessManager?");
+
+ rddProc->LaunchRDDProcess()->Then(
+ GetMainThreadSerialEventTarget(), __func__,
+ [promise, rddProc]() {
+ RDDChild* child = rddProc->GetRDDChild();
+ if (!rddProc) {
+ promise->MaybeReject(NS_ERROR_NOT_AVAILABLE);
+ }
+ MOZ_ASSERT(rddProc, "No RDD Proc?");
+
+ if (!child) {
+ promise->MaybeReject(NS_ERROR_NOT_AVAILABLE);
+ }
+ MOZ_ASSERT(child, "No RDD Child?");
+
+ Unused << child->SendTestTelemetryProbes();
+ promise->MaybeResolve((int32_t)rddProc->RDDProcessPid());
+ },
+ [promise](nsresult aError) {
+ MOZ_ASSERT_UNREACHABLE("RddProcessTest; failure to get RDD child");
+ promise->MaybeReject(aError);
+ });
+
+ promise.forget(aOutPromise);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+RddProcessTest::StopProcess() {
+ RDDProcessManager::RDDProcessShutdown();
+ return NS_OK;
+}
+
+NS_IMPL_ISUPPORTS(RddProcessTest, nsIRddProcessTest)
+
+} // namespace mozilla
+#endif // defined(ENABLE_TESTS)
diff --git a/dom/media/test/rdd_process_xpcom/RddProcessTest.h b/dom/media/test/rdd_process_xpcom/RddProcessTest.h
new file mode 100644
index 0000000000..b0281df45b
--- /dev/null
+++ b/dom/media/test/rdd_process_xpcom/RddProcessTest.h
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+#ifndef _include_dom_media_RddProcessTest_h_
+#define _include_dom_media_RddProcessTest_h_
+
+#if defined(ENABLE_TESTS)
+# include "nsIRddProcessTest.h"
+
+namespace mozilla {
+
+class RddProcessTest final : public nsIRddProcessTest {
+ public:
+ NS_DECL_THREADSAFE_ISUPPORTS
+ NS_DECL_NSIRDDPROCESSTEST
+
+ RddProcessTest() = default;
+
+ private:
+ ~RddProcessTest() = default;
+};
+
+} // namespace mozilla
+#endif // defined(ENABLE_TESTS)
+
+#endif // _include_dom_media_RddProcessTest_h_
diff --git a/dom/media/test/rdd_process_xpcom/components.conf b/dom/media/test/rdd_process_xpcom/components.conf
new file mode 100644
index 0000000000..507559851b
--- /dev/null
+++ b/dom/media/test/rdd_process_xpcom/components.conf
@@ -0,0 +1,15 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+Classes = [
+ {
+ 'cid': '{12f7d302-5368-412d-bdc9-26d151518e6c}',
+ 'contract_ids': ['@mozilla.org/rdd-process-test;1'],
+ 'type': 'mozilla::RddProcessTest',
+ 'headers': ['mozilla/RddProcessTest.h'],
+ 'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+ },
+]
diff --git a/dom/media/test/rdd_process_xpcom/moz.build b/dom/media/test/rdd_process_xpcom/moz.build
new file mode 100644
index 0000000000..87dbb39bc1
--- /dev/null
+++ b/dom/media/test/rdd_process_xpcom/moz.build
@@ -0,0 +1,21 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+EXPORTS.mozilla += ["RddProcessTest.h"]
+
+UNIFIED_SOURCES += ["RddProcessTest.cpp"]
+
+XPCOM_MANIFESTS += ["components.conf"]
+
+XPIDL_MODULE = "rdd_process_xpcom_test"
+
+XPIDL_SOURCES += [
+ "nsIRddProcessTest.idl",
+]
+
+include("/ipc/chromium/chromium-config.mozbuild")
+
+FINAL_LIBRARY = "xul"
diff --git a/dom/media/test/rdd_process_xpcom/nsIRddProcessTest.idl b/dom/media/test/rdd_process_xpcom/nsIRddProcessTest.idl
new file mode 100644
index 0000000000..a10fdbd249
--- /dev/null
+++ b/dom/media/test/rdd_process_xpcom/nsIRddProcessTest.idl
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
+/* 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/. */
+
+#include "nsISupports.idl"
+
+[scriptable, uuid(12f7d302-5368-412d-bdc9-26d151518e6c)]
+interface nsIRddProcessTest : nsISupports
+{
+ /**
+ * ** Test-only Method **
+ *
+ * Sending Telemetry probes
+ */
+ [implicit_jscontext]
+ Promise testTelemetryProbes();
+
+ /**
+ * ** Test-only Method **
+ *
+ * Stop existing RDD process
+ */
+ void stopProcess();
+};