From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../resources/managed-configuration-helper.js | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 testing/web-platform/tests/managed/resources/managed-configuration-helper.js (limited to 'testing/web-platform/tests/managed/resources') diff --git a/testing/web-platform/tests/managed/resources/managed-configuration-helper.js b/testing/web-platform/tests/managed/resources/managed-configuration-helper.js new file mode 100644 index 0000000000..c3213a4dad --- /dev/null +++ b/testing/web-platform/tests/managed/resources/managed-configuration-helper.js @@ -0,0 +1,51 @@ +'use strict'; + +// These tests rely on the User Agent providing an implementation of +// Managed Configuration API +// (https://wicg.github.io/WebApiDevice/managed_config). +// +// In Chromium-based browsers this implementation is provided by a polyfill +// in order to reduce the amount of test-only code shipped to users. To enable +// these tests the browser must be run with these options: +// +// --enable-blink-features=MojoJS,MojoJSTest +let fakeManagedConfigurationService = undefined; + +async function loadChromiumResources() { + await import('/resources/chromium/mock-managed-config.js'); +} + +// User Agents must provide their own implementation of `ManagedConfigTest`, +// which must contain the following this interface: +// class ManagedConfigTest { +// /** Replaces the provided managed config with the given one. */ +// /** @param {?Object} config */ +// setManagedConfig(config); +// /** Asynchronously waits for a new observer to be added */ +// waitTillObserverAdded(); +// } + +async function createManagedConfigTest() { + if (typeof ManagedConfigTest === 'undefined') { + if (isChromiumBased) { + await loadChromiumResources(); + } + } + assert_implements(ManagedConfigTest, 'ManagedConfigTest is unavailable.'); + + if (fakeManagedConfigurationService !== undefined) { + await fakeManagedConfigurationService.initialize(); + return fakeManagedConfigurationService; + } + let managedConfigTest = new ManagedConfigTest(); + await managedConfigTest.initialize(); + fakeManagedConfigurationService = managedConfigTest; + return managedConfigTest; +} + +function managed_config_test(func, description) { + promise_test(async test => { + const managedConfigTest = await createManagedConfigTest(); + await func(test, managedConfigTest); + }, description); +} -- cgit v1.2.3