Bug 1110759 - Remove Iterator() from some tests. r=smaug

This commit is contained in:
Tom Schuster 2015-01-08 19:58:45 +01:00
parent 94ec2143c9
commit b7974c146f
6 changed files with 45 additions and 45 deletions

View File

@ -122,16 +122,12 @@ var AccessFuTest = {
},
nextTest: function AccessFuTest_nextTest() {
var testFunc;
try {
// Get the next test function from the iterator. If none left,
// StopIteration exception is thrown.
testFunc = gIterator.next()[1];
} catch (ex) {
// StopIteration exception.
var result = gIterator.next();
if (result.done) {
this.finish();
return;
}
var testFunc = result.value;
testFunc();
},
@ -143,7 +139,11 @@ var AccessFuTest = {
}
// Create an Iterator for gTestFuncs array.
gIterator = Iterator(gTestFuncs); // jshint ignore:line
gIterator = (function*() {
for (var testFunc of gTestFuncs) {
yield testFunc;
}
})();
// Start AccessFu and put it in stand-by.
Components.utils.import("resource://gre/modules/accessibility/AccessFu.jsm");

View File

@ -167,7 +167,13 @@ function runSocialTestWithProvider(manifest, callback, finishcallback) {
}
function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) {
let testIter = Iterator(tests);
let testIter = (function*() {
for (let name in tests) {
if (tests.hasOwnProperty(name)) {
yield [name, tests[name]];
}
}
})();
let providersAtStart = Social.providers.length;
info("runSocialTests: start test run with " + providersAtStart + " providers");
window.focus();
@ -182,16 +188,15 @@ function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) {
}
function runNextTest() {
let name, func;
try {
[name, func] = testIter.next();
} catch (err if err instanceof StopIteration) {
let result = testIter.next();
if (result.done) {
// out of items:
(cbFinish || defaultFinishChecks)();
is(providersAtStart, Social.providers.length,
"runSocialTests: finish test run with " + Social.providers.length + " providers");
return;
}
let [name, func] = result.value;
// We run on a timeout as the frameworker also makes use of timeouts, so
// this helps keep the debug messages sane.
executeSoon(function() {

View File

@ -94,21 +94,17 @@ function test() {
}
function runNextSpinTest() {
try {
var [index, test] = spinTests.next();
test();
} catch(e) {
if (e == StopIteration) {
SimpleTest.finish();
return; // We're all done
}
throw e;
var test = spinTests.shift();
if (!test) {
SimpleTest.finish();
return;
}
test();
}
const SETTIMEOUT_DELAY = 500;
var spinTests = Iterator([
var spinTests = [
// Test spining when the mouse button is kept depressed on the spin-up
// button, then moved over the spin-down button:
function() {
@ -192,7 +188,7 @@ var spinTests = Iterator([
}, false);
synthesizeMouse(input, SPIN_DOWN_X, SPIN_DOWN_Y, { type: "mousedown" });
}
]);
];
</script>
</pre>

View File

@ -17,12 +17,12 @@
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runNextTest, window);
const kTests = Iterator([
const kTests = [
{ type: "text", value: "foo", key: "b", expectedNewValue: "foo" },
{ type: "number", value: "123", key: "4", expectedNewValue: "123" },
{ type: "number", value: "123", key: KeyEvent.DOM_VK_UP, expectedNewValue: "123" },
{ type: "number", value: "123", key: KeyEvent.DOM_VK_DOWN, expectedNewValue: "123" },
]);
];
function sendUntrustedKeyEvent(eventType, keyCode, target) {
var evt = document.createEvent("KeyboardEvent");
@ -70,14 +70,11 @@ function runNextTest() {
gotEvents.keyup = false;
gotEvents.keypress = false;
try {
var [index, test] = kTests.next();
} catch(e) {
if (e == StopIteration) {
SimpleTest.finish();
return; // We're all done
}
throw e;
var test = kTests.shift();
if (!test) {
SimpleTest.finish();
return; // We're all done
}
input.type = test.type;

View File

@ -13,7 +13,13 @@ let SocialService = Components.utils.import("resource://gre/modules/SocialServic
// foo: function(cbnext) {... cbnext();}
// }
function runTests(tests, cbPreTest, cbPostTest, cbFinish) {
let testIter = Iterator(tests);
let testIter = (function*() {
for (let name in tests) {
if (tests.hasOwnProperty(name)) {
yield [name, tests[name]];
}
}
})();
if (cbPreTest === undefined) {
cbPreTest = function(cb) {cb()};
@ -23,14 +29,13 @@ function runTests(tests, cbPreTest, cbPostTest, cbFinish) {
}
function runNextTest() {
let name, func;
try {
[name, func] = testIter.next();
} catch (err if err instanceof StopIteration) {
let result = testIter.next();
if (result.done) {
// out of items:
(cbFinish || finish)();
return;
}
let [name, func] = result.value;
// We run on a timeout as the frameworker also makes use of timeouts, so
// this helps keep the debug messages sane.
executeSoon(function() {

View File

@ -329,18 +329,15 @@ var tests = [
]
function runTests() {
var testIter = Iterator(tests);
function runNextTest() {
let name, anchorPos, test;
try {
let index;
[index, [name, anchorPos, test]] = testIter.next();
} catch (err if err instanceof StopIteration) {
let result = tests.shift();
if (!result) {
// out of tests
panel.hidePopup();
SimpleTest.finish();
return;
}
let [name, anchorPos, test] = result;
SimpleTest.info("sub-test " + anchorPos + "." + name + " starting");
// first arrange for the anchor to be where the test requires it.
panel.hidePopup();