Bug 848943 - Wait for popupshown to know when the context menu is ready. r=gavin

This commit is contained in:
Matthew Noorenberghe 2013-03-12 08:38:42 -04:00
parent e1b5e8aef2
commit 085f2473e2
2 changed files with 17 additions and 4 deletions

View File

@ -20,7 +20,7 @@ function test() {
//ss.currentEngine = engine;
break;
case "engine-current":
ok(ss.currentEngine.name == ENGINE_NAME, "currentEngine set");
is(ss.currentEngine.name, ENGINE_NAME, "currentEngine set");
startTest();
break;
case "engine-removed":
@ -40,16 +40,16 @@ function test() {
ok(contextMenu, "Got context menu XUL");
doOnloadOnce(testContextMenu);
var tab = gBrowser.addTab("data:text/plain,test%20search");
var tab = gBrowser.addTab("data:text/plain;charset=utf8,test%20search");
gBrowser.selectedTab = tab;
}
function testContextMenu() {
function rightClickOnDocument() {
waitForBrowserContextMenu(checkContextMenu);
var clickTarget = content.document.body;
var eventDetails = { type: "contextmenu", button: 2 };
EventUtils.synthesizeMouseAtCenter(clickTarget, eventDetails, content);
SimpleTest.executeSoon(checkContextMenu);
}
// check the search menu item and then perform a search

View File

@ -17,3 +17,16 @@ function isSubObjectOf(expectedObj, actualObj, name) {
}
}
}
function waitForPopupShown(aPopupId, aCallback) {
let popup = document.getElementById(aPopupId);
function onPopupShown() {
popup.removeEventListener("popupshown", onPopupShown);
SimpleTest.executeSoon(aCallback);
}
popup.addEventListener("popupshown", onPopupShown);
}
function waitForBrowserContextMenu(aCallback) {
waitForPopupShown(gBrowser.selectedBrowser.contextMenu, aCallback);
}