B2G/gecko/browser/modules/test/unit/test_newtab-migrate-v1.js
/**
 * Asynchronously load test data from chromeappstore.sqlite.
 *
 * @param aDBFile
 *        the database file to load
 * @return {Promise} resolved when the load is complete
  */
Asynchronously load test data from chromeappstore.sqlite.
@param aDBFile
the database file to load
@return {Promise} resolved when the load is complete
Asynchronously load test data from chromeappstore . sqlite . @param aDBFile the database file to load @return { Promise } resolved when the load is complete
function promiseLoadChromeAppsStore(aDBFile) {
  let deferred = Promise.defer();
  let pinnedLinks = [];
  let blockedLinks = [];
  let db = Services.storage.openUnsharedDatabase(aDBFile);
  let stmt = db.createAsyncStatement(
    "SELECT key, value FROM webappsstore2 WHERE scope = 'batwen.:about'");
  try {
    stmt.executeAsync({
      handleResult: function(aResultSet) {
        for (let row = aResultSet.getNextRow(); row;
             row = aResultSet.getNextRow()) {
          let value = JSON.parse(row.getResultByName("value"));
          if (row.getResultByName("key") == "pinnedLinks") {
            pinnedLinks = value;
          } else {
            for (let url of Object.keys(value)) {
              blockedLinks.push({ url: url, title: "" });
            }
          }
        }
      },
      handleError: function(aError) {
        deferred.reject(new Components.Exception("Error", Cr.NS_ERROR_FAILURE));
      },
      handleCompletion: function(aReason) {
        if (aReason === Ci.mozIStorageStatementCallback.REASON_FINISHED) {
          deferred.resolve([pinnedLinks, blockedLinks]);
        }
      }
    });
  } finally {
    stmt.finalize();
    db.asyncClose();
  }
  return deferred.promise;
}
function promiseLoadChromeAppsStore ( aDBFile ) { let deferred = Promise . defer ( ) ; let pinnedLinks = [ ] ; let blockedLinks = [ ] ; let db = Services . storage . openUnsharedDatabase ( aDBFile ) ; let stmt = db . createAsyncStatement ( "SELECT key, value FROM webappsstore2 WHERE scope = 'batwen.:about'" ) ; try { stmt . executeAsync ( { handleResult : function ( aResultSet ) { for ( let row = aResultSet . getNextRow ( ) ; row ; row = aResultSet . getNextRow ( ) ) { let value = JSON . parse ( row . getResultByName ( "value" ) ) ; if ( row . getResultByName ( "key" ) == "pinnedLinks" ) { pinnedLinks = value ; } else { for ( let url of Object . keys ( value ) ) { blockedLinks . push ( { url : url , title : "" } ) ; } } } } , handleError : function ( aError ) { deferred . reject ( new Components . Exception ( "Error" , Cr . NS_ERROR_FAILURE ) ) ; } , handleCompletion : function ( aReason ) { if ( aReason === Ci . mozIStorageStatementCallback . REASON_FINISHED ) { deferred . resolve ( [ pinnedLinks , blockedLinks ] ) ; } } } ) ; } finally { stmt . finalize ( ) ; db . asyncClose ( ) ; } return deferred . promise ; }
Asynchronously load test data from chromeappstore.sqlite.
Asynchronously load test data from chromeappstore . sqlite .