Bug 247606 - Review Firefox JS for dangerous eval() use. r=bryner.

This commit is contained in:
jruderman%hmc.edu 2004-07-07 03:04:09 +00:00
parent 7f86031073
commit a429b6720a
12 changed files with 31 additions and 23 deletions

View File

@ -865,7 +865,7 @@ function constructGoMenuItem(goMenu, beforeItem, url, title)
function onGoMenuHidden()
{
setTimeout("destroyGoMenuItems(document.getElementById('goPopup'));", 0);
setTimeout(destroyGoMenuItems, 0, document.getElementById('goPopup'));
}
function destroyGoMenuItems(goMenu) {
@ -1024,7 +1024,7 @@ function BrowserOpenTab()
{
gBrowser.selectedTab = gBrowser.addTab('about:blank');
if (gURLBar)
setTimeout("gURLBar.focus();", 0);
setTimeout(function() { gURLBar.focus(); }, 0);
}
/* Called from the openLocation dialog. This allows that dialog to instruct
@ -1033,7 +1033,12 @@ function BrowserOpenTab()
though oddly only on Linux. */
function delayedOpenWindow(chrome,flags,url)
{
setTimeout("openDialog('"+chrome+"','_blank','"+flags+"','"+url+"')", 10);
// The other way to use setTimeout,
// setTimeout(openDialog, 10, chrome, "_blank", flags, url),
// doesn't work here. The extra "magic" extra argument setTimeout adds to
// the callback function would confuse prepareForStartup() by making
// window.arguments[1] be an integer instead of null.
setTimeout(function() { openDialog(chrome, "_blank", flags, url); }, 10);
}
/* Required because the tab needs time to set up its content viewers and get the load of
@ -2441,8 +2446,11 @@ nsBrowserStatusHandler.prototype =
}
// Turn the progress meter and throbber off.
gProgressCollapseTimer = window.setTimeout("gProgressMeterPanel.collapsed = true; gProgressCollapseTimer = null;",
100);
gProgressCollapseTimer = window.setTimeout(
function() {
gProgressMeterPanel.collapsed = true;
gProgressCollapseTimer = null;
}, 100);
if (this.throbberElement)
this.throbberElement.removeAttribute("busy");
@ -2489,7 +2497,7 @@ nsBrowserStatusHandler.prototype =
}
UpdateBackForwardButtons();
setTimeout("updatePageTheme();", 0);
setTimeout(updatePageTheme, 0);
},
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
@ -4116,9 +4124,9 @@ function UpdateMenus(event)
// when onmenucomplete is ready then use it instead of oncreate
// see bug 78290 for the detail
UpdateCurrentCharset();
setTimeout("UpdateCurrentCharset()", 0);
setTimeout(UpdateCurrentCharset, 0);
UpdateCharsetDetector();
setTimeout("UpdateCharsetDetector()", 0);
setTimeout(UpdateCharsetDetector, 0);
}
function CreateMenu(node)

View File

@ -32,7 +32,7 @@
<dialog id="pageReportFirstTime"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&caption.label;"
onload="setTimeout('window.sizeToContent();', 100);"
onload="setTimeout(function() { window.sizeToContent(); }, 100);"
style="width: 40em;"
buttons="accept"
persist="screenX screenY"

View File

@ -131,7 +131,7 @@
{
var cb = document.getElementById("creditsBox");
cb.scrollTop = 0;
setTimeout("runCredits()", 3000);
setTimeout(runCredits, 3000);
}
function runCredits()

View File

@ -74,7 +74,7 @@ var BookmarksMenu = {
hideOpenInTabsMenuItem: function (aTarget)
{
gOpenInTabsParent = aTarget;
setTimeout("BookmarksMenu.delayedHideOpenInTabsMenuItem()", 0);
setTimeout(function() { BookmarksMenu.delayedHideOpenInTabsMenuItem(); }, 0);
},
#else

View File

@ -267,7 +267,7 @@ var MigrationWizard = {
if (this._autoMigrate) {
// We're done now.
this._wiz.advance();
setTimeout("close()", 5000);
setTimeout(close, 5000);
}
else {
var nextButton = this._wiz.getButton("next");

View File

@ -56,7 +56,7 @@ function init()
var x = document.documentElement.getAttribute("screenX");
if (x == "")
setTimeout("centerOverParent()", 0);
setTimeout(centerOverParent, 0);
}
// This should actually go into some sort of pref fe utilities file.

View File

@ -11,7 +11,7 @@
<![CDATA[
function inspectorWindowLoad()
{
setTimeout("initWindowMediator()", 0);
setTimeout(initWindowMediator, 0);
}
function initWindowMediator()

View File

@ -166,7 +166,7 @@ var PrintUtils = {
observe: function(aSubject, aTopic, aData)
{
// delay the print preview to show the content of the progress dialog
setTimeout("PrintUtils.enterPrintPreview();", 0);
setTimeout(function () { PrintUtils.enterPrintPreview(); }, 0);
},
QueryInterface : function(iid)

View File

@ -512,10 +512,10 @@ function ModifyPref(entry)
return false;
switch (entry.typeCol) {
case nsIPrefBranch.PREF_BOOL:
gPrefBranch.setBoolPref(entry.prefCol, eval(result.value));
gPrefBranch.setBoolPref(entry.prefCol, result.value == "true" || !!parseInt(result.value, 10));
break;
case nsIPrefBranch.PREF_INT:
gPrefBranch.setIntPref(entry.prefCol, eval(result.value));
gPrefBranch.setIntPref(entry.prefCol, parseInt(result.value, 10));
break;
default:
case nsIPrefBranch.PREF_STRING:

View File

@ -188,9 +188,9 @@ function UpdateMenus(event)
// when onmenucomplete is ready then use it instead of oncreate
// see bug 78290 for the detail
UpdateCurrentCharset();
setTimeout("UpdateCurrentCharset()", 0);
setTimeout(UpdateCurrentCharset, 0);
UpdateCharsetDetector();
setTimeout("UpdateCharsetDetector()", 0);
setTimeout(UpdateCharsetDetector, 0);
}
function CreateMenu(node)
@ -205,9 +205,9 @@ function UpdateMailMenus(event)
// when onmenucomplete is ready then use it instead of oncreate
// see bug 78290 for the detail
UpdateCurrentMailCharset();
setTimeout("UpdateCurrentMailCharset()", 0);
setTimeout(UpdateCurrentMailCharset, 0);
UpdateCharsetDetector();
setTimeout("UpdateCharsetDetector()", 0);
setTimeout(UpdateCharsetDetector, 0);
}
var gCharsetMenu = Components.classes['@mozilla.org/rdf/datasource;1?name=charset-menu'].getService().QueryInterface(Components.interfaces.nsICurrentCharsetListener);

View File

@ -114,7 +114,7 @@ function init()
var x = document.documentElement.getAttribute("screenX");
if (x == "")
setTimeout("centerOverParent()", 0);
setTimeout(centerOverParent, 0);
}
function setLiteralValue(aResource, aProperty, aValue)

View File

@ -164,7 +164,7 @@ function Startup()
toggleDMPrefUI(document.getElementById("showWhenStarting"));
#endif
setTimeout("postStart()", 0);
setTimeout(postStart, 0);
}
function postStart()