Backed out 2 changesets (bug 1443942) for bustage on /testing/xpcshell/selftest.py on a CLOSED TREE
authorNoemi Erli <nerli@mozilla.com>
Tue, 13 Mar 2018 00:43:31 +0200
changeset 407663 f505a9fa69d180fd8562404c402330b12fa85d86
parent 407662 fa5bcc246d0f83b5260944740f8f27cf11f9ff4c
child 407754 a29e28df0a142521b8520ce645bfb4c5339b7367
push id61014
push usernerli@mozilla.com
push dateMon, 12 Mar 2018 22:44:04 +0000
treeherderautoland@f505a9fa69d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1443942
milestone60.0a1
backs outfa5bcc246d0f83b5260944740f8f27cf11f9ff4c
2257546ec4843183daeaff69e35c8a0a1e2ff5c4
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
Backed out 2 changesets (bug 1443942) for bustage on /testing/xpcshell/selftest.py on a CLOSED TREE Backed out changeset fa5bcc246d0f (bug 1443942) Backed out changeset 2257546ec484 (bug 1443942)
dom/media/ChannelMediaDecoder.cpp
dom/media/DecoderTraits.cpp
dom/media/DecoderTraits.h
dom/media/MediaPrefs.h
dom/media/test/midflight-redirect.sjs
dom/media/test/mochitest.ini
dom/media/test/test_midflight_redirect_blocked.html
--- a/dom/media/ChannelMediaDecoder.cpp
+++ b/dom/media/ChannelMediaDecoder.cpp
@@ -161,19 +161,20 @@ ChannelMediaDecoder::NotifyPrincipalChan
   if (!mInitialChannelPrincipalKnown) {
     // We'll receive one notification when the channel's initial principal
     // is known, after all HTTP redirects have resolved. This isn't really a
     // principal change, so return here to avoid the mSameOriginMedia check
     // below.
     mInitialChannelPrincipalKnown = true;
     return;
   }
-  if (!mSameOriginMedia && MediaPrefs::BlockMidflightRedirects()) {
-    // Block mid-flight redirects to non CORS same origin destinations.
-    // See bugs 1441153, 1443942.
+  if (!mSameOriginMedia &&
+      DecoderTraits::CrossOriginRedirectsProhibited(ContainerType())) {
+    // For some content types we block mid-flight channel redirects to cross
+    // origin destinations due to security constraints. See bug 1441153.
     LOG("ChannnelMediaDecoder prohibited cross origin redirect blocked.");
     NetworkError(MediaResult(NS_ERROR_DOM_BAD_URI,
                              "Prohibited cross origin redirect blocked"));
   }
 }
 
 void
 ChannelMediaDecoder::ResourceCallback::NotifySuspendedStatusChanged(
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -320,9 +320,16 @@ bool DecoderTraits::IsSupportedInVideoDo
     ADTSDecoder::IsSupportedType(*type) ||
     FlacDecoder::IsSupportedType(*type) ||
 #ifdef MOZ_ANDROID_HLS_SUPPORT
     HLSDecoder::IsSupportedType(*type) ||
 #endif
     false;
 }
 
+/* static */
+bool
+DecoderTraits::CrossOriginRedirectsProhibited(const MediaContainerType& aType)
+{
+  return WaveDecoder::IsSupportedType(aType);
+}
+
 } // namespace mozilla
--- a/dom/media/DecoderTraits.h
+++ b/dom/media/DecoderTraits.h
@@ -52,14 +52,18 @@ public:
 
   // Returns true if aType is MIME type of hls.
   static bool IsHttpLiveStreamingType(const MediaContainerType& aType);
 
   // Returns true if aType is matroska type.
   static bool IsMatroskaType(const MediaContainerType& aType);
 
   static bool IsSupportedType(const MediaContainerType& aType);
+
+  // For some content types we block channel redirects to cross origin
+  // destinations due to security constraints. See bug 1441153.
+  static bool CrossOriginRedirectsProhibited(const MediaContainerType& aType);
 };
 
 } // namespace mozilla
 
 #endif
 
--- a/dom/media/MediaPrefs.h
+++ b/dom/media/MediaPrefs.h
@@ -200,19 +200,16 @@ private:
   DECL_MEDIA_PREF("media.resume-bkgnd-video-on-tabhover",     ResumeVideoDecodingOnTabHover, bool, false);
 
   // Enable sandboxing support for cubeb
   DECL_MEDIA_PREF("media.cubeb.sandbox",                      CubebSandbox, bool, false);
   DECL_MEDIA_PREF("media.videocontrols.lock-video-orientation",  VideoOrientationLockEnabled, bool, false);
 
   // Media Seamless Looping
   DECL_MEDIA_PREF("media.seamless-looping",                   SeamlessLooping, bool, true);
-
-  DECL_MEDIA_PREF("media.block-midflight-redirects",           BlockMidflightRedirects, bool, true);
-
 public:
   // Manage the singleton:
   static MediaPrefs& GetSingleton();
   static bool SingletonExists();
 
 private:
   template<class T> friend class StaticAutoPtr;
   static StaticAutoPtr<MediaPrefs> sInstance;
deleted file mode 100644
--- a/dom/media/test/midflight-redirect.sjs
+++ /dev/null
@@ -1,71 +0,0 @@
-function parseQuery(query, key) {
-  for (let p of query.split('&')) {
-    if (p == key) {
-      return true;
-    }
-    if (p.startsWith(key + "=")) {
-      return p.substring(key.length + 1);
-    }
-  }
-}
-
-// Return the first few bytes in a short byte range response. When Firefox
-// requests subsequent bytes in a second range request, respond with a
-// redirect. Requests after the first redirected are serviced as expected.
-function handleRequest(request, response)
-{
-  var query = request.queryString;
-  var resource = parseQuery(query, "resource");
-  var redirected = parseQuery(query, "redirected") || false;
-  var useCors = parseQuery(query, "cors") || false;
-
-  var file = Components.classes["@mozilla.org/file/directory_service;1"].
-                        getService(Components.interfaces.nsIProperties).
-                        get("CurWorkD", Components.interfaces.nsIFile);
-  var fis  = Components.classes['@mozilla.org/network/file-input-stream;1'].
-                        createInstance(Components.interfaces.nsIFileInputStream);
-  var bis  = Components.classes["@mozilla.org/binaryinputstream;1"].
-                        createInstance(Components.interfaces.nsIBinaryInputStream);
-  var paths = "tests/dom/media/test/" + resource;
-  var split = paths.split("/");
-  for (var i = 0; i < split.length; ++i) {
-    file.append(split[i]);
-  }
-  fis.init(file, -1, -1, false);
-
-  bis.setInputStream(fis);
-  var bytes = bis.readBytes(bis.available());
-  let [from, to] = request.getHeader("range").split("=")[1].split("-").map(s => parseInt(s));
-
-  if (!redirected && from > 0) {
-    var origin = request.host == "mochi.test" ? "example.org" : "mochi.test:8888";
-    response.setStatusLine(request.httpVersion, 303, "See Other");
-    let url = "http://" + origin +
-              "/tests/dom/media/test/midflight-redirect.sjs?redirected&" + query;
-    response.setHeader("Location", url);
-    response.setHeader("Content-Type", "text/html");
-    return;
-  }
-
-  if (from == 0 && !redirected) {
-    to = Math.min(bytes.length / 4, 200);
-  } else {
-    to = to || Math.max(from, bytes.length - 1);
-  }
-
-  byterange = bytes.substring(from, to + 1);
-
-  let contentRange = "bytes "+ from +"-"+ to +"/"+ bytes.length;
-  let contentLength = (to - from + 1).toString();
-
-  response.setStatusLine(request.httpVersion, 206, "Partial Content");
-  response.setHeader("Content-Range", contentRange);
-  response.setHeader("Content-Length", contentLength, false);
-  response.setHeader("Content-Type", "video/ogg", false);
-  response.setHeader("Accept-Ranges", "bytes", false);
-  if (redirected && useCors) {
-    response.setHeader("Access-Control-Allow-Origin", "*");
-  }
-  response.write(byterange, byterange.length);
-  bis.close();
-}
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -488,17 +488,16 @@ support-files =
   invalid-m2c1.opus
   invalid-m2c1.opus^headers^
   invalid-neg_discard.webm
   invalid-neg_discard.webm^headers^
   invalid-preskip.webm
   invalid-preskip.webm^headers^
   long.vtt
   manifest.js
-  midflight-redirect.sjs
   multiple-bos.ogg
   multiple-bos.ogg^headers^
   multiple-bos-more-header-fileds.ogg
   multiple-bos-more-header-fileds.ogg^headers^
   no-cues.webm
   no-cues.webm^headers^
   notags.mp3
   notags.mp3^headers^
@@ -940,17 +939,16 @@ skip-if = android_version == '17' # andr
 tags=msg
 [test_mediatrack_events.html]
 skip-if = android_version == '17' # android(bug 1232305)
 [test_mediatrack_parsing_ogg.html]
 skip-if = android_version == '17' # android(bug 1232305)
 [test_mediatrack_replay_from_end.html]
 skip-if = toolkit == 'android' # android(bug 1232305)
 [test_metadata.html]
-[test_midflight_redirect_blocked.html]
 [test_mixed_principals.html]
 skip-if = toolkit == 'android' # bug 1309814, android(bug 1232305)
 [test_mozHasAudio.html]
 skip-if = toolkit == 'android' # android(bug 1232305)
 [test_multiple_mediastreamtracks.html]
 skip-if = android_version == '17' # android(bug 1232305)
 [test_networkState.html]
 skip-if = android_version == '17' # android(bug 1232305)
deleted file mode 100644
--- a/dom/media/test/test_midflight_redirect_blocked.html
+++ /dev/null
@@ -1,95 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-  <head>
-    <title>Test mid-flight cross site redirects are blocked</title>
-    <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
-    <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-    <script type="text/javascript" src="manifest.js"></script>
-  </head>
-  <body>
-    <pre id='test'>
-    <script class="testbody" type='application/javascript'>
-
-      function testIfLoadsToMetadata(test, useCors) {
-        return new Promise(function(resolve, reject) {
-          var elemType = getMajorMimeType(test.type);
-          var element = document.createElement(elemType);
-
-          if (useCors) {
-            element.crossOrigin = "anonymous";
-          }
-
-          // Log events for debugging.
-          [
-            "suspend", "play", "canplay", "canplaythrough", "loadstart",
-            "loadedmetadata", "loadeddata", "playing", "ended", "error",
-            "stalled", "emptied", "abort", "waiting", "pause"
-          ].forEach((eventName) => {
-            element.addEventListener(eventName, (event)=> {
-              info(test.name + " " + event.type);
-            });
-          });
-
-          element.addEventListener("loadedmetadata", ()=>{
-            resolve(true);
-            removeNodeAndSource(element);
-          }, false);
-
-          element.addEventListener("error", ()=>{
-            resolve(false);
-            removeNodeAndSource(element);
-          }, false);
-
-          let suffix = useCors ? "&cors" : "";
-          element.src = "midflight-redirect.sjs?resource=" + test.name + suffix;
-          element.preload = "metadata";
-          document.body.appendChild(element);
-          element.load()
-        });
-      }
-
-      let v = document.createElement("video");
-      const testCases = gSmallTests.filter(t => v.canPlayType(t.type));
-
-      function testMediaLoad(expectedToLoad, message, useCors) {
-        return new Promise(async function(resolve, reject) {
-          for (let test of testCases) {
-            let loaded = await testIfLoadsToMetadata(test, useCors);
-            is(loaded, expectedToLoad, test.name + " " + message);
-          }
-          resolve();
-        });
-      }
-
-      async function runTest() {
-        try {
-          SimpleTest.info("Allowing midflight redirects...");
-          await SpecialPowers.pushPrefEnv({'set': [["media.block-midflight-redirects", false]]});
-
-          SimpleTest.info("Test that all media plays...");
-          await testMediaLoad(true, "expected to load", false);
-
-          SimpleTest.info("Blocking midflight redirects...");
-          await SpecialPowers.pushPrefEnv({'set': [["media.block-midflight-redirects", true]]});
-
-          SimpleTest.info("Test that all media no longer play...");
-          await testMediaLoad(false, "expected to be blocked", false);
-
-          SimpleTest.info("Test that all media play if CORS used...");
-          await testMediaLoad(true, "expected to play with CORS", true);
-        } catch (e) {
-          info("Exception " + e.message);
-          ok(false, "Threw exception " + e.message);
-        }
-        SimpleTest.finish();
-      }
-
-      SimpleTest.waitForExplicitFinish();
-
-      addLoadEvent(runTest);
-
-    </script>
-    </pre>
-  </body>
-</html>