зеркало из https://github.com/mozilla/pjs.git
Bug 720095. (Av1a-mochitest) Fix some strict warnings and nits. r=ted.mielczarek.
This commit is contained in:
Родитель
efa35f490d
Коммит
acd01533c7
|
@ -33,7 +33,7 @@ this.$ = this.getElement;
|
|||
|
||||
function sendMouseEvent(aEvent, aTarget, aWindow) {
|
||||
if (['click', 'mousedown', 'mouseup', 'mouseover', 'mouseout'].indexOf(aEvent.type) == -1) {
|
||||
throw new Error("sendMouseEvent doesn't know about event type '"+aEvent.type+"'");
|
||||
throw new Error("sendMouseEvent doesn't know about event type '" + aEvent.type + "'");
|
||||
}
|
||||
|
||||
if (!aWindow) {
|
||||
|
@ -99,9 +99,10 @@ function sendString(aStr, aWindow) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Send the non-character key aKey to the focused node. The name of the key
|
||||
* should be a lowercase version of the part that comes after "DOM_VK_" in the
|
||||
* KeyEvent constant name for this key. No modifiers are handled at this point.
|
||||
* Send the non-character key aKey to the focused node.
|
||||
* The name of the key should be the part that comes after "DOM_VK_" in the
|
||||
* KeyEvent constant name for this key.
|
||||
* No modifiers are handled at this point.
|
||||
*/
|
||||
function sendKey(aKey, aWindow) {
|
||||
var keyName = "VK_" + aKey.toUpperCase();
|
||||
|
@ -171,7 +172,7 @@ function synthesizeMouseAtPoint(left, top, aEvent, aWindow)
|
|||
var clickCount = aEvent.clickCount || 1;
|
||||
var modifiers = _parseModifiers(aEvent);
|
||||
|
||||
if (aEvent.type) {
|
||||
if (("type" in aEvent) && aEvent.type) {
|
||||
utils.sendMouseEvent(aEvent.type, left, top, button, clickCount, modifiers);
|
||||
}
|
||||
else {
|
||||
|
@ -231,7 +232,7 @@ function synthesizeMouseScroll(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
|
|||
var left = rect.left;
|
||||
var top = rect.top;
|
||||
|
||||
var type = aEvent.type || "DOMMouseScroll";
|
||||
var type = (("type" in aEvent) && aEvent.type) || "DOMMouseScroll";
|
||||
var axis = aEvent.axis || "vertical";
|
||||
var scrollFlags = (axis == "horizontal") ? kIsHorizontal : kIsVertical;
|
||||
if (aEvent.hasPixels) {
|
||||
|
@ -386,12 +387,8 @@ function synthesizeKey(aKey, aEvent, aWindow)
|
|||
|
||||
var modifiers = _parseModifiers(aEvent);
|
||||
|
||||
if (aEvent.type == "keypress") {
|
||||
utils.sendKeyEvent(aEvent.type, charCode ? 0 : keyCode,
|
||||
charCode, modifiers);
|
||||
} else if (aEvent.type) {
|
||||
utils.sendKeyEvent(aEvent.type, keyCode, 0, modifiers);
|
||||
} else {
|
||||
if (!("type" in aEvent) || !aEvent.type) {
|
||||
// Send keydown + (optional) keypress + keyup events.
|
||||
var keyDownDefaultHappened =
|
||||
utils.sendKeyEvent("keydown", keyCode, 0, modifiers);
|
||||
if (isKeypressFiredKey(keyCode)) {
|
||||
|
@ -399,6 +396,13 @@ function synthesizeKey(aKey, aEvent, aWindow)
|
|||
modifiers, !keyDownDefaultHappened);
|
||||
}
|
||||
utils.sendKeyEvent("keyup", keyCode, 0, modifiers);
|
||||
} else if (aEvent.type == "keypress") {
|
||||
// Send standalone keypress event.
|
||||
utils.sendKeyEvent(aEvent.type, charCode ? 0 : keyCode,
|
||||
charCode, modifiers);
|
||||
} else {
|
||||
// Send other standalone event than keypress.
|
||||
utils.sendKeyEvent(aEvent.type, keyCode, 0, modifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -511,7 +515,8 @@ function _getDOMWindowUtils(aWindow)
|
|||
// chrome: toolkit/content/tests/chrome/test_popup_anchor.xul
|
||||
if ("SpecialPowers" in window && window.SpecialPowers != undefined) {
|
||||
return SpecialPowers.getDOMWindowUtils(aWindow);
|
||||
} else if ("SpecialPowers" in parent && parent.SpecialPowers != undefined) {
|
||||
}
|
||||
if ("SpecialPowers" in parent && parent.SpecialPowers != undefined) {
|
||||
return parent.SpecialPowers.getDOMWindowUtils(aWindow);
|
||||
}
|
||||
|
||||
|
@ -642,9 +647,8 @@ function synthesizeQuerySelectedText(aWindow)
|
|||
{
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (!utils) {
|
||||
return nsnull;
|
||||
return null;
|
||||
}
|
||||
|
||||
return utils.sendQueryContentEvent(utils.QUERY_SELECTED_TEXT, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче