Bug 677372 - Add onContextMenuShown option to test_contextmenu. r?markh
MozReview-Commit-ID: D7sdRrsWRCF
--- a/browser/base/content/test/general/contextmenu_common.js
+++ b/browser/base/content/test/general/contextmenu_common.js
@@ -237,16 +237,17 @@ let lastElementSelector = null;
* the element, optional
* offsetY: vertical mouse offset from the top-left corner of the
* element, optional
* centered: if true, mouse position is centered in element, defaults
* to true if offsetX and offsetY are not provided
* waitForSpellCheck: wait until spellcheck is initialized before
* starting test
* preCheckContextMenuFn: callback to run before opening menu
+ * onContextMenuShown: callback to run when the context menu is shown
* postCheckContextMenuFn: callback to run after opening menu
* @return {Promise} resolved after the test finishes
*/
function* test_contextmenu(selector, menuItems, options={}) {
contextMenu = document.getElementById("contentAreaContextMenu");
is(contextMenu.state, "closed", "checking if popup is closed");
// Default to centered if no positioning is defined.
@@ -290,16 +291,21 @@ function* test_contextmenu(selector, men
button: 2,
shiftkey: options.shiftkey,
centered: options.centered
},
gBrowser.selectedBrowser);
yield awaitPopupShown;
info("Popup Shown");
+ if (options.onContextMenuShown) {
+ yield options.onContextMenuShown();
+ info("Completed onContextMenuShown");
+ }
+
if (menuItems) {
if (Services.prefs.getBoolPref("devtools.inspector.enabled")) {
let inspectItems = ["---", null,
"context-inspect", true];
menuItems = menuItems.concat(inspectItems);
}
checkContextMenu(menuItems);