Make the test more awesome with generator send support.
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Mon, 10 May 2010 10:49:42 -0700
changeset 43988 8d33bc40b3dd6c2e684e8e1d585c98afc214486d
parent 43987 8de2e436badd0448685a00775d45bd1b69a70c12
child 43989 52d482ba5f953283e55c8672d76ff2c2db76a4de
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
milestone1.9.3a5pre
Make the test more awesome with generator send support.
dom/indexedDB/test/test_objectStore_remove_values.html
--- a/dom/indexedDB/test/test_objectStore_remove_values.html
+++ b/dom/indexedDB/test/test_objectStore_remove_values.html
@@ -7,28 +7,26 @@
   <title>Indexed Database Property Test</title>
 
   <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 
   <script type="text/javascript;version=1.7">
 
-var event;
 function continueTest(aEvent)
 {
   SimpleTest.executeSoon(function() {
-    event = aEvent;
-    gGen.next();
+    gGen.send(aEvent);
   });
 }
 
 function errorHandler(aEvent)
 {
-  ok(false, "indexedDB error (" + event.code + "): " + event.message);
+  ok(false, "indexedDB error (" + aEvent.code + "): " + aEvent.message);
   SimpleTest.executeSoon(finishTest);
 }
 
 function unexpectedSuccessHandler()
 {
   ok(false, "Got success, but did not expect it!");
   SimpleTest.executeSoon(finishTest);
 }
@@ -36,73 +34,73 @@ function unexpectedSuccessHandler()
 function ExpectError(aCode)
 {
   this._code = aCode;
 }
 ExpectError.prototype = {
   handleEvent: function(aEvent)
   {
     is(this._code, aEvent.code, "Expected error was thrown.");
-    continueTest();
+    continueTest(aEvent);
   },
 };
 
 function testSteps()
 {
   const IDBObjectStore = Components.interfaces.nsIIDBObjectStore;
   const IDBDatabaseException = Components.interfaces.nsIIDBDatabaseException;
   const name = window.location.pathname;
   const description = "My Test Database";
 
   var request = indexedDB.open(name, description);
   request.onerror = errorHandler;
   request.onsuccess = continueTest;
-  yield;
+  var event = yield;
 
   var db = event.result;
 
   // Check removal for inline keys, with a key generator.
   var objectStoreName = "inline key; key generator";
   var request = db.createObjectStore(objectStoreName, "id", true);
   request.onerror = errorHandler;
   request.onsuccess = continueTest;
-  yield;
+  event = yield;
 
   request = db.openObjectStore(objectStoreName);
   request.onerror = errorHandler;
   request.onsuccess = continueTest;
-  yield;
+  event = yield;
 
   var objectStore = event.result;
   var storedObject = {name: "Lincoln"};
   request = objectStore.put(storedObject);
   request.onerror = errorHandler;
   request.onsuccess = continueTest;
-  yield;
+  event = yield;
 
   var id = event.result;
   request = objectStore.get(id);
   request.onerror = errorHandler;
   request.onsuccess = continueTest;
-  yield;
+  event = yield;
 
   // Sanity check!
   SimpleTest.is(storedObject.name, event.result.name,
                 "The correct object was stored.");
 
   request = objectStore.remove(id);
   request.onerror = errorHandler;
   request.onsuccess = continueTest;
-  yield;
+  event = yield;
 
   // Make sure it was removed.
   request = objectStore.get(id);
   request.onerror = new ExpectError(IDBDatabaseException.NOT_FOUND_ERR);
   request.onsuccess = unexpectedSuccessHandler;
-  yield;
+  event = yield;
 
   // TODO test the other cases!
 
   SimpleTest.executeSoon(finishTest);
   yield;
 }
 
 function finishTest()