Bug 1311477 - Avoid using an unsafe CPOW in browser_save_link-perwindowpb.js; r=mrbkap
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 19 Oct 2016 14:46:41 -0400
changeset 319327 621f85162b23a4be91fd47fa9aa79172fe182d78
parent 319260 2dca0ba58df6abd5c5f5b260644b3b56f6e7e69b
child 319328 e95a6c178d8893cdb4f5ea1a8d5e42b1d92b7ba4
push id30870
push userphilringnalda@gmail.com
push dateWed, 26 Oct 2016 05:04:25 +0000
treeherdermozilla-central@f9f3cc95d728 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1311477
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1311477 - Avoid using an unsafe CPOW in browser_save_link-perwindowpb.js; r=mrbkap
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();