Bug 1321217 - Remove legacy generator from docshell/. r=smaug
authorTooru Fujisawa <arai_a@mac.com>
Thu, 01 Dec 2016 18:04:50 +0900
changeset 324890 43472882f637c01e43e3ecbfd37c1ffff7fabfa1
parent 324889 7dc7e58f62f4f837410f92527e70c2eaa543b50b
child 324891 4a8703321e8a8bf3c8769dec1007e72dad3b01dd
push id84537
push userarai_a@mac.com
push dateThu, 01 Dec 2016 09:12:42 +0000
treeherdermozilla-inbound@78e008ce3a8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1321217
milestone53.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 1321217 - Remove legacy generator from docshell/. r=smaug
docshell/test/browser/browser_bug349769.js
docshell/test/chrome/bug112564_window.xul
docshell/test/chrome/bug215405_window.xul
docshell/test/chrome/bug293235_window.xul
docshell/test/chrome/bug294258_window.xul
docshell/test/chrome/bug298622_window.xul
docshell/test/chrome/bug301397_window.xul
docshell/test/chrome/bug303267_window.xul
docshell/test/chrome/bug321671_window.xul
docshell/test/chrome/bug360511_window.xul
docshell/test/chrome/bug364461_window.xul
docshell/test/chrome/bug396519_window.xul
docshell/test/chrome/bug396649_window.xul
docshell/test/chrome/bug449780_window.xul
docshell/test/chrome/bug582176_window.xul
docshell/test/chrome/bug662200_window.xul
docshell/test/chrome/bug690056_window.xul
docshell/test/chrome/bug89419_window.xul
docshell/test/chrome/bug92598_window.xul
docshell/test/chrome/test_bug453650.xul
docshell/test/chrome/test_bug608669.xul
docshell/test/test_bfcache_plus_hash.html
docshell/test/test_bug385434.html
docshell/test/test_bug475636.html
docshell/test/test_bug509055.html
docshell/test/test_bug640387_1.html
docshell/test/test_bug640387_2.html
docshell/test/test_bug669671.html
--- a/docshell/test/browser/browser_bug349769.js
+++ b/docshell/test/browser/browser_bug349769.js
@@ -1,14 +1,14 @@
 add_task(function* test() {
   const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
   const uris = [undefined, "about:blank"];
 
-  function checkContentProcess(uri) {
-    yield ContentTask.spawn(newBrowser, uri, function* (uri) {
+  function checkContentProcess(newBrowser, uri) {
+    return ContentTask.spawn(newBrowser, uri, function* (uri) {
       var prin = content.document.nodePrincipal;
       Assert.notEqual(prin, null, "Loaded principal must not be null when adding " + uri);
       Assert.notEqual(prin, undefined, "Loaded principal must not be undefined when loading " + uri);
 
       const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
                        .getService(Ci.nsIScriptSecurityManager);
       Assert.equal(secMan.isSystemPrincipal(prin), false,
          "Loaded principal must not be system when loading " + uri);
@@ -23,25 +23,25 @@ add_task(function* test() {
       isnot(prin, null, "Forced principal must not be null when loading " + uri);
       isnot(prin, undefined,
             "Forced principal must not be undefined when loading " + uri);
       is(secMan.isSystemPrincipal(prin), false,
          "Forced principal must not be system when loading " + uri);
 
       // Belt-and-suspenders e10s check: make sure that the same checks hold
       // true in the content process.
-      checkContentProcess(uri);
+      yield checkContentProcess(newBrowser, uri);
 
       yield BrowserTestUtils.browserLoaded(newBrowser);
 
       prin = newBrowser.contentPrincipal;
       isnot(prin, null, "Loaded principal must not be null when adding " + uri);
       isnot(prin, undefined, "Loaded principal must not be undefined when loading " + uri);
       is(secMan.isSystemPrincipal(prin), false,
          "Loaded principal must not be system when loading " + uri);
 
       // Belt-and-suspenders e10s check: make sure that the same checks hold
       // true in the content process.
-      checkContentProcess(uri);
+      yield checkContentProcess(newBrowser, uri);
     });
   }
 });
 
--- a/docshell/test/chrome/bug112564_window.xul
+++ b/docshell/test/chrome/bug112564_window.xul
@@ -71,24 +71,20 @@
       }
 
       if (gExpected.length == 0) {
         setTimeout(nextTest, 0);
       }
     }
 
     function nextTest() {
-      try {
-        gTestsIterator.next();
-      } catch (err if err instanceof StopIteration) {
-        finish();
-      }
+      gTestsIterator.next();
     }
 
-    function testsIterator() {
+    function* testsIterator() {
       // Load a secure page with a no-cache header, followed by a simple page.
       // no-cache should not interfere with the bfcache in the way no-store
       // does.
       var test1DocURI = "https://example.com:443/tests/docshell/test/chrome/112564_nocache.html";
 
       gExpected = [{type: "pagehide", persisted: true},
                    {type: "load", title: "test1"},
                    {type: "pageshow", title: "test1", persisted: false}];
@@ -105,13 +101,15 @@
       yield undefined;
 
       // Now go back in history. First page has been cached.
       // Check persisted property to confirm
       gExpected = [{type: "pagehide", title: "test2", persisted: true},
                    {type: "pageshow", title: "test1", persisted: true}];
       gBrowser.goBack();
       yield undefined;
+
+      finish();
     }
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug215405_window.xul
+++ b/docshell/test/chrome/bug215405_window.xul
@@ -48,24 +48,20 @@
       nextTest();
     }
 
     function eventListener(event) {
       setTimeout(nextTest, 0);
     }
 
     function nextTest() {
-      try {
-        gTestsIterator.next();
-      } catch (err if err instanceof StopIteration) {
-        finish();
-      }
+      gTestsIterator.next();
     }
 
-    function testsIterator() {
+    function* testsIterator() {
       // No-store tests
       var testName = "[nostore]";
 
       // Load a page with a no-store header
       gBrowser.loadURI(nostoreURI);
       yield undefined;
 
 
@@ -151,17 +147,14 @@
       // and form contents are restored
       is(gBrowser.contentWindow.scrollX, scrollX, testName +
          " horizontal axis scroll position not correctly restored");
       is(gBrowser.contentWindow.scrollY, scrollY, testName +
          " vertical axis scroll position not correctly restored");
       var formValue = gBrowser.contentDocument.getElementById("inp").value;
       is(formValue, text, testName + " form value not correctly restored");
       
-      // nextTest has to be called from here, as no events are fired in this
-      // step
-      setTimeout(nextTest, 0);
-      yield undefined;
+      finish();
     }
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug293235_window.xul
+++ b/docshell/test/chrome/bug293235_window.xul
@@ -37,17 +37,17 @@
     function $(id) { return TestWindow.getDocument().getElementById(id); }
 
     ////
     // Generator function for test steps for bug 293235:
     // A visited link should have the :visited style applied
     // to it when displayed on a page which was fetched from
     // the bfcache.
     //
-    function testIterator()
+    function* testIterator()
     {
       // Register our observer to know when the link lookup is complete.
       let testURI = NetUtil.newURI(getHttpUrl("bug293235_p2.html"));
       let os = Cc["@mozilla.org/observer-service;1"].
                getService(Ci.nsIObserverService);
       const URI_VISITED_RESOLUTION_TOPIC = "visited-status-resolution";
       let observer = {
         notified: false,
@@ -145,18 +145,16 @@
         onNavComplete: nextTest
       });
       yield undefined;
 
       // Now we can test the link color.
       ok(snapshotsEqual(refVisited, snapshotWindow(TestWindow.getWindow())),
          "visited link should be purple");
 
-      // Tell the framework the test is finished.  Include the final 'yield'
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;
     }
 
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug294258_window.xul
+++ b/docshell/test/chrome/bug294258_window.xul
@@ -23,17 +23,17 @@
     }
 
     function $(id) { return TestWindow.getDocument().getElementById(id); }
 
     ////
     // Generator function for test steps for bug 294258:  
     // Form values should be preserved on reload.
     //
-    function testIterator()
+    function* testIterator()
     {
       // Load a page containing a form.
       doPageNavigation( {
           uri: getHttpUrl("bug294258_testcase.html"),
           onNavComplete: nextTest
         } );
       yield undefined;
       
@@ -59,18 +59,16 @@
       // Verify that none of the form data has changed.
       is($("text").value, "text value", "Text value changed");
       is($("checkbox").checked, true, "Checkbox value changed");
       is($("file").value, filePath, "File value changed");
       is($("textarea").value, "textarea value", "Textarea value changed");
       is($("radio1").checked, true, "Radio value changed");
       is($("select").selectedIndex, 2, "Select value changed");
 
-      // Tell the framework the test is finished.  Include the final 'yield' 
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;
     }
     
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug298622_window.xul
+++ b/docshell/test/chrome/bug298622_window.xul
@@ -24,17 +24,17 @@
       tests.next();
     }
 
     ////
     // Generator function for test steps for bug 298622:  
     // Find should work correctly on a page loaded from the
     // bfcache.
     //
-    function testIterator()
+    function* testIterator()
     {
       // Make sure bfcache is on.
       enableBFCache(true);
       
       // Load a test page which contains some text to be found.
       doPageNavigation({
         uri: "data:text/html,<html><head><title>test1</title></head>" +
              "<body>find this!</body></html>",
@@ -126,20 +126,18 @@
           "find this");
       }, nextTest, 20);
       yield undefined;
 
       is(TestWindow.getWindow().getSelection().toString().toLowerCase(),
          "find this",
          "find failed on page loaded from bfcache");
       
-      // Tell the framework the test is finished.  Include the final 'yield' 
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;
     }
     
   ]]></script>
 
   <commandset>
     <command id="cmd_find"
      oncommand="document.getElementById('FindToolbar').onFindCommand();"/>
   </commandset>
--- a/docshell/test/chrome/bug301397_window.xul
+++ b/docshell/test/chrome/bug301397_window.xul
@@ -38,17 +38,17 @@
     }
     
     ////
     // Generator function for test steps for bug 301397:  
     // The correct page should be displayed in an iframe when
     // navigating back and forwards, when the parent page
     // occupies multiple spots in the session history.
     //
-    function testIterator()
+    function* testIterator()
     {
       // Make sure the bfcache is enabled.
       enableBFCache(8);
 
       // Load a dummy page.
       doPageNavigation({
         uri: getHttpUrl("generic.html"),
         onNavComplete: nextTest
@@ -233,18 +233,16 @@
                             persisted: true,
                             title: "iframe parent" } ],
         onNavComplete: nextTest
       });
       yield undefined;
       
       verifyIframeInnerHtml("You made it");
       
-      // Tell the framework the test is finished.  Include the final 'yield' 
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;
     }
     
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug303267_window.xul
+++ b/docshell/test/chrome/bug303267_window.xul
@@ -22,17 +22,17 @@
       tests.next();
     }
 
     ////
     // Generator function for test steps for bug 303267:  When a page is 
     // displayed from the bfcache, the script globals should
     // remain intact from the page's initial load.
     //
-    function testIterator()
+    function* testIterator()
     {
       // Load an initial test page which should be saved in the bfcache.
       var navData = {
         uri: getHttpUrl("bug303267.html"),
         eventsToListenFor: ["pageshow"],
         expectedEvents: [ {type: "pageshow", title: "bug303267.html"} ],
         onNavComplete: nextTest
       };
@@ -77,20 +77,18 @@
       
       // After going back, if showpagecount() could access a global variable
       // and change the test div's innerHTML, then we pass.  Otherwise, it
       // threw an exception and the following test will fail.
       var newHTML = getInnerHTMLById("div1");
       isnot(originalHTML, 
         newHTML, "HTML not updated on pageshow; javascript broken?");
 
-      // Tell the framework the test is finished.  Include the final 'yield' 
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;
     }
 
     ////
     // Return the innerHTML of a particular element in the content document.
     //
     function getInnerHTMLById(id) {
       return TestWindow.getDocument().getElementById(id).innerHTML;
     }
