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 --- .../glean/tests/xpcshell/test_FOGIPCLimit.js | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 toolkit/components/glean/tests/xpcshell/test_FOGIPCLimit.js (limited to 'toolkit/components/glean/tests/xpcshell/test_FOGIPCLimit.js') diff --git a/toolkit/components/glean/tests/xpcshell/test_FOGIPCLimit.js b/toolkit/components/glean/tests/xpcshell/test_FOGIPCLimit.js new file mode 100644 index 0000000000..10ab9f5bc3 --- /dev/null +++ b/toolkit/components/glean/tests/xpcshell/test_FOGIPCLimit.js @@ -0,0 +1,51 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const { AppConstants } = ChromeUtils.importESModule( + "resource://gre/modules/AppConstants.sys.mjs" +); + +const { ContentTaskUtils } = ChromeUtils.importESModule( + "resource://testing-common/ContentTaskUtils.sys.mjs" +); + +add_setup( + /* on Android FOG is set up through head.js */ + { skip_if: () => !runningInParent || AppConstants.platform == "android" }, + function test_setup() { + // Give FOG a temp profile to init within. + do_get_profile(); + + // We need to initialize it once, otherwise operations will be stuck in the pre-init queue. + Services.fog.initializeFOG(); + } +); + +// Keep in sync with ipc.rs. +// "Why no -1?" Because the limit's 100k. The -1 is because of atomic ops. +const FOG_IPC_PAYLOAD_ACCESS_LIMIT = 100000; + +add_task({ skip_if: () => runningInParent }, async function run_child_stuff() { + for (let i = 0; i < FOG_IPC_PAYLOAD_ACCESS_LIMIT + 1; i++) { + Glean.testOnly.badCode.add(1); + } +}); + +add_task( + { skip_if: () => !runningInParent }, + async function test_fog_ipc_limit() { + await run_test_in_child("test_FOGIPCLimit.js"); + + await ContentTaskUtils.waitForCondition(() => { + return !!Glean.testOnly.badCode.testGetValue(); + }, "Waiting for IPC."); + + // The child exceeded the number of accesses to trigger an IPC flush. + Assert.greater( + Glean.testOnly.badCode.testGetValue(), + FOG_IPC_PAYLOAD_ACCESS_LIMIT + ); + } +); -- cgit v1.2.3