B2G/gecko/dom/browser-element/mochitest/browserElementTestHelpers.js
// resolve if priority matches expectedPriority.
resolve if priority matches expectedPriority.
resolve if priority matches expectedPriority .
function expectPriorityChange(childID, expectedPriority,
                               expectedCPUPriority) {
  var deferred = Promise.defer();
  var observed = false;
  browserElementTestHelpers.addProcessPriorityObserver(
    'process-priority-set',
    function(subject, topic, data) {
      if (observed) {
        return;
      }
      [id, priority, cpuPriority] = data.split(":");
      if (id != childID) {
        return;
      }
      observed = true;
      is(priority, expectedPriority,
         'Expected priority of childID ' + childID +
         ' to change to ' + expectedPriority);
      if (expectedCPUPriority) {
        is(cpuPriority, expectedCPUPriority,
           'Expected CPU priority of childID ' + childID +
           ' to change to ' + expectedCPUPriority);
      }
      if (priority == expectedPriority &&
          (!expectedCPUPriority || expectedCPUPriority == cpuPriority)) {
        deferred.resolve();
      } else {
        deferred.reject();
      }
    }
  );
  return deferred.promise;
}
function expectPriorityChange ( childID , expectedPriority , expectedCPUPriority ) { var deferred = Promise . defer ( ) ; var observed = false ; browserElementTestHelpers . addProcessPriorityObserver ( 'process-priority-set' , function ( subject , topic , data ) { if ( observed ) { return ; } [ id , priority , cpuPriority ] = data . split ( ":" ) ; if ( id != childID ) { return ; } observed = true ; is ( priority , expectedPriority , 'Expected priority of childID ' + childID + ' to change to ' + expectedPriority ) ; if ( expectedCPUPriority ) { is ( cpuPriority , expectedCPUPriority , 'Expected CPU priority of childID ' + childID + ' to change to ' + expectedCPUPriority ) ; } if ( priority == expectedPriority && ( ! expectedCPUPriority || expectedCPUPriority == cpuPriority ) ) { deferred . resolve ( ) ; } else { deferred . reject ( ) ; } } ) ; return deferred . promise ; }
resolve if priority matches expectedPriority.
resolve if priority matches expectedPriority .
/* optional */ // Make sure we run the is() calls in this observer only once, otherwise // we'll expect /every/ priority change to match expectedPriority.