Bug 1423732 - removed JSON.stringify() encapsulating result[0].getInt32(0) on line 1181 in sqlite.jsm and changed equal() to strictEqual() on lines 112, 116 and 132; r=kitcambridge draft
authorJoshua Mengel, Bailey Hudson <17039@cgs.act.edu.au>
Mon, 22 Jan 2018 16:10:46 -0800
changeset 723341 60e667b8da10
parent 723336 bd35f45fba5a
child 746835 e3e9538b6dc5
push id96401
push userbmo:17039@cgs.act.edu.au
push dateTue, 23 Jan 2018 00:11:51 +0000
reviewerskitcambridge
bugs1423732
milestone59.0a1
Bug 1423732 - removed JSON.stringify() encapsulating result[0].getInt32(0) on line 1181 in sqlite.jsm and changed equal() to strictEqual() on lines 112, 116 and 132; r=kitcambridge MozReview-Commit-ID: KLJ7W3ZnmJU
toolkit/modules/Sqlite.jsm
toolkit/modules/tests/xpcshell/test_sqlite.js
--- a/toolkit/modules/Sqlite.jsm
+++ b/toolkit/modules/Sqlite.jsm
@@ -1166,23 +1166,24 @@ OpenedConnection.prototype = Object.free
 
   /**
    * The integer schema version of the database.
    *
    * This is 0 if not schema version has been set.
    *
    * @return Promise<int>
    */
+
   getSchemaVersion() {
     return this.execute("PRAGMA user_version").then(
       function onSuccess(result) {
         if (result == null) {
           return 0;
         }
-        return JSON.stringify(result[0].getInt32(0));
+        return result[0].getInt32(0);
       }
     );
   },
 
   setSchemaVersion(value) {
     if (!Number.isInteger(value)) {
       // Guarding against accidental SQLi
       throw new TypeError("Schema version must be an integer. Got " + value);
--- a/toolkit/modules/tests/xpcshell/test_sqlite.js
+++ b/toolkit/modules/tests/xpcshell/test_sqlite.js
@@ -104,37 +104,37 @@ add_task(async function test_get_dummy_d
   Assert.equal(typeof(db), "object");
   await db.close();
 });
 
 add_task(async function test_schema_version() {
   let db = await getDummyDatabase("schema_version");
 
   let version = await db.getSchemaVersion();
-  Assert.equal(version, 0);
+  Assert.strictEqual(version, 0);
 
   db.setSchemaVersion(14);
   version = await db.getSchemaVersion();
-  Assert.equal(version, 14);
+  Assert.strictEqual(version, 14);
 
   for (let v of [0.5, "foobar", NaN]) {
     let success;
     try {
       await db.setSchemaVersion(v);
       info("Schema version " + v + " should have been rejected");
       success = false;
     } catch (ex) {
       if (!ex.message.startsWith("Schema version must be an integer."))
         throw ex;
       success = true;
     }
     Assert.ok(success);
 
     version = await db.getSchemaVersion();
-    Assert.equal(version, 14);
+    Assert.strictEqual(version, 14);
   }
 
   await db.close();
 });
 
 add_task(async function test_simple_insert() {
   let c = await getDummyDatabase("simple_insert");