Bug 1484615 - Followup comment fix for bug 1409641; r=janv
authorTom Tung <shes050117@gmail.com>
Mon, 20 Aug 2018 11:46:24 +0200
changeset 432587 dcbb7762dc2fa3afbbf969016c29b125d97b52f2
parent 432586 bd62249f8b51bb395883e0115f0cac099555be1c
child 432588 6d8d234a983ae65eee63239a8536dd24428f6db1
push id34480
push userdluca@mozilla.com
push dateTue, 21 Aug 2018 16:01:44 +0000
treeherdermozilla-central@130bb81b5f4f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv
bugs1484615, 1409641
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1484615 - Followup comment fix for bug 1409641; r=janv This patch add comments to IndexedDBHelper.jsm to clarify how txn.result is set. The comments should clear up any confusion caused by previous commit message (fix for bug 1409641).
dom/base/IndexedDBHelper.jsm
--- a/dom/base/IndexedDBHelper.jsm
+++ b/dom/base/IndexedDBHelper.jsm
@@ -129,17 +129,17 @@ IndexedDBHelper.prototype = {
    *        Type of transaction (e.g. "readwrite")
    * @param store_name
    *        The object store you want to be passed to the callback
    * @param callback
    *        Function to call when the transaction is available. It will
    *        be invoked with the transaction and the `store' object store.
    * @param successCb
    *        Success callback to call on a successful transaction commit.
-   *        The result is stored in txn.result.
+   *        The result is stored in txn.result (in the callback function).
    * @param failureCb
    *        Error callback to call when an error is encountered.
    */
   newTxn: function newTxn(txn_type, store_name, callback, successCb, failureCb) {
     this.ensureDB(() => {
       if (DEBUG) debug("Starting new transaction" + txn_type);
       let txn;
       try {
@@ -157,27 +157,41 @@ IndexedDBHelper.prototype = {
           stores.push(txn.objectStore(store_name[i]));
         }
       } else {
         stores = txn.objectStore(store_name);
       }
 
       txn.oncomplete = function () {
         if (DEBUG) debug("Transaction complete. Returning to callback.");
+        /*
+         * txn.result property is not part of the transaction object returned
+         * by this._db.transaction method called above.
+         * The property is expected to be set in the callback function.
+         * However, it can happen that the property is not set for some reason,
+         * so we have to check if the property exists before calling the
+         * success callback.
+         */
         if (successCb) {
           if ("result" in txn) {
             successCb(txn.result);
           } else {
             successCb();
           }
         }
       };
 
       txn.onabort = function () {
         if (DEBUG) debug("Caught error on transaction");
+        /*
+         * txn.error property is part of the transaction object returned by
+         * this._db.transaction method called above.
+         * The attribute is defined in IDBTranscation WebIDL interface.
+         * It may be null.
+         */
         if (failureCb) {
           failureCb(getErrorName(txn.error));
         }
       };
       callback(txn, stores);
     }, failureCb);
   },