[gjs: 4/5] testGObjectClass: Verify that we properly sanitize the provided GType name
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 4/5] testGObjectClass: Verify that we properly sanitize the provided GType name
- Date: Thu, 24 Oct 2019 05:22:50 +0000 (UTC)
commit e4d9ce68e2844c0335296f2866470583f96cfaa5
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Sun Sep 1 09:09:06 2019 +0200
testGObjectClass: Verify that we properly sanitize the provided GType name
installed-tests/js/testGObjectClass.js | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
---
diff --git a/installed-tests/js/testGObjectClass.js b/installed-tests/js/testGObjectClass.js
index f4bfafa7..a19cc43a 100644
--- a/installed-tests/js/testGObjectClass.js
+++ b/installed-tests/js/testGObjectClass.js
@@ -2,6 +2,7 @@
imports.gi.versions.Gtk = '3.0';
const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
@@ -522,4 +523,22 @@ describe('Register GType name', function () {
expect(GtypeClass.$gtype.name).toEqual('GTypeTestManualName');
});
+
+ it('sanitizes user provided class name', function () {
+ let gtypeName = 'GType$Test/WithLòt\'s of*bad§chars!';
+ let expectedSanitized = 'GType_Test_WithL_t_s_of_bad_chars_';
+
+ GLib.test_expect_message('Gjs', GLib.LogLevelFlags.LEVEL_WARNING,
+ `*RangeError: Provided GType name '${gtypeName}' is not valid; ` +
+ `automatically sanitized to '${expectedSanitized}'*`);
+
+ const GtypeClass = GObject.registerClass({
+ GTypeName: gtypeName,
+ }, class extends GObject.Object {});
+
+ GLib.test_assert_expected_messages_internal('Gjs', 'testGObjectClass.js', 0,
+ 'testGObjectRegisterClassSanitize');
+
+ expect(GtypeClass.$gtype.name).toEqual(expectedSanitized);
+ });
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]