Bug 1321222 - Remove legacy generator from js/xpconnect/. r=mrbkap
authorTooru Fujisawa <arai_a@mac.com>
Thu, 01 Dec 2016 18:12:14 +0900
changeset 324985 5d5c575b4a262e56077f05ca8a6c596a0409c5ac
parent 324984 d29194b9a835f320ddfb8507db29a089375bd3e6
child 324986 9296b223a23dd1ffb510c628bf965896beadf222
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmrbkap
bugs1321222
milestone53.0a1
Bug 1321222 - Remove legacy generator from js/xpconnect/. r=mrbkap
js/xpconnect/tests/chrome/test_bug853571.xul
js/xpconnect/tests/mochitest/test_bug505915.html
--- a/js/xpconnect/tests/chrome/test_bug853571.xul
+++ b/js/xpconnect/tests/chrome/test_bug853571.xul
@@ -16,17 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
   /** Test for Bug 853571 **/
   SimpleTest.waitForExplicitFinish();
   const Cu = Components.utils;
 
-  function mainTest() {
+  function* mainTest() {
     var iwin = $('ifr').contentWindow;
 
     // Test with a simple sandbox with no prototype.
     checkSource(iwin, new Cu.Sandbox(iwin), null, "should get null source with no sandboxPrototype");
     yield;
 
     // Test with a sandboxPrototype.
     checkSource(iwin, new Cu.Sandbox(iwin, { sandboxPrototype: iwin }), iwin, "should be able to impersonate the prototype");
@@ -41,19 +41,18 @@ https://bugzilla.mozilla.org/show_bug.cg
     gen = mainTest();
     gen.next();
   }
 
   function checkSource(target, sb, expectedSource, message) {
     target.addEventListener("message", function listener(event) {
       target.removeEventListener("message", listener);
       is(event.source, expectedSource, message);
-      try {
-        gen.next();
-      } catch (e if e instanceof StopIteration) {
+      let {done} = gen.next();
+      if (done) {
         // We're done.
       }
     });
 
     sb.target = target;
     Cu.evalInSandbox("target.postMessage('foo', '*');", sb);
   }
 
--- a/js/xpconnect/tests/mochitest/test_bug505915.html
+++ b/js/xpconnect/tests/mochitest/test_bug505915.html
@@ -13,17 +13,19 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script type="application/javascript;version=1.7">
 
 /** Test for Bug 505915 **/
-window.addEventListener("message", function () { gen.next() }, false);
+window.addEventListener("message", function () {
+  ok(false, "should not receive message");
+}, false);
 
 function go() {
     var ifr = $('ifr');
     try {
         // NB: the contentDocument getter now returns null for cross-origin
         // frames, so use SpecialPowers to get a security wrapper to the document.
         var xdoc = SpecialPowers.unwrap(SpecialPowers.wrap(ifr).contentDocument)
         document.createTreeWalker(xdoc, 0, null);
@@ -31,20 +33,19 @@ function go() {
     } catch (e) {
         ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e) ||
            /TypeError: Argument 1 of Document.createTreeWalker does not implement interface Node/.test(e),
            "threw a security exception or binding exception instead of an " +
            "invalid child exception");
     }
 
     SimpleTest.finish();
-    yield;
 }
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 
-<iframe id="ifr" onload="gen = go(); gen.next();" src="http://example.org/"></iframe>
+<iframe id="ifr" onload="go();" src="http://example.org/"></iframe>
 
 </body>
 </html>