Skip to content

Commit

Permalink
Bug 1720252 - Get rid of "dom.input_events.beforeinput.enabled" from …
Browse files Browse the repository at this point in the history
…tests r=smaug

`beforeinput` event was shipped and it won't be disabled for avoiding confusion
of web developers. So, we can drop the pref setting of
"dom.input_events.beforeinput.enabled" in our tests.

Depends on D119716

Differential Revision: https://phabricator.services.mozilla.com/D119729
  • Loading branch information
masayuki-nakano committed Jul 13, 2021
1 parent b823b8b commit 3169bc5
Show file tree
Hide file tree
Showing 41 changed files with 27 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@
}

async function confirmClear(selector) {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});
info("Await for clearing input");
let promise = new Promise(resolve => {
let beforeInputFired = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ async function triggerAutofillAndCheckProfile(profile) {
const adaptedProfile = _getAdaptedProfile(profile);
const promises = [];

await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

for (const [fieldName, value] of Object.entries(adaptedProfile)) {
info(`triggerAutofillAndCheckProfile: ${fieldName}`);
const element = document.getElementById(fieldName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@
add_task(async function setup() {
// This test relies on being able to fill a Canadian address which isn't possible
// without `supportedCountries` allowing Canada
await SpecialPowers.pushPrefEnv({"set": [["extensions.formautofill.supportedCountries", "US,CA"],
["dom.input_events.beforeinput.enabled", true]]});
await SpecialPowers.pushPrefEnv({"set": [["extensions.formautofill.supportedCountries", "US,CA"]]});

await setupAddressStorage();
});
Expand Down
7 changes: 1 addition & 6 deletions devtools/server/actors/utils/event-breakpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

"use strict";

const Services = require("Services");

function generalEvent(groupID, eventType) {
return {
id: `event.${groupID}.${eventType}`,
Expand Down Expand Up @@ -177,10 +175,7 @@ const AVAILABLE_BREAKPOINTS = [
{
name: "Keyboard",
items: [
Services.prefs &&
Services.prefs.getBoolPref("dom.input_events.beforeinput.enabled")
? generalEvent("keyboard", "beforeinput")
: null,
generalEvent("keyboard", "beforeinput"),
generalEvent("keyboard", "input"),
generalEvent("keyboard", "keydown"),
generalEvent("keyboard", "keyup"),
Expand Down
3 changes: 0 additions & 3 deletions dom/base/test/chrome/window_nsITextInputProcessor.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -4330,9 +4330,6 @@ async function runCallbackTests(aForTests)
async function runTests()
{
textareaInFrame = iframe.contentDocument.getElementById("textarea");
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});
runBeginInputTransactionMethodTests();
runReleaseTests();
runCompositionTests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ async function installAndStartExtension() {
}

add_task(async function() {
await pushPrefs(["dom.input_events.beforeinput.enabled", true]);

const extension = await installAndStartExtension();
const tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
Expand Down
6 changes: 2 additions & 4 deletions dom/events/test/test_dom_keyboard_event.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

const kStrictKeyPressEvents =
SpecialPowers.getBoolPref("dom.keyboardevent.keypress.dispatch_non_printable_keys_only_system_group_in_content");
const kBeforeinputEventEnabled =
SpecialPowers.getBoolPref("dom.input_events.beforeinput.enabled");

function testInitializingUntrustedEvent()
{
Expand Down Expand Up @@ -427,7 +425,7 @@
is(keypressFired, true,
kDescription + "keypress event should be fired when Enter key is pressed");
if (isEditable) {
is(beforeinputFired, kBeforeinputEventEnabled,
ok(beforeinputFired,
kDescription + "beforeinput event should be fired (if it's enabled) when Enter key is pressed");
} else {
is(beforeinputFired, false,
Expand All @@ -448,7 +446,7 @@
is(keypressFired, true,
kDescription + "keypress event should be fired when Shift + Enter key is pressed");
if (isEditable) {
is(beforeinputFired, kBeforeinputEventEnabled,
ok(beforeinputFired,
kDescription + "beforeinput event should be fired (if it's enabled) when Shift + Enter key is pressed");
} else {
is(beforeinputFired, false,
Expand Down
3 changes: 0 additions & 3 deletions dom/html/test/forms/test_MozEditableElement_setUserInput.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
SimpleTest.waitForExplicitFinish();
// eslint-disable-next-line complexity
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});
const kSetUserInputCancelable = SpecialPowers.getBoolPref("dom.input_event.allow_to_cancel_set_user_input");

let content = document.getElementById("content");
Expand Down
5 changes: 1 addition & 4 deletions dom/html/test/forms/test_input_event.html
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,7 @@
}

SimpleTest.waitForExplicitFinish();
document.addEventListener("DOMContentLoaded", async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});
document.addEventListener("DOMContentLoaded", () => {
init();
SimpleTest.waitForFocus(testUserInput);
}, {once: true});
Expand Down
5 changes: 1 addition & 4 deletions dom/html/test/forms/test_input_setting_value.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@

<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});
SimpleTest.waitForFocus(() => {
const kSetUserInputCancelable = SpecialPowers.getBoolPref("dom.input_event.allow_to_cancel_set_user_input");

let input = document.querySelector("input[type=text]");
Expand Down
2 changes: 0 additions & 2 deletions dom/tests/mochitest/general/test_clipboard_events.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
// NOTE: The tests operate under the assumption that the protected mode of
// DataTransfer is enabled.
["dom.events.dataTransfer.protected.enabled", true],
// GlobalEventHandlers.onbeforeinput is required.
["dom.input_events.beforeinput.enabled", true],
]
});
let childWindow =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async function() {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

document.execCommand("enableAbsolutePositionEditing", false, true);
ok(document.queryCommandState("enableAbsolutePositionEditing"),
"Absolute positioned element editor should be enabled by the call of execCommand");
Expand Down
5 changes: 1 addition & 4 deletions editor/libeditor/tests/test_bug430392.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@

/** Test for Bug 430392 **/

async function test() {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});
function test() {
var edit = document.getElementById("edit");
var html = edit.innerHTML;
var expectedText = edit.textContent;
Expand Down
3 changes: 1 addition & 2 deletions editor/libeditor/tests/test_bug520189.html
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,7 @@

addLoadEvent(function() {
SpecialPowers.pushPrefEnv(
{ "set": [["layout.css.moz-document.content.enabled", true],
["dom.input_events.beforeinput.enabled", true]]},
{ "set": [["layout.css.moz-document.content.enabled", true]]},
doNextTest);
});
</script>
Expand Down
6 changes: 1 addition & 5 deletions editor/libeditor/tests/test_bug596333.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@
});
}

async function runTest() {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

function runTest() {
var edit = document.getElementById("edit");
edit.focus();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@
const kIsWin = navigator.platform.indexOf("Win") == 0;
const kIsMac = navigator.platform.indexOf("Mac") == 0;

async function runTests() {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

function runTests() {
const kWordSelectEatSpaceToNextWord = SpecialPowers.getBoolPref("layout.word_select.eat_space_to_next_word");
const kImgURL =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAEElEQVR42mNgaGD4D8YwBgAw9AX9Y9zBwwAAAABJRU5ErkJggg==";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
const kIsWin = navigator.platform.indexOf("Win") == 0;
const kIsMac = navigator.platform.indexOf("Mac") == 0;

async function runTests() {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

function runTests() {
const kWordSelectEatSpaceToNextWord = SpecialPowers.getBoolPref("layout.word_select.eat_space_to_next_word");

function doTests(aElement, aDescription, aIsTextarea) {
Expand Down
4 changes: 0 additions & 4 deletions editor/libeditor/tests/test_dragdrop.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@
}

async function doTest() {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

let container = document.getElementById("container");
let dropZone = document.getElementById("dropZone");

Expand Down
3 changes: 1 addition & 2 deletions editor/libeditor/tests/test_middle_click_paste.html
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,7 @@
async function doTests() {
await SpecialPowers.pushPrefEnv({"set": [["middlemouse.paste", true],
["middlemouse.contentLoadURL", false],
["dom.event.clipboardevents.enabled", true],
["dom.input_events.beforeinput.enabled", true]]});
["dom.event.clipboardevents.enabled", true]]});
let container = document.getElementById("container");
container.innerHTML = "<textarea id=\"editor\"></textarea>";
await doTextareaTests(document.getElementById("editor"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
<script class="testbody" type="application/javascript">

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

SimpleTest.waitForFocus(() => {
let editor = document.getElementById("content");
let selection = document.getSelection();

Expand Down
6 changes: 1 addition & 5 deletions editor/libeditor/tests/test_nsIEditor_insertLineBreak.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@

SimpleTest.waitForExplicitFinish();
SimpleTest.expectAssertions(0, 2); // In a11y module
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

SimpleTest.waitForFocus(() => {
let input = document.getElementsByTagName("input")[0];
let textarea = document.getElementsByTagName("textarea")[0];
let contenteditable = document.getElementById("content");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@

SimpleTest.waitForExplicitFinish();

SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

SimpleTest.waitForFocus(() => {
let editor = document.getElementById("content");
let selection = window.getSelection();
let description, condition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
"use strict";

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

SimpleTest.waitForFocus(() => {
let editor = document.getElementById("content");
let selection = document.getSelection();
let selectionRanges = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
"use strict";

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

SimpleTest.waitForFocus(() => {
let editor = document.getElementById("content");
let selection = document.getSelection();
let selectionRanges = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
"use strict";

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

SimpleTest.waitForFocus(() => {
let editor = document.getElementById("content");
let selection = document.getSelection();
let selectionRanges = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
"use strict";

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

SimpleTest.waitForFocus(() => {
let editor = document.getElementById("content");
let selection = document.getSelection();
let selectionRanges = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
"use strict";

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

SimpleTest.waitForFocus(() => {
let editor = document.getElementById("content");
let selection = document.getSelection();
let selectionRanges = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
"use strict";

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

SimpleTest.waitForFocus(() => {
let editor = document.getElementById("content");
let selection = document.getSelection();
let selectionRanges = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
"use strict";

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

SimpleTest.waitForFocus(() => {
let editor = document.getElementById("content");
let selection = document.getSelection();
let selectionRanges = [];
Expand Down
4 changes: 0 additions & 4 deletions editor/libeditor/tests/test_resizers_resizing_elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true]],
});

document.execCommand("enableObjectResizing", false, true);
ok(document.queryCommandState("enableObjectResizing"),
"Object resizer should be enabled by the call of execCommand");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
// eslint-disable-next-line complexity
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [["dom.input_events.beforeinput.enabled", true],
["editor.truncate_user_pastes", false],
],
});

SimpleTest.waitForFocus(() => {
let content = document.getElementById("content");
for (let test of [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
SimpleTest.waitForFocus(async () => {
await SpecialPowers.pushPrefEnv({
set: [
["dom.input_events.beforeinput.enabled", true],
// Even if `beforeinput` events for `setUserInput()` calls are not
// allowed to cancel, correcting the spells should be cancelable for
// compatibility with the other browsers.
Expand Down
Loading

0 comments on commit 3169bc5

Please sign in to comment.