зеркало из https://github.com/mozilla/gecko-dev.git
Bug 674323 - convert most eventutils.js functions to use SpecialPowers. r=ted, a=test-only
This commit is contained in:
Родитель
f76f05bba1
Коммит
53d448d706
|
@ -33,10 +33,12 @@ SimpleTest.waitForExplicitFinish();
|
|||
function mouseHandler(aEvent)
|
||||
{
|
||||
gNumberOfMouseEventsCatched++;
|
||||
var classList = SpecialPowers.getPrivilegedProps(aEvent, "originalTarget.classList");
|
||||
var nodeName = SpecialPowers.getPrivilegedProps(aEvent, "originalTarget.nodeName");
|
||||
|
||||
is(aEvent.originalTarget.nodeName, "DIV", "An inner div should be the target of the event");
|
||||
is(nodeName, "DIV", "An inner div should be the target of the event");
|
||||
|
||||
ok(aEvent.originalTarget.classList.contains("anonymous-div") && !aEvent.originalTarget.classList.contains("placeholder"),
|
||||
ok(classList.contains("anonymous-div") && !classList.contains("placeholder"),
|
||||
"The target div class doesn't correcspond to the editor div class");
|
||||
}
|
||||
|
||||
|
@ -44,13 +46,13 @@ function checkMouseEvents(element)
|
|||
{
|
||||
gNumberOfMouseEventsCatched = 0;
|
||||
|
||||
synthesizeMouse(element, 5, 5, {type: "mousedown", button: 0})
|
||||
synthesizeMouse(element, 5, 5, {type: "mouseup", button: 0})
|
||||
synthesizeMouse(element, 5, 5, {type: "mousedown", button: 1})
|
||||
synthesizeMouse(element, 5, 5, {type: "mousedown", button: 0});
|
||||
synthesizeMouse(element, 5, 5, {type: "mouseup", button: 0});
|
||||
synthesizeMouse(element, 5, 5, {type: "mousedown", button: 1});
|
||||
// NOTE: this event is going to copy the buffer on linux, this should not be a problem
|
||||
synthesizeMouse(element, 5, 5, {type: "mouseup", button: 1})
|
||||
synthesizeMouse(element, 5, 5, {type: "mousedown", button: 2})
|
||||
synthesizeMouse(element, 5, 5, {type: "mouseup", button: 2})
|
||||
synthesizeMouse(element, 5, 5, {type: "mouseup", button: 1});
|
||||
synthesizeMouse(element, 5, 5, {type: "mousedown", button: 2});
|
||||
synthesizeMouse(element, 5, 5, {type: "mouseup", button: 2});
|
||||
|
||||
is(gNumberOfMouseEventsCatched, 6, "Some mouse events have not been catched");
|
||||
}
|
||||
|
|
|
@ -218,13 +218,8 @@ function _parseModifiers(aEvent)
|
|||
*/
|
||||
function synthesizeMouse(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
|
||||
if (!aWindow)
|
||||
aWindow = window;
|
||||
|
||||
var utils = aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
if (utils) {
|
||||
var button = aEvent.button || 0;
|
||||
var clickCount = aEvent.clickCount || 1;
|
||||
|
@ -278,13 +273,8 @@ function synthesizeMouseAtCenter(aTarget, aEvent, aWindow)
|
|||
*/
|
||||
function synthesizeMouseScroll(aTarget, aOffsetX, aOffsetY, aEvent, aWindow)
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
|
||||
if (!aWindow)
|
||||
aWindow = window;
|
||||
|
||||
var utils = aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
if (utils) {
|
||||
// See nsMouseScrollFlags in nsGUIEvent.h
|
||||
const kIsVertical = 0x02;
|
||||
|
@ -406,13 +396,7 @@ function _computeKeyCodeFromChar(aChar)
|
|||
*/
|
||||
function synthesizeKey(aKey, aEvent, aWindow)
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
if (!aWindow)
|
||||
aWindow = window;
|
||||
|
||||
var utils = aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (utils) {
|
||||
var keyCode = 0, charCode = 0;
|
||||
if (aKey.indexOf("VK_") == 0)
|
||||
|
@ -531,13 +515,8 @@ function synthesizeKeyExpectEvent(key, aEvent, aExpectedTarget, aExpectedEvent,
|
|||
|
||||
function disableNonTestMouseEvents(aDisable)
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
var utils =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
if (utils)
|
||||
utils.disableNonTestMouseEvents(aDisable);
|
||||
var domutils = _getDOMWindowUtils();
|
||||
domutils.disableNonTestMouseEvents(aDisable);
|
||||
}
|
||||
|
||||
function _getDOMWindowUtils(aWindow)
|
||||
|
@ -545,8 +524,20 @@ function _getDOMWindowUtils(aWindow)
|
|||
if (!aWindow) {
|
||||
aWindow = window;
|
||||
}
|
||||
|
||||
// we need parent.SpecialPowers for:
|
||||
// layout/base/tests/test_reftests_with_caret.html
|
||||
// chrome: toolkit/content/tests/chrome/test_findbar.xul
|
||||
// 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) {
|
||||
return parent.SpecialPowers.getDOMWindowUtils(aWindow);
|
||||
}
|
||||
|
||||
//TODO: this is assuming we are in chrome space
|
||||
return aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -565,8 +556,6 @@ function _getDOMWindowUtils(aWindow)
|
|||
*/
|
||||
function synthesizeComposition(aEvent, aWindow)
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (!utils) {
|
||||
return;
|
||||
|
@ -575,7 +564,6 @@ function synthesizeComposition(aEvent, aWindow)
|
|||
utils.sendCompositionEvent(aEvent.type, aEvent.data ? aEvent.data : "",
|
||||
aEvent.locale ? aEvent.locale : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Synthesize a text event.
|
||||
*
|
||||
|
@ -618,8 +606,6 @@ function synthesizeComposition(aEvent, aWindow)
|
|||
*/
|
||||
function synthesizeText(aEvent, aWindow)
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (!utils) {
|
||||
return;
|
||||
|
@ -668,8 +654,6 @@ function synthesizeText(aEvent, aWindow)
|
|||
*/
|
||||
function synthesizeQuerySelectedText(aWindow)
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
var utils = _getDOMWindowUtils(aWindow);
|
||||
if (!utils) {
|
||||
return nsnull;
|
||||
|
|
Загрузка…
Ссылка в новой задаче