Adjust test to not use new GObject syntax

The test was backported from a newer gjs version, and uses syntax
that isn't available in the version we use.

Resolves: #2170044
This commit is contained in:
Florian Müllner 2023-02-17 00:37:29 +01:00
parent 8f7bb64b5c
commit f7c564fcd5

View File

@ -1,4 +1,4 @@
From 5d6724389a16ee4c43ec9207588747d01b9418ef Mon Sep 17 00:00:00 2001
From cf128c8d52a3b86177d5231f32c2e156837fa8e7 Mon Sep 17 00:00:00 2001
From: Philip Chimento <philip.chimento@gmail.com>
Date: Mon, 14 Nov 2022 22:01:59 -0800
Subject: [PATCH] gobject: Guard against null JS wrapper in set/get property
@ -10,9 +10,9 @@ property.
Closes: #510
---
gi/gobject.cpp | 12 +++++++++
installed-tests/js/testIntrospection.js | 35 +++++++++++++++++++++++++
2 files changed, 47 insertions(+)
gi/gobject.cpp | 12 ++++++++++
installed-tests/js/testIntrospection.js | 31 +++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/gi/gobject.cpp b/gi/gobject.cpp
index b86872c2..881c06f8 100644
@ -45,27 +45,23 @@ index b86872c2..881c06f8 100644
JS::RootedObject js_obj(cx, priv->wrapper());
diff --git a/installed-tests/js/testIntrospection.js b/installed-tests/js/testIntrospection.js
index 5e2ee7df..8716327e 100644
index 5e2ee7df..a0ffeefe 100644
--- a/installed-tests/js/testIntrospection.js
+++ b/installed-tests/js/testIntrospection.js
@@ -140,6 +140,41 @@ describe('Garbage collection of introspected objects', function () {
@@ -140,6 +140,37 @@ describe('Garbage collection of introspected objects', function () {
System.gc();
GLib.idle_add(GLib.PRIORITY_LOW, () => done());
});
+
+ // This tests a race condition that would crash; it should warn instead
+ it('handles setting a property from C on an object whose JS wrapper has been collected', function (done) {
+ class SomeObject extends GObject.Object {
+ static [GObject.properties] = {
+ const SomeObject = GObject.registerClass({
+ Properties: {
+ 'screenfull': GObject.ParamSpec.boolean('screenfull', '', '',
+ GObject.ParamFlags.READWRITE,
+ false),
+ };
+
+ static {
+ GObject.registerClass(this);
+ }
+ }
+ },
+ }, class SomeObject extends GObject.Object {});
+
+ GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
+ '*property screenfull*');