michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if JSON responses with unusal/custom MIME types are handled correctly. michael@0: */ michael@0: michael@0: function test() { michael@0: initNetMonitor(JSON_TEXT_MIME_URL).then(([aTab, aDebuggee, aMonitor]) => { michael@0: info("Starting test... "); michael@0: michael@0: let { document, L10N, NetMonitorView } = aMonitor.panelWin; michael@0: let { RequestsMenu } = NetMonitorView; michael@0: michael@0: RequestsMenu.lazyUpdate = false; michael@0: michael@0: waitForNetworkEvents(aMonitor, 1).then(() => { michael@0: verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0), michael@0: "GET", CONTENT_TYPE_SJS + "?fmt=json-text-mime", { michael@0: status: 200, michael@0: statusText: "OK", michael@0: type: "plain", michael@0: fullMimeType: "text/plain; charset=utf-8", michael@0: size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 0.04), michael@0: time: true michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: document.getElementById("details-pane-toggle")); michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: document.querySelectorAll("#details-pane tab")[3]); michael@0: michael@0: let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED; michael@0: waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED) michael@0: .then(testResponseTab) michael@0: .then(() => teardown(aMonitor)) michael@0: .then(finish); michael@0: michael@0: function testResponseTab() { michael@0: let tab = document.querySelectorAll("#details-pane tab")[3]; michael@0: let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3]; michael@0: michael@0: is(tab.getAttribute("selected"), "true", michael@0: "The response tab in the network details pane should be selected."); michael@0: michael@0: is(tabpanel.querySelector("#response-content-info-header") michael@0: .hasAttribute("hidden"), true, michael@0: "The response info header doesn't have the intended visibility."); michael@0: is(tabpanel.querySelector("#response-content-json-box") michael@0: .hasAttribute("hidden"), false, michael@0: "The response content json box doesn't have the intended visibility."); michael@0: is(tabpanel.querySelector("#response-content-textarea-box") michael@0: .hasAttribute("hidden"), true, michael@0: "The response content textarea box doesn't have the intended visibility."); michael@0: is(tabpanel.querySelector("#response-content-image-box") michael@0: .hasAttribute("hidden"), true, michael@0: "The response content image box doesn't have the intended visibility."); michael@0: michael@0: is(tabpanel.querySelectorAll(".variables-view-scope").length, 1, michael@0: "There should be 1 json scope displayed in this tabpanel."); michael@0: is(tabpanel.querySelectorAll(".variables-view-property").length, 2, michael@0: "There should be 2 json properties displayed in this tabpanel."); michael@0: is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0, michael@0: "The empty notice should not be displayed in this tabpanel."); michael@0: michael@0: let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; michael@0: is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), michael@0: "greeting", "The first json property name was incorrect."); michael@0: is(jsonScope.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"), michael@0: "\"Hello third-party JSON!\"", "The first json property value was incorrect."); michael@0: michael@0: is(jsonScope.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"), michael@0: "__proto__", "The second json property name was incorrect."); michael@0: is(jsonScope.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"), michael@0: "Object", "The second json property value was incorrect."); michael@0: } michael@0: }); michael@0: michael@0: aDebuggee.performRequests(); michael@0: }); michael@0: }