--- a/docshell/test/chrome/bug321671_window.xul
+++ b/docshell/test/chrome/bug321671_window.xul
@@ -29,17 +29,17 @@
       tests.next();
     }
 
     ////
     // Generator function for test steps for bug 321671:  Scroll position 
     // should be retained when moving backwards and forwards through pages 
     // when bfcache is enabled.
     //
-    function testIterator()
+    function* testIterator()
     {
       // Variable to hold the scroll positions of the test pages.
       var scrollPositions = [];
       
       // Make sure bfcache is on.
       enableBFCache(true);
       
       // Load enough test pages that so the first one is evicted from the
@@ -116,18 +116,16 @@
           onNavComplete: nextTest
         } );
         yield undefined;
         
         is(TestWindow.getWindow().scrollY, scrollPositions[i],
           "Scroll position not restored while going forward!");
       }
       
-      // Tell the framework the test is finished.  Include the final 'yield' 
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;
     }
     
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug360511_window.xul
+++ b/docshell/test/chrome/bug360511_window.xul
@@ -22,17 +22,17 @@
       tests.next();
     }
 
     ////
     // Generator function for test steps for bug 360511:  
     // Fragment uri's in session history should be restored correctly
     // upon back navigation.
     //
-    function testIterator()
+    function* testIterator()
     {
       // Case 1: load a page containing a fragment link; the page should be 
       // stored in the bfcache.
       // Case 2: load a page containing a fragment link; the page should NOT 
       // be stored in the bfcache.
       for (var i = 1; i < 3; i++)
       {
         var url = "bug360511_case" + i + ".html";
@@ -117,18 +117,16 @@
       
         // Verify the current url is the original url without fragment
         is(TestWindow.getBrowser().currentURI.spec, originalUrl, 
           "current url is not the original url");
         is(TestWindow.getDocument().location.href, originalDocLocation,
           "document.location is not the original url");
       }
                       
-      // Tell the framework the test is finished.  Include the final 'yield' 
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;
     }
     
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug364461_window.xul
+++ b/docshell/test/chrome/bug364461_window.xul
@@ -67,24 +67,20 @@
       }
 
       if (gExpected.length == 0) {
         setTimeout(nextTest, 0);
       }
     }
 
     function nextTest() {
-      try {
-        gTestsIterator.next();
-      } catch (err if err instanceof StopIteration) {
-        finish();
-      }
+      gTestsIterator.next();
     }
 
-    function testsIterator() {
+    function* testsIterator() {
 
       // Tests 1 + 2:
       //  Back/forward between two simple documents. Bfcache will be used.
 
       var test1Doc = "data:text/html,<html><head><title>test1</title></head>" +
                      "<body>test1</body></html>";
 
       gExpected = [{type: "pagehide", persisted: true},
@@ -261,17 +257,14 @@
                    {type: "load"},
                    {type: "pageshow", persisted: false}];
       clickIframeLink();
       yield undefined;
       
       is(gBrowser.currentURI.spec, "data:text/plain,aaa",
          "Navigation is blocked when clicking link");
 
-      // nextTest has to be called from here, as no events are fired in this
-      // step
-      setTimeout(nextTest, 0);
-      yield undefined;
+      finish();
     }
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug396519_window.xul
+++ b/docshell/test/chrome/bug396519_window.xul
@@ -87,24 +87,20 @@
       else {
         is(history.count, gExpected.length, "Wrong history length in test "+gTestCount);
       }
 
       setTimeout(nextTest, 0);
     }
 
     function nextTest() {
-      try {
-        gTestsIterator.next();
-      } catch (err if err instanceof StopIteration) {
-        finish();
-      }
+      gTestsIterator.next();
     }
 
-    function testsIterator() {
+    function* testsIterator() {
 
       // Tests 1 + 2:
       //  Back/forward between two simple documents. Bfcache will be used.
 
       var test1Doc = "data:text/html,<html><head><title>test1</title></head>" +
                      "<body>test1</body></html>";
 
       gTestCount++;
@@ -157,13 +153,15 @@
       gExpected = [false, true, true, true, false, false];
       gBrowser.goBack();
       yield undefined;
 
       gTestCount++;
       gExpected = [false, false, true, true, false, false];
       gBrowser.gotoIndex(5);
       yield undefined;
+
+      finish();
     }
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug396649_window.xul
+++ b/docshell/test/chrome/bug396649_window.xul
@@ -35,17 +35,17 @@
       tests.next();
     }
 
     ////
     // Generator function for test steps for bug 396649:  Content
     // viewers should be evicted from bfcache when going back if more
     // than MAX_BFCACHE_PAGES from the current index.
     //
-    function testIterator()
+    function* testIterator()
     {
       // Make sure bfcache is on.
       enableBFCache(true);
       
       // Load enough pages so that the first loaded is eviced from
       // the bfcache, since it is greater the MAX_BFCACHE_PAGES from
       // the current position in the session history. Verify all
       // of the pages are initially stored in the bfcache when
@@ -105,18 +105,16 @@
                             { type: "pageshow", 
                               title: "bug396649 page" + i,
                               persisted: i < MAX_BFCACHE_PAGES + 1 } ],
           onNavComplete: nextTest
         } );
         yield undefined;
       }
       
-      // Tell the framework the test is finished.  Include the final 'yield' 
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;
     }
     
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug449780_window.xul
+++ b/docshell/test/chrome/bug449780_window.xul
@@ -32,17 +32,17 @@
     /** Test for Bug 449780 **/
     var doc1 = "data:text/html,<html><body>This is a test</body></html>";
     var doc2 = "data:text/html,<html><body>This is a second test</body></html>";
 
     function getDOM(id) {
       return $(id).contentDocument.documentElement.innerHTML;
     }
 
-    var tester = (function() {
+    var tester = (function*() {
       var origDOM = getDOM("f1");
       $("f1").contentDocument.body.textContent = "Modified";
       var modifiedDOM = getDOM("f1");
       isnot(origDOM, modifiedDOM, "DOM should be different");
       $("f1").contentWindow.location.href = doc2;
       yield undefined;
 
       $("f1").goBack();
@@ -57,17 +57,16 @@
       $("f1").swapDocShells($("f2"));
       $("f2").addEventListener("pageshow", testDriver, false);
       $("f2").goBack();
       yield undefined;
 
       is(getDOM("f2"), origDOM, "Should have not have been bfcached");
       window.close();
       SimpleTest.finish();
-      yield undefined;
     })();
 
     function testDriver() {
       setTimeout(function() { tester.next() }, 0);
     }
 
     function doTheTest() {
       $("f1").addEventListener("pageshow", testDriver, false);
--- a/docshell/test/chrome/bug582176_window.xul
+++ b/docshell/test/chrome/bug582176_window.xul
@@ -21,17 +21,17 @@
     function nextTestAsync() {
       SimpleTest.executeSoon(tests.next.bind(tests));
     }
 
     ////
     // Generator function for test steps for bug 582176:
     // Description goes here.
     //
-    function testIterator()
+    function* testIterator()
     {
       var browser = document.getElementById('content');
       browser.addEventListener("pageshow", nextTestAsync, true);
 
       enableBFCache(true);
 
       var notificationCount = 0;
       var observer = {
@@ -72,17 +72,15 @@
       browser.loadURI("http://mochi.test:8888/tests/docshell/test/chrome/582176_xml.xml");
       yield undefined;
       is(browser.contentDocument.body.textContent, "xslt result",
          "Transform performed successfully");
       is(notificationCount, 3, "Should notify only once on XSLT navigation");
 
       os.removeObserver(observer, "content-document-global-created")
 
-      // Tell the framework the test is finished.  Include the final 'yield' 
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;
     }
     
   ]]></script>
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug662200_window.xul
+++ b/docshell/test/chrome/bug662200_window.xul
@@ -23,17 +23,17 @@
     function nextTest() {
       tests.next();
     }
 
     ////
     // Generator function for test steps for bug 662200:  
     // Description goes here.
     //
-    function testIterator()
+    function* testIterator()
     {
       // Load the first test page
       var navData = {
         uri: getHttpUrl("662200a.html"),
         eventsToListenFor: ["pageshow"],
         expectedEvents: [ {type: "pageshow", title: "A"} ],
         onNavComplete: nextTest
       };
@@ -112,18 +112,16 @@
       shistory.reload(0);
       yield undefined;
 
       // After this sequence of events, we should be able to go back and forward
       is(TestWindow.getBrowser().canGoBack, true, "Should be able to go back!");
       is(TestWindow.getBrowser().canGoForward, true, "Should be able to go forward!");
       is(shistory.requestedIndex, -1, "Requested index should be cleared!");
 
-      // Tell the framework the test is finished.  Include the final 'yield' 
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;
     }
     
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug690056_window.xul
+++ b/docshell/test/chrome/bug690056_window.xul
@@ -13,17 +13,17 @@
   <script type="application/javascript"><![CDATA[
     var tests = testIterator();
 
     function nextTest() {
       tests.next();
     }
 
     // Makes sure that we fire the visibilitychange events
-    function testIterator() {
+    function* testIterator() {
       // Enable bfcache
       enableBFCache(8);
 
       // Load something for a start
       doPageNavigation({
         uri: 'data:text/html,<title>initial load</title>',
         onNavComplete: nextTest
       });
@@ -160,17 +160,15 @@
                           { type: "pageshow",
                             title: "new load",
                             persisted: true },
                         ],
         onNavComplete: nextTest
       });
       yield undefined;
 
-      // Tell the framework the test is finished.  Include the final 'yield' 
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;      
     }
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug89419_window.xul
+++ b/docshell/test/chrome/bug89419_window.xul
@@ -30,17 +30,17 @@
     }
 
     ////
     // Generator function for test steps for bug 89419:
     // A visited link should have the :visited style applied
     // to it when displayed on a page which was fetched from
     // the bfcache.
     //
-    function testIterator()
+    function* testIterator()
     {
       // Load a test page containing an image referring to the sjs that returns
       // a different redirect every time it's loaded.
       doPageNavigation({
         uri: getHttpUrl("89419.html"),
         onNavComplete: nextTest,
         preventBFCache: true
       });
@@ -65,18 +65,16 @@
         onNavComplete: nextTest
       });
       yield undefined;
 
       var third = snapshotWindow(TestWindow.getWindow());
       ok(!snapshotsEqual(third, second), "going back should not be the same as about:blank");
       ok(snapshotsEqual(first, third), "going back should be the same as the initial load");
 
