Bug 1244725: DevTools: Show text of a HTTP response for video live streaming content types r=Honza

MozReview-Commit-ID: CA4tiyEtsTX

--HG--
extra : rebase_source : cb53c731f051df2083f197ccc5977e96ab19b52f
This commit is contained in:
Jarda Snajdr 2016-03-03 04:39:00 -08:00
parent 9308035592
commit 3986fe2698
5 changed files with 86 additions and 0 deletions

View File

@ -51,6 +51,7 @@ const CONTENT_MIME_TYPE_MAPPINGS = {
"/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

View File

@ -121,6 +121,7 @@ skip-if = (e10s && debug && os == 'mac') # Bug 1253037
[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]

View File

@ -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.");
}
}

View File

@ -224,6 +224,23 @@ function handleRequest(request, response) {
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);

View File

@ -440,6 +440,8 @@ var NetworkHelper = {
"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",
@ -455,6 +457,7 @@ var NetworkHelper = {
"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",