Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
bug 631519: remove add-on bar keyboard shortcut now that it is built …
Browse files Browse the repository at this point in the history
…into Firefox; r=myk
  • Loading branch information
ochameau authored and mykmelez committed Feb 23, 2011
1 parent 9f0477b commit 79e2f79
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
26 changes: 1 addition & 25 deletions packages/addon-kit/lib/widget.js
Expand Up @@ -317,31 +317,7 @@ BrowserWindow.prototype = {
// symbiont: contentSymbiont
// }
this._items = [];

// Add keypress listener
this.window.addEventListener("keypress", this, false);
},

// nsIDOMEventListener
handleEvent: function BW_handleEvent(aEvent) {
switch (aEvent.type) {
case "keypress":
this._onKeyPress(aEvent);
break;
}
},

_onKeyPress: function BW__onKeyPress(aEvent) {
let accelKey = /^Mac/.test(this.window.navigator.platform) ?
aEvent.metaKey : aEvent.ctrlKey;
let nonAccelKey = /^Mac/.test(this.window.navigator.platform) ?
aEvent.ctrlKey : aEvent.metaKey;
if (aEvent.which == aEvent.DOM_VK_U && aEvent.shiftKey &&
accelKey && !nonAccelKey && !aEvent.altKey) {
this._onToggleUI();
// Work around bug 582052 by preventing the (nonexistent) default action.
aEvent.preventDefault();
}

},

get container() {
Expand Down
26 changes: 0 additions & 26 deletions packages/addon-kit/tests/test-widget.js
Expand Up @@ -376,32 +376,6 @@ exports.testConstructor = function(test) {
}});
});

// test the visibility keyboard shortcut
tests.push(function() {
// Test hide/show the widget bar
function toggleUI() {
let keyEvent = doc.createEvent("KeyEvents");
let ctrlKey = false, metaKey = false, shiftKey = true, altKey = false, charCode = keyEvent.DOM_VK_U, keyCode = 0;
if(/^Mac/.test(browserWindow.navigator.platform))
metaKey = true;
else
ctrlKey = true;
keyEvent.initKeyEvent("keypress", true, true, browserWindow, ctrlKey, altKey, shiftKey, metaKey, keyCode, charCode);
doc.dispatchEvent(keyEvent);
}

test.assert(container().collapsed, "UI is not visible when no widgets");
let w = widgets.Widget({label: "foo", content: "bar"});
test.assert(container(), "UI exists when widgets are created");
test.assertEqual(container().collapsed, false, "UI is visible by default");
toggleUI();
test.assertEqual(container().collapsed, true, "keyboard shortcut hides UI when visible");
toggleUI();
test.assertEqual(container().collapsed, false, "keyboard shortcut shows UI when hidden");
w.destroy();
doneTest();
});

// test widget.width
tests.push(function() testSingleWidget({
label: "test widget.width",
Expand Down

0 comments on commit 79e2f79

Please sign in to comment.