$OpenBSD: patch-test_js_testEverythingBasic_js,v 1.1 2013/04/12 07:26:44 jasper Exp $

From f4a5b2c9af715668e3559ff0b66a311d7e9936b2 Mon Sep 17 00:00:00 2001
From: Giovanni Campagna <gcampagna@src.gnome.org>
Date: Tue, 02 Apr 2013 16:04:13 +0000
Subject: Fix crash when marshalling a GType array containing non objects

It would cast a jsval of the wrong type to object and pass NULL
to gjs_gtype_get_actual_gtype()

Tests included.

https://bugzilla.gnome.org/show_bug.cgi?id=696933

--- test/js/testEverythingBasic.js.orig	Tue Dec 18 17:28:44 2012
+++ test/js/testEverythingBasic.js	Fri Apr 12 09:23:34 2013
@@ -10,6 +10,7 @@ if (!('assertEquals' in this)) { /* allow running this
 // We use Gio to have some objects that we know exist
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
+const GObject = imports.gi.GObject;
 const Lang = imports.lang;
 
 const INT8_MIN = (-128);
@@ -312,6 +313,20 @@ function testArrayIn() {
     assertEquals(10, Everything.test_array_gint8_in("\x01\x02\x03\x04"));
     assertEquals(10, Everything.test_array_gint16_in("\x01\x02\x03\x04"));
     assertEquals(2560, Everything.test_array_gint16_in("\u0100\u0200\u0300\u0400"));
+
+    // GType arrays
+    assertEquals('[GSimpleAction,GIcon,GBoxed,]',
+                 Everything.test_array_gtype_in([Gio.SimpleAction, Gio.Icon, GObject.TYPE_BOXED]));
+    assertRaises(function() {
+        Everything.test_array_gtype_in(42);
+    });
+    assertRaises(function() {
+        Everything.test_array_gtype_in([undefined]);
+    });
+    assertRaises(function() {
+        // 80 is G_TYPE_OBJECT, but we don't want it to work
+        Everything.test_array_gtype_in([80]);
+    });
 }
 
 function testArrayOut() {