-      // Tell the framework the test is finished.  Include the final 'yield'
-      // statement to prevent a StopIteration exception from being thrown.
+      // Tell the framework the test is finished.
       finish();
-      yield undefined;
     }
 
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/bug92598_window.xul
+++ b/docshell/test/chrome/bug92598_window.xul
@@ -71,24 +71,20 @@
       }
 
       if (gExpected.length == 0) {
         setTimeout(nextTest, 0);
       }
     }
 
     function nextTest() {
-      try {
-        gTestsIterator.next();
-      } catch (err if err instanceof StopIteration) {
-        finish();
-      }
+      gTestsIterator.next();
     }
 
-    function testsIterator() {
+    function* testsIterator() {
       // Load a page with a no-cache header, followed by a simple page
       // On pagehide, first page should report it is not being persisted
       var test1DocURI = "http://mochi.test:8888/tests/docshell/test/chrome/92598_nostore.html";
 
       gExpected = [{type: "pagehide", persisted: true},
                    {type: "load", title: "test1"},
                    {type: "pageshow", title: "test1", persisted: false}];
       gBrowser.loadURI(test1DocURI);
@@ -106,13 +102,15 @@
 
       // Now go back in history. First page should not have been cached.
       // Check persisted property to confirm
       gExpected = [{type: "pagehide", title: "test2", persisted: true},
                    {type: "load", title: "test1"},
                    {type: "pageshow", title: "test1", persisted: false}];
       gBrowser.goBack();
       yield undefined;
+
+      finish();
     }
   ]]></script>
 
   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
 </window>
--- a/docshell/test/chrome/test_bug453650.xul
+++ b/docshell/test/chrome/test_bug453650.xul
@@ -18,33 +18,35 @@ https://bugzilla.mozilla.org/show_bug.cg
   SimpleTest.waitForExplicitFinish();
 
   var Ci = Components.interfaces;
   var Cr = Components.results;
 
   var iter = runTests();
   nextTest();
 
