title: Use cursor.continue() in a callback
body: <p>I am trying to use cursor.continue() in chrome.tabs.update() callbacks. I always get the following error.</p>
  
  <p>DOM IDBDatabase Exception 0 Error: A request was placed against a transaction which is either currently not active, or which is finished.</p>
  
  <pre><code>Error in event handler for 'undefined': TransactionInactiveError: DOM IDBDatabase Exception 0 Error: A request was placed against a transaction which is either currently not active, or which is finished.
  at chrome-extension://fiipdmhnjimefhdbdfpgllkckomakfkh/sample.js:62:20
  at miscellaneous_bindings:288:9
  at chrome.Event.dispatchToListener (event_bindings:390:21)
  at chrome.Event.dispatch_ (event_bindings:376:27)
  at chrome.Event.dispatch (event_bindings:396:17)
  at Object.chromeHidden.Port.dispatchOnMessage (miscellaneous_bindings:254:22)     event_bindings:380
  chrome.Event.dispatch_ event_bindings:380
  chrome.Event.dispatch event_bindings:396
  chromeHidden.Port.dispatchOnMessage
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>//background.js
  store = getObjectStore(DB_STORE_NAME, 'readwrite');
  var req;
  req = store.count();
  
  req.onsuccess = function(evt) {
    console.log('&lt;p&gt;There are &lt;strong&gt;' + evt.target.result +
                   '&lt;/strong&gt; record(s) in the object store.&lt;/p&gt;');
                  // store = getObjectStore(DB_STORE_NAME, 'readwrite');
  };
  req.onerror = function(evt) {
    console.error("add error", this.error);
   // store = getObjectStore(DB_STORE_NAME, 'readwrite');
    //displayActionFailure(this.error);
  };
  
    var i = 0;
  req = store.openCursor();
  req.onsuccess = function(evt) {
    cursor = evt.target.result;
  //store = getObjectStore(DB_STORE_NAME, 'readwrite');
    // If the cursor is pointing at something, ask for the data
    if (cursor) {
      //cursor.advance(i);
      console.log("rol cursor:", cursor);
      req = store.get(cursor.key);
      req.onsuccess = function (evt) {        
      var value = evt.target.result;                
      chrome.tabs.update(cTab.id,{url:value.uri,active:true},function(t){         
          console.log(value.uri,value.path);    
          chrome.tabs.executeScript(t.id,{file:"/lib/jquery-ui-1.8.6/js/jquery-1.9.0.min.js",runAt:"document_end"},function() {
          chrome.tabs.executeScript(t.id, { code:"var jClaw = jQuery.noConflict();jClaw('html, body').animate({scrollTop:jClaw('"+value.path+"').offset().top}, 2000);jClaw('"+value.path+"').css({background:'yellow'},1000);",runAt:"document_end"},function(){ 
          chrome.tabs.sendMessage(t.id,value.path,function(response){
  
              cursor.continue();
          });
          });
  
  //cursor.update(cursor.value);
      });
          //cursor.update(cursor.value);
          //chrome.tabs.sendMessage(t.id,"scrollTo");
  }); 
      };
  
      // Move on to the next object in store
      //cursor.continue();
      //cursor.update(cursor.value);
  
      // This counter serves only to create distinct ids
      i++;
    } else {
      console.log("No more entries");
    }
  };
  </code></pre>
  
  <p>I have tried various ways to keep the transaction open. But couldn't succeed. </p>
  
  <pre><code>function getObjectStore(store_name, mode) {
  var tx = dbp.transaction(store_name, mode);
  tx.oncomplete = function(e){
      console.log("Transaction Complete");
    };
    tx.onabort = function(e){
      console.log("Transaction Aborted");
    };
    tx.onerror = function(e){
      console.log("Transaction Error");
    };
    //tx.onsuccess=keepAlive;
  return tx.objectStore(store_name);
  }
  </code></pre>
  
  <p>As you can see I want to iterate through indexed DB and use the URL to populate the page. Then I wanted to inject script to fetch some text using message passing. But, if I place cursor.continue() outside callback it's just moving on to next URL as the chrome.tabs.update is async.</p>
  
  <p>Can somebody please help me here?</p>