diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/gdb/tests/test-JSObject.cpp | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/gdb/tests/test-JSObject.cpp')
-rw-r--r-- | js/src/gdb/tests/test-JSObject.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/js/src/gdb/tests/test-JSObject.cpp b/js/src/gdb/tests/test-JSObject.cpp new file mode 100644 index 0000000000..b1780a7332 --- /dev/null +++ b/js/src/gdb/tests/test-JSObject.cpp @@ -0,0 +1,54 @@ +#include "gdb-tests.h" +#include "jsapi.h" +#include "js/GlobalObject.h" +#include "js/Object.h" // JS::GetClass + +FRAGMENT(JSObject, simple) { + JS::Rooted<JSObject*> glob(cx, JS::CurrentGlobalOrNull(cx)); + JS::Rooted<JSObject*> plain(cx, JS_NewPlainObject(cx)); + JS::Rooted<JSObject*> objectProto(cx, JS::GetRealmObjectPrototype(cx)); + JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx)); + JS::Rooted<JSObject*> func( + cx, (JSObject*)JS_NewFunction(cx, (JSNative)1, 0, 0, "dys")); + JS::Rooted<JSObject*> anon( + cx, (JSObject*)JS_NewFunction(cx, (JSNative)1, 0, 0, nullptr)); + JS::Rooted<JSFunction*> funcPtr( + cx, JS_NewFunction(cx, (JSNative)1, 0, 0, "formFollows")); + + // JS_NewObject will now assert if you feed it a bad class name, so mangle + // the name after construction. + char namebuf[20] = "goodname"; + static JSClass cls{namebuf}; + JS::RootedObject badClassName(cx, JS_NewObject(cx, &cls)); + MOZ_RELEASE_ASSERT(badClassName); + strcpy(namebuf, "\xc7X"); + + JSObject& plainRef = *plain; + JSFunction& funcRef = *funcPtr; + JSObject* plainRaw = plain; + JSObject* funcRaw = func; + + breakpoint(); + + use(glob); + use(plain); + use(objectProto); + use(func); + use(anon); + use(funcPtr); + use(&plainRef); + use(&funcRef); + use(JS::GetClass((JSObject*)&funcRef)); + use(plainRaw); + use(funcRaw); +} + +FRAGMENT(JSObject, null) { + JS::Rooted<JSObject*> null(cx, nullptr); + JSObject* nullRaw = null; + + breakpoint(); + + use(null); + use(nullRaw); +} |