Bug 1495937 - Wait for file picker promise before saving so we don't miss it. rs=firebot, a=test-only
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 05 Feb 2019 13:59:32 +0000
changeset 515798 4db5256e25c945715be752ded2e7a145d8f067c5
parent 515797 d4aab6a72e81ce12deecb5461f50dc836f4754e5
child 515799 a7a132f180899962a3af0e3e82bbc03790ed89bb
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirebot, test-only
bugs1495937
milestone66.0
Bug 1495937 - Wait for file picker promise before saving so we don't miss it. rs=firebot, a=test-only
toolkit/content/tests/browser/browser_saveImageURL.js
--- a/toolkit/content/tests/browser/browser_saveImageURL.js
+++ b/toolkit/content/tests/browser/browser_saveImageURL.js
@@ -31,31 +31,31 @@ add_task(async function preferred_API() 
     gBrowser,
     url: IMAGE_PAGE,
   }, async function(browser) {
     let url = await ContentTask.spawn(browser, null, async function() {
       let image = content.document.getElementById("image");
       return image.href;
     });
 
+    let filePickerPromise = waitForFilePicker();
     saveImageURL(url, "image.jpg", null, true, false, null, null, null, null,
       false, gBrowser.contentPrincipal);
     await ContentTask.spawn(gBrowser.selectedBrowser, null, async () => {
       let channel = docShell.currentDocumentChannel;
       if (channel) {
         todo(channel.QueryInterface(Ci.nsIHttpChannelInternal)
                     .channelIsForDownload);
 
         // Throttleable is the only class flag assigned to downloads.
         todo(channel.QueryInterface(Ci.nsIClassOfService).classFlags ==
              Ci.nsIClassOfService.Throttleable);
       }
     });
-
-    await waitForFilePicker();
+    await filePickerPromise;
   });
 });
 
 /**
  * Test that saveImageURL will still work when passed a document instead
  * of the aIsContentWindowPrivate argument. This is the deprecated API, and
  * will not work in apps using remote browsers having PREF_UNSAFE_FORBIDDEN
  * set to true.
@@ -84,12 +84,13 @@ add_task(async function deprecated_API()
         todo(channel.QueryInterface(Ci.nsIHttpChannelInternal)
                     .channelIsForDownload);
 
         // Throttleable is the only class flag assigned to downloads.
         todo(channel.QueryInterface(Ci.nsIClassOfService).classFlags ==
              Ci.nsIClassOfService.Throttleable);
       }
     });
+    let filePickerPromise = waitForFilePicker();
     saveImageURL(url, "image.jpg", null, true, false, null, doc, null, null);
-    await waitForFilePicker();
+    await filePickerPromise;
   });
 });