Bug 1321227 - Remove legacy generator from parser/. r=wchen
authorTooru Fujisawa <arai_a@mac.com>
Thu, 01 Dec 2016 18:12:14 +0900
changeset 324986 9296b223a23dd1ffb510c628bf965896beadf222
parent 324985 5d5c575b4a262e56077f05ca8a6c596a0409c5ac
child 324987 fc40e02bb78ead28d05158c2b52cfbf84296d135
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerswchen
bugs1321227
milestone53.0a1
Bug 1321227 - Remove legacy generator from parser/. r=wchen
parser/htmlparser/tests/mochitest/parser_datreader.js
parser/htmlparser/tests/mochitest/parser_web_testrunner.js
--- a/parser/htmlparser/tests/mochitest/parser_datreader.js
+++ b/parser/htmlparser/tests/mochitest/parser_datreader.js
@@ -78,17 +78,17 @@ function parseTestcase(testcase) {
 
 /**
  * A generator function that accepts a list of strings. Each list
  * member corresponds to the contents of a ".dat" file from the
  * html5lib test suite.
  *
  * @param The list of strings
  */
-function test_parser(testlist) {
+function* test_parser(testlist) {
   for (var testgroup of testlist) {
     var tests = testgroup.split("#data\n");
     tests = tests.filter(test => test).map(test => "#data\n" + test);
     for (var test of tests) {
       yield parseTestcase(test);
     }
   }
 }
--- a/parser/htmlparser/tests/mochitest/parser_web_testrunner.js
+++ b/parser/htmlparser/tests/mochitest/parser_web_testrunner.js
@@ -95,31 +95,32 @@ function makeFragmentTestChecker(input,
     }
     nextTest(testframe);
   } 
 }
 
 var testcases;
 function nextTest(testframe) {
   var test = 0;
-  try {
-    var [input, output, errors, fragment] = testcases.next();
-    if (fragment) {
-      asyncRun(makeFragmentTestChecker(input, 
-                                       output, 
-                                       errors, 
-                                       fragment, 
-                                       testframe));
-    } else {
-      dataURL = "data:text/html;charset=utf-8," + encodeURIComponent(input);
-      testframe.onload = makeTestChecker(input, output, errors);
-      testframe.src = dataURL;
-    }
-  } catch (err if err instanceof StopIteration) {
+  var {done, value} = testcases.next();
+  if (done) {
     SimpleTest.finish();
+    return;
+  }
+  var [input, output, errors, fragment] = value;
+  if (fragment) {
+    asyncRun(makeFragmentTestChecker(input, 
+                                     output, 
+                                     errors, 
+                                     fragment, 
+                                     testframe));
+  } else {
+    dataURL = "data:text/html;charset=utf-8," + encodeURIComponent(input);
+    testframe.onload = makeTestChecker(input, output, errors);
+    testframe.src = dataURL;
   }
 }
 
 var testFileContents = [];
 function loadNextTestFile() {
   var datFile = parserDatFiles.shift();
   if (datFile) {
     var xhr = new XMLHttpRequest();