summaryrefslogtreecommitdiffstats
path: root/js/xpconnect/tests/unit/test_function_names.js
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 /js/xpconnect/tests/unit/test_function_names.js
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/xpconnect/tests/unit/test_function_names.js')
-rw-r--r--js/xpconnect/tests/unit/test_function_names.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/js/xpconnect/tests/unit/test_function_names.js b/js/xpconnect/tests/unit/test_function_names.js
new file mode 100644
index 0000000000..6eadc1fce7
--- /dev/null
+++ b/js/xpconnect/tests/unit/test_function_names.js
@@ -0,0 +1,37 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function callback() {}
+
+let sandbox = Cu.Sandbox(this);
+let callbackWrapped = Cu.evalInSandbox("(function wrapped() {})", sandbox);
+
+function run_test() {
+ let functions = [
+ [{ notify: callback }, "callback[test_function_names.js]:JS"],
+ [{ notify: { notify: callback } }, "callback[test_function_names.js]:JS"],
+ [callback, "callback[test_function_names.js]:JS"],
+ [function() {}, "run_test/functions<[test_function_names.js]:JS"],
+ [function foobar() {}, "foobar[test_function_names.js]:JS"],
+ [function Δ() {}, "Δ[test_function_names.js]:JS"],
+ [{ notify1: callback, notify2: callback }, "nonfunction:JS"],
+ [{ notify: 10 }, "nonfunction:JS"],
+ [{}, "nonfunction:JS"],
+ [{ notify: callbackWrapped }, "wrapped[test_function_names.js]:JS"],
+ ];
+
+ // Use the observer service so we can get double-wrapped functions.
+ var obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
+
+ function observer(subject, topic, data)
+ {
+ let named = subject.QueryInterface(Ci.nsINamed);
+ Assert.equal(named.name, data);
+ dump(`name: ${named.name}\n`);
+ }
+ obs.addObserver(observer, "test-obs-fun", false);
+
+ for (let [f, requiredName] of functions) {
+ obs.notifyObservers(f, "test-obs-fun", requiredName);
+ }
+}