Bug 677372 - Add onContextMenuShown option to test_contextmenu. r?markh draft
authorEdouard Oger <eoger@fastmail.com>
Mon, 27 Jun 2016 16:46:43 -0700
changeset 387923 2779ad911175e237fae585f0466807f173cd08bb
parent 387623 08f8a5aacd8308a73f6040fe522be7ba38497561
child 387924 76deb4138c4432d23ab15d8ba9c2b259c9dbe4fa
push id23105
push userbmo:edouard.oger@gmail.com
push dateFri, 15 Jul 2016 01:50:01 +0000
reviewersmarkh
bugs677372
milestone50.0a1
Bug 677372 - Add onContextMenuShown option to test_contextmenu. r?markh MozReview-Commit-ID: D7sdRrsWRCF
browser/base/content/test/general/contextmenu_common.js
--- 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);