Bug 804834 - Part 1: Fix tests depending on E4X for-each in content JS. r=waldo

This commit is contained in:
Masatoshi Kimura 2012-12-21 20:47:52 +09:00
parent e37969e6b1
commit 2a245d47d2
78 changed files with 162 additions and 160 deletions

View File

@ -88,11 +88,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=377611
var feeds = [];
for each (var aFeed in discovered) {
for (var aFeed of discovered) {
feeds[aFeed.href] = true;
}
for each (var aLink in document.getElementsByTagName("link")) {
for (var aLink of document.getElementsByTagName("link")) {
// ignore real stylesheets, and anything without an href property
if (aLink.type != "text/css" && aLink.href) {
if (/bogus/i.test(aLink.title)) {

View File

@ -25,7 +25,7 @@ window.addEventListener("message", function(e) {
};
var xhr = new XMLHttpRequest();
for each(type in ["load", "abort", "error", "loadstart", "loadend"]) {
for (type of ["load", "abort", "error", "loadstart", "loadend"]) {
xhr.addEventListener(type, function(e) {
res.events.push(e.type);
}, false);

View File

@ -14,7 +14,7 @@ window.addEventListener("message", function(e) {\n\
};\n\
\n\
var xhr = new XMLHttpRequest();\n\
for each(type in ["load", "abort", "error", "loadstart", "loadend"]) {\n\
for (type of ["load", "abort", "error", "loadstart", "loadend"]) {\n\
xhr.addEventListener(type, function(e) {\n\
res.events.push(e.type);\n\
}, false);\n\

View File

@ -572,7 +572,7 @@ function runTest() {
tests = [];
}
for each(test in tests) {
for (test of tests) {
var req = {
url: baseURL + "allowOrigin=" + escape(test.origin || origin),
method: test.method,
@ -787,7 +787,7 @@ function runTest() {
tests = [];
}
for each(test in tests) {
for (test of tests) {
req = {
url: baseURL + "allowOrigin=" + escape(test.origin || origin),
method: test.method,
@ -1112,7 +1112,7 @@ function runTest() {
tests = [];
}
for each(test in tests) {
for (test of tests) {
req = {
url: test.hops[0].server + basePath + "hop=1&hops=" +
escape(test.hops.toSource()),

View File

@ -432,7 +432,7 @@ function runTest() {
setStateURL = baseURL + "setState=";
var unique = Date.now();
for each (test in tests) {
for (test of tests) {
if (test.newTest) {
unique++;
continue;

View File

@ -64,7 +64,7 @@ function runTest() {
basePath = "/tests/content/base/test/file_CrossSiteXHR_server.sjs?"
baseURL = "http://mochi.test:8888" + basePath;
for each(originEntry in origins) {
for (originEntry of origins) {
origin = originEntry.origin || originEntry.server;
loader.src = originEntry.file ||
@ -113,7 +113,7 @@ function runTest() {
failTests = failTests.filter(function(v) { return v != origin });
}
for each(allowOrigin in passTests) {
for (allowOrigin of passTests) {
req = {
url: baseURL +
"allowOrigin=" + escape(allowOrigin) +
@ -136,7 +136,7 @@ function runTest() {
"wrong responseText in test for " + allowOrigin);
}
for each(allowOrigin in failTests) {
for (allowOrigin of failTests) {
req = {
url: baseURL + "allowOrigin=" + escape(allowOrigin),
method: "GET",

View File

@ -213,7 +213,7 @@ for (var i = 0; i < testDOMFiles.length; i++) {
}
try {
for each(test in tests) {
for (test of tests) {
xhr = new XMLHttpRequest;
xhr.open("POST", "file_XHRSendData.sjs", !!test.resType);
if (test.contentType)

View File

@ -52,11 +52,11 @@ function checkPrincipal() {
addLoadEvent(function() {
checkPrincipal();
for each (var i in [ "one", "two", "three", "four" ]) {
for (var i of [ "one", "two", "three", "four" ]) {
doPrincipalTest(i);
}
for each (i in [ "five", "six" ]) {
for (i of [ "five", "six" ]) {
doContentTest(i);
}

View File

@ -30,7 +30,7 @@ var body = [
isupports_string
];
for each (var i in body) {
for (var i of body) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
if (i == isupports_string)

View File

@ -25,7 +25,7 @@ addLoadEvent(function() {
const scriptContainers = ["div", "iframe", "noframes", "noembed"];
for (var i = 0; i < scriptContainers.length; ++i) {
for each (var func in scriptCreationFuncs) {
for (var func of scriptCreationFuncs) {
var cont = scriptContainers[i];
var node = document.createElement(cont);
document.body.appendChild(node);

View File

@ -12,7 +12,7 @@
function test_method(context, method, arity) {
function testParams(existingParams, depth) {
for each (var arg in stringArgs) {
for (var arg of stringArgs) {
var code = "context[method](" + existingParams + arg + ")";
try {
eval(code);

View File

@ -36,7 +36,7 @@ addLoadEvent(function() {
/** @see test_bug336682.js */
MAX_STATE = 4;
for each(var event in ["online", "offline"]) {
for (var event of ["online", "offline"]) {
document.body.addEventListener(
event,
makeHandler("document.body.addEventListener('%1', ..., false)",

View File

@ -77,7 +77,7 @@ function sendTouchEvent(windowUtils, aType, aEvent, aModifiers) {
var ids = [], xs=[], ys=[], rxs = [], rys = [],
rotations = [], forces = [];
for each (var touchType in ["touches", "changedTouches", "targetTouches"]) {
for (var touchType of ["touches", "changedTouches", "targetTouches"]) {
for (var i = 0; i < aEvent[touchType].length; i++) {
if (ids.indexOf(aEvent[touchType][i].identifier) == -1) {
ids.push(aEvent[touchType][i].identifier);

View File

@ -72,7 +72,7 @@ function sendTouchEvent(windowUtils, aType, aEvent, aModifiers) {
var ids = [], xs=[], ys=[], rxs = [], rys = [],
rotations = [], forces = [];
for each (var touchType in ["touches", "changedTouches", "targetTouches"]) {
for (var touchType of ["touches", "changedTouches", "targetTouches"]) {
for (var i = 0; i < aEvent[touchType].length; i++) {
if (ids.indexOf(aEvent[touchType][i].identifier) == -1) {
ids.push(aEvent[touchType][i].identifier);

View File

@ -7,7 +7,7 @@
var body = document.body;
var elements = ["input", "textarea", "select", "button"];
for each (var e in elements) {
for (var e of elements) {
var el = document.createElement(e);
el.autofocus = true;
body.appendChild(el);

View File

@ -407,7 +407,7 @@ var todoElements = [
['keygen', 'Keygen'],
];
for each(var e in todoElements) {
for (var e of todoElements) {
var node = document.createElement(e[0]);
var nodeString = HTMLElement.prototype.toString.apply(node);
nodeString = nodeString.replace(/Element[\] ].*/, "Element");
@ -415,22 +415,22 @@ for each(var e in todoElements) {
e[0] + " should not be implemented");
}
for each(var name in elementNames) {
for (var name of elementNames) {
var elements = [
document.createElement(name),
document.createElement(name),
];
for each(var func in functions) {
for (var func of functions) {
// Clean-up.
while (content.firstChild) {
content.removeChild(content.firstChild);
}
for each(form in forms) {
for (form of forms) {
content.appendChild(form);
form.removeAttribute('id');
}
for each(e in elements) {
for (e of elements) {
content.appendChild(e);
e.removeAttribute('form');
is(e.form, null, "The element should not have a form owner");
@ -459,7 +459,7 @@ for each(var name in elementNames) {
}
// Cleaning-up.
for each(e in elements) {
for (e of elements) {
e.parentNode.removeChild(e);
e = null;
}

View File

@ -144,7 +144,7 @@ legalCharacters += "0123456789";
legalCharacters += "!#$%&'*+-/=?^_`{|}~.";
// Add all username legal characters individually to the list.
for each (c in legalCharacters) {
for (c of legalCharacters) {
values.push([c + "@bar.com", true]);
}
// Add the concatenation of all legal characters too.
@ -152,7 +152,7 @@ values.push([legalCharacters + "@bar.com", true]);
// Add username illegal characters, the same way.
var illegalCharacters = "()<>[]:;@\\, \t";
for each (c in illegalCharacters) {
for (c of illegalCharacters) {
values.push([illegalCharacters + "@bar.com", false]);
}
@ -164,7 +164,7 @@ legalCharacters += "0123456789";
legalCharacters += "-";
// Add domain legal characters (except '.' because it's special).
for each (c in legalCharacters) {
for (c of legalCharacters) {
values.push(["foo@foo.bar" + c, true]);
}
// Add the concatenation of all legal characters too.
@ -172,7 +172,7 @@ values.push(["foo@bar.com" + legalCharacters, true]);
// Add domain illegal characters.
illegalCharacters = "()<>[]:;@\\,!#$%&'*+/=?^_`{|}~ \t";
for each (c in illegalCharacters) {
for (c of illegalCharacters) {
values.push(['foo@foo.ba' + c + 'r', false]);
}

View File

@ -235,7 +235,7 @@ var tests = [ test1, test2, test3, test4, test5, test6, test7, test8, test9,
test0();
for each (var test in tests) {
for (var test of tests) {
var content = document.getElementById('content');
// Clean-up.

View File

@ -107,7 +107,7 @@ addLoadEvent(function () {
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms", true]]}, function() {
input.type = "number";
for each (data in validData) {
for (data of validData) {
input.value = "";
SpecialPowers.focus(input);
sendString(data);
@ -115,7 +115,7 @@ addLoadEvent(function () {
is(input.value, data, "valid user input should not be sanitized");
}
for each (data in invalidData) {
for (data of invalidData) {
input.value = "";
SpecialPowers.focus(input);
sendString(data);

View File

@ -79,7 +79,7 @@ function checkValidity(aElement, aValidity, aApply, aRangeApply)
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms", true]]}, function() {
for each (var data in types) {
for (var data of types) {
input.type = data[0];
var apply = data[1];

View File

@ -86,7 +86,7 @@ function checkValueAttribute()
var element = document.createElement('meter');
for each(var test in tests) {
for (var test of tests) {
if (test[2]) {
element.setAttribute('max', test[2]);
}
@ -118,7 +118,7 @@ function checkMinAttribute()
var element = document.createElement('meter');
for each(var test in tests) {
for (var test of tests) {
checkAttribute(element, 'min', test[0], test[1]);
}
}
@ -144,7 +144,7 @@ function checkMaxAttribute()
var element = document.createElement('meter');
for each(var test in tests) {
for (var test of tests) {
if (test[2]) {
element.setAttribute('min', test[2]);
}
@ -181,7 +181,7 @@ function checkLowAttribute()
var element = document.createElement('meter');
for each(var test in tests) {
for (var test of tests) {
if (test[2]) {
element.setAttribute('min', test[2]);
}
@ -222,7 +222,7 @@ function checkHighAttribute()
var element = document.createElement('meter');
for each(var test in tests) {
for (var test of tests) {
if (test[2]) {
element.setAttribute('min', test[2]);
}
@ -263,7 +263,7 @@ function checkOptimumAttribute()
var element = document.createElement('meter');
for each(var test in tests) {
for (var test of tests) {
if (test[2]) {
element.setAttribute('min', test[2]);
}

View File

@ -79,7 +79,7 @@ function checkValidity(aElement, aValidity, aApply, aRangeApply)
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms", true]]}, function() {
for each (var data in types) {
for (var data of types) {
input.type = data[0];
var apply = data[1];

View File

@ -105,19 +105,19 @@ function checkMozIsTextFieldValueTodo(aInput, aResult)
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms", true]]}, function() {
// Check if the method is defined for the correct elements.
for each (data in gElementTestData) {
for (data of gElementTestData) {
checkMozIsTextFieldDefined(data[0], data[1]);
}
// Check if the method returns the correct value.
var input = document.createElement('input');
for each (data in gInputTestData) {
for (data of gInputTestData) {
input.type = data[0];
checkMozIsTextFieldValue(input, data[1]);
}
// Check for the todo's.
for each (data in gInputTodoData) {
for (data of gInputTodoData) {
input.type = data[0];
checkMozIsTextFieldValueTodo(input, data[1]);
}

View File

@ -268,18 +268,18 @@ var invalidTypes = Array('checkbox', 'radio', 'file', 'number');
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms", true]]}, function() {
for each (type in validTypes) {
for (type of validTypes) {
input.type = type;
completeValidityCheck(input, false);
checkPatternValidity(input);
}
for each (type in barredTypes) {
for (type of barredTypes) {
input.type = type;
completeValidityCheck(input, true, true);
}
for each (type in invalidTypes) {
for (type of invalidTypes) {
input.type = type;
completeValidityCheck(input, true);
}

View File

@ -85,7 +85,7 @@ function checkValueAttribute()
var element = document.createElement('progress');
for each(var test in tests) {
for (var test of tests) {
if (test[2]) {
element.setAttribute('max', test[2]);
}
@ -114,7 +114,7 @@ function checkMaxAttribute()
var element = document.createElement('progress');
for each(var test in tests) {
for (var test of tests) {
checkAttribute(element, 'max', test[0], test[1]);
}
}
@ -165,7 +165,7 @@ function checkPositionAttribute()
var element = document.createElement('progress');
for each(var test in tests) {
for (var test of tests) {
checkPositionValue(element, test[0], test[1], test[2], test[3]);
}
}
@ -206,7 +206,7 @@ function checkIndeterminatePseudoClass()
var element = document.createElement('progress');
for each(var test in tests) {
for (var test of tests) {
checkIndeterminate(element, test[0], test[1], test[2]);
}
}

View File

@ -358,14 +358,14 @@ checkTextareaRequiredValidity();
// First of all, checks for types that make the element barred from
// constraint validation.
var typeBarredFromConstraintValidation = ["hidden", "button", "reset", "submit", "image"];
for each (type in typeRequireNotApply) {
for (type of typeBarredFromConstraintValidation) {
checkInputRequiredNotApply(type, true);
}
// Then, checks for the types which do not use the required attribute.
// TODO: check 'color' and 'range' when they will be implemented.
var typeRequireNotApply = [];
for each (type in typeRequireNotApply) {
for (type of typeRequireNotApply) {
checkInputRequiredNotApply(type, false);
}
@ -375,7 +375,7 @@ for each (type in typeRequireNotApply) {
var typeRequireApply = ["text", "password", "search", "tel", "email", "url",
"number"];
for each (type in typeRequireApply) {
for (type of typeRequireApply) {
checkInputRequiredValidity(type);
}

View File

@ -76,7 +76,7 @@ function checkValidity(aElement, aValidity, aApply, aData)
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms", true]]}, function() {
for each (var data in types) {
for (var data of types) {
var input = getFreshElement(data[0]);
var apply = data[1];

View File

@ -66,7 +66,7 @@ function checkAvailability()
var element = document.createElement("input");
element.setAttribute('value', '0');
for each (data in testData) {
for (data of testData) {
var exceptionCaught = false;
element.type = data[0];
try {
@ -85,7 +85,7 @@ function checkAvailability()
is(exceptionCaught, !data[1], "stepUp() availability is not correct");
}
for each (data in todoList) {
for (data of todoList) {
var exceptionCaught = false;
element.type = data[0];
try {
@ -180,7 +180,7 @@ function checkStepDownForNumber()
[ '1', '2', null, null, null, '-1', false ],
];
for each (var data in testData) {
for (var data of testData) {
var element = document.createElement("input");
element.type = 'number';
@ -290,7 +290,7 @@ function checkStepUpForNumber()
[ '1', '2', null, null, null, '3', false ],
];
for each (var data in testData) {
for (var data of testData) {
var element = document.createElement("input");
element.type = 'number';

View File

@ -60,7 +60,7 @@ function checkAvailability()
];
for each (data in testData) {
for (data of testData) {
var exceptionCatched = false;
element.type = data[0];
try {
@ -81,7 +81,7 @@ function checkAvailability()
" availability is not correct");
}
for each (data in todoList) {
for (data of todoList) {
var exceptionCatched = false;
element.type = data[0];
try {
@ -124,7 +124,7 @@ function checkGet()
];
element.type = "number";
for each (data in testData) {
for (data of testData) {
element.value = data[0];
if (data[1] != null) {
is(element.valueAsNumber, data[1], "valueAsNumber should return the " +
@ -153,7 +153,7 @@ function checkSet()
];
element.type = "number";
for each (data in testData) {
for (data of testData) {
element.valueAsNumber = data[0];
if (data[1] != null) {
is(element.value, data[1],

View File

@ -156,7 +156,7 @@ function reflectUnsignedInt(aParameters)
var values = [ 1, 3, 42, 2147483647 ];
for each (var value in values) {
for (var value of values) {
element[attr] = value;
is(element[attr], value, "." + attr + " should be equals " + value);
is(element.getAttribute(attr), value,
@ -188,7 +188,7 @@ function reflectUnsignedInt(aParameters)
[ 3147483647, 3147483647 ],
];
for each (var values in nonValidValues) {
for (var values of nonValidValues) {
element[attr] = values[0];
is(element.getAttribute(attr), values[1],
"@" + attr + " should be equals to " + values[1]);
@ -196,7 +196,7 @@ function reflectUnsignedInt(aParameters)
"." + attr + " should be equals to " + defaultValue);
}
for each (var values in nonValidValues) {
for (var values of nonValidValues) {
element.setAttribute(attr, values[0]);
is(element.getAttribute(attr), values[0],
"@" + attr + " should be equals to " + values[0]);

View File

@ -75,7 +75,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=274626
"textarea_enabled", "textarea_disabled", "select_enabled",
"select_disabled", "fieldset_enabled", "fieldset_disabled"];
for each(id in controls) {
for (id of controls) {
var ctrl = document.getElementById(id);
ctrl.addEventListener('mousemove', HandlesMouseMove, false);
ctrl.handlesMouseMove = false;

View File

@ -78,7 +78,7 @@ const objectIfaces = [
];
var objectIfaces2 = [];
for each (var iface in objectIfaces) {
for (var iface of objectIfaces) {
objectIfaces2.push(iface);
}
objectIfaces2.push("nsIImageLoadingContent");
@ -227,7 +227,7 @@ function tagName(aTag) {
return "<" + aTag + ">";
}
for each (var tag in allTags) {
for (var tag of allTags) {
var node = document.createElement(tag);
// Have to use the proto's toString(), since HTMLAnchorElement and company
@ -249,7 +249,7 @@ for each (var tag in allTags) {
tagName(tag) + " is an instance of nsIDOMHTMLUnknownElement");
// Check that each node QIs to all the things we expect it to QI to
for each (var iface in interfaces[tag].concat(interfacesNonClassinfo[tag])) {
for (var iface of interfaces[tag].concat(interfacesNonClassinfo[tag])) {
is(iface in SpecialPowers.Ci, true,
iface + " not in Components.interfaces");
is(node instanceof SpecialPowers.Ci[iface], true,
@ -265,14 +265,14 @@ for each (var tag in allTags) {
map(function(id) { return SpecialPowers.Components.interfacesByID[id].toString(); });
// Make sure that we know about all the things classinfo claims
for each (var classInfoInterface in classInfoInterfaces) {
for (var classInfoInterface of classInfoInterfaces) {
isnot(interfaces[tag].indexOf(classInfoInterface), -1,
"Should know about " + tagName(tag) + " implementing " +
classInfoInterface);
}
// And make sure classinfo claims all the things we know about
for each (iface in interfaces[tag]) {
for (iface of interfaces[tag]) {
isnot(classInfoInterfaces.indexOf(iface), -1,
"Classinfo for " + tagName(tag) + " should claim to implement " +
iface);

View File

@ -433,7 +433,7 @@ function testElements(parent, tags, shouldBeFocusable)
focusable = focusableInContentEditable;
}
for each (var tag in tags) {
for (var tag of tags) {
parent.ownerDocument.body.focus();
if (focusableElementsTODO.indexOf(tag) > -1) {

View File

@ -36,7 +36,7 @@ function setFileInputs () {
SpecialPowers.wrap(singleFileInput).mozSetFileNameArray([f.path], 1);
var input2FileNames = [];
for each (file in input2Files) {
for (file of input2Files) {
f = createFileWithData(file.name, file.body);
input2FileNames.push(f.path);
}

View File

@ -89,7 +89,7 @@ function checkSanitizing(element)
"1.234567898765432",
];
for each (value in testData) {
for (value of testData) {
element.setAttribute('value', value);
is(element.value, sanitizeValue(type, value),
"The value has not been correctly sanitized for type=" + type);
@ -133,7 +133,7 @@ function checkSanitizing(element)
var pref = SpecialPowers.getBoolPref("dom.experimental_forms");
SpecialPowers.setBoolPref("dom.experimental_forms", true);
for each (type in inputTypes) {
for (type of inputTypes) {
var form = document.forms[0];
var element = document.createElement("input");
element.style.display = "none";
@ -155,7 +155,7 @@ for each (type in inputTypes) {
form.removeChild(element);
}
for each (type in todoTypes) {
for (type of todoTypes) {
// The only meaning of this is to have a failure when new types are introduced
// so we will know we have to write the tests here.
var form = document.forms[0];

View File

@ -162,7 +162,7 @@ function test1()
gHandled = 0;
// Initialize children without click expected.
for each(var name in elementsPreventingClick) {
for (var name of elementsPreventingClick) {
var element = document.createElement(name);
fieldset2.appendChild(element);
element.addEventListener("click", clickShouldNotHappenHandler, false);
@ -170,7 +170,7 @@ function test1()
}
// Initialize children with click expected.
for each(var name in elementsWithClick) {
for (var name of elementsWithClick) {
var element = document.createElement(name);
fieldset2.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler, false);
@ -185,7 +185,7 @@ function test2()
fieldset2.disabled = true;
// Initialize children without click expected.
for each(var name in elementsPreventingClick) {
for (var name of elementsPreventingClick) {
var element = document.createElement(name);
fieldset2.appendChild(element);
element.addEventListener("click", clickShouldNotHappenHandler2, false);
@ -193,7 +193,7 @@ function test2()
}
// Initialize children with click expected.
for each(var name in elementsWithClick) {
for (var name of elementsWithClick) {
var element = document.createElement(name);
fieldset2.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler2, false);
@ -208,7 +208,7 @@ function test3()
fieldset2.disabled = false;
// All elements should accept the click.
for each(var name in elementsPreventingClick) {
for (var name of elementsPreventingClick) {
var element = document.createElement(name);
fieldset2.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler3, false);
@ -216,7 +216,7 @@ function test3()
}
// Initialize children with click expected.
for each(var name in elementsWithClick) {
for (var name of elementsWithClick) {
var element = document.createElement(name);
fieldset2.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler3, false);
@ -233,7 +233,7 @@ function test4()
fieldset2.appendChild(legendA);
// All elements should accept the click.
for each(var name in elementsPreventingClick) {
for (var name of elementsPreventingClick) {
var element = document.createElement(name);
legendA.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler4, false);
@ -241,7 +241,7 @@ function test4()
}
// Initialize children with click expected.
for each(var name in elementsWithClick) {
for (var name of elementsWithClick) {
var element = document.createElement(name);
legendA.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler4, false);
@ -255,7 +255,7 @@ function test5()
fieldset2.insertBefore(legendB, legendA);
// Initialize children without click expected.
for each(var name in elementsPreventingClick) {
for (var name of elementsPreventingClick) {
var element = document.createElement(name);
legendA.appendChild(element);
element.addEventListener("click", clickShouldNotHappenHandler5, false);
@ -263,7 +263,7 @@ function test5()
}
// Initialize children with click expected.
for each(var name in elementsWithClick) {
for (var name of elementsWithClick) {
var element = document.createElement(name);
legendA.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler5, false);
@ -282,7 +282,7 @@ function test6()
legendA.appendChild(fieldset2);
// All elements should accept the click.
for each(var name in elementsPreventingClick) {
for (var name of elementsPreventingClick) {
var element = document.createElement(name);
fieldset2.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler6, false);
@ -290,7 +290,7 @@ function test6()
}
// Initialize children with click expected.
for each(var name in elementsWithClick) {
for (var name of elementsWithClick) {
var element = document.createElement(name);
fieldset2.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler6, false);
@ -308,7 +308,7 @@ function test7()
fieldset2.appendChild(legendA);
// All elements should accept the click.
for each(var name in elementsPreventingClick) {
for (var name of elementsPreventingClick) {
var element = document.createElement(name);
legendA.appendChild(element);
element.addEventListener("click", clickShouldNotHappenHandler7, false);
@ -316,7 +316,7 @@ function test7()
}
// Initialize children with click expected.
for each(var name in elementsWithClick) {
for (var name of elementsWithClick) {
var element = document.createElement(name);
legendA.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler7, false);
@ -335,7 +335,7 @@ function test8()
fieldset2.appendChild(legendB);
// All elements should accept the click.
for each(var name in elementsPreventingClick) {
for (var name of elementsPreventingClick) {
var element = document.createElement(name);
legendB.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler8, false);
@ -343,7 +343,7 @@ function test8()
}
// Initialize children with click expected.
for each(var name in elementsWithClick) {
for (var name of elementsWithClick) {
var element = document.createElement(name);
legendB.appendChild(element);
element.addEventListener("click", clickShouldHappenHandler8, false);

View File

@ -38,7 +38,7 @@ function checkDisabledPseudoClass(aElement, aDisabled)
var disabledElements = document.querySelectorAll(":disabled");
var found = false;
for each(var e in disabledElements) {
for (var e of disabledElements) {
if (aElement == e) {
found = true;
break;
@ -55,7 +55,7 @@ function checkEnabledPseudoClass(aElement, aEnabled)
var enabledElements = document.querySelectorAll(":enabled");
var found = false;
for each(var e in enabledElements) {
for (var e of enabledElements) {
if (aElement == e) {
found = true;
break;
@ -141,7 +141,7 @@ content.appendChild(fieldset1);
fieldset1.appendChild(fieldset2);
fieldset2.disabled = true;
for each(var data in elements) {
for (var data of elements) {
var element = document.createElement(data);
if (data[4]) {

View File

@ -55,7 +55,7 @@ var inputs = [
function doSubmit()
{
for each(e in inputs) {
for (e of inputs) {
e.focus();
synthesizeKey("VK_RETURN", {});
}

View File

@ -40,7 +40,7 @@ function checkInvalid(elmt)
"rgb(255, 0, 0)", ":invalid pseudo-class should apply");
}
for each (var elmtName in elements) {
for (var elmtName of elements) {
var elmt = document.createElement(elmtName);
content.appendChild(elmt);

View File

@ -26,7 +26,7 @@ var testData = [
var x = document.getElementById('x');
for each (v in testData) {
for (v of testData) {
x.innerHTML = v;
is(x.innerHTML, v, "innerHTML value should not be escaped");
}

View File

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=590353
var testData = ['checkbox', 'radio'];
for each(var data in testData) {
for (var data of testData) {
var e = document.createElement('input');
e.type = data;
e.checked = true;

View File

@ -53,7 +53,7 @@ var content = document.getElementById('content');
var form = document.createElement('form');
content.appendChild(form);
for each (var data in testData) {
for (var data of testData) {
var e = document.createElement('input');
e.type = data[0];

View File

@ -64,7 +64,7 @@ for (var i=0; i<length; ++i) {
// For type='file' .value doesn't behave the same way.
// We are just going to check that we do not loose the value.
for each (var data in testData) {
for (var data of testData) {
var e = document.createElement('input');
e.type = data[0];
e.value = 'foo';
@ -81,7 +81,7 @@ for each (var data in testData) {
}
// TODO checks
for each (var type in todoTypes) {
for (var type of todoTypes) {
var e = document.createElement('input');
e.type = type;
todo_is(e.type, type, type + " type isn't supported yet");

View File

@ -32,7 +32,7 @@ is(fieldset.getAttribute("name"), null,
is(fieldset.name, "",
"By default, name IDL attribute should be the empty string");
for each(var data in testData) {
for (var data of testData) {
fieldset.setAttribute("name", data);
is(fieldset.getAttribute("name"), data,
"name content attribute should be " + data);

View File

@ -83,7 +83,7 @@ var testData = [
[ "<button></button><fieldset></fieldset><input><keygen><object><output></output><select></select><textarea></textarea>", 8, [ HTMLButtonElement, HTMLFieldSetElement, HTMLInputElement, HTMLSelectElement, HTMLObjectElement, HTMLOutputElement, HTMLSelectElement, HTMLTextAreaElement ] ],
];
for each(var data in testData) {
for (var data of testData) {
fieldset.innerHTML = data[0];
is(fieldset.elements.length, data[1],
"fieldset.elements should contain " + data[1] + " elements");

View File

@ -44,7 +44,7 @@ var objects = document.getElementsByTagName("object");
function runTests()
{
for each(var data in testData) {
for (var data of testData) {
var obj = objects[data[0]];
if (data[1]) {

View File

@ -60,7 +60,7 @@ input.maxLength = 1;
input.value = "foo";
// Too long types.
for each (type in types[0]) {
for (type of types[0]) {
input.type = type
if (type == 'email') {
input.value = "foo@bar.com";
@ -78,7 +78,7 @@ for each (type in types[0]) {
}
// Not too long types.
for each (type in types[1]) {
for (type of types[1]) {
input.type = type
ok(input.validity.valid, "the element should be valid [type=" + type + "]");
ok(!input.validity.tooLong,
@ -86,7 +86,7 @@ for each (type in types[1]) {
}
// Not too long types but TODO.
for each (type in types[2]) {
for (type of types[2]) {
input.type = type
ok(input.validity.valid, "the element should be valid [type=" + type + "]");
ok(!input.validity.tooLong,

View File

@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=600155
var subjectForConstraintValidation = [ "input", "select", "textarea" ];
var content = document.getElementById('content');
for each (var eName in subjectForConstraintValidation) {
for (var eName of subjectForConstraintValidation) {
var e = document.createElement(eName);
content.appendChild(e);
e.setAttribute("x-moz-errormessage", "foo");

View File

@ -52,14 +52,14 @@ function reflectURL(aElement, aAttr)
[ "http://a b/", "http://a b/" ], // TODO: doesn't follow the specs, should be "".
];
for each (var value in values) {
for (var value of values) {
aElement[idl] = value[0];
is(aElement[idl], value[1], "." + idl + " value should be " + value[1]);
is(aElement.getAttribute(attr), value[0],
"@" + attr + " value should be " + value[0]);
}
for each (var value in values) {
for (var value of values) {
aElement.setAttribute(attr, value[0]);
is(aElement[idl], value[1], "." + idl + " value should be " + value[1]);
is(aElement.getAttribute(attr), value[0],

View File

@ -35,7 +35,7 @@ function eventHandler(event)
function beginTest()
{
for each (var e in events) {
for (var e of events) {
handled[e] = false;
}
@ -44,7 +44,7 @@ function beginTest()
function endTest()
{
for each (var e in events) {
for (var e of events) {
ok(handled[e], "on" + e + " should have been called");
}

View File

@ -23,7 +23,7 @@ function checkReflection(option, attribute) {
// When attribute isn't present.
var tests = [ "", "foo" ];
for each (var test in tests) {
for (var test of tests) {
option.removeAttribute(attribute);
option.textContent = test;
is(option.getAttribute(attribute), null,
@ -39,7 +39,7 @@ function checkReflection(option, attribute) {
[ "foo", "bar" ],
[ "foo", "" ],
];
for each (var test in tests) {
for (var test of tests) {
option.setAttribute(attribute, test[0]);
option.textContent = test[1];
is(option[attribute], option.getAttribute(attribute),
@ -55,7 +55,7 @@ function checkReflection(option, attribute) {
[ "", "new" ],
[ "foo", "new" ],
];
for each (var test in tests) {
for (var test of tests) {
option.removeAttribute(attribute);
option.textContent = test[0];
option[attribute] = test[1]
@ -73,7 +73,7 @@ function checkReflection(option, attribute) {
[ "foo", "bar", "new" ],
[ "foo", "", "new" ],
];
for each (var test in tests) {
for (var test of tests) {
option.setAttribute(attribute, test[0]);
option.textContent = test[1];
option[attribute] = test[2];

View File

@ -39,7 +39,7 @@ var tests = [
var element = null;
for each (var test in tests) {
for (var test of tests) {
appendHTML(content, test[1]);
element = content.getElementsByTagName(test[0])[0];
is(element.disabled, false, "element shouldn't be disabled");

View File

@ -455,7 +455,7 @@ function run_baseVal_API_tests()
var res, threw, items;
var eventChecker = new MutationEventChecker;
for each (var t in tests) {
for (var t of tests) {
// Test .clear():
@ -850,7 +850,7 @@ function run_animVal_API_tests()
{
var threw, item;
for each (var t in tests) {
for (var t of tests) {
if (!t.animVal)
continue; // SVGStringList isn't animatable
@ -949,7 +949,7 @@ function run_animVal_API_tests()
*/
function run_basic_setAttribute_tests()
{
for each (var t in tests) {
for (var t of tests) {
// Since the t.prop, t.baseVal and t.animVal objects should never ever
// change, we leave testing of them to our caller so that it can check
@ -1046,7 +1046,7 @@ function run_basic_setAttribute_tests()
*/
function run_list_mutation_tests()
{
for each (var t in tests) {
for (var t of tests) {
if (t.animVal) {
// Test removeItem()
// =================
@ -1142,7 +1142,7 @@ function run_animation_timeline_tests()
{
var svg = document.getElementById('svg');
for each (var t in tests) {
for (var t of tests) {
// Skip if there is no animVal for this test or if it is a transform list
// since these are handled specially
if (!t.animVal || is_transform_attr(t.attr_name))
@ -1368,7 +1368,7 @@ function run_tests()
{
// Initialize each test object with some useful properties, and create their
// 'animate' elements. Note that 'prop' and 'animVal' may be null.
for each (var t in tests) {
for (var t of tests) {
t.element = document.getElementById(t.target_element_id);
t.prop = t.prop_name ? t.element[t.prop_name] : null;
t.baseVal = ( t.prop || t.element )[t.bv_name];
@ -1409,7 +1409,7 @@ function run_tests()
// After all the other test manipulations, we check that the following
// objects have still not changed, since they never should:
for each (var t in tests) {
for (var t of tests) {
if (t.prop) {
ok(t.prop === t.element[t.prop_name],
'The same '+t.prop_type+' object should ALWAYS be returned for '+

View File

@ -136,7 +136,7 @@ var features = [
];
function testIsSupported(elem) {
for each (var [feature, version, accepted_result] in features) {
for (var [feature, version, accepted_result] of features) {
if (accepted_result) {
ok(elem.isSupported(feature, version), "isSupported(" + feature + ", " + version + ") returned wrong value, Was it changed to unsupported feature?");
} else {

View File

@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=427060
/** Test for Bug 427060 **/
var xmldoc, xsltdoc;
[ xmldoc, xsltdoc ] = [ new DOMParser().parseFromString(xml, "text/xml") for each (xml in [
[ xmldoc, xsltdoc ] = [ new DOMParser().parseFromString(xml, "text/xml") for (xml of [
'<opml version="1.0"><body></body></opml>' ,

View File

@ -26,7 +26,7 @@ function isTxResult(node)
}
var xmldoc, xsltdoc;
[ xmldoc, xsltdoc ] = [ new DOMParser().parseFromString(xml, "text/xml") for each (xml in [
[ xmldoc, xsltdoc ] = [ new DOMParser().parseFromString(xml, "text/xml") for (xml of [
'<items><item><id>1</id></item><item><id>2</id></item><item><id>3</id></item></items>' ,

View File

@ -28,7 +28,7 @@ http://www.exslt.org/regexp/index.html
expResult: "XSLT is great" }
];
for each(test in tests) {
for (test of tests) {
var style =
'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' +
'xmlns:regexp="http://exslt.org/regular-expressions" '+

View File

@ -55,7 +55,7 @@
var plugin = document.getElementById("plugin1");
// Test calling NPN_Evaluate from within plugin code.
for each (var test in tests) {
for (var test of tests) {
var expected = test[1];
var result = plugin.npnEvaluateTest(test[0]);
// serialize the two values for easy comparison

View File

@ -115,7 +115,7 @@
var plugin = document.getElementById("plugin1");
var result;
for each (var test in tests) {
for (var test of tests) {
switch (test[0].length) {
case 2:
result = plugin.npnInvokeTest(test[0][0], test[0][1]);

View File

@ -91,7 +91,7 @@
var plugin = document.getElementById("plugin1");
// Test calling NPN_InvokeDefault from within plugin code.
for each (var test in tests) {
for (var test of tests) {
var result;
var expected = test[test.length - 1];
switch (test.length) {

View File

@ -32,7 +32,7 @@ var observer = {
"the install origin didn't change");
navigator.mozApps.mgmt.getAll().onsuccess = function onGetAll() {
var app = [a for each (a in this.result) if (a.manifestURL == url)][0];
var app = [a for (a of this.result) if (a.manifestURL == url)][0];
app.uninstall().onsuccess = function onUninstall() {
SimpleTest.finish();
}

View File

@ -70,10 +70,10 @@ function installAppFromOtherOrigin(next) {
function getInstalled(next) {
navigator.mozApps.getInstalled().onsuccess = function onGetInstalled() {
var app1 = [a for each (a in this.result) if (a.manifestURL == url1)][0];
var app1 = [a for (a of this.result) if (a.manifestURL == url1)][0];
ok(app1, "getInstalled() includes app installed from own origin");
var app2 = [a for each (a in this.result) if (a.manifestURL == url2)][0];
var app2 = [a for (a of this.result) if (a.manifestURL == url2)][0];
ok(!app2, "getInstalled() excludes app installed from other origin");
next();
@ -82,10 +82,10 @@ function getInstalled(next) {
function getAll(next) {
navigator.mozApps.mgmt.getAll().onsuccess = function onMgmtGetAll() {
var app1 = [a for each (a in this.result) if (a.manifestURL == url1)][0];
var app1 = [a for (a of this.result) if (a.manifestURL == url1)][0];
ok(app1, "mgmt.getAll() includes app installed from own origin");
var app2 = [a for each (a in this.result) if (a.manifestURL == url2)][0];
var app2 = [a for (a of this.result) if (a.manifestURL == url2)][0];
ok(app2, "mgmt.getAll() includes app installed from other origin");
next();

View File

@ -64,7 +64,7 @@ function install(next) {
function getInstalledReturnsApp(next) {
navigator.mozApps.getInstalled().onsuccess = function onGetInstalled() {
// Retrieve the app we just installed from the list of installed apps.
var a = [a for each (a in this.result) if (a.manifestURL == url)][0];
var a = [a for (a of this.result) if (a.manifestURL == url)][0];
// Compare the values of the two app objects to make sure install()
// and getInstalled() return identical objects.
@ -87,7 +87,7 @@ function uninstall(next) {
// Try to retrieve the app we just uninstalled, to make sure it no longer
// exists in the registry.
navigator.mozApps.getInstalled().onsuccess = function onGetInstalled() {
var a = [a for each (a in this.result) if (a.manifestURL == url)][0];
var a = [a for (a of this.result) if (a.manifestURL == url)][0];
is(a, undefined, "getInstalled() returns nothing again after uninstall");
next();

View File

@ -64,7 +64,7 @@ function install(next) {
function getInstalledReturnsApp(next) {
navigator.mozApps.getInstalled().onsuccess = function onGetInstalled() {
// Retrieve the app we just installed from the list of installed apps.
var a = [a for each (a in this.result) if (a.manifestURL == url)][0];
var a = [a for (a of this.result) if (a.manifestURL == url)][0];
// Compare the values of the two app objects to make sure install()
// and getInstalled() return identical objects.
@ -87,7 +87,7 @@ function uninstall(next) {
// Try to retrieve the app we just uninstalled, to make sure it no longer
// exists in the registry.
navigator.mozApps.getInstalled().onsuccess = function onGetInstalled() {
var a = [a for each (a in this.result) if (a.manifestURL == url)][0];
var a = [a for (a of this.result) if (a.manifestURL == url)][0];
is(a, undefined, "getInstalled() returns nothing again after uninstall");
next();

View File

@ -294,12 +294,16 @@ function jsTestDriverBrowserInit()
// If the version is not specified, and the browser is Gecko,
// use the default version corresponding to the shell's version(0).
// See https://bugzilla.mozilla.org/show_bug.cgi?id=522760#c11
// Otherwise adjust the version to match the suite version for 1.7,
// and later due to the use of let, yield, etc.
// Otherwise adjust the version to match the suite version for 1.6,
// and later due to the use of for-each, let, yield, etc.
//
// Note that js1_8, js1_8_1, and js1_8_5 are treated identically in
// the browser.
if (properties.test.match(/^js1_7/))
if (properties.test.match(/^js1_6/))
{
properties.version = '1.6';
}
else if (properties.test.match(/^js1_7/))
{
properties.version = '1.7';
}

View File

@ -10,7 +10,7 @@ var global = this;
configurable: global.__defineSetter__("", function() {})
}));
}
for each(y in [0]) {
for (y of [0]) {
_ = new f();
}
})();

View File

@ -18,7 +18,7 @@ var b = new B;
b.y = 1;
var arr = [a, b]; // same shape prior to bug 497789 fix
for each (var obj in arr)
for (var obj of arr)
obj.x = 2; // should call b's setter but doesn't
reportCompare(expect, actual, summary);

View File

@ -235,8 +235,6 @@ function COWTests() {
var props = [name for (name in getCOW(readable))];
is(props.length, 1, "COW w/ one exposed prop should enumerate once");
is(props[0], 'foo', "COW w/ one exposed prop should enumerate it");
props = [value for each (value in getCOW(readable))];
is(props[0], 5, "for-each over COWs works");
} catch (e) {
ok(false, "COW w/ a readable prop should not raise exc " +
"on enumeration: " + e);

View File

@ -86,7 +86,7 @@ function testPhoom(isCapturing, x, y, expectEvent) {
var eventGen = (function() {
var innerdoc = document.getElementById('testframe').contentDocument;
for each (var doc in [document, innerdoc]) {
for (var doc of [document, innerdoc]) {
var inner = (doc == innerdoc);
var w, h, result, listener;

View File

@ -36,7 +36,7 @@
<script type="application/javascript">
var imports = [ "SimpleTest", "is", "isnot", "ok" ];
for each (var name in imports) {
for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}

View File

@ -53,7 +53,7 @@ for (var char in chars) {
var mapent = wsmap[is_whitespace];
div.setAttribute("class", "classvalue" + String.fromCharCode(char) + "b")
div.setAttribute("title", "a" + String.fromCharCode(char) + "titlevalue")
for each (var prop in ["text-decoration", "visibility"]) {
for (var prop of ["text-decoration", "visibility"]) {
is(cs.getPropertyValue(prop), mapent[prop],
"Character " + char + " should" + mapent.str +
" be treated as whitespace ("

View File

@ -54,9 +54,9 @@ var e = document.getElementById("display");
var s = e.style;
var c = window.getComputedStyle(e, "");
for each (var set in gProps) {
for (var set of gProps) {
var values = values_for(set);
for each (var val in values) {
for (var val of values) {
function check(dir, plogical, pvisual) {
var v0 = c.getPropertyValue(pvisual);
s.setProperty("direction", dir, "");

View File

@ -536,7 +536,7 @@ function run() {
function idset(ids) { // takes an array of ids
return function idset_filter(doc) {
var result = [];
for each (var id in ids)
for (var id of ids)
result.push(doc.getElementById(id));
return result;
}

View File

@ -151,7 +151,7 @@ for (var tf in timingFunctions) {
// Check that the timing function continues even when we restyle in the
// middle.
var interrupt_tests = [];
for each (var restyleParent in [true, false]) {
for (var restyleParent of [true, false]) {
for (var itime = 2; itime < 8; itime += 2) {
var p = document.createElement("p");
var t = document.createTextNode("interrupt on " +

View File

@ -146,7 +146,7 @@ function commonInit() {
var disabledHosts = pwmgr.getAllDisabledHosts();
if (disabledHosts.length) {
//todo(false, "Warning: wasn't expecting disabled hosts to be present.");
for each (var host in disabledHosts)
for (var host of disabledHosts)
pwmgr.setLoginSavingEnabled(host, true);
}

View File

@ -103,7 +103,7 @@ var TestObserver = {
};
// Initialize the object that stores the results of notifications.
for each (var formID in ["form1", "form2", "form3", "form4", "form5"])
for (var formID of ["form1", "form2", "form3", "form4", "form5"])
TestObserver.results[formID] = { receivedNotification: false, data: null };
// Add the observer

View File

@ -140,7 +140,7 @@ fh.addEntry("searchbar-history", "blacklist test");
var todoTypes = [ "datetime", "date", "month", "week", "time", "datetime-local",
"range", "color" ];
var todoInput = document.createElement("input");
for each (var type in todoTypes) {
for (var type of todoTypes) {
todoInput.type = type;
todo_is(todoInput.type, type, type + " type shouldn't be implemented");
}