Skip to content

Commit

Permalink
Bug 1445942, make the backspace key a non-reserved key so that it isn…
Browse files Browse the repository at this point in the history
…'t blocked by shortcut permissions, r=felipe
  • Loading branch information
EnnDeakin2 committed Dec 17, 2018
1 parent 5a1e07c commit 778c883
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions browser/base/content/browser-sets.inc
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@
<key id="key_delete" keycode="VK_DELETE" command="cmd_delete"/>
<key id="key_selectAll" key="&selectAllCmd.key;" modifiers="accel"/>

<key keycode="VK_BACK" command="cmd_handleBackspace"/>
<key keycode="VK_BACK" command="cmd_handleShiftBackspace" modifiers="shift"/>
<key keycode="VK_BACK" command="cmd_handleBackspace" reserved="false"/>
<key keycode="VK_BACK" command="cmd_handleShiftBackspace" modifiers="shift" reserved="false"/>
#ifndef XP_MACOSX
<key id="goBackKb" keycode="VK_LEFT" command="Browser:Back" modifiers="alt"/>
<key id="goForwardKb" keycode="VK_RIGHT" command="Browser:Forward" modifiers="alt"/>
Expand Down
26 changes: 26 additions & 0 deletions browser/base/content/test/permissions/browser_reservedkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,29 @@ if (!navigator.platform.includes("Mac")) {
BrowserTestUtils.removeTab(tab1);
});
}

// There is a <key> element for Backspace with reserved="false", so make sure that it is not
// treated as a blocked shortcut key.
add_task(async function test_backspace() {
await new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": [["permissions.default.shortcuts", 2]]}, resolve);
});

// The input field is autofocused. If this test fails, backspace can go back
// in history so cancel the beforeunload event and adjust the field to make the test fail.
const uri = "data:text/html,<body onbeforeunload='document.getElementById('field').value = 'failed'; event.preventDefault();'>" +
"<input id='field' value='something' autofocus></body>";
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, uri);

// Move the caret so backspace will go delete the first character.
EventUtils.synthesizeKey("KEY_ArrowRight", {});
EventUtils.synthesizeKey("KEY_Backspace", {});

let fieldValue = await ContentTask.spawn(tab.linkedBrowser, { }, async function() {
return content.document.getElementById("field").value;
});
is(fieldValue, "omething", "backspace not prevented");

BrowserTestUtils.removeTab(tab);
});

0 comments on commit 778c883

Please sign in to comment.