Bug 511639 - Login manager should ignore untrusted events. r=gavin, sr=mconnor, a190=dveditz

git-svn-id: svn://10.0.0.236/trunk@258483 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dolske%mozilla.com
2009-09-23 21:06:46 +00:00
parent 3a066cf53c
commit 528941fc27
2 changed files with 27 additions and 14 deletions

View File

@@ -316,6 +316,9 @@ LoginManager.prototype = {
handleEvent : function (event) {
if (!event.isTrusted)
return;
this._pwmgr.log("domEventListener: got event " + event.type);
var doc, inputElement;

View File

@@ -150,6 +150,12 @@ function doKey(aKey, modifier) {
}
function sendFakeAutocompleteEvent(element) {
var acEvent = document.createEvent("HTMLEvents");
acEvent.initEvent("DOMAutoComplete", true, false);
element.dispatchEvent(acEvent);
}
/*
* Main section of test...
@@ -161,7 +167,11 @@ function doKey(aKey, modifier) {
*/
function runTest(testNum) {
// Seems we need to enable this again, or sendKeyEvent() complaints.
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
// But don't for test 14, or else dispatchEvent will send it as a trusted
// event (we're testing to see if we ignore untrusted events, so don't want
// that).
if (testNum != 14)
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
ok(true, "Starting test #" + testNum);
switch(testNum) {
@@ -323,6 +333,19 @@ function runTest(testNum) {
doKey("page_down");
doKey("return");
checkACForm("zzzuser4", "zzzpass4");
restoreForm();
break;
case 14:
// Send a fake (untrusted) event.
checkACForm("", "");
uname.value = "zzzuser4";
sendFakeAutocompleteEvent(uname);
checkACForm("zzzuser4", "");
break;
case 15:
checkACForm("zzzuser4", "");
// Trigger autocomplete popup
restoreForm();
@@ -330,19 +353,6 @@ function runTest(testNum) {
testNum = 49;
break;
case 14:
// Abort with ESC
// XXX This isn't working in the test suite, seems to fubar any later tests.
// doKey("down");
// doKey("down");
// doKey("escape");
// checkACForm("", "");
// Trigger autocomplete popup
// restoreForm();
// doKey("down");
break;
// XXX tried sending character "t" before/during dropdown to test
// filtering, but had no luck. Seemed like the character was getting lost.
// Setting uname.value didn't seem to work either. This works with a human