Bug 1244725: DevTools: Show text of a HTTP response for video live streaming content types r=Honza
authorJarda Snajdr <jsnajdr@gmail.com>
Thu, 03 Mar 2016 04:39:00 -0800
changeset 323259 8bedab78c87044bd17055e5072495329ac4d15a3
parent 323258 fdcd2bcdfdcc5182e6734354c846405ff7381f29
child 323260 c1b8631b15a81d77f87616b42609bcb7d4dad2be
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1244725
milestone47.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 1244725: DevTools: Show text of a HTTP response for video live streaming content types r=Honza MozReview-Commit-ID: CA4tiyEtsTX
devtools/client/netmonitor/netmonitor-view.js
devtools/client/netmonitor/test/browser.ini
devtools/client/netmonitor/test/browser_net_streaming-response.js
devtools/client/netmonitor/test/sjs_content-type-test-server.sjs
devtools/shared/webconsole/network-helper.js
--- a/devtools/client/netmonitor/netmonitor-view.js
+++ b/devtools/client/netmonitor/netmonitor-view.js
@@ -46,16 +46,17 @@ const CONTENT_MIME_TYPE_MAPPINGS = {
   "/ecmascript": Editor.modes.js,
   "/javascript": Editor.modes.js,
   "/x-javascript": Editor.modes.js,
   "/html": Editor.modes.html,
   "/xhtml": Editor.modes.html,
   "/xml": Editor.modes.html,
   "/atom": Editor.modes.html,
   "/soap": Editor.modes.html,
+  "/vnd.mpeg.dash.mpd": Editor.modes.html,
   "/rdf": Editor.modes.css,
   "/rss": Editor.modes.css,
   "/css": Editor.modes.css
 };
 const DEFAULT_EDITOR_CONFIG = {
   mode: Editor.modes.text,
   readOnly: true,
   lineNumbers: true
--- a/devtools/client/netmonitor/test/browser.ini
+++ b/devtools/client/netmonitor/test/browser.ini
@@ -116,11 +116,12 @@ skip-if = e10s # Bug 1091612
 [browser_net_sort-01.js]
 skip-if = (e10s && debug && os == 'mac') # Bug 1253037
 [browser_net_sort-02.js]
 [browser_net_sort-03.js]
 [browser_net_statistics-01.js]
 [browser_net_statistics-02.js]
 [browser_net_statistics-03.js]
 [browser_net_status-codes.js]
+[browser_net_streaming-response.js]
 [browser_net_timeline_ticks.js]
 [browser_net_timing-division.js]
 [browser_net_persistent_logs.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/netmonitor/test/browser_net_streaming-response.js
@@ -0,0 +1,64 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests if reponses from streaming content types (MPEG-DASH, HLS) are
+ * displayed as XML or plain text
+ */
+
+function test() {
+  Task.spawn(function*() {
+    let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
+
+    info("Starting test... ");
+    let { panelWin } = monitor;
+    let { document, Editor, NetMonitorView } = panelWin;
+    let { RequestsMenu } = NetMonitorView;
+
+    const REQUESTS = [
+      [ "hls-m3u8", /^#EXTM3U/, Editor.modes.text ],
+      [ "mpeg-dash", /^<\?xml/, Editor.modes.html ]
+    ];
+
+    RequestsMenu.lazyUpdate = false;
+
+    REQUESTS.forEach(([ fmt ]) => {
+      debuggee.performRequests(1, CONTENT_TYPE_SJS + "?fmt=" + fmt);
+    });
+
+    yield waitForNetworkEvents(monitor, REQUESTS.length);
+
+    REQUESTS.forEach(([ fmt ], i) => {
+      verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
+        "GET", CONTENT_TYPE_SJS + "?fmt=" + fmt, {
+          status: 200,
+          statusText: "OK"
+        });
+    });
+
+    EventUtils.sendMouseEvent({ type: "mousedown" },
+      document.getElementById("details-pane-toggle"));
+    EventUtils.sendMouseEvent({ type: "mousedown" },
+      document.querySelectorAll("#details-pane tab")[3]);
+
+    yield panelWin.once(panelWin.EVENTS.RESPONSE_BODY_DISPLAYED);
+    let editor = yield NetMonitorView.editor("#response-content-textarea");
+
+    testEditorContent(editor, REQUESTS[0]); // the hls-m3u8 part
+
+    RequestsMenu.selectedIndex = 1;
+    yield panelWin.once(panelWin.EVENTS.TAB_UPDATED);
+
+    testEditorContent(editor, REQUESTS[1]); // the mpeg-dash part
+
+    yield teardown(monitor);
+    finish();
+  });
+
+  function testEditorContent(editor, [ fmt, textRe, mode ]) {
+    ok(editor.getText().match(textRe),
+      "The text shown in the source editor for " + fmt + " is incorrect.");
+    is(editor.getMode(), mode,
+      "The mode active in the source editor for " + fmt + " is incorrect.");
+  }
+}
--- a/devtools/client/netmonitor/test/sjs_content-type-test-server.sjs
+++ b/devtools/client/netmonitor/test/sjs_content-type-test-server.sjs
@@ -219,16 +219,33 @@ function handleRequest(request, response
             response.write(buffer);
             response.finish();
           }
         };
         let data = new Array(1000).join("Hello gzip!");
         doubleGzipCompressString(data, observer);
         break;
       }
