diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/managed/managed-config-success.https.window.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/managed/managed-config-success.https.window.js')
-rw-r--r-- | testing/web-platform/tests/managed/managed-config-success.https.window.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/testing/web-platform/tests/managed/managed-config-success.https.window.js b/testing/web-platform/tests/managed/managed-config-success.https.window.js new file mode 100644 index 0000000000..ef9ad81a15 --- /dev/null +++ b/testing/web-platform/tests/managed/managed-config-success.https.window.js @@ -0,0 +1,56 @@ +// META: script=/resources/test-only-api.js +// META: script=resources/managed-configuration-helper.js + +'use strict' + +managed_config_test(async (test, managedConfigTest) => { + promise_rejects_dom( + test, 'NotAllowedError', + navigator.managed.getManagedConfiguration(['a'])); +}, 'App is not managed.'); + +managed_config_test(async (test, managedConfigTest) => { + managedConfigTest.setManagedConfig({a: 2}); + const result = await navigator.managed.getManagedConfiguration(['a']); + assert_equals(Object.keys(result).length, 1); + assert_equals(result.a, 2); +}, 'Configuration is returned'); + +managed_config_test(async (test, managedConfigTest) => { + managedConfigTest.setManagedConfig({a: 2, b: 3, c: 1}); + const result = await navigator.managed.getManagedConfiguration(['b', 'c']); + assert_equals(Object.keys(result).length, 2); + assert_equals(result.b, 3); + assert_equals(result.c, 1); +}, 'Selected keys are returned.'); + +managed_config_test(async (test, managedConfigTest) => { + managedConfigTest.setManagedConfig({a: 2, b: 3, c: 1}); + const result = await navigator.managed.getManagedConfiguration(['b', 'e']); + assert_equals(Object.keys(result).length, 1); + assert_equals(result.b, 3); +}, 'Only existing keys are returned.'); + +managed_config_test(async (test, managedConfigTest) => { + managedConfigTest.setManagedConfig({a: 2, b: false, c: {x: 3}}); + const result = + await navigator.managed.getManagedConfiguration(['a', 'b', 'c']); + assert_equals(Object.keys(result).length, 3); + assert_equals(result.a, 2); + assert_equals(result.b, false); + assert_equals(Object.keys(result.c).length, 1); + assert_equals(result.c.x, 3); +}, 'Values can be of any type'); + +managed_config_test(async (test, managedConfigTest) => { + const nextObserverAdded = managedConfigTest.nextObserverAdded(); + const watcher = + new EventWatcher(test, navigator.managed, ['managedconfigurationchange']); + await nextObserverAdded; + const event = watcher.wait_for(['managedconfigurationchange']); + managedConfigTest.setManagedConfig({'a': 2}); + await event; + const result = await navigator.managed.getManagedConfiguration(['a']); + assert_equals(Object.keys(result).length, 1); + assert_equals(result.a, 2); +}, 'A change in managed configuration is observed.'); |