summaryrefslogtreecommitdiffstats
path: root/devtools/client/netmonitor/test/browser_net_streaming-response.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/netmonitor/test/browser_net_streaming-response.js')
-rw-r--r--devtools/client/netmonitor/test/browser_net_streaming-response.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/devtools/client/netmonitor/test/browser_net_streaming-response.js b/devtools/client/netmonitor/test/browser_net_streaming-response.js
new file mode 100644
index 000000000..49a75ec32
--- /dev/null
+++ b/devtools/client/netmonitor/test/browser_net_streaming-response.js
@@ -0,0 +1,69 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Tests if reponses from streaming content types (MPEG-DASH, HLS) are
+ * displayed as XML or plain text
+ */
+
+add_task(function* () {
+ let { tab, 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;
+
+ let wait = waitForNetworkEvents(monitor, REQUESTS.length);
+ for (let [fmt] of REQUESTS) {
+ let url = CONTENT_TYPE_SJS + "?fmt=" + fmt;
+ yield ContentTask.spawn(tab.linkedBrowser, { url }, function* (args) {
+ content.wrappedJSObject.performRequests(1, args.url);
+ });
+ }
+ yield wait;
+
+ 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");
+
+ // the hls-m3u8 part
+ testEditorContent(editor, REQUESTS[0]);
+
+ RequestsMenu.selectedIndex = 1;
+ yield panelWin.once(panelWin.EVENTS.TAB_UPDATED);
+ yield panelWin.once(panelWin.EVENTS.RESPONSE_BODY_DISPLAYED);
+
+ // the mpeg-dash part
+ testEditorContent(editor, REQUESTS[1]);
+
+ return teardown(monitor);
+
+ function testEditorContent(e, [ fmt, textRe, mode ]) {
+ ok(e.getText().match(textRe),
+ "The text shown in the source editor for " + fmt + " is correct.");
+ is(e.getMode(), mode,
+ "The mode active in the source editor for " + fmt + " is correct.");
+ }
+});