+      case "hls-m3u8": {
+        response.setStatusLine(request.httpVersion, status, "OK");
+        response.setHeader("Content-Type", "application/x-mpegurl", false);
+        setCacheHeaders();
+        response.write("#EXTM3U\n");
+        response.finish();
+        break;
+      }
+      case "mpeg-dash": {
+        response.setStatusLine(request.httpVersion, status, "OK");
+        response.setHeader("Content-Type", "video/vnd.mpeg.dash.mpd", false);
+        setCacheHeaders();
+        response.write('<?xml version="1.0" encoding="UTF-8"?>\n');
+        response.write('<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></MPD>\n');
+        response.finish();
+        break;
+      }
       default: {
         response.setStatusLine(request.httpVersion, 404, "Not Found");
         response.setHeader("Content-Type", "text/html; charset=utf-8", false);
         setCacheHeaders();
         response.write("<blink>Not Found</blink>");
         response.finish();
         break;
       }
--- a/devtools/shared/webconsole/network-helper.js
+++ b/devtools/shared/webconsole/network-helper.js
@@ -435,31 +435,34 @@ var NetworkHelper = {
     "application/javascript": "js",
     "application/x-javascript": "js",
     "application/x-httpd-php": "txt",
     "application/rdf+xml": "xml",
     "application/ecmascript": "js",
     "application/http-index-format": "txt",
     "application/json": "json",
     "application/x-js": "txt",
+    "application/x-mpegurl": "txt",
+    "application/vnd.apple.mpegurl": "txt",
     "multipart/mixed": "txt",
     "multipart/x-mixed-replace": "txt",
     "image/svg+xml": "svg",
     "application/octet-stream": "bin",
     "image/jpeg": "image",
     "image/jpg": "image",
     "image/gif": "image",
     "image/png": "image",
     "image/bmp": "image",
     "application/x-shockwave-flash": "flash",
     "video/x-flv": "flash",
     "audio/mpeg3": "media",
     "audio/x-mpeg-3": "media",
     "video/mpeg": "media",
     "video/x-mpeg": "media",
+    "video/vnd.mpeg.dash.mpd": "xml",
     "audio/ogg": "media",
     "application/ogg": "media",
     "application/x-ogg": "media",
     "application/x-midi": "media",
     "audio/midi": "media",
     "audio/x-mid": "media",
     "audio/x-midi": "media",
     "music/crescendo": "media",