[gjs/wip/ptomato/mozjs38: 19/21] js: Various SpiderMonkey 38 improvements



commit b70b3fa15864c56803cf75ebea5a4eb210e1c637
Author: Philip Chimento <philip endlessm com>
Date:   Thu Jan 26 16:19:53 2017 -0800

    js: Various SpiderMonkey 38 improvements
    
    Here are two places where SpiderMonkey 38 offers a better API than the
    one we were using.
    
    The third spot, we could use JS::CallArgs::requireAtLeast(), but there is
    an issue with the visibility of that symbol in the shared library. Add a
    link to the Mozilla bug for that.

 gjs/jsapi-constructor-proxy.cpp |    3 +--
 gjs/jsapi-util-args.h           |    3 ++-
 installed-tests/js/testGDBus.js |   11 +++--------
 3 files changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/gjs/jsapi-constructor-proxy.cpp b/gjs/jsapi-constructor-proxy.cpp
index 02dc1a1..aede3c3 100644
--- a/gjs/jsapi-constructor-proxy.cpp
+++ b/gjs/jsapi-constructor-proxy.cpp
@@ -144,8 +144,7 @@ create_gjs_constructor_proxy(JSContext *cx,
         return false;
     }
 
-    if (!args[0].isObject() || !JS_ObjectIsFunction(cx, &args[0].toObject())) {
-        /* COMPAT: Use JS::IsConstructor() in mozjs38 */
+    if (!args[0].isObject() || !JS::IsConstructor(&args[0].toObject())) {
         gjs_throw(cx, "First argument must be a constructor");
         return false;
     }
diff --git a/gjs/jsapi-util-args.h b/gjs/jsapi-util-args.h
index 3229350..665aeb6 100644
--- a/gjs/jsapi-util-args.h
+++ b/gjs/jsapi-util-args.h
@@ -394,7 +394,8 @@ gjs_parse_call_args(JSContext    *cx,
 
     JSAutoRequest ar(cx);
 
-    /* COMPAT: In future, use args.requireAtLeast() */
+    /* COMPAT: In future, use args.requireAtLeast()
+     * https://bugzilla.mozilla.org/show_bug.cgi?id=1334338 */
     if (args.length() < n_required ||
         (args.length() > n_total && !ignore_trailing_args)) {
         if (n_required == n_total) {
diff --git a/installed-tests/js/testGDBus.js b/installed-tests/js/testGDBus.js
index 28e1f15..ab21585 100644
--- a/installed-tests/js/testGDBus.js
+++ b/installed-tests/js/testGDBus.js
@@ -158,7 +158,7 @@ Test.prototype = {
     },
 
     arrayOutBadSig: function() {
-        return [ "Hello", "World", "!" ];
+        return Symbol('Hello World!');
     },
 
     byteArrayEcho: function(binaryString) {
@@ -375,19 +375,14 @@ describe('Exported DBus object', function () {
         loop.run();
     });
 
-    /* COMPAT: This test should test what happens when a TypeError is thrown
-     * during argument marshalling, but conversions don't throw TypeErrors
-     * anymore, so we can't test that ... until we upgrade to mozjs38 which has
-     * Symbols. Converting a Symbol to an int32 or string will throw a TypeError.
-     */
-    xit('handles a bad signature by throwing an exception', function () {
+    it('handles a bad signature by throwing an exception', function () {
         proxy.arrayOutBadSigRemote(function(result, excp) {
             expect(result).toBeNull();
             expect(excp).not.toBeNull();
             loop.quit();
         });
         loop.run();
-    }).pend('currently cannot throw TypeError during conversion');
+    });
 
     it('can call a remote method that is implemented asynchronously', function () {
         let someString = "Hello world!";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]