-  function runTests() {
+  function* runTests() {
     var iframe = document.createElement("iframe");
     iframe.style.width = "300px";
     iframe.style.height = "300px";
     iframe.setAttribute("src", "data:text/html,<h1 id='h'>hello</h1>");
 
     document.documentElement.appendChild(iframe);
     yield whenLoaded(iframe);
     info("iframe loaded");
 
     var h1 = iframe.contentDocument.getElementById("h");
     h1.style.width = "400px";
     yield waitForInterruptibleReflow(iframe.docShell);
 
     h1.style.width = "300px";
     waitForReflow(iframe.docShell);
     yield is(300, h1.offsetWidth, "h1 has correct width");
+
+    SimpleTest.finish();
   }
 
   function waitForInterruptibleReflow(docShell) {
     waitForReflow(docShell, true);
   }
 
   function waitForReflow(docShell, interruptible = false) {
     function done() {
@@ -92,21 +94,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   function whenLoaded(iframe) {
     iframe.addEventListener("load", function onLoad() {
       iframe.removeEventListener("load", onLoad);
       SimpleTest.executeSoon(nextTest);
     });
   }
 
   function nextTest() {
-    try {
-      iter.next();
-    } catch (e if e instanceof StopIteration) {
-      SimpleTest.finish();
-    }
+    iter.next();
   }
 
   ]]>
   </script>
 
   <!-- test results are displayed in the html:body -->
   <body xmlns="http://www.w3.org/1999/xhtml">
   <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=453650"
--- a/docshell/test/chrome/test_bug608669.xul
+++ b/docshell/test/chrome/test_bug608669.xul
@@ -45,17 +45,17 @@ SimpleTest.waitForExplicitFinish();
 addLoadEvent(nextTest);
 
 gen = doTest();
 
 function nextTest() {
   gen.next();
 }
 
-function doTest() {
+function* doTest() {
   var container = document.getElementById('container');
 
   setCachePref(true);
 
   var notificationCount = 0;
   var observer = {
     observe: function(aSubject, aTopic, aData) {
       is(aTopic, "chrome-document-global-created",
@@ -100,17 +100,16 @@ function doTest() {
   yield undefined;
   is(notificationCount, 3, "after window.open load");
   popup.close();
 
   setCachePref(false);
   os.removeObserver(observer, "chrome-document-global-created");
   os.removeObserver(observer, "content-document-global-created");
   SimpleTest.finish();
-  yield undefined;
 }
 
 
 
   ]]></script>
   <vbox id="container" flex="1">
     <description>Below will an iframe be added</description>
   </vbox>
--- a/docshell/test/test_bfcache_plus_hash.html
+++ b/docshell/test/test_bfcache_plus_hash.html
@@ -42,19 +42,16 @@ var expectedLoadNum = -1;
 function childLoad(n) {
   if (n == expectedLoadNum) {
     debug('Got load ' + n);
     expectedLoadNum = -1;
 
     // Spin the event loop before calling gGen.next() so the generator runs
     // outside the onload handler.  This prevents us from encountering all
     // sorts of docshell quirks.
-    //
-    // (I don't know why I need to wrap gGen.next() in a function, but it
-    // throws an error otherwise.)
     setTimeout(function() { gGen.next() }, 0);
   }
   else {
     debug('Got unexpected load ' + n);
     ok(false, 'Got unexpected load ' + n);
   }
 }
 
@@ -79,17 +76,17 @@ function waitForLoad(n) {
   expectedLoadNum = n;
 }
 
 function waitForShow(n) {
   debug('Waiting for show ' + n);
   expectedPageshowNum = n;
 }
 
-function test() {
+function* test() {
   var popup = window.open('data:text/html,' +
                           '<html><body onload="opener.childLoad(1)" ' +
                                       'onpageshow="opener.childPageshow(1)">' +
                                 'Popup 1' +
                                 '</body></html>');
   waitForLoad(1);
   yield undefined;
 
@@ -101,19 +98,16 @@ function test() {
 
   // Now go back 2.  The first page should be retrieved from bfcache.
   popup.history.go(-2);
   waitForShow(1);
   yield undefined;
 
   popup.close();
   SimpleTest.finish();
-  
-  // Yield once more so we don't throw a StopIteration exception.
-  yield undefined;
 }
 
 var gGen = test();
 gGen.next();
 
 </script>
 </pre>
 </body>
--- a/docshell/test/test_bug385434.html
+++ b/docshell/test/test_bug385434.html
@@ -192,17 +192,16 @@ function run_test() {
    *     not "complete" (bug 504837).
    */
   frameCw.document.location = "file_bug385434_3.html";
   yield undefined;
   eventExpected("Hashchange should fire even if the document " +
                 "hasn't finished loading.");
 
   SimpleTest.finish();
-  yield undefined;
 }
 
 var gGen = run_test();
 gGen.next();
 
 </script>
 </pre>
 </body>
--- a/docshell/test/test_bug475636.html
+++ b/docshell/test/test_bug475636.html
@@ -22,29 +22,29 @@ Test that refresh to data: URIs don't in
 
 SimpleTest.waitForExplicitFinish();
 
 gen = runTests();
 
 window.private = 42;
 
 window.addEventListener("message", function(e) {
-  gen.send(e.data);
+  gen.next(e.data);
 }, false);
 
 var url = "file_bug475636.sjs?";
 
-function runTests() {
+function* runTests() {
   var loader = document.getElementById('loader');
   for (var testNum = 1; ; ++testNum) {
     loader.src = url + testNum;
     let res = (yield);
     if (res == "done") {
       SimpleTest.finish();
-      yield undefined;
+      return;
     }
     is(res, "pass");
   }
 }
 
 
 </script>
 </pre>
--- a/docshell/test/test_bug509055.html
+++ b/docshell/test/test_bug509055.html
@@ -35,17 +35,17 @@ function onChildHashchange(e) {
     gGen.next();
 }
 
 function onChildLoad(e) {
   if(gGen)
     gGen.next();
 }
 
-function runTest() {
+function* runTest() {
   var popup = window.open("file_bug509055.html", "popup 0",
                            "height=200,width=200,location=yes," +
                            "menubar=yes,status=yes,toolbar=yes,dependent=yes");
   popup.hashchangeCallback = onChildHashchange;
   popup.onload = onChildLoad;
   dump('Waiting for initial load.\n');
   yield undefined;
 
@@ -77,18 +77,16 @@ function runTest() {
 
   // Get the title of the inner popup's current SHEntry 
   var sheTitle = sh.getEntryAtIndex(sh.index, false).title;
   is(sheTitle, "Changed", "SHEntry's title should change when we change.");
 
   popup.close();
 
   SimpleTest.executeSoon(SimpleTest.finish);
-  dump('Final yield.\n');
-  yield undefined;
 }
 
 window.addEventListener('load', function() {
   gGen = runTest();
   gGen.next();
 }, false);
 
 </script>
--- a/docshell/test/test_bug640387_1.html
+++ b/docshell/test/test_bug640387_1.html
@@ -10,17 +10,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=640387">Mozilla Bug 640387</a>
 
 <script type='application/javascript;version=1.7'>
 SimpleTest.waitForExplicitFinish();
 
-function test() {
+function* test() {
   /* Spin the event loop so we get out of the onload handler. */
   SimpleTest.executeSoon(function() { gGen.next() });
   yield undefined;
 
   popup.history.pushState('', '', '#hash1');
   popup.history.pushState('', '', '#hash2');
 
   // Now the history looks like:
@@ -66,17 +66,16 @@ function test() {
   gCallbackOnPopstate = false;
 
   // Spin the event loop so hashchange has a chance to fire, if it's going to.
   SimpleTest.executeSoon(function() { gGen.next() });
   yield undefined;
 
   popup.close();
   SimpleTest.finish();
-  yield undefined;
 }
 
 gGen = null;
 function childLoad() {
   gGen = test();
   gGen.next();
 }
 
--- a/docshell/test/test_bug640387_2.html
+++ b/docshell/test/test_bug640387_2.html
@@ -40,17 +40,17 @@ function childHashchange() {
     ok(false, 'Got unexpected hashchange.');
   }
   if (callbackOnHashchange) {
     callbackOnHashchange = false;
     gGen.next();
   }
 }
 
-function run_test() {
+function* run_test() {
   var iframe = $('iframe').contentWindow;
 
   ok(true, 'Got first load');
 
   // Spin the event loop so we exit the onload handler.
   SimpleTest.executeSoon(function() { gGen.next() });
   yield undefined;
 
@@ -71,17 +71,16 @@ function run_test() {
 
   ok(true, 'Got final load.');
 
   // Spin the event loop to give hashchange a chance to fire, if it's going to.
   SimpleTest.executeSoon(function() { gGen.next() });
   yield undefined;
 
   SimpleTest.finish();
-  yield undefined;
 }
 
 callbackOnLoad = true;
 gGen = run_test();
 
 </script>
 
 <iframe id='iframe' src='file_bug640387.html'></iframe>
--- a/docshell/test/test_bug669671.html
+++ b/docshell/test/test_bug669671.html
@@ -60,17 +60,17 @@ function checkPopupLoadCount()
   // because we didn't do a load we should have, let's not cause a cascade of
   // failures by incrementing _loadCount.
   var origCount = _loadCount;
   if (popup.document.body.innerHTML >= _loadCount + '')
     _loadCount++;
   return origCount;
 }
 
-function test()
+function* test()
 {
   // Step 0 - Make sure the count is reset to 0 in case of reload
   popup.location = 'file_bug669671.sjs?countreset';
   yield;
   is(popup.document.body.innerHTML, '0',
      'Load count should be reset to 0');
 
   // Step 1 - The popup's body counts how many times we've requested the
@@ -127,17 +127,16 @@ function test()
   checkPopupLoadCount();
   SpecialPowers.wrap(popup).back();
   yield undefined;
   is(popup.document.body.innerHTML, initialCount + '',
      'Load count (should be cached)');
   popup.close();
 
   SimpleTest.finish();
-  yield undefined;
 }
 
 // This will call into onChildLoad once it loads.
 var popup = window.open('file_bug669671.sjs?pushed');
 
 var gGen = test();
 
 </script>