Created
February 15, 2010 18:10
-
-
Save olleolleolle/304850 to your computer and use it in GitHub Desktop.
general jslint work, surprise on #321
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: common/src/js/core/scripts/selenium-browserbot.js | |
=================================================================== | |
--- common/src/js/core/scripts/selenium-browserbot.js (revision 8354) | |
+++ common/src/js/core/scripts/selenium-browserbot.js (working copy) | |
@@ -100,9 +100,10 @@ | |
}; | |
this.isNewPageLoaded = function() { | |
+ var e; | |
if (this.pageLoadError) { | |
LOG.error("isNewPageLoaded found an old pageLoadError"); | |
- var e = this.pageLoadError; | |
+ e = this.pageLoadError; | |
this.pageLoadError = null; | |
throw e; | |
} | |
@@ -114,7 +115,7 @@ | |
if (!((self.xhrResponseCode >= 200 && self.xhrResponseCode <= 399) || self.xhrResponseCode == 0)) { | |
// TODO: for IE status like: 12002, 12007, ... provide corresponding statusText messages also. | |
LOG.error("XHR failed with message " + self.xhrStatusText); | |
- var e = "XHR ERROR: URL = " + self.xhrOpenLocation + " Response_Code = " + self.xhrResponseCode + " Error_Message = " + self.xhrStatusText | |
+ e = "XHR ERROR: URL = " + self.xhrOpenLocation + " Response_Code = " + self.xhrResponseCode + " Error_Message = " + self.xhrStatusText; | |
self.abortXhr = false; | |
self.isXhrSent = false; | |
self.isXhrDone = false; | |
@@ -209,13 +210,13 @@ | |
var object = eval(name); | |
var s = 'state:' + serializeObject(name, object) + "\n"; | |
sendToRC(s,"state=true"); | |
-} | |
+}; | |
BrowserBot.prototype.resetPopups = function() { | |
this.recordedAlerts = []; | |
this.recordedConfirmations = []; | |
this.recordedPrompts = []; | |
-} | |
+}; | |
BrowserBot.prototype.getNextAlert = function() { | |
var t = this.recordedAlerts.shift(); | |
@@ -257,8 +258,9 @@ | |
var screenY = 0; | |
canBubble = (typeof(canBubble) == undefined) ? true : canBubble; | |
+ var evt; | |
if (element.fireEvent && element.ownerDocument && element.ownerDocument.createEventObject) { //IE | |
- var evt = createEventObject(element, this.controlKeyDown, this.altKeyDown, this.shiftKeyDown, this.metaKeyDown); | |
+ evt = createEventObject(element, this.controlKeyDown, this.altKeyDown, this.shiftKeyDown, this.metaKeyDown); | |
evt.detail = 0; | |
evt.button = button ? button : 1; // default will be the left mouse click ( http://www.javascriptkit.com/jsref/event.shtml ) | |
evt.relatedTarget = null; | |
@@ -290,7 +292,7 @@ | |
} | |
} | |
else { | |
- var evt = document.createEvent('MouseEvents'); | |
+ evt = document.createEvent('MouseEvents'); | |
if (evt.initMouseEvent) | |
{ | |
// see http://developer.mozilla.org/en/docs/DOM:event.button and | |
@@ -314,7 +316,7 @@ | |
} | |
element.dispatchEvent(evt); | |
} | |
-} | |
+}; | |
BrowserBot.prototype._windowClosed = function(win) { | |
var c = win.closed; | |
@@ -390,7 +392,7 @@ | |
this.currentWindow = this.topWindow; | |
this.topFrame = this.topWindow; | |
this.isSubFrameSelected = false; | |
-} | |
+}; | |
BrowserBot.prototype._selectWindowByWindowId = function(windowId) { | |
try { | |
@@ -406,7 +408,7 @@ | |
this.topFrame = this.currentWindow; | |
this.currentWindowName = target; | |
this.isSubFrameSelected = false; | |
-} | |
+}; | |
BrowserBot.prototype._selectWindowByTitle = function(target) { | |
var windowName = this.getWindowNameByTitle(target); | |
@@ -415,7 +417,7 @@ | |
} else { | |
this._selectWindowByName(windowName); | |
} | |
-} | |
+}; | |
BrowserBot.prototype._selectFirstNonTopWindow = function() { | |
var names = this.getNonTopWindowNames(); | |
@@ -425,9 +427,10 @@ | |
}; | |
BrowserBot.prototype.selectFrame = function(target) { | |
+ var frame; | |
if (target.indexOf("index=") == 0) { | |
target = target.substr(6); | |
- var frame = this.getCurrentWindow().frames[target]; | |
+ frame = this.getCurrentWindow().frames[target]; | |
if (frame == null) { | |
throw new SeleniumError("Not found: frames["+target+"]"); | |
} | |
@@ -444,7 +447,7 @@ | |
this.currentWindow = this.topFrame; | |
this.isSubFrameSelected = false; | |
} else { | |
- var frame = this.findElement(target); | |
+ frame = this.findElement(target); | |
if (frame == null) { | |
throw new SeleniumError("Not found: " + target); | |
} | |
@@ -559,7 +562,7 @@ | |
this.xhr.abort(); | |
} | |
} | |
-} | |
+}; | |
BrowserBot.prototype.onXhrStateChange = function(method) { | |
LOG.info("onXhrStateChange(): xhr.readyState = " + this.xhr.readyState + " method = " + method + " time = " + new Date().getTime()); | |
@@ -615,7 +618,7 @@ | |
this.xhr.open("HEAD", url, true); | |
this.xhr.send(""); | |
this.isXhrSent = true; | |
-} | |
+}; | |
BrowserBot.prototype.openLocation = function(target) { | |
// We're moving to a new page - clear the current one | |
@@ -723,7 +726,7 @@ | |
return openedWindow; | |
}; | |
- if (browserVersion.isHTA) { | |
+ if (isHTA) { | |
originalOpenReference = 'selenium_originalOpen' + new Date().getTime(); | |
newOpenReference = 'selenium_newOpen' + new Date().getTime(); | |
var setOriginalRef = "this['" + originalOpenReference + "'] = this.open;"; | |
@@ -790,7 +793,7 @@ | |
if (!browserVersion.isHTA) return false; | |
// DGF this is wrong! what if "win" isn't the selected window? | |
return this.isSubFrameSelected; | |
-} | |
+}; | |
BrowserBot.prototype._getFrameElement = function(win) { | |
var frameElement = null; | |
@@ -826,7 +829,7 @@ | |
LOG.debug("frameElement.name="+frameElement.name); | |
} | |
return frameElement; | |
-} | |
+}; | |
BrowserBot.prototype._getFrameElementByName = function(name, doc, win) { | |
var frames; | |
@@ -849,7 +852,7 @@ | |
// DGF weird; we only call this function when we know the doc contains the frame | |
LOG.warn("_getFrameElementByName couldn't find a frame or iframe; checking every element for the name " + name); | |
return BrowserBot.prototype.locateElementByName(win.name, win.parent.document); | |
-} | |
+}; | |
/** | |
@@ -908,7 +911,7 @@ | |
BrowserBot.prototype._isSamePage = function(windowObject, originalDocument, originalLocation, originalHref, marker) { | |
var currentDocument = windowObject.document; | |
var currentLocation = windowObject.location; | |
- var currentHref = currentLocation.href | |
+ var currentHref = currentLocation.href; | |
var sameDoc = this._isSameDocument(originalDocument, currentDocument); | |
@@ -940,7 +943,7 @@ | |
LOG.debug("_isSamePage: sameHref: " + sameHref); | |
LOG.debug("_isSamePage: markedLoc: " + markedLoc); | |
- return sameDoc && sameLoc && sameHref && markedLoc | |
+ return sameDoc && sameLoc && sameHref && markedLoc; | |
}; | |
BrowserBot.prototype._isSameDocument = function(originalDocument, currentDocument) { | |
@@ -1204,11 +1207,11 @@ | |
} catch (e) {} // DGF element highlighting is low-priority and possibly dangerous | |
} | |
return element; | |
-} | |
+}; | |
BrowserBot.prototype.setShouldHighlightElement = function (shouldHighlight) { | |
this.shouldHighlightLocatedElement = shouldHighlight; | |
-} | |
+}; | |
/*****************************************************************/ | |
/* BROWSER-SPECIFIC FUNCTIONS ONLY AFTER THIS LINE */ | |
@@ -1254,11 +1257,11 @@ | |
} | |
return this.locateElementByIdentifier(locator, inDocument, inWindow); | |
}; | |
-} | |
+}; | |
BrowserBot.prototype.getDocument = function() { | |
return this.getCurrentWindow().document; | |
-} | |
+}; | |
BrowserBot.prototype.getTitle = function() { | |
var t = this.getDocument().title; | |
@@ -1266,7 +1269,7 @@ | |
t = t.trim(); | |
} | |
return t; | |
-} | |
+}; | |
BrowserBot.prototype.getCookieByName = function(cookieName, doc) { | |
if (!doc) doc = this.getDocument(); | |
@@ -1282,7 +1285,7 @@ | |
} | |
} | |
return null; | |
-} | |
+}; | |
BrowserBot.prototype.getAllCookieNames = function(doc) { | |
if (!doc) doc = this.getDocument(); | |
@@ -1297,7 +1300,7 @@ | |
cookieNames.push(ckName); | |
} | |
return cookieNames; | |
-} | |
+}; | |
BrowserBot.prototype.deleteCookie = function(cookieName, domain, path, doc) { | |
if (!doc) doc = this.getDocument(); | |
@@ -1312,13 +1315,13 @@ | |
cookie += "expires=" + new Date(expireDateInMilliseconds).toGMTString(); | |
LOG.debug("Setting cookie to: " + cookie); | |
doc.cookie = cookie; | |
-} | |
+}; | |
/** Try to delete cookie, return false if it didn't work */ | |
BrowserBot.prototype._maybeDeleteCookie = function(cookieName, domain, path, doc) { | |
this.deleteCookie(cookieName, domain, path, doc); | |
return (!this.getCookieByName(cookieName, doc)); | |
-} | |
+}; | |
BrowserBot.prototype._recursivelyDeleteCookieDomains = function(cookieName, domain, path, doc) { | |
@@ -1333,7 +1336,7 @@ | |
// No more dots; try just not passing in a domain at all | |
return this._maybeDeleteCookie(cookieName, null, path, doc); | |
} | |
-} | |
+}; | |
BrowserBot.prototype._recursivelyDeleteCookie = function(cookieName, domain, path, doc) { | |
var slashIndex = path.lastIndexOf("/"); | |
@@ -1346,7 +1349,7 @@ | |
if (deleted) return true; | |
} | |
return this._recursivelyDeleteCookieDomains(cookieName, domain, path, doc); | |
-} | |
+}; | |
BrowserBot.prototype.recursivelyDeleteCookie = function(cookieName, domain, path, win) { | |
if (!win) win = this.getCurrentWindow(); | |
@@ -1363,7 +1366,7 @@ | |
deleted = this._recursivelyDeleteCookieDomains(cookieName, "." + domain, null, doc); | |
if (deleted) return; | |
throw new SeleniumError("Couldn't delete cookie " + cookieName); | |
-} | |
+}; | |
/* | |
* Finds an element recursively in frames and nested frames | |
@@ -1412,7 +1415,7 @@ | |
var element = this.findElementOrNull(locator, win); | |
if (element == null) throw new SeleniumError("Element " + locator + " not found"); | |
return element; | |
-} | |
+}; | |
/** | |
* In non-IE browsers, getElementById() does not search by name. Instead, we | |
@@ -1517,7 +1520,7 @@ | |
} else { | |
throw new Error("Unknown namespace: " + prefix + "."); | |
} | |
-} | |
+}; | |
/** | |
* Returns the number of xpath results. | |
@@ -1633,7 +1636,7 @@ | |
var maxLengthAttr = element.getAttribute("maxLength"); | |
var actualValue = stringValue; | |
if (maxLengthAttr != null) { | |
- var maxLength = parseInt(maxLengthAttr); | |
+ var maxLength = parseInt(maxLengthAttr, 10); | |
if (stringValue.length > maxLength) { | |
actualValue = stringValue.substr(0, maxLength); | |
} | |
@@ -1642,7 +1645,7 @@ | |
if (getTagName(element) == "body") { | |
if (element.ownerDocument && element.ownerDocument.designMode) { | |
var designMode = new String(element.ownerDocument.designMode).toLowerCase(); | |
- if (designMode = "on") { | |
+ if (designMode == "on") { | |
// this must be a rich text control! | |
element.innerHTML = actualValue; | |
} | |
@@ -1677,7 +1680,7 @@ | |
// pause for up to 2s while this command runs | |
var terminationCondition = function () { | |
return !win[marker]; | |
- } | |
+ }; | |
return Selenium.decorateFunctionWithTimeout(terminationCondition, 2000); | |
} else { | |
actuallySubmit = formElement.onsubmit(); | |
@@ -1691,7 +1694,7 @@ | |
} else { | |
formElement.submit(); | |
} | |
-} | |
+}; | |
BrowserBot.prototype.clickElement = function(element, clientX, clientY) { | |
this._fireEventOnElement("click", element, clientX, clientY); | |
@@ -1718,7 +1721,7 @@ | |
} | |
} | |
} | |
-} | |
+}; | |
BrowserBot.prototype._handleClickingImagesInsideLinks = function(targetWindow, element) { | |
@@ -1730,7 +1733,7 @@ | |
} | |
itrElement = itrElement.parentNode; | |
} | |
-} | |
+}; | |
BrowserBot.prototype._getTargetWindow = function(element) { | |
var targetWindow = element.ownerDocument.defaultView; | |
@@ -1738,7 +1741,7 @@ | |
targetWindow = this._getFrameFromGlobal(element.target); | |
} | |
return targetWindow; | |
-} | |
+}; | |
BrowserBot.prototype._getFrameFromGlobal = function(target) { | |
@@ -1760,7 +1763,7 @@ | |
var win = this.getWindowByName(target); | |
if (win) return win; | |
return this.getCurrentWindow().open('', target); | |
-} | |
+}; | |
BrowserBot.prototype.bodyText = function() { | |
@@ -1908,10 +1911,10 @@ | |
BrowserBot.prototype.locateElementByClass = function(locator, document) { | |
return elementFindFirstMatchingChild(document, | |
function(element) { | |
- return element.className == locator | |
+ return element.className == locator; | |
} | |
); | |
-} | |
+}; | |
/** | |
* Find an element by alt | |
@@ -1919,10 +1922,10 @@ | |
BrowserBot.prototype.locateElementByAlt = function(locator, document) { | |
return elementFindFirstMatchingChild(document, | |
function(element) { | |
- return element.alt == locator | |
+ return element.alt == locator; | |
} | |
); | |
-} | |
+}; | |
/** | |
* Find an element by css selector | |
@@ -1932,7 +1935,7 @@ | |
if (elements.length != 0) | |
return elements[0]; | |
return null; | |
-} | |
+}; | |
/** | |
* This function is responsible for mapping a UI specifier string to an element | |
@@ -1964,7 +1967,7 @@ | |
} | |
return locatedElement; | |
-} | |
+}; | |
BrowserBot.prototype.locateElementByUIElement.prefix = 'ui'; | |
@@ -2027,7 +2030,7 @@ | |
if ("about:blank" != win.location.href) { | |
var startLoc = parseUrl(win.location.href); | |
startLoc.hash = null; | |
- var startUrl = reassembleLocation(startLoc); | |
+ startUrl = reassembleLocation(startLoc); | |
} | |
LOG.debug("startUrl="+startUrl); | |
LOG.debug("win.location.href="+win.location.href); | |
@@ -2051,7 +2054,7 @@ | |
// originalDocument and currentDocument are different objects | |
// while their location are same. | |
if (originalDocument) { | |
- return originalDocument.location == currentDocument.location | |
+ return originalDocument.location == currentDocument.location; | |
} else { | |
return originalDocument === currentDocument; | |
} | |
@@ -2076,7 +2079,7 @@ | |
} else { | |
iframe.src = location; | |
} | |
-} | |
+}; | |
function IEBrowserBot(frame) { | |
BrowserBot.call(this, frame); | |
@@ -2166,8 +2169,9 @@ | |
if (!this.permDeniedCount[marker]) this.permDeniedCount[marker] = 0; | |
BrowserBot.prototype.pollForLoad.call(this, loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker); | |
if (this.pageLoadError) { | |
+ var self; | |
if (this.pageUnloading) { | |
- var self = this; | |
+ self = this; | |
LOG.debug("pollForLoad UNLOADING (" + marker + "): caught exception while firing events on unloading page: " + this.pageLoadError.message); | |
this.reschedulePoller(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker); | |
this.pageLoadError = null; | |
@@ -2193,7 +2197,7 @@ | |
} | |
} | |
- var self = this; | |
+ self = this; | |
LOG.debug("pollForLoad (" + marker + "): " + this.pageLoadError.message + " (" + this.permDeniedCount[marker] + "), waiting to see if it goes away"); | |
this.reschedulePoller(loadFunction, windowObject, originalDocument, originalLocation, originalHref, marker); | |
this.pageLoadError = null; | |
@@ -2391,7 +2395,7 @@ | |
win.location.hash = ""; | |
var actuallyReload = function() { | |
win.location.reload(true); | |
- } | |
+ }; | |
window.setTimeout(actuallyReload, 1); | |
} else { | |
win.location.reload(true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment