Skip to content

Commit

Permalink
Bug 1172536 - Stop using for each loops in layout; r=roc
Browse files Browse the repository at this point in the history
These are SpiderMonkey-proprietary legacy feature which has been deprecated
and is expected to be removed in due course.

This commit also fixes a number of bugs in test_bug708874.xul. In particular,
because of the semicolon after the for head, the (alleged) loop body was only
executed for the final element of the array ({}), and because each of the
functions under test threw an exception, only the first call was executed.

I do not know of a way to test the changes in frame-verify.js, so I can't
guarantee they actually work.

--HG--
extra : commitid : 9WYVkuNzWOA
  • Loading branch information
Ms2ger committed Jun 20, 2015
1 parent fe46527 commit 98d44fa
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<script type="application/javascript">
<![CDATA[
var imports = [ "SimpleTest", "is", "isnot", "ok", "SpecialPowers" ];
for each (var name in imports) {
for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}
Expand Down
2 changes: 1 addition & 1 deletion layout/base/tests/chrome/chrome_over_plugin_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<script type="application/javascript">
<![CDATA[
var imports = [ "SimpleTest", "is", "isnot", "ok", "todo" ];
for each (var name in imports) {
for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}
Expand Down
2 changes: 1 addition & 1 deletion layout/base/tests/chrome/default_background_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
SimpleTest.waitForExplicitFinish();
var imports = [ "SimpleTest", "is", "isnot", "ok" ];
for each (var name in imports) {
for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}
Expand Down
2 changes: 1 addition & 1 deletion layout/base/tests/chrome/no_clip_iframe_window.xul
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<script type="application/javascript">
<![CDATA[
var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror" ];
for each (var name in imports) {
for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name];
}
Expand Down
8 changes: 4 additions & 4 deletions layout/generic/frame-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function inheritsFrom(t, baseName)
if (name == baseName)
return true;

for each (let base in t.bases)
for (let base of t.bases)
if (inheritsFrom(base.type, baseName))
return true;

Expand All @@ -33,7 +33,7 @@ function process_type(t)

output.push('CLASS-DEF: %s'.format(t.name));

for each (let base in t.bases) {
for (let base of t.bases) {
if (inheritsFrom(base.type, 'nsIFrame')) {
output.push('%s -> %s;'.format(base.type.name, t.name));
}
Expand All @@ -43,7 +43,7 @@ function process_type(t)
}

output.push('%s [label="%s%s"];'.format(t.name, t.name,
["\\n(%s)".format(b) for each (b in nonFrameBases)].join('')));
nonFrameBases.map(b => "\\n(%s)".format(b)).join('')));
}
}
}
Expand Down Expand Up @@ -83,7 +83,7 @@ function process_cp_pre_genericize(d)

function input_end()
{
for each (let [name, loc] in needIDs) {
for (let [name, loc] of needIDs) {
if (!haveIDs.hasOwnProperty(name)) {
error("nsQueryFrame<%s> found, but %s::kFrameIID is not declared".format(name, name), loc);
}
Expand Down
19 changes: 9 additions & 10 deletions layout/inspector/tests/chrome/test_bug708874.xul
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,15 @@ function testInvalid() {
}
function testNotElement() {
var values = [null, undefined, {}];
try {
for each (value in values); {
DOMUtils.hasPseudoClassLock(value, ":hover");
DOMUtils.addPseudoClassLock(value, ":hover");
DOMUtils.removePseudoClassLock(value, ":hover");
DOMUtils.clearPseudoClassLocks(value);
}
} catch(e) {
// just make sure we don't crash on non-elements
for (var value of [null, undefined, {}]) {
SimpleTest.doesThrow(() => DOMUtils.hasPseudoClassLock(value, ":hover"),
"hasPseudoClassLock should throw for " + value);
SimpleTest.doesThrow(() => DOMUtils.addPseudoClassLock(value, ":hover"),
"addPseudoClassLock should throw for " + value);
SimpleTest.doesThrow(() => DOMUtils.removePseudoClassLock(value, ":hover"),
"removePseudoClassLock should throw for " + value);
SimpleTest.doesThrow(() => DOMUtils.clearPseudoClassLocks(value),
"clearPseudoClassLocks should throw for " + value);
}
}
]]>
Expand Down

0 comments on commit 98d44fa

Please sign in to comment.