зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1878629 - part 4: Use EventTarget.addEventListener to add system group event listeners instead of nsIEventListenerService (editor/) r=masayuki
Depends on D201045 Differential Revision: https://phabricator.services.mozilla.com/D201046
This commit is contained in:
Родитель
dc7fa76c9d
Коммит
9a182a662f
|
@ -54,19 +54,15 @@ function runTest() {
|
||||||
sendAsyncMessage("ok", [true, "onPromptFocus is called"]);
|
sendAsyncMessage("ok", [true, "onPromptFocus is called"]);
|
||||||
gPromptInput.removeEventListener("focus", onPromptFocus);
|
gPromptInput.removeEventListener("focus", onPromptFocus);
|
||||||
|
|
||||||
var listenerService = Services.els;
|
|
||||||
|
|
||||||
var listener = {
|
var listener = {
|
||||||
handleEvent: function _hv(aEvent) {
|
handleEvent: function _hv(aEvent) {
|
||||||
var isPrevented = aEvent.defaultPrevented;
|
var isPrevented = aEvent.defaultPrevented;
|
||||||
sendAsyncMessage("ok", [!isPrevented,
|
sendAsyncMessage("ok", [!isPrevented,
|
||||||
"ESC key event is prevented by editor"]);
|
"ESC key event is prevented by editor"]);
|
||||||
listenerService.removeSystemEventListener(gPromptInput, "keypress",
|
gPromptInput.removeEventListener("keypress", listener, { mozSystemGroup: true });
|
||||||
listener, false);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
listenerService.addSystemEventListener(gPromptInput, "keypress",
|
gPromptInput.addEventListener("keypress", listener, { mozSystemGroup: true });
|
||||||
listener, false);
|
|
||||||
|
|
||||||
sendAsyncMessage("info", "sending key");
|
sendAsyncMessage("info", "sending key");
|
||||||
var EventUtils = {};
|
var EventUtils = {};
|
||||||
|
|
|
@ -55,7 +55,7 @@ function startTests() {
|
||||||
SimpleTest.executeSoon(runNextTest);
|
SimpleTest.executeSoon(runNextTest);
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
SpecialPowers.addSystemEventListener(window, "auxclick", function(aEvent) {
|
SpecialPowers.wrap(window).addEventListener("auxclick", function(aEvent) {
|
||||||
// When the click event should cause default action, e.g., opening the link,
|
// When the click event should cause default action, e.g., opening the link,
|
||||||
// the event shouldn't have been consumed except the link handler.
|
// the event shouldn't have been consumed except the link handler.
|
||||||
// However, in e10s mode, it's not consumed during propagating the event but
|
// However, in e10s mode, it's not consumed during propagating the event but
|
||||||
|
@ -74,7 +74,7 @@ function startTests() {
|
||||||
// In this case, "storage" event won't be fired.
|
// In this case, "storage" event won't be fired.
|
||||||
SimpleTest.executeSoon(runNextTest);
|
SimpleTest.executeSoon(runNextTest);
|
||||||
}
|
}
|
||||||
}, false);
|
}, { mozSystemGroup: true });
|
||||||
|
|
||||||
SimpleTest.executeSoon(runNextTest);
|
SimpleTest.executeSoon(runNextTest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,7 @@ function runTests() {
|
||||||
aEvent.preventDefault(); // prevent the browser default behavior
|
aEvent.preventDefault(); // prevent the browser default behavior
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
var els = Services.els;
|
SpecialPowers.wrap(window).addEventListener("keypress", listener, { mozSystemGroup: true });
|
||||||
els.addSystemEventListener(window, "keypress", listener, false);
|
|
||||||
|
|
||||||
var staticContent = document.getElementById("static");
|
var staticContent = document.getElementById("static");
|
||||||
staticContent._defaultValue = getTextValue(staticContent);
|
staticContent._defaultValue = getTextValue(staticContent);
|
||||||
|
@ -306,7 +305,7 @@ function runTests() {
|
||||||
testTextInput(inputInEditor);
|
testTextInput(inputInEditor);
|
||||||
testTextInput(textareaInEditor);
|
testTextInput(textareaInEditor);
|
||||||
|
|
||||||
els.removeSystemEventListener(window, "keypress", listener, false);
|
SpecialPowers.wrap(window).removeEventListener("keypress", listener, { mozSystemGroup: true });
|
||||||
|
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,8 +79,8 @@ async function runTests() {
|
||||||
getDesciption(aPreventedOnBubbling) + "prevented on bubbling phase");
|
getDesciption(aPreventedOnBubbling) + "prevented on bubbling phase");
|
||||||
}
|
}
|
||||||
|
|
||||||
SpecialPowers.addSystemEventListener(window, "keypress", listener, true);
|
SpecialPowers.wrap(window).addEventListener("keypress", listener, { capture: true, mozSystemGroup: true });
|
||||||
SpecialPowers.addSystemEventListener(window, "keypress", listener, false);
|
SpecialPowers.wrap(window).addEventListener("keypress", listener, { capture: false, mozSystemGroup: true });
|
||||||
|
|
||||||
// eslint-disable-next-line complexity
|
// eslint-disable-next-line complexity
|
||||||
async function doTest(
|
async function doTest(
|
||||||
|
@ -754,8 +754,8 @@ async function runTests() {
|
||||||
await doTest(htmlEditor, "readonly and non-tabbable HTML editor but plaintext mode",
|
await doTest(htmlEditor, "readonly and non-tabbable HTML editor but plaintext mode",
|
||||||
true, false, true);
|
true, false, true);
|
||||||
|
|
||||||
SpecialPowers.removeSystemEventListener(window, "keypress", listener, true);
|
SpecialPowers.wrap(window).removeEventListener("keypress", listener, { capture: true, mozSystemGroup: true });
|
||||||
SpecialPowers.removeSystemEventListener(window, "keypress", listener, false);
|
SpecialPowers.wrap(window).removeEventListener("keypress", listener, { capture: false, mozSystemGroup: true });
|
||||||
|
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,10 +80,8 @@ async function runTests() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var parentElement = document.getElementById("display");
|
var parentElement = document.getElementById("display");
|
||||||
SpecialPowers.addSystemEventListener(parentElement, "keypress", listener,
|
SpecialPowers.wrap(parentElement).addEventListener("keypress", listener, { capture: true, mozSystemGroup: true });
|
||||||
true);
|
SpecialPowers.wrap(parentElement).addEventListener("keypress", listener, { capture: false, mozSystemGroup: true });
|
||||||
SpecialPowers.addSystemEventListener(parentElement, "keypress", listener,
|
|
||||||
false);
|
|
||||||
|
|
||||||
async function doTest(aElement, aDescription, aIsSingleLine, aIsReadonly) {
|
async function doTest(aElement, aDescription, aIsSingleLine, aIsReadonly) {
|
||||||
function reset(aText) {
|
function reset(aText) {
|
||||||
|
@ -457,10 +455,8 @@ async function runTests() {
|
||||||
textarea.setAttribute("readonly", "readonly");
|
textarea.setAttribute("readonly", "readonly");
|
||||||
await doTest(textarea, "<textarea readonly>", false, true);
|
await doTest(textarea, "<textarea readonly>", false, true);
|
||||||
|
|
||||||
SpecialPowers.removeSystemEventListener(parentElement, "keypress", listener,
|
SpecialPowers.wrap(parentElement).removeEventListener("keypress", listener, { capture: true, mozSystemGroup: true });
|
||||||
true);
|
SpecialPowers.wrap(parentElement).removeEventListener("keypress", listener, { capture: false, mozSystemGroup: true });
|
||||||
SpecialPowers.removeSystemEventListener(parentElement, "keypress", listener,
|
|
||||||
false);
|
|
||||||
|
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче