Bug 1638007 - Replace WebRequest.jsm with ^headers^ in browser_default_image_filename_redirect.js r=mixedpuppy
authorRob Wu <rob@robwu.nl>
Thu, 28 May 2020 15:14:48 +0000
changeset 532916 0cb9e7cd5267b85f2743b89f0f278fa6e3070ddd
parent 532915 32fd6309add3cd256f67d20d85ebd6a21185d9bb
child 532917 c2500c43aa794486e9350a8a9cfcde48185f7d7c
push id37460
push userbtara@mozilla.com
push dateFri, 29 May 2020 15:59:09 +0000
treeherdermozilla-central@60a406d3b53a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1638007
milestone78.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 1638007 - Replace WebRequest.jsm with ^headers^ in browser_default_image_filename_redirect.js r=mixedpuppy This test doesn't need to use WebRequest.jsm, so remove the dependency. Differential Revision: https://phabricator.services.mozilla.com/D77173
toolkit/content/tests/browser/browser.ini
toolkit/content/tests/browser/browser_default_image_filename_redirect.js
toolkit/content/tests/browser/firebird.png^headers^
--- a/toolkit/content/tests/browser/browser.ini
+++ b/toolkit/content/tests/browser/browser.ini
@@ -21,18 +21,16 @@ support-files =
   file_redirect.html
   file_redirect_to.html
   file_silentAudioTrack.html
   file_webAudio.html
   head.js
   image.jpg
   image_page.html
   silentAudioTrack.webm
-  doggy.png
-  firebird.png
 
 [browser_autoplay_policy.js]
 support-files =
   file_empty.html
 skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
 [browser_autoplay_policy_play_twice.js]
 support-files =
   gizmo.mp4
@@ -104,16 +102,20 @@ skip-if = true # bug 1399845 tracks re-e
 [browser_content_url_annotation.js]
 skip-if = !e10s || !crashreporter
 [browser_contentTitle.js]
 [browser_crash_previous_frameloader.js]
 run-if = e10s && crashreporter
 [browser_datetime_datepicker.js]
 [browser_default_image_filename.js]
 [browser_default_image_filename_redirect.js]
+support-files =
+  doggy.png
+  firebird.png
+  firebird.png^headers^
 [browser_f7_caret_browsing.js]
 [browser_findbar.js]
 skip-if = os == "linux" && bits == 64 && os_version = "18.04" # Bug 1614739
 [browser_findbar_disabled_manual.js]
 [browser_isSynthetic.js]
 [browser_keyevents_during_autoscrolling.js]
 [browser_label_textlink.js]
 [browser_suspend_videos_outside_viewport.js]
--- a/toolkit/content/tests/browser/browser_default_image_filename_redirect.js
+++ b/toolkit/content/tests/browser/browser_default_image_filename_redirect.js
@@ -1,37 +1,22 @@
 /**
  * TestCase for bug 1406253
  * <https://bugzilla.mozilla.org/show_bug.cgi?id=1406253>
  *
  * Load firebird.png, redirect it to doggy.png, and verify the filename is
  * doggy.png in file picker dialog.
  */
 
-let { WebRequest } = ChromeUtils.import(
-  "resource://gre/modules/WebRequest.jsm"
-);
 let MockFilePicker = SpecialPowers.MockFilePicker;
 MockFilePicker.init(window);
 add_task(async function() {
+  // This URL will redirect to doggy.png.
   const URL_FIREBIRD =
     "http://mochi.test:8888/browser/toolkit/content/tests/browser/firebird.png";
-  const URL_DOGGY =
-    "http://mochi.test:8888/browser/toolkit/content/tests/browser/doggy.png";
-  function redirect(requestDetails) {
-    info("Redirecting: " + requestDetails.url);
-    return {
-      redirectUrl: URL_DOGGY,
-    };
-  }
-  WebRequest.onBeforeRequest.addListener(
-    redirect,
-    { urls: new MatchPatternSet(["http://*/*firebird.png"]) },
-    ["blocking"]
-  );
 
   await BrowserTestUtils.withNewTab(URL_FIREBIRD, async function(browser) {
     // Click image to show context menu.
     let popupShownPromise = BrowserTestUtils.waitForEvent(
       document,
       "popupshown"
     );
     await BrowserTestUtils.synthesizeMouseAtCenter(
@@ -60,11 +45,9 @@ add_task(async function() {
     let contextMenu = document.getElementById("contentAreaContextMenu");
     let popupHiddenPromise = BrowserTestUtils.waitForEvent(
       contextMenu,
       "popuphidden"
     );
     contextMenu.hidePopup();
     await popupHiddenPromise;
   });
-
-  WebRequest.onBeforeRequest.removeListener(redirect);
 });
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/browser/firebird.png^headers^
@@ -0,0 +1,2 @@
+HTTP 302 Found
+Location: doggy.png