Bug 1266952 - Remove cpow usage from browser_contextmenu_childprocess.js. r=felipe, a=test-only
authorNeil Deakin <neil@mozilla.com>
Wed, 14 Sep 2016 09:30:15 -0400
changeset 348180 e595d844f05d603bf1b069241b2ac52774ae8a6b
parent 348179 6b9c6e4a05773b239076134671b282f277549204
child 348181 d16c69ae7598faae957bfc58311cee859dab1632
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe, test-only
bugs1266952
milestone50.0a2
Bug 1266952 - Remove cpow usage from browser_contextmenu_childprocess.js. r=felipe, a=test-only
browser/base/content/test/general/browser_contextmenu_childprocess.js
--- a/browser/base/content/test/general/browser_contextmenu_childprocess.js
+++ b/browser/base/content/test/general/browser_contextmenu_childprocess.js
@@ -1,34 +1,31 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const gBaseURL = "https://example.com/browser/browser/base/content/test/general/";
 
 add_task(function *() {
-  let tab = gBrowser.addTab();
-  let browser = gBrowser.getBrowserForTab(tab);
+  let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gBaseURL + "subtst_contextmenu.html");
 
-  gBrowser.selectedTab = tab;
-  yield promiseTabLoadEvent(tab, gBaseURL + "subtst_contextmenu.html");
-
-  let popupShownPromise = promiseWaitForEvent(window, "popupshown", true);
+  let contextMenu = document.getElementById("contentAreaContextMenu");
 
   // Get the point of the element with the page menu (test-pagemenu) and
   // synthesize a right mouse click there.
-  let eventDetails = { type : "contextmenu", button : 2 };
-  let rect = browser.contentWindow.document.getElementById("test-pagemenu").getBoundingClientRect();
-  EventUtils.synthesizeMouse(browser, rect.x + rect.width / 2, rect.y + rect.height / 2, eventDetails, window);
-
+  let popupShownPromise = BrowserTestUtils.waitForEvent(contextMenu, "popupshown");
+  yield BrowserTestUtils.synthesizeMouse("#test-pagemenu", 5, 5, { type : "contextmenu", button : 2 }, tab.linkedBrowser);
   let event = yield popupShownPromise;
 
-  let contextMenu = document.getElementById("contentAreaContextMenu");
   checkMenu(contextMenu);
+
+  let popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
   contextMenu.hidePopup();
-  gBrowser.removeCurrentTab();
+  yield popupHiddenPromise;
+
+  yield BrowserTestUtils.removeTab(tab);
 });
 
 function checkItems(menuitem, arr)
 {
   for (let i = 0; i < arr.length; i += 2) {
     let str = arr[i];
     let details = arr[i + 1];
     if (str == "---") {