Bug 1311477 - Avoid using an unsafe CPOW in browser_save_link-perwindowpb.js. r=mrbkap, a=test-only
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 19 Oct 2016 14:46:41 -0400
changeset 356299 982c72148922b9cb4b970be2e9d96386dfedadf9
parent 356298 d114796a13b1bcdd87d73d6da769d8360429fa4e
child 356300 d9cd36fc09b2211bc30f17c66160f47a29bfe484
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, test-only
bugs1311477
milestone51.0a2
Bug 1311477 - Avoid using an unsafe CPOW in browser_save_link-perwindowpb.js. r=mrbkap, a=test-only
browser/base/content/test/general/browser_save_link-perwindowpb.js
--- a/browser/base/content/test/general/browser_save_link-perwindowpb.js
+++ b/browser/base/content/test/general/browser_save_link-perwindowpb.js
@@ -10,38 +10,26 @@ MockFilePicker.init(window);
 // during the second request.
 function triggerSave(aWindow, aCallback) {
   info("started triggerSave");
   var fileName;
   let testBrowser = aWindow.gBrowser.selectedBrowser;
   // This page sets a cookie if and only if a cookie does not exist yet
   let testURI = "http://mochi.test:8888/browser/browser/base/content/test/general/bug792517-2.html";
   testBrowser.loadURI(testURI);
-  testBrowser.addEventListener("pageshow", function pageShown(event) {
-    info("got pageshow with " + event.target.location);
-    if (event.target.location != testURI) {
-      info("try again!");
-      testBrowser.loadURI(testURI);
-      return;
-    }
-    info("found our page!");
-    testBrowser.removeEventListener("pageshow", pageShown, false);
-
+  BrowserTestUtils.browserLoaded(testBrowser, false, testURI)
+                  .then(() => {
     waitForFocus(function () {
       info("register to handle popupshown");
       aWindow.document.addEventListener("popupshown", contextMenuOpened, false);
 
-      var link = testBrowser.contentDocument.getElementById("fff");
-      info("link: " + link);
-      EventUtils.synthesizeMouseAtCenter(link,
-                                         { type: "contextmenu", button: 2 },
-                                         testBrowser.contentWindow);
+      BrowserTestUtils.synthesizeMouseAtCenter("#fff", {type: "contextmenu", button: 2}, testBrowser);
       info("right clicked!");
-    }, testBrowser);
-  }, false);
+    }, aWindow);
+  });
 
   function contextMenuOpened(event) {
     info("contextMenuOpened");
     aWindow.document.removeEventListener("popupshown", contextMenuOpened);
 
     // Create the folder the link will be saved into.
     var destDir = createTemporarySaveDirectory();
     var destFile = destDir.clone();