Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion javascript/firefox-driver/js/syntheticMouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ SyntheticMouse.prototype.move = function(target, xOffset, yOffset) {
// Are we about to be dragged out of the window?

var isOption = bot.dom.isElement(element, goog.dom.TagName.OPTION);
var isSVG = Utils.isSVG(element.ownerDocument);

if (!isOption && !inViewAfterScroll) {
if (!isOption && !isSVG && !inViewAfterScroll) {
return SyntheticMouse.newResponse(bot.ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS,
'Element cannot be scrolled into view:' + element);
}
Expand Down
21 changes: 16 additions & 5 deletions javascript/firefox-driver/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Utils.getActiveElement = function(doc) {

// Default to the body
if (!element) {
element = doc.body;
element = Utils.getMainDocumentElement(doc);
}

return element;
Expand Down Expand Up @@ -1176,8 +1176,8 @@ Utils.getPageUnloadedIndicator = function(element) {
var unloadFunction = function() { toReturn.wasUnloaded = true };
toReturn.callback = unloadFunction;

element.ownerDocument.body.addEventListener('unload',
unloadFunction, false);
var mainDocumentElement = Utils.getMainDocumentElement(element.ownerDocument);
mainDocumentElement.addEventListener('unload', unloadFunction, false);

// This is a Firefox specific event - See:
// https://developer.mozilla.org/En/Using_Firefox_1.5_caching
Expand All @@ -1191,8 +1191,9 @@ Utils.removePageUnloadEventListener = function(element, pageUnloadData) {
if (pageUnloadData.callback) {
// Remove event listeners...
if (element.ownerDocument) {
if (element.ownerDocument.body) {
element.ownerDocument.body.removeEventListener('unload',
var mainDocumentElement = Utils.getMainDocumentElement(element.ownerDocument);
if (mainDocumentElement) {
mainDocumentElement.removeEventListener('unload',
pageUnloadData.callback, false);
}
if (element.ownerDocument.defaultView) {
Expand Down Expand Up @@ -1227,3 +1228,13 @@ Utils.convertNSIArrayToNative = function(arrayToConvert) {

return returnArray;
};

Utils.isSVG = function(doc) {
return doc.documentElement && doc.documentElement.nodeName == 'svg';
};

Utils.getMainDocumentElement = function(doc) {
if (Utils.isSVG(doc))
return doc.documentElement;
return doc.body;
};
6 changes: 4 additions & 2 deletions javascript/firefox-driver/js/wrappedElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ WebElement.clickElement = function(respond, parameters) {
unwrapped,
new goog.math.Coordinate(elementHalfWidth, elementHalfHeight));

if (!inViewAfterScroll) {
var isSVG = Utils.isSVG(element.ownerDocument);

if (!isSVG && !inViewAfterScroll) {
respond.sendError(
new WebDriverError(bot.ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS,
'Element cannot be scrolled into view:' + element));
Expand Down Expand Up @@ -388,7 +390,7 @@ WebElement.getElementLocationOnceScrolledIntoView = function(
respond.session.getDocument());

var theDoc = element.ownerDocument;
theDoc.body.focus();
Utils.getMainDocumentElement(theDoc).focus();
var elementLocation = Utils.getLocationOnceScrolledIntoView(element);

respond.value = {
Expand Down