diff --git a/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js b/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js index b25c0eca267..652f0f5cca7 100644 --- a/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js +++ b/mozilla/toolkit/components/passwordmgr/src/nsLoginManager.js @@ -316,6 +316,9 @@ LoginManager.prototype = { handleEvent : function (event) { + if (!event.isTrusted) + return; + this._pwmgr.log("domEventListener: got event " + event.type); var doc, inputElement; diff --git a/mozilla/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html b/mozilla/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html index 61202bd9419..831f99f5ee3 100644 --- a/mozilla/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html +++ b/mozilla/toolkit/components/passwordmgr/test/test_basic_form_autocomplete.html @@ -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