mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 07:40:42 +00:00
Merge m-c to inbound. a=merge
This commit is contained in:
commit
feb9c5a04a
@ -90,6 +90,15 @@
|
||||
);
|
||||
} else {
|
||||
SimpleTest.ok(true, "Testing Firefox tabbrowser UI.");
|
||||
let newTabChildren = [];
|
||||
if (SpecialPowers.getBoolPref("privacy.userContext.enabled")) {
|
||||
newTabChildren = [
|
||||
{
|
||||
role: ROLE_MENUPOPUP,
|
||||
children: []
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
// NB: The (3) buttons are not visible, unless manually hovered,
|
||||
// probably due to size reduction in this test.
|
||||
@ -119,7 +128,7 @@
|
||||
{
|
||||
// xul:toolbarbutton ("Open a new tab")
|
||||
role: ROLE_PUSHBUTTON,
|
||||
children: []
|
||||
children: newTabChildren
|
||||
}
|
||||
// "List all tabs" dropdown
|
||||
// XXX: This child(?) is not present in this test.
|
||||
|
@ -119,6 +119,16 @@ tabbrowser {
|
||||
visibility: hidden; /* temporary space to keep a tab's close button under the cursor */
|
||||
}
|
||||
|
||||
.tabs-newtab-button > .toolbarbutton-menu-dropmarker,
|
||||
#new-tab-button > .toolbarbutton-menu-dropmarker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tabs-newtab-button > .toolbarbutton-icon,
|
||||
#new-tab-button > .toolbarbutton-icon {
|
||||
margin-inline-end: 0;
|
||||
}
|
||||
|
||||
.tabbrowser-tab {
|
||||
-moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-tab");
|
||||
}
|
||||
@ -177,6 +187,7 @@ tabbrowser {
|
||||
transition: transform 200ms ease-out;
|
||||
}
|
||||
|
||||
.new-tab-popup,
|
||||
#alltabs-popup {
|
||||
-moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-alltabs-popup");
|
||||
}
|
||||
|
@ -263,66 +263,6 @@ function UpdateBackForwardCommands(aWebNavigation) {
|
||||
* XXXmano: should this live in toolbarbutton.xml?
|
||||
*/
|
||||
function SetClickAndHoldHandlers() {
|
||||
var timer;
|
||||
|
||||
function openMenu(aButton) {
|
||||
cancelHold(aButton);
|
||||
aButton.firstChild.hidden = false;
|
||||
aButton.open = true;
|
||||
}
|
||||
|
||||
function mousedownHandler(aEvent) {
|
||||
if (aEvent.button != 0 ||
|
||||
aEvent.currentTarget.open ||
|
||||
aEvent.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
// Prevent the menupopup from opening immediately
|
||||
aEvent.currentTarget.firstChild.hidden = true;
|
||||
|
||||
aEvent.currentTarget.addEventListener("mouseout", mouseoutHandler, false);
|
||||
aEvent.currentTarget.addEventListener("mouseup", mouseupHandler, false);
|
||||
timer = setTimeout(openMenu, 500, aEvent.currentTarget);
|
||||
}
|
||||
|
||||
function mouseoutHandler(aEvent) {
|
||||
let buttonRect = aEvent.currentTarget.getBoundingClientRect();
|
||||
if (aEvent.clientX >= buttonRect.left &&
|
||||
aEvent.clientX <= buttonRect.right &&
|
||||
aEvent.clientY >= buttonRect.bottom)
|
||||
openMenu(aEvent.currentTarget);
|
||||
else
|
||||
cancelHold(aEvent.currentTarget);
|
||||
}
|
||||
|
||||
function mouseupHandler(aEvent) {
|
||||
cancelHold(aEvent.currentTarget);
|
||||
}
|
||||
|
||||
function cancelHold(aButton) {
|
||||
clearTimeout(timer);
|
||||
aButton.removeEventListener("mouseout", mouseoutHandler, false);
|
||||
aButton.removeEventListener("mouseup", mouseupHandler, false);
|
||||
}
|
||||
|
||||
function clickHandler(aEvent) {
|
||||
if (aEvent.button == 0 &&
|
||||
aEvent.target == aEvent.currentTarget &&
|
||||
!aEvent.currentTarget.open &&
|
||||
!aEvent.currentTarget.disabled) {
|
||||
let cmdEvent = document.createEvent("xulcommandevent");
|
||||
cmdEvent.initCommandEvent("command", true, true, window, 0,
|
||||
aEvent.ctrlKey, aEvent.altKey, aEvent.shiftKey,
|
||||
aEvent.metaKey, null);
|
||||
aEvent.currentTarget.dispatchEvent(cmdEvent);
|
||||
}
|
||||
}
|
||||
|
||||
function _addClickAndHoldListenersOnElement(aElm) {
|
||||
aElm.addEventListener("mousedown", mousedownHandler, true);
|
||||
aElm.addEventListener("click", clickHandler, true);
|
||||
}
|
||||
|
||||
// Bug 414797: Clone the back/forward buttons' context menu into both buttons.
|
||||
let popup = document.getElementById("backForwardMenu").cloneNode(true);
|
||||
popup.removeAttribute("id");
|
||||
@ -332,13 +272,83 @@ function SetClickAndHoldHandlers() {
|
||||
let backButton = document.getElementById("back-button");
|
||||
backButton.setAttribute("type", "menu");
|
||||
backButton.appendChild(popup);
|
||||
_addClickAndHoldListenersOnElement(backButton);
|
||||
addClickAndHoldListenersOnElement(backButton);
|
||||
|
||||
let forwardButton = document.getElementById("forward-button");
|
||||
popup = popup.cloneNode(true);
|
||||
forwardButton.setAttribute("type", "menu");
|
||||
forwardButton.appendChild(popup);
|
||||
_addClickAndHoldListenersOnElement(forwardButton);
|
||||
addClickAndHoldListenersOnElement(forwardButton);
|
||||
}
|
||||
|
||||
let holdTimersMap = new Map();
|
||||
function holdMousedownHandler(aEvent) {
|
||||
if (aEvent.button != 0 ||
|
||||
aEvent.currentTarget.open ||
|
||||
aEvent.currentTarget.disabled)
|
||||
return;
|
||||
|
||||
// Prevent the menupopup from opening immediately
|
||||
aEvent.currentTarget.firstChild.hidden = true;
|
||||
|
||||
aEvent.currentTarget.addEventListener("mouseout", holdMouseoutHandler, false);
|
||||
aEvent.currentTarget.addEventListener("mouseup", holdMouseupHandler, false);
|
||||
holdTimersMap.set(aEvent.currentTarget, setTimeout(holdOpenMenu, 500, aEvent.currentTarget));
|
||||
}
|
||||
|
||||
function holdClickHandler(aEvent) {
|
||||
if (aEvent.button == 0 &&
|
||||
aEvent.target == aEvent.currentTarget &&
|
||||
!aEvent.currentTarget.open &&
|
||||
!aEvent.currentTarget.disabled) {
|
||||
let cmdEvent = document.createEvent("xulcommandevent");
|
||||
cmdEvent.initCommandEvent("command", true, true, window, 0,
|
||||
aEvent.ctrlKey, aEvent.altKey, aEvent.shiftKey,
|
||||
aEvent.metaKey, null);
|
||||
aEvent.currentTarget.dispatchEvent(cmdEvent);
|
||||
}
|
||||
// This is here to cancel the XUL default event
|
||||
// dom.click() triggers a command even if there is a click handler
|
||||
// however this can now be prevented with preventDefault().
|
||||
aEvent.preventDefault();
|
||||
}
|
||||
|
||||
function holdOpenMenu(aButton) {
|
||||
cancelHold(aButton);
|
||||
aButton.firstChild.hidden = false;
|
||||
aButton.open = true;
|
||||
}
|
||||
|
||||
function holdMouseoutHandler(aEvent) {
|
||||
let buttonRect = aEvent.currentTarget.getBoundingClientRect();
|
||||
if (aEvent.clientX >= buttonRect.left &&
|
||||
aEvent.clientX <= buttonRect.right &&
|
||||
aEvent.clientY >= buttonRect.bottom)
|
||||
holdOpenMenu(aEvent.currentTarget);
|
||||
else
|
||||
cancelHold(aEvent.currentTarget);
|
||||
}
|
||||
|
||||
function holdMouseupHandler(aEvent) {
|
||||
cancelHold(aEvent.currentTarget);
|
||||
}
|
||||
|
||||
function cancelHold(aButton) {
|
||||
clearTimeout(holdTimersMap.get(aButton));
|
||||
aButton.removeEventListener("mouseout", holdMouseoutHandler, false);
|
||||
aButton.removeEventListener("mouseup", holdMouseupHandler, false);
|
||||
}
|
||||
|
||||
function removeClickAndHoldListenersOnElement(aElm) {
|
||||
aElm.removeEventListener("mousedown", holdMousedownHandler, true);
|
||||
aElm.removeEventListener("click", holdClickHandler, true);
|
||||
}
|
||||
|
||||
function addClickAndHoldListenersOnElement(aElm) {
|
||||
holdTimersMap.delete(aElm);
|
||||
|
||||
aElm.addEventListener("mousedown", holdMousedownHandler, true);
|
||||
aElm.addEventListener("click", holdClickHandler, true);
|
||||
}
|
||||
|
||||
const gSessionHistoryObserver = {
|
||||
|
@ -4939,7 +4939,7 @@
|
||||
</xul:arrowscrollbox>
|
||||
</content>
|
||||
|
||||
<implementation implements="nsIDOMEventListener">
|
||||
<implementation implements="nsIDOMEventListener, nsIObserver">
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.mTabClipWidth = Services.prefs.getIntPref("browser.tabs.tabClipWidth");
|
||||
@ -4958,9 +4958,21 @@
|
||||
this._tabAnimationLoggingEnabled = false;
|
||||
}
|
||||
this._browserNewtabpageEnabled = Services.prefs.getBoolPref("browser.newtabpage.enabled");
|
||||
this.observe(null, "nsPref:changed", "privacy.userContext.enabled");
|
||||
Services.prefs.addObserver("privacy.userContext.enabled", this, false);
|
||||
]]>
|
||||
</constructor>
|
||||
|
||||
<destructor>
|
||||
<![CDATA[
|
||||
Services.prefs.removeObserver("privacy.userContext.enabled", this);
|
||||
]]>
|
||||
</destructor>
|
||||
|
||||
<field name="newtabUndoCloseTab" readonly="true">
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "newtab_undoCloseTab");
|
||||
</field>
|
||||
|
||||
<field name="tabbrowser" readonly="true">
|
||||
document.getElementById(this.getAttribute("tabbrowser"));
|
||||
</field>
|
||||
@ -4986,6 +4998,54 @@
|
||||
<field name="_afterHoveredTab">null</field>
|
||||
<field name="_hoveredTab">null</field>
|
||||
|
||||
<method name="observe">
|
||||
<parameter name="aSubject"/>
|
||||
<parameter name="aTopic"/>
|
||||
<parameter name="aData"/>
|
||||
<body><![CDATA[
|
||||
switch (aTopic) {
|
||||
case "nsPref:changed":
|
||||
// This is the only pref observed.
|
||||
let containersEnabled = Services.prefs.getBoolPref("privacy.userContext.enabled");
|
||||
|
||||
const newTab = document.getElementById("new-tab-button");
|
||||
const newTab2 = document.getAnonymousElementByAttribute(this, "anonid", "tabs-newtab-button")
|
||||
|
||||
if (containersEnabled) {
|
||||
for (let parent of [newTab, newTab2]) {
|
||||
if (!parent)
|
||||
continue;
|
||||
let popup = document.createElementNS(
|
||||
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
||||
"menupopup");
|
||||
if (parent.id) {
|
||||
popup.id = "newtab-popup";
|
||||
} else {
|
||||
popup.setAttribute("anonid", "newtab-popup");
|
||||
}
|
||||
popup.oncommand="event.stopPropagation();";
|
||||
popup.className = "new-tab-popup";
|
||||
popup.setAttribute("position", "after_end");
|
||||
parent.appendChild(popup);
|
||||
|
||||
addClickAndHoldListenersOnElement(parent);
|
||||
parent.setAttribute("type", "menu");
|
||||
}
|
||||
} else {
|
||||
for (let parent of [newTab, newTab2]) {
|
||||
if (!parent)
|
||||
continue;
|
||||
removeClickAndHoldListenersOnElement(parent);
|
||||
parent.removeAttribute("type");
|
||||
parent.firstChild.remove();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<property name="_isCustomizing" readonly="true">
|
||||
<getter>
|
||||
let root = document.documentElement;
|
||||
@ -6673,30 +6733,36 @@
|
||||
}
|
||||
|
||||
let containersEnabled = Services.prefs.getBoolPref("privacy.userContext.enabled");
|
||||
document.getElementById("alltabs-popup-separator-1").hidden = !containersEnabled;
|
||||
let containersTab = document.getElementById("alltabs_containersTab");
|
||||
|
||||
containersTab.hidden = !containersEnabled;
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(window)) {
|
||||
containersTab.setAttribute("disabled", "true");
|
||||
if (event.target.getAttribute('anonid') == "newtab-popup" ||
|
||||
event.target.id == "newtab-popup") {
|
||||
createUserContextMenu(event);
|
||||
} else {
|
||||
document.getElementById("alltabs-popup-separator-1").hidden = !containersEnabled;
|
||||
let containersTab = document.getElementById("alltabs_containersTab");
|
||||
|
||||
containersTab.hidden = !containersEnabled;
|
||||
if (PrivateBrowsingUtils.isWindowPrivate(window)) {
|
||||
containersTab.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
document.getElementById("alltabs_undoCloseTab").disabled =
|
||||
SessionStore.getClosedTabCount(window) == 0;
|
||||
|
||||
var tabcontainer = gBrowser.tabContainer;
|
||||
|
||||
// Listen for changes in the tab bar.
|
||||
tabcontainer.addEventListener("TabAttrModified", this, false);
|
||||
tabcontainer.addEventListener("TabClose", this, false);
|
||||
tabcontainer.mTabstrip.addEventListener("scroll", this, false);
|
||||
|
||||
let tabs = gBrowser.visibleTabs;
|
||||
for (var i = 0; i < tabs.length; i++) {
|
||||
if (!tabs[i].pinned)
|
||||
this._createTabMenuItem(tabs[i]);
|
||||
}
|
||||
this._updateTabsVisibilityStatus();
|
||||
}
|
||||
|
||||
document.getElementById("alltabs_undoCloseTab").disabled =
|
||||
SessionStore.getClosedTabCount(window) == 0;
|
||||
|
||||
var tabcontainer = gBrowser.tabContainer;
|
||||
|
||||
// Listen for changes in the tab bar.
|
||||
tabcontainer.addEventListener("TabAttrModified", this, false);
|
||||
tabcontainer.addEventListener("TabClose", this, false);
|
||||
tabcontainer.mTabstrip.addEventListener("scroll", this, false);
|
||||
|
||||
let tabs = gBrowser.visibleTabs;
|
||||
for (var i = 0; i < tabs.length; i++) {
|
||||
if (!tabs[i].pinned)
|
||||
this._createTabMenuItem(tabs[i]);
|
||||
}
|
||||
this._updateTabsVisibilityStatus();
|
||||
]]></handler>
|
||||
|
||||
<handler event="popuphidden">
|
||||
@ -6712,6 +6778,9 @@
|
||||
menuItem.tab.mCorrespondingMenuitem = null;
|
||||
this.removeChild(menuItem);
|
||||
}
|
||||
if (menuItem.hasAttribute("usercontextid")) {
|
||||
this.removeChild(menuItem);
|
||||
}
|
||||
}
|
||||
var tabcontainer = gBrowser.tabContainer;
|
||||
tabcontainer.mTabstrip.removeEventListener("scroll", this, false);
|
||||
|
@ -13,6 +13,7 @@ skip-if = (debug && (os == "win" || os == "linux")) # intermittent negative leak
|
||||
[browser_eme.js]
|
||||
[browser_favicon.js]
|
||||
[browser_forgetaboutsite.js]
|
||||
[browser_newtabButton.js]
|
||||
[browser_usercontext.js]
|
||||
[browser_usercontextid_tabdrop.js]
|
||||
skip-if = os == "mac" || os == "win" # Intermittent failure - bug 1268276
|
||||
|
@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
|
||||
// Testing that when the user opens the add tab menu and clicks menu items
|
||||
// the correct context id is opened
|
||||
|
||||
add_task(function* test() {
|
||||
yield SpecialPowers.pushPrefEnv({"set": [
|
||||
["privacy.userContext.enabled", true]
|
||||
]});
|
||||
|
||||
let newTab = document.getElementById('tabbrowser-tabs');
|
||||
let newTabButton = document.getAnonymousElementByAttribute(newTab, "anonid", "tabs-newtab-button");
|
||||
ok(newTabButton, "New tab button exists");
|
||||
ok(!newTabButton.hidden, "New tab button is visible");
|
||||
let popup = document.getAnonymousElementByAttribute(newTab, "anonid", "newtab-popup");
|
||||
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
let popupShownPromise = BrowserTestUtils.waitForEvent(popup, "popupshown");
|
||||
EventUtils.synthesizeMouseAtCenter(newTabButton, {type: "mousedown"});
|
||||
|
||||
yield popupShownPromise;
|
||||
let contextIdItem = popup.querySelector(`menuitem[usercontextid="${i}"]`);
|
||||
|
||||
ok(contextIdItem, `User context id ${i} exists`);
|
||||
|
||||
let waitForTabPromise = BrowserTestUtils.waitForNewTab(gBrowser);
|
||||
EventUtils.synthesizeMouseAtCenter(contextIdItem, {});
|
||||
|
||||
let tab = yield waitForTabPromise;
|
||||
|
||||
is(tab.getAttribute('usercontextid'), i, `New tab has UCI equal ${i}`);
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
});
|
@ -48,23 +48,29 @@ toolbar[brighttext] #downloads-button[cui-areatype="toolbar"]:not([attention="su
|
||||
background-image: var(--downloads-indicator-icon-inverted);
|
||||
}
|
||||
|
||||
#downloads-button[cui-areatype="toolbar"][attention="warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
|
||||
#downloads-button[cui-areatype="toolbar"][attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
#downloads-button[attention="warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
|
||||
#downloads-button[attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
display: -moz-box;
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
background-size: contain;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
filter: drop-shadow(0 1px 0 hsla(206, 50%, 10%, .15));
|
||||
height: 8px;
|
||||
width: 8px;
|
||||
min-width: 0;
|
||||
border-radius: 50%;
|
||||
/* "!important" is necessary to override the rule in toolbarbutton.css */
|
||||
margin-top: -1px !important;
|
||||
margin-right: -2px !important;
|
||||
}
|
||||
|
||||
#downloads-button[cui-areatype="toolbar"][attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
background: #D90000 url(chrome://browser/skin/update-badge-failed.svg) no-repeat center;
|
||||
#downloads-button[cui-areatype="toolbar"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
height: 7px;
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
#downloads-button[cui-areatype="toolbar"][attention="warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
background: #FFBF00 url(chrome://browser/skin/update-badge-failed.svg) no-repeat center;
|
||||
#downloads-button[attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
background: #D90000;
|
||||
}
|
||||
|
||||
#downloads-button[attention="warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
background: #FFBF00;
|
||||
}
|
||||
|
||||
#downloads-button[cui-areatype="toolbar"][attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge:-moz-window-inactive,
|
||||
|
@ -36,20 +36,26 @@ toolbar[brighttext] #downloads-indicator-icon {
|
||||
#downloads-button[attention="warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
|
||||
#downloads-button[attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
display: -moz-box;
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
background-size: contain;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
filter: drop-shadow(0 1px 0 hsla(206, 50%, 10%, .15));
|
||||
height: 8px;
|
||||
width: 8px;
|
||||
min-width: 0;
|
||||
border-radius: 50%;
|
||||
/* "!important" is necessary to override the rule in toolbarbutton.css */
|
||||
margin-top: -1px !important;
|
||||
margin-right: -2px !important;
|
||||
}
|
||||
|
||||
#downloads-button[cui-areatype="toolbar"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
height: 7px;
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
#downloads-button[attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
background: #D90000 url(chrome://browser/skin/update-badge-failed.svg) no-repeat center;
|
||||
background: #D90000;
|
||||
}
|
||||
|
||||
#downloads-button[attention="warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
background: #FFBF00 url(chrome://browser/skin/update-badge-failed.svg) no-repeat center;
|
||||
background: #FFBF00;
|
||||
}
|
||||
|
||||
#downloads-button[attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge:-moz-window-inactive,
|
||||
|
@ -115,7 +115,6 @@
|
||||
height: 13px;
|
||||
}
|
||||
|
||||
#PanelUI-menu-button[badge-status="download-severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
|
||||
#PanelUI-menu-button[badge-status="update-failed"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
background: #D90000 url(chrome://browser/skin/update-badge-failed.svg) no-repeat center;
|
||||
height: 13px;
|
||||
@ -123,16 +122,31 @@
|
||||
|
||||
#PanelUI-menu-button[badge-status="download-warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
|
||||
#PanelUI-menu-button[badge-status="fxa-needs-authentication"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
height: 13px;
|
||||
box-shadow: none;
|
||||
filter: drop-shadow(0 1px 0 hsla(206, 50%, 10%, .15));
|
||||
}
|
||||
|
||||
#PanelUI-menu-button[badge-status="download-warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
|
||||
#PanelUI-menu-button[badge-status="download-severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
min-width: 0;
|
||||
border-radius: 50%;
|
||||
/* "!important" is necessary to override the rule in toolbarbutton.css */
|
||||
margin-top: -1px !important;
|
||||
margin-right: -2px !important;
|
||||
}
|
||||
|
||||
#PanelUI-menu-button[badge-status="download-warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
background: #FFBF00 url(chrome://browser/skin/update-badge-failed.svg) no-repeat center;
|
||||
background: #FFBF00;
|
||||
}
|
||||
|
||||
#PanelUI-menu-button[badge-status="download-severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
background: #D90000;
|
||||
}
|
||||
|
||||
#PanelUI-menu-button[badge-status="fxa-needs-authentication"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
height: 13px;
|
||||
background: transparent url(chrome://browser/skin/warning.svg) no-repeat center;
|
||||
}
|
||||
|
||||
|
@ -51,20 +51,26 @@ toolbar[brighttext] #downloads-button:not([attention="success"]) > #downloads-in
|
||||
#downloads-button[attention="warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
|
||||
#downloads-button[attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
display: -moz-box;
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
background-size: contain;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
filter: drop-shadow(0 1px 0 hsla(206, 50%, 10%, .15));
|
||||
height: 8px;
|
||||
width: 8px;
|
||||
min-width: 0;
|
||||
border-radius: 50%;
|
||||
/* "!important" is necessary to override the rule in toolbarbutton.css */
|
||||
margin-top: -1px !important;
|
||||
margin-right: -2px !important;
|
||||
}
|
||||
|
||||
#downloads-button[cui-areatype="toolbar"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
height: 7px;
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
#downloads-button[attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
background: #D90000 url(chrome://browser/skin/update-badge-failed.svg) no-repeat center;
|
||||
background: #D90000;
|
||||
}
|
||||
|
||||
#downloads-button[attention="warning"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
|
||||
background: #FFBF00 url(chrome://browser/skin/update-badge-failed.svg) no-repeat center;
|
||||
background: #FFBF00;
|
||||
}
|
||||
|
||||
#downloads-button[attention="severe"] > .toolbarbutton-badge-stack > .toolbarbutton-badge:-moz-window-inactive,
|
||||
|
12
config/external/icu/defs.mozbuild
vendored
12
config/external/icu/defs.mozbuild
vendored
@ -36,5 +36,17 @@ elif CONFIG['OS_TARGET'] == 'WINNT':
|
||||
DISABLE_STL_WRAPPING = True
|
||||
ALLOW_COMPILER_WARNINGS = True
|
||||
|
||||
# We allow compiler warnings, but we can at least cut down on spammy
|
||||
# warnings that get triggered for every file.
|
||||
if CONFIG['CLANG_CL']:
|
||||
CFLAGS += [
|
||||
'-Wno-macro-redefined',
|
||||
'-Wno-microsoft-include',
|
||||
]
|
||||
CXXFLAGS += [
|
||||
'-Wno-macro-redefined',
|
||||
'-Wno-microsoft-include',
|
||||
]
|
||||
|
||||
if CONFIG['OS_TARGET'] == 'Android' and CONFIG['MOZ_ANDROID_CXX_STL'] == 'mozstlport':
|
||||
LOCAL_INCLUDES += ['/build/gabi++/include']
|
||||
|
@ -16,6 +16,7 @@ const { CanvasFront } = require("devtools/shared/fronts/canvas");
|
||||
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||
const flags = require("devtools/shared/flags");
|
||||
const { LocalizationHelper } = require("devtools/shared/l10n");
|
||||
const { PluralForm } = require("devtools/shared/plural-form");
|
||||
const { Heritage, WidgetMethods, setNamedTimeout, clearNamedTimeout,
|
||||
setConditionalTimeout } = require("devtools/client/shared/widgets/view-helpers");
|
||||
|
||||
@ -23,9 +24,6 @@ const CANVAS_ACTOR_RECORDING_ATTEMPT = flags.testing ? 500 : 5000;
|
||||
|
||||
const { Task } = require("devtools/shared/task");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
|
||||
"resource://gre/modules/FileUtils.jsm");
|
||||
|
||||
|
@ -1576,7 +1576,7 @@ Toolbox.prototype = {
|
||||
// Returns an instance of the preference actor
|
||||
get _preferenceFront() {
|
||||
return this.target.root.then(rootForm => {
|
||||
return new L10N.getFormatStr(this.target.client, rootForm);
|
||||
return new getPreferenceFront(this.target.client, rootForm);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -18,9 +18,6 @@ const {OutputParser} = require("devtools/client/shared/output-parser");
|
||||
const {PrefObserver, PREF_ORIG_SOURCES} = require("devtools/client/styleeditor/utils");
|
||||
const {createChild} = require("devtools/client/inspector/shared/utils");
|
||||
const {gDevTools} = require("devtools/client/framework/devtools");
|
||||
/* eslint-disable mozilla/reject-some-requires */
|
||||
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
/* eslint-enable mozilla/reject-some-requires */
|
||||
const {getCssProperties} = require("devtools/shared/fronts/css-properties");
|
||||
|
||||
const overlays = require("devtools/client/inspector/shared/style-inspector-overlays");
|
||||
@ -29,9 +26,6 @@ const {KeyShortcuts} = require("devtools/client/shared/key-shortcuts");
|
||||
const {LayoutView} = require("devtools/client/inspector/layout/layout");
|
||||
const clipboardHelper = require("devtools/shared/platform/clipboard");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
const STYLE_INSPECTOR_PROPERTIES = "devtools-shared/locale/styleinspector.properties";
|
||||
const {LocalizationHelper} = require("devtools/shared/l10n");
|
||||
const STYLE_INSPECTOR_L10N = new LocalizationHelper(STYLE_INSPECTOR_PROPERTIES);
|
||||
|
@ -52,21 +52,16 @@ const {KeyShortcuts} = require("devtools/client/shared/key-shortcuts");
|
||||
const {template} = require("devtools/shared/gcli/templater");
|
||||
const nodeConstants = require("devtools/shared/dom-node-constants");
|
||||
const nodeFilterConstants = require("devtools/shared/dom-node-filter-constants");
|
||||
/* eslint-disable mozilla/reject-some-requires */
|
||||
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
/* eslint-enable mozilla/reject-some-requires */
|
||||
const {getCssProperties} = require("devtools/shared/fronts/css-properties");
|
||||
const {KeyCodes} = require("devtools/client/shared/keycodes");
|
||||
|
||||
const {AutocompletePopup} = require("devtools/client/shared/autocomplete-popup");
|
||||
const clipboardHelper = require("devtools/shared/platform/clipboard");
|
||||
|
||||
const {PluralForm} = require("devtools/shared/plural-form");
|
||||
const {LocalizationHelper} = require("devtools/shared/l10n");
|
||||
const INSPECTOR_L10N = new LocalizationHelper("devtools/locale/inspector.properties");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
/**
|
||||
* Vocabulary for the purposes of this file:
|
||||
*
|
||||
|
@ -7,9 +7,7 @@
|
||||
* Basic tests for exporting Network panel content into HAR format.
|
||||
*/
|
||||
add_task(function* () {
|
||||
// The first 'tab' isn't necessary so, don't create a var for it
|
||||
// to avoid eslint warning.
|
||||
let [ , debuggee, monitor ] = yield initNetMonitor(SIMPLE_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
|
||||
info("Starting test... ");
|
||||
|
||||
@ -18,9 +16,10 @@ add_task(function* () {
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
debuggee.location.reload();
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
tab.linkedBrowser.reload();
|
||||
yield wait;
|
||||
|
||||
yield waitForNetworkEvents(monitor, 1);
|
||||
yield RequestsMenu.copyAllAsHar();
|
||||
|
||||
let jsonString = SpecialPowers.getClipboardData("text/unicode");
|
||||
@ -46,5 +45,5 @@ add_task(function* () {
|
||||
"Check response body");
|
||||
isnot(entry.timings, undefined, "Check timings");
|
||||
|
||||
teardown(monitor).then(finish);
|
||||
return teardown(monitor);
|
||||
});
|
||||
|
@ -7,9 +7,7 @@
|
||||
* Tests for exporting POST data into HAR format.
|
||||
*/
|
||||
add_task(function* () {
|
||||
// The first 'tab' isn't necessary so, don't create a var for it
|
||||
// to avoid eslint warning.
|
||||
let [ , debuggee, monitor ] = yield initNetMonitor(
|
||||
let { tab, monitor } = yield initNetMonitor(
|
||||
HAR_EXAMPLE_URL + "html_har_post-data-test-page.html");
|
||||
|
||||
info("Starting test... ");
|
||||
@ -20,8 +18,11 @@ add_task(function* () {
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
// Execute one POST request on the page and wait till its done.
|
||||
debuggee.executeTest();
|
||||
yield waitForNetworkEvents(monitor, 0, 1);
|
||||
let wait = waitForNetworkEvents(monitor, 0, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.executeTest();
|
||||
});
|
||||
yield wait;
|
||||
|
||||
// Copy HAR into the clipboard (asynchronous).
|
||||
let jsonString = yield RequestsMenu.copyAllAsHar();
|
||||
@ -39,5 +40,5 @@ add_task(function* () {
|
||||
"Check post data payload");
|
||||
|
||||
// Clean up
|
||||
teardown(monitor).then(finish);
|
||||
return teardown(monitor);
|
||||
});
|
||||
|
@ -11,7 +11,7 @@ add_task(function* () {
|
||||
});
|
||||
|
||||
function* throttleUploadTest(actuallyThrottle) {
|
||||
let [ , debuggee, monitor ] = yield initNetMonitor(
|
||||
let { tab, monitor } = yield initNetMonitor(
|
||||
HAR_EXAMPLE_URL + "html_har_post-data-test-page.html");
|
||||
|
||||
info("Starting test... (actuallyThrottle = " + actuallyThrottle + ")");
|
||||
@ -44,8 +44,11 @@ function* throttleUploadTest(actuallyThrottle) {
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
// Execute one POST request on the page and wait till its done.
|
||||
debuggee.executeTest2(size);
|
||||
yield waitForNetworkEvents(monitor, 0, 1);
|
||||
let wait = waitForNetworkEvents(monitor, 0, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, { size }, function* (args) {
|
||||
content.wrappedJSObject.executeTest2(args.size);
|
||||
});
|
||||
yield wait;
|
||||
|
||||
// Copy HAR into the clipboard (asynchronous).
|
||||
let jsonString = yield RequestsMenu.copyAllAsHar();
|
||||
|
@ -124,9 +124,6 @@ XPCOMUtils.defineConstant(this, "Editor", Editor);
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Chart",
|
||||
"resource://devtools/client/shared/widgets/Chart.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper",
|
||||
"@mozilla.org/widget/clipboardhelper;1", "nsIClipboardHelper");
|
||||
|
||||
|
@ -40,6 +40,7 @@ const NET_STRINGS_URI = "devtools/locale/netmonitor.properties";
|
||||
const WEBCONSOLE_STRINGS_URI = "devtools/locale/webconsole.properties";
|
||||
var L10N = new LocalizationHelper(NET_STRINGS_URI);
|
||||
const WEBCONSOLE_L10N = new LocalizationHelper(WEBCONSOLE_STRINGS_URI);
|
||||
const {PluralForm} = require("devtools/shared/plural-form");
|
||||
|
||||
// ms
|
||||
const WDA_DEFAULT_VERIFY_INTERVAL = 50;
|
||||
|
@ -1,28 +1,28 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if the network monitor leaks on initialization and sudden destruction.
|
||||
* You can also use this initialization format as a template for other tests.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, NetMonitorView, NetMonitorController } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
let { document, NetMonitorView, NetMonitorController } = monitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
|
||||
ok(aTab, "Should have a tab available.");
|
||||
ok(aDebuggee, "Should have a debuggee available.");
|
||||
ok(aMonitor, "Should have a network monitor pane available.");
|
||||
ok(tab, "Should have a tab available.");
|
||||
ok(monitor, "Should have a network monitor pane available.");
|
||||
|
||||
ok(document, "Should have a document available.");
|
||||
ok(NetMonitorView, "Should have a NetMonitorView object available.");
|
||||
ok(NetMonitorController, "Should have a NetMonitorController object available.");
|
||||
ok(RequestsMenu, "Should have a RequestsMenu object available.");
|
||||
ok(NetworkDetails, "Should have a NetworkDetails object available.");
|
||||
ok(document, "Should have a document available.");
|
||||
ok(NetMonitorView, "Should have a NetMonitorView object available.");
|
||||
ok(NetMonitorController, "Should have a NetMonitorController object available.");
|
||||
ok(RequestsMenu, "Should have a RequestsMenu object available.");
|
||||
ok(NetworkDetails, "Should have a NetworkDetails object available.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
}
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,83 +1,87 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if focus modifiers work for the SideMenuWidget.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
// It seems that this test may be slow on Ubuntu builds running on ec2.
|
||||
requestLongerTimeout(2);
|
||||
// It seems that this test may be slow on Ubuntu builds running on ec2.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
let { NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 2).then(() => {
|
||||
check(-1, false);
|
||||
let count = 0;
|
||||
function check(selectedIndex, paneVisibility) {
|
||||
info("Performing check " + (count++) + ".");
|
||||
|
||||
RequestsMenu.focusLastVisibleItem();
|
||||
check(1, true);
|
||||
RequestsMenu.focusFirstVisibleItem();
|
||||
check(0, true);
|
||||
is(RequestsMenu.selectedIndex, selectedIndex,
|
||||
"The selected item in the requests menu was incorrect.");
|
||||
is(NetMonitorView.detailsPaneHidden, !paneVisibility,
|
||||
"The network requests details pane visibility state was incorrect.");
|
||||
}
|
||||
|
||||
RequestsMenu.focusNextItem();
|
||||
check(1, true);
|
||||
RequestsMenu.focusPrevItem();
|
||||
check(0, true);
|
||||
|
||||
RequestsMenu.focusItemAtDelta(+1);
|
||||
check(1, true);
|
||||
RequestsMenu.focusItemAtDelta(-1);
|
||||
check(0, true);
|
||||
|
||||
RequestsMenu.focusItemAtDelta(+10);
|
||||
check(1, true);
|
||||
RequestsMenu.focusItemAtDelta(-10);
|
||||
check(0, true);
|
||||
|
||||
aDebuggee.performRequests(18);
|
||||
return waitForNetworkEvents(aMonitor, 18);
|
||||
})
|
||||
.then(() => {
|
||||
RequestsMenu.focusLastVisibleItem();
|
||||
check(19, true);
|
||||
RequestsMenu.focusFirstVisibleItem();
|
||||
check(0, true);
|
||||
|
||||
RequestsMenu.focusNextItem();
|
||||
check(1, true);
|
||||
RequestsMenu.focusPrevItem();
|
||||
check(0, true);
|
||||
|
||||
RequestsMenu.focusItemAtDelta(+10);
|
||||
check(10, true);
|
||||
RequestsMenu.focusItemAtDelta(-10);
|
||||
check(0, true);
|
||||
|
||||
RequestsMenu.focusItemAtDelta(+100);
|
||||
check(19, true);
|
||||
RequestsMenu.focusItemAtDelta(-100);
|
||||
check(0, true);
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
|
||||
let count = 0;
|
||||
|
||||
function check(aSelectedIndex, aPaneVisibility) {
|
||||
info("Performing check " + (count++) + ".");
|
||||
|
||||
is(RequestsMenu.selectedIndex, aSelectedIndex,
|
||||
"The selected item in the requests menu was incorrect.");
|
||||
is(NetMonitorView.detailsPaneHidden, !aPaneVisibility,
|
||||
"The network requests details pane visibility state was incorrect.");
|
||||
}
|
||||
|
||||
aDebuggee.performRequests(2);
|
||||
let wait = waitForNetworkEvents(monitor, 2);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests(2);
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
check(-1, false);
|
||||
|
||||
RequestsMenu.focusLastVisibleItem();
|
||||
check(1, true);
|
||||
RequestsMenu.focusFirstVisibleItem();
|
||||
check(0, true);
|
||||
|
||||
RequestsMenu.focusNextItem();
|
||||
check(1, true);
|
||||
RequestsMenu.focusPrevItem();
|
||||
check(0, true);
|
||||
|
||||
RequestsMenu.focusItemAtDelta(+1);
|
||||
check(1, true);
|
||||
RequestsMenu.focusItemAtDelta(-1);
|
||||
check(0, true);
|
||||
|
||||
RequestsMenu.focusItemAtDelta(+10);
|
||||
check(1, true);
|
||||
RequestsMenu.focusItemAtDelta(-10);
|
||||
check(0, true);
|
||||
|
||||
wait = waitForNetworkEvents(monitor, 18);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests(18);
|
||||
});
|
||||
yield wait;
|
||||
|
||||
RequestsMenu.focusLastVisibleItem();
|
||||
check(19, true);
|
||||
RequestsMenu.focusFirstVisibleItem();
|
||||
check(0, true);
|
||||
|
||||
RequestsMenu.focusNextItem();
|
||||
check(1, true);
|
||||
RequestsMenu.focusPrevItem();
|
||||
check(0, true);
|
||||
|
||||
RequestsMenu.focusItemAtDelta(+10);
|
||||
check(10, true);
|
||||
RequestsMenu.focusItemAtDelta(-10);
|
||||
check(0, true);
|
||||
|
||||
RequestsMenu.focusItemAtDelta(+100);
|
||||
check(19, true);
|
||||
RequestsMenu.focusItemAtDelta(-100);
|
||||
check(0, true);
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,126 +1,130 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if keyboard and mouse navigation works in the network requests menu.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
// It seems that this test may be slow on Ubuntu builds running on ec2.
|
||||
requestLongerTimeout(2);
|
||||
// It seems that this test may be slow on Ubuntu builds running on ec2.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
let { window, $, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { window, $, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 2).then(() => {
|
||||
check(-1, false);
|
||||
let count = 0;
|
||||
function check(selectedIndex, paneVisibility) {
|
||||
info("Performing check " + (count++) + ".");
|
||||
|
||||
EventUtils.sendKey("DOWN", window);
|
||||
check(0, true);
|
||||
EventUtils.sendKey("UP", window);
|
||||
check(0, true);
|
||||
is(RequestsMenu.selectedIndex, selectedIndex,
|
||||
"The selected item in the requests menu was incorrect.");
|
||||
is(NetMonitorView.detailsPaneHidden, !paneVisibility,
|
||||
"The network requests details pane visibility state was incorrect.");
|
||||
}
|
||||
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(1, true);
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(0, true);
|
||||
|
||||
EventUtils.sendKey("END", window);
|
||||
check(1, true);
|
||||
EventUtils.sendKey("HOME", window);
|
||||
check(0, true);
|
||||
|
||||
aDebuggee.performRequests(18);
|
||||
return waitForNetworkEvents(aMonitor, 18);
|
||||
})
|
||||
.then(() => {
|
||||
EventUtils.sendKey("DOWN", window);
|
||||
check(1, true);
|
||||
EventUtils.sendKey("DOWN", window);
|
||||
check(2, true);
|
||||
EventUtils.sendKey("UP", window);
|
||||
check(1, true);
|
||||
EventUtils.sendKey("UP", window);
|
||||
check(0, true);
|
||||
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(4, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(8, true);
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(4, true);
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(0, true);
|
||||
|
||||
EventUtils.sendKey("HOME", window);
|
||||
check(0, true);
|
||||
EventUtils.sendKey("HOME", window);
|
||||
check(0, true);
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(0, true);
|
||||
EventUtils.sendKey("HOME", window);
|
||||
check(0, true);
|
||||
|
||||
EventUtils.sendKey("END", window);
|
||||
check(19, true);
|
||||
EventUtils.sendKey("END", window);
|
||||
check(19, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(19, true);
|
||||
EventUtils.sendKey("END", window);
|
||||
check(19, true);
|
||||
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(15, true);
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(11, true);
|
||||
EventUtils.sendKey("UP", window);
|
||||
check(10, true);
|
||||
EventUtils.sendKey("UP", window);
|
||||
check(9, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(13, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(17, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(19, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(19, true);
|
||||
|
||||
EventUtils.sendKey("HOME", window);
|
||||
check(0, true);
|
||||
EventUtils.sendKey("DOWN", window);
|
||||
check(1, true);
|
||||
EventUtils.sendKey("END", window);
|
||||
check(19, true);
|
||||
EventUtils.sendKey("DOWN", window);
|
||||
check(19, true);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
check(-1, false);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $(".side-menu-widget-item"));
|
||||
check(0, true);
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
|
||||
let count = 0;
|
||||
|
||||
function check(aSelectedIndex, aPaneVisibility) {
|
||||
info("Performing check " + (count++) + ".");
|
||||
|
||||
is(RequestsMenu.selectedIndex, aSelectedIndex,
|
||||
"The selected item in the requests menu was incorrect.");
|
||||
is(NetMonitorView.detailsPaneHidden, !aPaneVisibility,
|
||||
"The network requests details pane visibility state was incorrect.");
|
||||
}
|
||||
|
||||
aDebuggee.performRequests(2);
|
||||
let wait = waitForNetworkEvents(monitor, 2);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests(2);
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
check(-1, false);
|
||||
|
||||
EventUtils.sendKey("DOWN", window);
|
||||
check(0, true);
|
||||
EventUtils.sendKey("UP", window);
|
||||
check(0, true);
|
||||
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(1, true);
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(0, true);
|
||||
|
||||
EventUtils.sendKey("END", window);
|
||||
check(1, true);
|
||||
EventUtils.sendKey("HOME", window);
|
||||
check(0, true);
|
||||
|
||||
wait = waitForNetworkEvents(monitor, 18);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests(18);
|
||||
});
|
||||
yield wait;
|
||||
|
||||
EventUtils.sendKey("DOWN", window);
|
||||
check(1, true);
|
||||
EventUtils.sendKey("DOWN", window);
|
||||
check(2, true);
|
||||
EventUtils.sendKey("UP", window);
|
||||
check(1, true);
|
||||
EventUtils.sendKey("UP", window);
|
||||
check(0, true);
|
||||
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(4, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(8, true);
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(4, true);
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(0, true);
|
||||
|
||||
EventUtils.sendKey("HOME", window);
|
||||
check(0, true);
|
||||
EventUtils.sendKey("HOME", window);
|
||||
check(0, true);
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(0, true);
|
||||
EventUtils.sendKey("HOME", window);
|
||||
check(0, true);
|
||||
|
||||
EventUtils.sendKey("END", window);
|
||||
check(19, true);
|
||||
EventUtils.sendKey("END", window);
|
||||
check(19, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(19, true);
|
||||
EventUtils.sendKey("END", window);
|
||||
check(19, true);
|
||||
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(15, true);
|
||||
EventUtils.sendKey("PAGE_UP", window);
|
||||
check(11, true);
|
||||
EventUtils.sendKey("UP", window);
|
||||
check(10, true);
|
||||
EventUtils.sendKey("UP", window);
|
||||
check(9, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(13, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(17, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(19, true);
|
||||
EventUtils.sendKey("PAGE_DOWN", window);
|
||||
check(19, true);
|
||||
|
||||
EventUtils.sendKey("HOME", window);
|
||||
check(0, true);
|
||||
EventUtils.sendKey("DOWN", window);
|
||||
check(1, true);
|
||||
EventUtils.sendKey("END", window);
|
||||
check(19, true);
|
||||
EventUtils.sendKey("DOWN", window);
|
||||
check(19, true);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
check(-1, false);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $(".side-menu-widget-item"));
|
||||
check(0, true);
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,40 +1,39 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests whether API call URLs (without a filename) are correctly displayed (including Unicode)
|
||||
* Tests whether API call URLs (without a filename) are correctly displayed
|
||||
* (including Unicode)
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(API_CALLS_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(API_CALLS_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, EVENTS, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
const REQUEST_URIS = [
|
||||
"http://example.com/api/fileName.xml",
|
||||
"http://example.com/api/file%E2%98%A2.xml",
|
||||
"http://example.com/api/ascii/get/",
|
||||
"http://example.com/api/unicode/%E2%98%A2/",
|
||||
"http://example.com/api/search/?q=search%E2%98%A2"
|
||||
];
|
||||
const REQUEST_URIS = [
|
||||
"http://example.com/api/fileName.xml",
|
||||
"http://example.com/api/file%E2%98%A2.xml",
|
||||
"http://example.com/api/ascii/get/",
|
||||
"http://example.com/api/unicode/%E2%98%A2/",
|
||||
"http://example.com/api/search/?q=search%E2%98%A2"
|
||||
];
|
||||
|
||||
Task.spawn(function* () {
|
||||
yield waitForNetworkEvents(aMonitor, 5);
|
||||
|
||||
REQUEST_URIS.forEach(function (uri, index) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(index), "GET", uri);
|
||||
});
|
||||
|
||||
yield teardown(aMonitor);
|
||||
finish();
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
let wait = waitForNetworkEvents(monitor, 5);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
REQUEST_URIS.forEach(function (uri, index) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(index), "GET", uri);
|
||||
});
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,32 +1,24 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// /////////////////
|
||||
//
|
||||
// Whitelisting this test.
|
||||
// As part of bug 1077403, the leaking uncaught rejection should be fixed.
|
||||
//
|
||||
thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: aValue.content is undefined");
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Bug 863102 - Automatically scroll down upon new network requests.
|
||||
*/
|
||||
add_task(function* () {
|
||||
requestLongerTimeout(2);
|
||||
let monitor, debuggee, requestsContainer, scrollTop;
|
||||
|
||||
let [aTab, aDebuggee, aMonitor] = yield initNetMonitor(INFINITE_GET_URL);
|
||||
monitor = aMonitor;
|
||||
debuggee = aDebuggee;
|
||||
let { monitor } = yield initNetMonitor(INFINITE_GET_URL);
|
||||
let win = monitor.panelWin;
|
||||
let topNode = win.document.getElementById("requests-menu-contents");
|
||||
requestsContainer = topNode.getElementsByTagName("scrollbox")[0];
|
||||
let requestsContainer = topNode.getElementsByTagName("scrollbox")[0];
|
||||
ok(!!requestsContainer, "Container element exists as expected.");
|
||||
|
||||
// (1) Check that the scroll position is maintained at the bottom
|
||||
// when the requests overflow the vertical size of the container.
|
||||
yield waitForRequestsToOverflowContainer(monitor, requestsContainer);
|
||||
yield waitForScroll(monitor);
|
||||
yield waitForRequestsToOverflowContainer();
|
||||
yield waitForScroll();
|
||||
ok(scrolledToBottom(requestsContainer), "Scrolled to bottom on overflow.");
|
||||
|
||||
// (2) Now set the scroll position somewhere in the middle and check
|
||||
@ -35,7 +27,8 @@ add_task(function* () {
|
||||
let middleNode = children.item(children.length / 2);
|
||||
middleNode.scrollIntoView();
|
||||
ok(!scrolledToBottom(requestsContainer), "Not scrolled to bottom.");
|
||||
scrollTop = requestsContainer.scrollTop; // save for comparison later
|
||||
// save for comparison later
|
||||
let scrollTop = requestsContainer.scrollTop;
|
||||
yield waitForNetworkEvents(monitor, 8);
|
||||
yield waitSomeTime();
|
||||
is(requestsContainer.scrollTop, scrollTop, "Did not scroll.");
|
||||
@ -45,7 +38,7 @@ add_task(function* () {
|
||||
requestsContainer.scrollTop = requestsContainer.scrollHeight;
|
||||
ok(scrolledToBottom(requestsContainer), "Set scroll position to bottom.");
|
||||
yield waitForNetworkEvents(monitor, 8);
|
||||
yield waitForScroll(monitor);
|
||||
yield waitForScroll();
|
||||
ok(scrolledToBottom(requestsContainer), "Still scrolled to bottom.");
|
||||
|
||||
// (4) Now select an item in the list and check that additional requests
|
||||
@ -58,29 +51,25 @@ add_task(function* () {
|
||||
// Done: clean up.
|
||||
yield teardown(monitor);
|
||||
|
||||
finish();
|
||||
|
||||
function waitForRequestsToOverflowContainer(aMonitor, aContainer) {
|
||||
return waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
if (aContainer.scrollHeight > aContainer.clientHeight) {
|
||||
return promise.resolve();
|
||||
} else {
|
||||
return waitForRequestsToOverflowContainer(aMonitor, aContainer);
|
||||
function* waitForRequestsToOverflowContainer() {
|
||||
while (true) {
|
||||
yield waitForNetworkEvents(monitor, 1);
|
||||
if (requestsContainer.scrollHeight > requestsContainer.clientHeight) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function scrolledToBottom(aElement) {
|
||||
return aElement.scrollTop + aElement.clientHeight >= aElement.scrollHeight;
|
||||
function scrolledToBottom(element) {
|
||||
return element.scrollTop + element.clientHeight >= element.scrollHeight;
|
||||
}
|
||||
|
||||
function waitSomeTime() {
|
||||
let waitSomeTime = promise.defer();
|
||||
setTimeout(waitSomeTime.resolve, 50); // Wait to make sure no scrolls happen
|
||||
return waitSomeTime.promise;
|
||||
// Wait to make sure no scrolls happen
|
||||
return wait(50);
|
||||
}
|
||||
|
||||
function waitForScroll(aMonitor) {
|
||||
return aMonitor._view.RequestsMenu.widget.once("scroll-to-bottom");
|
||||
function waitForScroll() {
|
||||
return monitor._view.RequestsMenu.widget.once("scroll-to-bottom");
|
||||
}
|
||||
});
|
||||
|
@ -1,24 +1,18 @@
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
// /////////////////
|
||||
//
|
||||
// Whitelisting this test.
|
||||
// As part of bug 1077403, the leaking uncaught rejection should be fixed.
|
||||
//
|
||||
thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: can't convert undefined to object");
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if cached requests have the correct status code
|
||||
*/
|
||||
|
||||
var test = Task.async(function* () {
|
||||
let [tab, debuggee, monitor] = yield initNetMonitor(STATUS_CODES_URL, null, true);
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(STATUS_CODES_URL, null, true);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
@ -61,7 +55,7 @@ var test = Task.async(function* () {
|
||||
details: {
|
||||
status: 200,
|
||||
statusText: "OK (cached)",
|
||||
displayedStatus : "cached",
|
||||
displayedStatus: "cached",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8"
|
||||
}
|
||||
@ -90,12 +84,10 @@ var test = Task.async(function* () {
|
||||
];
|
||||
|
||||
info("Performing requests #1...");
|
||||
debuggee.performCachedRequests();
|
||||
yield waitForNetworkEvents(monitor, 3);
|
||||
yield performRequestsAndWait();
|
||||
|
||||
info("Performing requests #2...");
|
||||
debuggee.performCachedRequests();
|
||||
yield waitForNetworkEvents(monitor, 3);
|
||||
yield performRequestsAndWait();
|
||||
|
||||
let index = 0;
|
||||
for (let request of REQUEST_DATA) {
|
||||
@ -108,5 +100,12 @@ var test = Task.async(function* () {
|
||||
}
|
||||
|
||||
yield teardown(monitor);
|
||||
finish();
|
||||
|
||||
function* performRequestsAndWait() {
|
||||
let wait = waitForNetworkEvents(monitor, 3);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performCachedRequests();
|
||||
});
|
||||
yield wait;
|
||||
}
|
||||
});
|
||||
|
@ -16,8 +16,8 @@ const EXPECTED_REQUESTS = [
|
||||
url: CAUSE_URL,
|
||||
causeType: "document",
|
||||
causeUri: "",
|
||||
// The document load is from JS function in e10s, native in non-e10s
|
||||
stack: !gMultiProcessBrowser
|
||||
// The document load has internal privileged JS code on the stack
|
||||
stack: true
|
||||
},
|
||||
{
|
||||
method: "GET",
|
||||
@ -77,21 +77,21 @@ const EXPECTED_REQUESTS = [
|
||||
},
|
||||
];
|
||||
|
||||
var test = Task.async(function* () {
|
||||
add_task(function* () {
|
||||
// the initNetMonitor function clears the network request list after the
|
||||
// page is loaded. That's why we first load a bogus page from SIMPLE_URL,
|
||||
// and only then load the real thing from CAUSE_URL - we want to catch
|
||||
// all the requests the page is making, not only the XHRs.
|
||||
// We can't use about:blank here, because initNetMonitor checks that the
|
||||
// page has actually made at least one request.
|
||||
let [, debuggee, monitor] = yield initNetMonitor(SIMPLE_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
let { $, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
debuggee.location = CAUSE_URL;
|
||||
|
||||
yield waitForNetworkEvents(monitor, EXPECTED_REQUESTS.length);
|
||||
let wait = waitForNetworkEvents(monitor, EXPECTED_REQUESTS.length);
|
||||
tab.linkedBrowser.loadURI(CAUSE_URL);
|
||||
yield wait;
|
||||
|
||||
is(RequestsMenu.itemCount, EXPECTED_REQUESTS.length,
|
||||
"All the page events should be recorded.");
|
||||
@ -141,5 +141,4 @@ var test = Task.async(function* () {
|
||||
});
|
||||
|
||||
yield teardown(monitor);
|
||||
finish();
|
||||
});
|
||||
|
@ -8,7 +8,7 @@
|
||||
* redirected without hitting the network (HSTS is one of such cases)
|
||||
*/
|
||||
|
||||
var test = Task.async(function* () {
|
||||
add_task(function* () {
|
||||
const EXPECTED_REQUESTS = [
|
||||
// Request to HTTP URL, redirects to HTTPS, has callstack
|
||||
{ status: 302, hasStack: true },
|
||||
@ -18,12 +18,13 @@ var test = Task.async(function* () {
|
||||
{ status: 200, hasStack: true },
|
||||
];
|
||||
|
||||
let [, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { RequestsMenu } = monitor.panelWin.NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
debuggee.performRequests(2, HSTS_SJS);
|
||||
yield waitForNetworkEvents(monitor, EXPECTED_REQUESTS.length);
|
||||
let wait = waitForNetworkEvents(monitor, EXPECTED_REQUESTS.length);
|
||||
yield performRequests(2, HSTS_SJS);
|
||||
yield wait;
|
||||
|
||||
EXPECTED_REQUESTS.forEach(({status, hasStack}, i) => {
|
||||
let { attachment } = RequestsMenu.getItemAtIndex(i);
|
||||
@ -42,9 +43,15 @@ var test = Task.async(function* () {
|
||||
});
|
||||
|
||||
// Send a request to reset the HSTS policy to state before the test
|
||||
debuggee.performRequests(1, HSTS_SJS + "?reset");
|
||||
yield waitForNetworkEvents(monitor, 1);
|
||||
wait = waitForNetworkEvents(monitor, 1);
|
||||
yield performRequests(1, HSTS_SJS + "?reset");
|
||||
yield wait;
|
||||
|
||||
yield teardown(monitor);
|
||||
finish();
|
||||
|
||||
function performRequests(count, url) {
|
||||
return ContentTask.spawn(tab.linkedBrowser, { count, url }, function* (args) {
|
||||
content.wrappedJSObject.performRequests(args.count, args.url);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,77 +1,73 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// /////////////////
|
||||
//
|
||||
// Whitelisting this test.
|
||||
// As part of bug 1077403, the leaking uncaught rejection should be fixed.
|
||||
//
|
||||
thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: can't convert undefined to object");
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Makes sure Pie Charts have the right internal structure.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, Chart } = aMonitor.panelWin;
|
||||
let container = document.createElement("box");
|
||||
let { document, Chart } = monitor.panelWin;
|
||||
|
||||
let pie = Chart.Pie(document, {
|
||||
width: 100,
|
||||
height: 100,
|
||||
data: [{
|
||||
size: 1,
|
||||
label: "foo"
|
||||
}, {
|
||||
size: 2,
|
||||
label: "bar"
|
||||
}, {
|
||||
size: 3,
|
||||
label: "baz"
|
||||
}]
|
||||
});
|
||||
|
||||
let node = pie.node;
|
||||
let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
|
||||
let labels = node.querySelectorAll(".pie-chart-label");
|
||||
|
||||
ok(node.classList.contains("pie-chart-container") &&
|
||||
node.classList.contains("generic-chart-container"),
|
||||
"A pie chart container was created successfully.");
|
||||
|
||||
is(slices.length, 3,
|
||||
"There should be 3 pie chart slices created.");
|
||||
ok(slices[0].getAttribute("d").match(/\s*M 50,50 L 49\.\d+,97\.\d+ A 47\.5,47\.5 0 0 1 49\.\d+,2\.5\d* Z/),
|
||||
"The first slice has the correct data.");
|
||||
ok(slices[1].getAttribute("d").match(/\s*M 50,50 L 91\.\d+,26\.\d+ A 47\.5,47\.5 0 0 1 49\.\d+,97\.\d+ Z/),
|
||||
"The second slice has the correct data.");
|
||||
ok(slices[2].getAttribute("d").match(/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 0 1 91\.\d+,26\.\d+ Z/),
|
||||
"The third slice has the correct data.");
|
||||
|
||||
ok(slices[0].hasAttribute("largest"),
|
||||
"The first slice should be the largest one.");
|
||||
ok(slices[2].hasAttribute("smallest"),
|
||||
"The third slice should be the smallest one.");
|
||||
|
||||
ok(slices[0].getAttribute("name"), "baz",
|
||||
"The first slice's name is correct.");
|
||||
ok(slices[1].getAttribute("name"), "bar",
|
||||
"The first slice's name is correct.");
|
||||
ok(slices[2].getAttribute("name"), "foo",
|
||||
"The first slice's name is correct.");
|
||||
|
||||
is(labels.length, 3,
|
||||
"There should be 3 pie chart labels created.");
|
||||
is(labels[0].textContent, "baz",
|
||||
"The first label's text is correct.");
|
||||
is(labels[1].textContent, "bar",
|
||||
"The first label's text is correct.");
|
||||
is(labels[2].textContent, "foo",
|
||||
"The first label's text is correct.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
let pie = Chart.Pie(document, {
|
||||
width: 100,
|
||||
height: 100,
|
||||
data: [{
|
||||
size: 1,
|
||||
label: "foo"
|
||||
}, {
|
||||
size: 2,
|
||||
label: "bar"
|
||||
}, {
|
||||
size: 3,
|
||||
label: "baz"
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
let node = pie.node;
|
||||
let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
|
||||
let labels = node.querySelectorAll(".pie-chart-label");
|
||||
|
||||
ok(node.classList.contains("pie-chart-container") &&
|
||||
node.classList.contains("generic-chart-container"),
|
||||
"A pie chart container was created successfully.");
|
||||
|
||||
is(slices.length, 3,
|
||||
"There should be 3 pie chart slices created.");
|
||||
ok(slices[0].getAttribute("d").match(
|
||||
/\s*M 50,50 L 49\.\d+,97\.\d+ A 47\.5,47\.5 0 0 1 49\.\d+,2\.5\d* Z/),
|
||||
"The first slice has the correct data.");
|
||||
ok(slices[1].getAttribute("d").match(
|
||||
/\s*M 50,50 L 91\.\d+,26\.\d+ A 47\.5,47\.5 0 0 1 49\.\d+,97\.\d+ Z/),
|
||||
"The second slice has the correct data.");
|
||||
ok(slices[2].getAttribute("d").match(
|
||||
/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 0 1 91\.\d+,26\.\d+ Z/),
|
||||
"The third slice has the correct data.");
|
||||
|
||||
ok(slices[0].hasAttribute("largest"),
|
||||
"The first slice should be the largest one.");
|
||||
ok(slices[2].hasAttribute("smallest"),
|
||||
"The third slice should be the smallest one.");
|
||||
|
||||
ok(slices[0].getAttribute("name"), "baz",
|
||||
"The first slice's name is correct.");
|
||||
ok(slices[1].getAttribute("name"), "bar",
|
||||
"The first slice's name is correct.");
|
||||
ok(slices[2].getAttribute("name"), "foo",
|
||||
"The first slice's name is correct.");
|
||||
|
||||
is(labels.length, 3,
|
||||
"There should be 3 pie chart labels created.");
|
||||
is(labels[0].textContent, "baz",
|
||||
"The first label's text is correct.");
|
||||
is(labels[1].textContent, "bar",
|
||||
"The first label's text is correct.");
|
||||
is(labels[2].textContent, "foo",
|
||||
"The first label's text is correct.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,49 +1,47 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Makes sure Pie Charts have the right internal structure when
|
||||
* initialized with empty data.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, Chart } = aMonitor.panelWin;
|
||||
let container = document.createElement("box");
|
||||
let { document, L10N, Chart } = monitor.panelWin;
|
||||
|
||||
let pie = Chart.Pie(document, {
|
||||
data: null,
|
||||
width: 100,
|
||||
height: 100
|
||||
});
|
||||
|
||||
let node = pie.node;
|
||||
let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
|
||||
let labels = node.querySelectorAll(".pie-chart-label");
|
||||
|
||||
ok(node.classList.contains("pie-chart-container") &&
|
||||
node.classList.contains("generic-chart-container"),
|
||||
"A pie chart container was created successfully.");
|
||||
|
||||
is(slices.length, 1,
|
||||
"There should be 1 pie chart slice created.");
|
||||
ok(slices[0].getAttribute("d").match(/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 1 1 49\.\d+,2\.5\d* Z/),
|
||||
"The first slice has the correct data.");
|
||||
|
||||
ok(slices[0].hasAttribute("largest"),
|
||||
"The first slice should be the largest one.");
|
||||
ok(slices[0].hasAttribute("smallest"),
|
||||
"The first slice should also be the smallest one.");
|
||||
ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.loading"),
|
||||
"The first slice's name is correct.");
|
||||
|
||||
is(labels.length, 1,
|
||||
"There should be 1 pie chart label created.");
|
||||
is(labels[0].textContent, "Loading",
|
||||
"The first label's text is correct.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
let pie = Chart.Pie(document, {
|
||||
data: null,
|
||||
width: 100,
|
||||
height: 100
|
||||
});
|
||||
}
|
||||
|
||||
let node = pie.node;
|
||||
let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
|
||||
let labels = node.querySelectorAll(".pie-chart-label");
|
||||
|
||||
ok(node.classList.contains("pie-chart-container") &&
|
||||
node.classList.contains("generic-chart-container"),
|
||||
"A pie chart container was created successfully.");
|
||||
|
||||
is(slices.length, 1, "There should be 1 pie chart slice created.");
|
||||
ok(slices[0].getAttribute("d").match(
|
||||
/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 1 1 49\.\d+,2\.5\d* Z/),
|
||||
"The first slice has the correct data.");
|
||||
|
||||
ok(slices[0].hasAttribute("largest"),
|
||||
"The first slice should be the largest one.");
|
||||
ok(slices[0].hasAttribute("smallest"),
|
||||
"The first slice should also be the smallest one.");
|
||||
ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.loading"),
|
||||
"The first slice's name is correct.");
|
||||
|
||||
is(labels.length, 1, "There should be 1 pie chart label created.");
|
||||
is(labels[0].textContent, "Loading", "The first label's text is correct.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,103 +1,104 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Makes sure Table Charts have the right internal structure.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, Chart } = aMonitor.panelWin;
|
||||
let container = document.createElement("box");
|
||||
let { document, L10N, Chart } = monitor.panelWin;
|
||||
|
||||
let table = Chart.Table(document, {
|
||||
title: "Table title",
|
||||
data: [{
|
||||
label1: 1,
|
||||
label2: 11.1
|
||||
}, {
|
||||
label1: 2,
|
||||
label2: 12.2
|
||||
}, {
|
||||
label1: 3,
|
||||
label2: 13.3
|
||||
}],
|
||||
strings: {
|
||||
label2: (value, index) => value + ["foo", "bar", "baz"][index]
|
||||
},
|
||||
totals: {
|
||||
label1: value => "Hello " + L10N.numberWithDecimals(value, 2),
|
||||
label2: value => "World " + L10N.numberWithDecimals(value, 2)
|
||||
}
|
||||
});
|
||||
|
||||
let node = table.node;
|
||||
let title = node.querySelector(".table-chart-title");
|
||||
let grid = node.querySelector(".table-chart-grid");
|
||||
let totals = node.querySelector(".table-chart-totals");
|
||||
let rows = grid.querySelectorAll(".table-chart-row");
|
||||
let sums = node.querySelectorAll(".table-chart-summary-label");
|
||||
|
||||
ok(node.classList.contains("table-chart-container") &&
|
||||
node.classList.contains("generic-chart-container"),
|
||||
"A table chart container was created successfully.");
|
||||
|
||||
ok(title,
|
||||
"A title node was created successfully.");
|
||||
is(title.getAttribute("value"), "Table title",
|
||||
"The title node displays the correct text.");
|
||||
|
||||
is(rows.length, 3,
|
||||
"There should be 3 table chart rows created.");
|
||||
|
||||
ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"),
|
||||
"A colored blob exists for the firt row.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "label1",
|
||||
"The first column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label2",
|
||||
"The second column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "1",
|
||||
"The first column of the first row displays the correct text.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("value"), "11.1foo",
|
||||
"The second column of the first row displays the correct text.");
|
||||
|
||||
ok(rows[1].querySelector(".table-chart-row-box.chart-colored-blob"),
|
||||
"A colored blob exists for the second row.");
|
||||
is(rows[1].querySelectorAll("label")[0].getAttribute("name"), "label1",
|
||||
"The first column of the second row exists.");
|
||||
is(rows[1].querySelectorAll("label")[1].getAttribute("name"), "label2",
|
||||
"The second column of the second row exists.");
|
||||
is(rows[1].querySelectorAll("label")[0].getAttribute("value"), "2",
|
||||
"The first column of the second row displays the correct text.");
|
||||
is(rows[1].querySelectorAll("label")[1].getAttribute("value"), "12.2bar",
|
||||
"The second column of the first row displays the correct text.");
|
||||
|
||||
ok(rows[2].querySelector(".table-chart-row-box.chart-colored-blob"),
|
||||
"A colored blob exists for the third row.");
|
||||
is(rows[2].querySelectorAll("label")[0].getAttribute("name"), "label1",
|
||||
"The first column of the third row exists.");
|
||||
is(rows[2].querySelectorAll("label")[1].getAttribute("name"), "label2",
|
||||
"The second column of the third row exists.");
|
||||
is(rows[2].querySelectorAll("label")[0].getAttribute("value"), "3",
|
||||
"The first column of the third row displays the correct text.");
|
||||
is(rows[2].querySelectorAll("label")[1].getAttribute("value"), "13.3baz",
|
||||
"The second column of the third row displays the correct text.");
|
||||
|
||||
is(sums.length, 2,
|
||||
"There should be 2 total summaries created.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1",
|
||||
"The first sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 6",
|
||||
"The first sum's value is correct.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2",
|
||||
"The second sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 36.60",
|
||||
"The second sum's value is correct.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
let table = Chart.Table(document, {
|
||||
title: "Table title",
|
||||
data: [{
|
||||
label1: 1,
|
||||
label2: 11.1
|
||||
}, {
|
||||
label1: 2,
|
||||
label2: 12.2
|
||||
}, {
|
||||
label1: 3,
|
||||
label2: 13.3
|
||||
}],
|
||||
strings: {
|
||||
label2: (value, index) => value + ["foo", "bar", "baz"][index]
|
||||
},
|
||||
totals: {
|
||||
label1: value => "Hello " + L10N.numberWithDecimals(value, 2),
|
||||
label2: value => "World " + L10N.numberWithDecimals(value, 2)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let node = table.node;
|
||||
let title = node.querySelector(".table-chart-title");
|
||||
let grid = node.querySelector(".table-chart-grid");
|
||||
let totals = node.querySelector(".table-chart-totals");
|
||||
let rows = grid.querySelectorAll(".table-chart-row");
|
||||
let sums = node.querySelectorAll(".table-chart-summary-label");
|
||||
|
||||
ok(node.classList.contains("table-chart-container") &&
|
||||
node.classList.contains("generic-chart-container"),
|
||||
"A table chart container was created successfully.");
|
||||
|
||||
ok(title, "A title node was created successfully.");
|
||||
is(title.getAttribute("value"), "Table title",
|
||||
"The title node displays the correct text.");
|
||||
|
||||
is(rows.length, 3, "There should be 3 table chart rows created.");
|
||||
|
||||
ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"),
|
||||
"A colored blob exists for the firt row.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "label1",
|
||||
"The first column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label2",
|
||||
"The second column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "1",
|
||||
"The first column of the first row displays the correct text.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("value"), "11.1foo",
|
||||
"The second column of the first row displays the correct text.");
|
||||
|
||||
ok(rows[1].querySelector(".table-chart-row-box.chart-colored-blob"),
|
||||
"A colored blob exists for the second row.");
|
||||
is(rows[1].querySelectorAll("label")[0].getAttribute("name"), "label1",
|
||||
"The first column of the second row exists.");
|
||||
is(rows[1].querySelectorAll("label")[1].getAttribute("name"), "label2",
|
||||
"The second column of the second row exists.");
|
||||
is(rows[1].querySelectorAll("label")[0].getAttribute("value"), "2",
|
||||
"The first column of the second row displays the correct text.");
|
||||
is(rows[1].querySelectorAll("label")[1].getAttribute("value"), "12.2bar",
|
||||
"The second column of the first row displays the correct text.");
|
||||
|
||||
ok(rows[2].querySelector(".table-chart-row-box.chart-colored-blob"),
|
||||
"A colored blob exists for the third row.");
|
||||
is(rows[2].querySelectorAll("label")[0].getAttribute("name"), "label1",
|
||||
"The first column of the third row exists.");
|
||||
is(rows[2].querySelectorAll("label")[1].getAttribute("name"), "label2",
|
||||
"The second column of the third row exists.");
|
||||
is(rows[2].querySelectorAll("label")[0].getAttribute("value"), "3",
|
||||
"The first column of the third row displays the correct text.");
|
||||
is(rows[2].querySelectorAll("label")[1].getAttribute("value"), "13.3baz",
|
||||
"The second column of the third row displays the correct text.");
|
||||
|
||||
is(sums.length, 2, "There should be 2 total summaries created.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"),
|
||||
"label1",
|
||||
"The first sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"),
|
||||
"Hello 6",
|
||||
"The first sum's value is correct.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"),
|
||||
"label2",
|
||||
"The second sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"),
|
||||
"World 36.60",
|
||||
"The second sum's value is correct.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,70 +1,73 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Makes sure Pie Charts have the right internal structure when
|
||||
* initialized with empty data.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, Chart } = aMonitor.panelWin;
|
||||
let container = document.createElement("box");
|
||||
let { document, L10N, Chart } = monitor.panelWin;
|
||||
|
||||
let table = Chart.Table(document, {
|
||||
title: "Table title",
|
||||
data: null,
|
||||
totals: {
|
||||
label1: value => "Hello " + L10N.numberWithDecimals(value, 2),
|
||||
label2: value => "World " + L10N.numberWithDecimals(value, 2)
|
||||
}
|
||||
});
|
||||
|
||||
let node = table.node;
|
||||
let title = node.querySelector(".table-chart-title");
|
||||
let grid = node.querySelector(".table-chart-grid");
|
||||
let totals = node.querySelector(".table-chart-totals");
|
||||
let rows = grid.querySelectorAll(".table-chart-row");
|
||||
let sums = node.querySelectorAll(".table-chart-summary-label");
|
||||
|
||||
ok(node.classList.contains("table-chart-container") &&
|
||||
node.classList.contains("generic-chart-container"),
|
||||
"A table chart container was created successfully.");
|
||||
|
||||
ok(title,
|
||||
"A title node was created successfully.");
|
||||
is(title.getAttribute("value"), "Table title",
|
||||
"The title node displays the correct text.");
|
||||
|
||||
is(rows.length, 1,
|
||||
"There should be 1 table chart row created.");
|
||||
|
||||
ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"),
|
||||
"A colored blob exists for the firt row.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size",
|
||||
"The first column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label",
|
||||
"The second column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "",
|
||||
"The first column of the first row displays the correct text.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.loading"),
|
||||
"The second column of the first row displays the correct text.");
|
||||
|
||||
is(sums.length, 2,
|
||||
"There should be 2 total summaries created.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1",
|
||||
"The first sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 0",
|
||||
"The first sum's value is correct.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2",
|
||||
"The second sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 0",
|
||||
"The second sum's value is correct.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
let table = Chart.Table(document, {
|
||||
title: "Table title",
|
||||
data: null,
|
||||
totals: {
|
||||
label1: value => "Hello " + L10N.numberWithDecimals(value, 2),
|
||||
label2: value => "World " + L10N.numberWithDecimals(value, 2)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let node = table.node;
|
||||
let title = node.querySelector(".table-chart-title");
|
||||
let grid = node.querySelector(".table-chart-grid");
|
||||
let totals = node.querySelector(".table-chart-totals");
|
||||
let rows = grid.querySelectorAll(".table-chart-row");
|
||||
let sums = node.querySelectorAll(".table-chart-summary-label");
|
||||
|
||||
ok(node.classList.contains("table-chart-container") &&
|
||||
node.classList.contains("generic-chart-container"),
|
||||
"A table chart container was created successfully.");
|
||||
|
||||
ok(title, "A title node was created successfully.");
|
||||
is(title.getAttribute("value"), "Table title",
|
||||
"The title node displays the correct text.");
|
||||
|
||||
is(rows.length, 1, "There should be 1 table chart row created.");
|
||||
|
||||
ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"),
|
||||
"A colored blob exists for the firt row.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size",
|
||||
"The first column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label",
|
||||
"The second column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "",
|
||||
"The first column of the first row displays the correct text.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("value"),
|
||||
L10N.getStr("tableChart.loading"),
|
||||
"The second column of the first row displays the correct text.");
|
||||
|
||||
is(sums.length, 2,
|
||||
"There should be 2 total summaries created.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"),
|
||||
"label1",
|
||||
"The first sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"),
|
||||
"Hello 0",
|
||||
"The first sum's value is correct.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"),
|
||||
"label2",
|
||||
"The second sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"),
|
||||
"World 0",
|
||||
"The second sum's value is correct.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,63 +1,59 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Makes sure Pie+Table Charts have the right internal structure.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, Chart } = aMonitor.panelWin;
|
||||
let container = document.createElement("box");
|
||||
let { document, L10N, Chart } = monitor.panelWin;
|
||||
|
||||
let chart = Chart.PieTable(document, {
|
||||
title: "Table title",
|
||||
data: [{
|
||||
size: 1,
|
||||
label: 11.1
|
||||
}, {
|
||||
size: 2,
|
||||
label: 12.2
|
||||
}, {
|
||||
size: 3,
|
||||
label: 13.3
|
||||
}],
|
||||
strings: {
|
||||
label2: (value, index) => value + ["foo", "bar", "baz"][index]
|
||||
},
|
||||
totals: {
|
||||
size: value => "Hello " + L10N.numberWithDecimals(value, 2),
|
||||
label: value => "World " + L10N.numberWithDecimals(value, 2)
|
||||
}
|
||||
});
|
||||
|
||||
ok(chart.pie, "The pie chart proxy is accessible.");
|
||||
ok(chart.table, "The table chart proxy is accessible.");
|
||||
|
||||
let node = chart.node;
|
||||
let slices = node.querySelectorAll(".pie-chart-slice");
|
||||
let rows = node.querySelectorAll(".table-chart-row");
|
||||
let sums = node.querySelectorAll(".table-chart-summary-label");
|
||||
|
||||
ok(node.classList.contains("pie-table-chart-container"),
|
||||
"A pie+table chart container was created successfully.");
|
||||
|
||||
ok(node.querySelector(".table-chart-title"),
|
||||
"A title node was created successfully.");
|
||||
ok(node.querySelector(".pie-chart-container"),
|
||||
"A pie chart was created successfully.");
|
||||
ok(node.querySelector(".table-chart-container"),
|
||||
"A table chart was created successfully.");
|
||||
|
||||
is(rows.length, 3,
|
||||
"There should be 3 pie chart slices created.");
|
||||
is(rows.length, 3,
|
||||
"There should be 3 table chart rows created.");
|
||||
is(sums.length, 2,
|
||||
"There should be 2 total summaries created.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
let chart = Chart.PieTable(document, {
|
||||
title: "Table title",
|
||||
data: [{
|
||||
size: 1,
|
||||
label: 11.1
|
||||
}, {
|
||||
size: 2,
|
||||
label: 12.2
|
||||
}, {
|
||||
size: 3,
|
||||
label: 13.3
|
||||
}],
|
||||
strings: {
|
||||
label2: (value, index) => value + ["foo", "bar", "baz"][index]
|
||||
},
|
||||
totals: {
|
||||
size: value => "Hello " + L10N.numberWithDecimals(value, 2),
|
||||
label: value => "World " + L10N.numberWithDecimals(value, 2)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ok(chart.pie, "The pie chart proxy is accessible.");
|
||||
ok(chart.table, "The table chart proxy is accessible.");
|
||||
|
||||
let node = chart.node;
|
||||
let rows = node.querySelectorAll(".table-chart-row");
|
||||
let sums = node.querySelectorAll(".table-chart-summary-label");
|
||||
|
||||
ok(node.classList.contains("pie-table-chart-container"),
|
||||
"A pie+table chart container was created successfully.");
|
||||
|
||||
ok(node.querySelector(".table-chart-title"),
|
||||
"A title node was created successfully.");
|
||||
ok(node.querySelector(".pie-chart-container"),
|
||||
"A pie chart was created successfully.");
|
||||
ok(node.querySelector(".table-chart-container"),
|
||||
"A table chart was created successfully.");
|
||||
|
||||
is(rows.length, 3, "There should be 3 pie chart slices created.");
|
||||
is(rows.length, 3, "There should be 3 table chart rows created.");
|
||||
is(sums.length, 2, "There should be 2 total summaries created.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,44 +1,45 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Makes sure Pie Charts correctly handle empty source data.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, Chart } = aMonitor.panelWin;
|
||||
let container = document.createElement("box");
|
||||
let { document, L10N, Chart } = monitor.panelWin;
|
||||
|
||||
let pie = Chart.Pie(document, {
|
||||
data: [],
|
||||
width: 100,
|
||||
height: 100
|
||||
});
|
||||
|
||||
let node = pie.node;
|
||||
let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
|
||||
let labels = node.querySelectorAll(".pie-chart-label");
|
||||
|
||||
is(slices.length, 1,
|
||||
"There should be 1 pie chart slice created.");
|
||||
ok(slices[0].getAttribute("d").match(/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 1 1 49\.\d+,2\.5\d* Z/),
|
||||
"The slice has the correct data.");
|
||||
|
||||
ok(slices[0].hasAttribute("largest"),
|
||||
"The slice should be the largest one.");
|
||||
ok(slices[0].hasAttribute("smallest"),
|
||||
"The slice should also be the smallest one.");
|
||||
ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.unavailable"),
|
||||
"The slice's name is correct.");
|
||||
|
||||
is(labels.length, 1,
|
||||
"There should be 1 pie chart label created.");
|
||||
is(labels[0].textContent, "Empty",
|
||||
"The label's text is correct.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
let pie = Chart.Pie(document, {
|
||||
data: [],
|
||||
width: 100,
|
||||
height: 100
|
||||
});
|
||||
}
|
||||
|
||||
let node = pie.node;
|
||||
let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
|
||||
let labels = node.querySelectorAll(".pie-chart-label");
|
||||
|
||||
is(slices.length, 1,
|
||||
"There should be 1 pie chart slice created.");
|
||||
ok(slices[0].getAttribute("d").match(
|
||||
/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 1 1 49\.\d+,2\.5\d* Z/),
|
||||
"The slice has the correct data.");
|
||||
|
||||
ok(slices[0].hasAttribute("largest"),
|
||||
"The slice should be the largest one.");
|
||||
ok(slices[0].hasAttribute("smallest"),
|
||||
"The slice should also be the smallest one.");
|
||||
ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.unavailable"),
|
||||
"The slice's name is correct.");
|
||||
|
||||
is(labels.length, 1,
|
||||
"There should be 1 pie chart label created.");
|
||||
is(labels[0].textContent, "Empty",
|
||||
"The label's text is correct.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,58 +1,61 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Makes sure Table Charts correctly handle empty source data.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, Chart } = aMonitor.panelWin;
|
||||
let container = document.createElement("box");
|
||||
let { document, L10N, Chart } = monitor.panelWin;
|
||||
|
||||
let table = Chart.Table(document, {
|
||||
data: [],
|
||||
totals: {
|
||||
label1: value => "Hello " + L10N.numberWithDecimals(value, 2),
|
||||
label2: value => "World " + L10N.numberWithDecimals(value, 2)
|
||||
}
|
||||
});
|
||||
|
||||
let node = table.node;
|
||||
let grid = node.querySelector(".table-chart-grid");
|
||||
let totals = node.querySelector(".table-chart-totals");
|
||||
let rows = grid.querySelectorAll(".table-chart-row");
|
||||
let sums = node.querySelectorAll(".table-chart-summary-label");
|
||||
|
||||
is(rows.length, 1,
|
||||
"There should be 1 table chart row created.");
|
||||
|
||||
ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"),
|
||||
"A colored blob exists for the firt row.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size",
|
||||
"The first column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label",
|
||||
"The second column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "",
|
||||
"The first column of the first row displays the correct text.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("value"), L10N.getStr("tableChart.unavailable"),
|
||||
"The second column of the first row displays the correct text.");
|
||||
|
||||
is(sums.length, 2,
|
||||
"There should be 2 total summaries created.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"), "label1",
|
||||
"The first sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"), "Hello 0",
|
||||
"The first sum's value is correct.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"), "label2",
|
||||
"The second sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"), "World 0",
|
||||
"The second sum's value is correct.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
let table = Chart.Table(document, {
|
||||
data: [],
|
||||
totals: {
|
||||
label1: value => "Hello " + L10N.numberWithDecimals(value, 2),
|
||||
label2: value => "World " + L10N.numberWithDecimals(value, 2)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let node = table.node;
|
||||
let grid = node.querySelector(".table-chart-grid");
|
||||
let totals = node.querySelector(".table-chart-totals");
|
||||
let rows = grid.querySelectorAll(".table-chart-row");
|
||||
let sums = node.querySelectorAll(".table-chart-summary-label");
|
||||
|
||||
is(rows.length, 1, "There should be 1 table chart row created.");
|
||||
|
||||
ok(rows[0].querySelector(".table-chart-row-box.chart-colored-blob"),
|
||||
"A colored blob exists for the firt row.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("name"), "size",
|
||||
"The first column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("name"), "label",
|
||||
"The second column of the first row exists.");
|
||||
is(rows[0].querySelectorAll("label")[0].getAttribute("value"), "",
|
||||
"The first column of the first row displays the correct text.");
|
||||
is(rows[0].querySelectorAll("label")[1].getAttribute("value"),
|
||||
L10N.getStr("tableChart.unavailable"),
|
||||
"The second column of the first row displays the correct text.");
|
||||
|
||||
is(sums.length, 2, "There should be 2 total summaries created.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("name"),
|
||||
"label1",
|
||||
"The first sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[0].getAttribute("value"),
|
||||
"Hello 0",
|
||||
"The first sum's value is correct.");
|
||||
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("name"),
|
||||
"label2",
|
||||
"The second sum's type is correct.");
|
||||
is(totals.querySelectorAll(".table-chart-summary-label")[1].getAttribute("value"),
|
||||
"World 0",
|
||||
"The second sum's value is correct.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,63 +1,64 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if the clear button empties the request menu.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, $, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let detailsPane = $("#details-pane");
|
||||
let detailsPaneToggleButton = $("#details-pane-toggle");
|
||||
let clearButton = $("#requests-menu-clear-button");
|
||||
let { $, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let detailsPane = $("#details-pane");
|
||||
let detailsPaneToggleButton = $("#details-pane-toggle");
|
||||
let clearButton = $("#requests-menu-clear-button");
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
// Make sure we start in a sane state
|
||||
assertNoRequestState(RequestsMenu, detailsPaneToggleButton);
|
||||
// Make sure we start in a sane state
|
||||
assertNoRequestState(RequestsMenu, detailsPaneToggleButton);
|
||||
|
||||
// Load one request and assert it shows up in the lis
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.NETWORK_EVENT, () => {
|
||||
assertSingleRequestState(RequestsMenu, detailsPaneToggleButton);
|
||||
// Load one request and assert it shows up in the list
|
||||
let networkEvent = monitor.panelWin.once(monitor.panelWin.EVENTS.NETWORK_EVENT);
|
||||
tab.linkedBrowser.reload();
|
||||
yield networkEvent;
|
||||
|
||||
// Click clear and make sure the requests are gone
|
||||
EventUtils.sendMouseEvent({ type: "click" }, clearButton);
|
||||
assertNoRequestState(RequestsMenu, detailsPaneToggleButton);
|
||||
assertSingleRequestState();
|
||||
|
||||
// Load a second request and make sure they still show up
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.NETWORK_EVENT, () => {
|
||||
assertSingleRequestState(RequestsMenu, detailsPaneToggleButton);
|
||||
// Click clear and make sure the requests are gone
|
||||
EventUtils.sendMouseEvent({ type: "click" }, clearButton);
|
||||
assertNoRequestState();
|
||||
|
||||
// Make sure we can now open the details pane
|
||||
NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
|
||||
ok(!detailsPane.classList.contains("pane-collapsed") &&
|
||||
!detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should be visible after clicking the toggle button.");
|
||||
// Load a second request and make sure they still show up
|
||||
networkEvent = monitor.panelWin.once(monitor.panelWin.EVENTS.NETWORK_EVENT);
|
||||
tab.linkedBrowser.reload();
|
||||
yield networkEvent;
|
||||
|
||||
// Click clear and make sure the details pane closes
|
||||
EventUtils.sendMouseEvent({ type: "click" }, clearButton);
|
||||
assertNoRequestState(RequestsMenu, detailsPaneToggleButton);
|
||||
ok(detailsPane.classList.contains("pane-collapsed") &&
|
||||
detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should not be visible clicking 'clear'.");
|
||||
assertSingleRequestState();
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
// Make sure we can now open the details pane
|
||||
NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
|
||||
ok(!detailsPane.classList.contains("pane-collapsed") &&
|
||||
!detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should be visible after clicking the toggle button.");
|
||||
|
||||
aDebuggee.location.reload();
|
||||
});
|
||||
// Click clear and make sure the details pane closes
|
||||
EventUtils.sendMouseEvent({ type: "click" }, clearButton);
|
||||
assertNoRequestState();
|
||||
ok(detailsPane.classList.contains("pane-collapsed") &&
|
||||
detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should not be visible clicking 'clear'.");
|
||||
|
||||
aDebuggee.location.reload();
|
||||
});
|
||||
return teardown(monitor);
|
||||
|
||||
/**
|
||||
* Asserts the state of the network monitor when one request has loaded
|
||||
*/
|
||||
function assertSingleRequestState(RequestsMenu, detailsPaneToggleButton) {
|
||||
function assertSingleRequestState() {
|
||||
is(RequestsMenu.itemCount, 1,
|
||||
"The request menu should have one item at this point.");
|
||||
is(detailsPaneToggleButton.hasAttribute("disabled"), false,
|
||||
@ -67,10 +68,10 @@ function test() {
|
||||
/**
|
||||
* Asserts the state of the network monitor when no requests have loaded
|
||||
*/
|
||||
function assertNoRequestState(RequestsMenu, detailsPaneToggleButton) {
|
||||
function assertNoRequestState() {
|
||||
is(RequestsMenu.itemCount, 0,
|
||||
"The request menu should be empty at this point.");
|
||||
is(detailsPaneToggleButton.hasAttribute("disabled"), true,
|
||||
"The pane toggle button should be disabled when the request menu is cleared.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,182 +1,193 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests whether complex request params and payload sent via POST are
|
||||
* displayed correctly.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(PARAMS_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(PARAMS_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, EVENTS, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
let { document, L10N, EVENTS, Editor, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
NetworkDetails._params.lazyEmpty = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
NetworkDetails._params.lazyEmpty = false;
|
||||
|
||||
Task.spawn(function* () {
|
||||
yield waitForNetworkEvents(aMonitor, 1, 6);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[2]);
|
||||
|
||||
yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
yield testParamsTab1("a", '""', '{ "foo": "bar" }', '""');
|
||||
|
||||
RequestsMenu.selectedIndex = 1;
|
||||
yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
yield testParamsTab1("a", '"b"', '{ "foo": "bar" }', '""');
|
||||
|
||||
RequestsMenu.selectedIndex = 2;
|
||||
yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
yield testParamsTab1("a", '"b"', "foo", '"bar"');
|
||||
|
||||
RequestsMenu.selectedIndex = 3;
|
||||
yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
yield testParamsTab2("a", '""', '{ "foo": "bar" }', "js");
|
||||
|
||||
RequestsMenu.selectedIndex = 4;
|
||||
yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
yield testParamsTab2("a", '"b"', '{ "foo": "bar" }', "js");
|
||||
|
||||
RequestsMenu.selectedIndex = 5;
|
||||
yield waitFor(aMonitor.panelWin, EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
yield testParamsTab2("a", '"b"', "?foo=bar", "text");
|
||||
|
||||
RequestsMenu.selectedIndex = 6;
|
||||
yield waitFor(aMonitor.panelWin, EVENTS.SIDEBAR_POPULATED);
|
||||
yield testParamsTab3("a", '"b"');
|
||||
|
||||
yield teardown(aMonitor);
|
||||
finish();
|
||||
});
|
||||
|
||||
function testParamsTab1(
|
||||
aQueryStringParamName, aQueryStringParamValue, aFormDataParamName, aFormDataParamValue)
|
||||
{
|
||||
let tab = document.querySelectorAll("#details-pane tab")[2];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
|
||||
"The number of param scopes displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, 2,
|
||||
"The number of param values displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The request params box should not be hidden.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The request post data textarea box should be hidden.");
|
||||
|
||||
let paramsScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
let formDataScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
|
||||
|
||||
is(paramsScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsQueryString"),
|
||||
"The params scope doesn't have the correct title.");
|
||||
is(formDataScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsFormData"),
|
||||
"The form data scope doesn't have the correct title.");
|
||||
|
||||
is(paramsScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
aQueryStringParamName,
|
||||
"The first query string param name was incorrect.");
|
||||
is(paramsScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
aQueryStringParamValue,
|
||||
"The first query string param value was incorrect.");
|
||||
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
aFormDataParamName,
|
||||
"The first form data param name was incorrect.");
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
aFormDataParamValue,
|
||||
"The first form data param value was incorrect.");
|
||||
}
|
||||
|
||||
function testParamsTab2(
|
||||
aQueryStringParamName, aQueryStringParamValue, aRequestPayload, aEditorMode)
|
||||
{
|
||||
let isJSON = aEditorMode == "js";
|
||||
let tab = document.querySelectorAll("#details-pane tab")[2];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
|
||||
"The number of param scopes displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, isJSON ? 4 : 1,
|
||||
"The number of param values displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The request params box should not be hidden.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), isJSON,
|
||||
"The request post data textarea box should be hidden.");
|
||||
|
||||
let paramsScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
let payloadScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
|
||||
|
||||
is(paramsScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsQueryString"),
|
||||
"The params scope doesn't have the correct title.");
|
||||
is(payloadScope.querySelector(".name").getAttribute("value"),
|
||||
isJSON ? L10N.getStr("jsonScopeName") : L10N.getStr("paramsPostPayload"),
|
||||
"The request payload scope doesn't have the correct title.");
|
||||
|
||||
is(paramsScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
aQueryStringParamName,
|
||||
"The first query string param name was incorrect.");
|
||||
is(paramsScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
aQueryStringParamValue,
|
||||
"The first query string param value was incorrect.");
|
||||
|
||||
if (isJSON) {
|
||||
let requestPayloadObject = JSON.parse(aRequestPayload);
|
||||
let requestPairs = Object.keys(requestPayloadObject).map(k => [k, requestPayloadObject[k]]);
|
||||
let displayedNames = payloadScope.querySelectorAll(".variables-view-property.variable-or-property .name");
|
||||
let displayedValues = payloadScope.querySelectorAll(".variables-view-property.variable-or-property .value");
|
||||
for (let i = 0; i < requestPairs.length; i++) {
|
||||
let [requestPayloadName, requestPayloadValue] = requestPairs[i];
|
||||
is(requestPayloadName, displayedNames[i].getAttribute("value"), "JSON property name " + i + " should be displayed correctly");
|
||||
is('"' + requestPayloadValue + '"', displayedValues[i].getAttribute("value"), "JSON property value " + i + " should be displayed correctly");
|
||||
}
|
||||
} else {
|
||||
return NetMonitorView.editor("#request-post-data-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), aRequestPayload,
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), Editor.modes[aEditorMode],
|
||||
"The mode active in the source editor is incorrect.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function testParamsTab3(aQueryStringParamName, aQueryStringParamValue) {
|
||||
let tab = document.querySelectorAll("#details-pane tab")[2];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 0,
|
||||
"The number of param scopes displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, 0,
|
||||
"The number of param values displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 1,
|
||||
"The empty notice should be displayed in this tabpanel.");
|
||||
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The request params box should not be hidden.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The request post data textarea box should be hidden.");
|
||||
}
|
||||
|
||||
aDebuggee.performRequests();
|
||||
let wait = waitForNetworkEvents(monitor, 1, 6);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
let onEvent = monitor.panelWin.once(EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[2]);
|
||||
yield onEvent;
|
||||
yield testParamsTab1("a", '""', '{ "foo": "bar" }', '""');
|
||||
|
||||
onEvent = monitor.panelWin.once(EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
RequestsMenu.selectedIndex = 1;
|
||||
yield onEvent;
|
||||
yield testParamsTab1("a", '"b"', '{ "foo": "bar" }', '""');
|
||||
|
||||
onEvent = monitor.panelWin.once(EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
RequestsMenu.selectedIndex = 2;
|
||||
yield onEvent;
|
||||
yield testParamsTab1("a", '"b"', "foo", '"bar"');
|
||||
|
||||
onEvent = monitor.panelWin.once(EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
RequestsMenu.selectedIndex = 3;
|
||||
yield onEvent;
|
||||
yield testParamsTab2("a", '""', '{ "foo": "bar" }', "js");
|
||||
|
||||
onEvent = monitor.panelWin.once(EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
RequestsMenu.selectedIndex = 4;
|
||||
yield onEvent;
|
||||
yield testParamsTab2("a", '"b"', '{ "foo": "bar" }', "js");
|
||||
|
||||
onEvent = monitor.panelWin.once(EVENTS.REQUEST_POST_PARAMS_DISPLAYED);
|
||||
RequestsMenu.selectedIndex = 5;
|
||||
yield onEvent;
|
||||
yield testParamsTab2("a", '"b"', "?foo=bar", "text");
|
||||
|
||||
onEvent = monitor.panelWin.once(EVENTS.SIDEBAR_POPULATED);
|
||||
RequestsMenu.selectedIndex = 6;
|
||||
yield onEvent;
|
||||
yield testParamsTab3("a", '"b"');
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
function testParamsTab1(queryStringParamName, queryStringParamValue,
|
||||
formDataParamName, formDataParamValue) {
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
|
||||
"The number of param scopes displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, 2,
|
||||
"The number of param values displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The request params box should not be hidden.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The request post data textarea box should be hidden.");
|
||||
|
||||
let paramsScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
let formDataScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
|
||||
|
||||
is(paramsScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsQueryString"),
|
||||
"The params scope doesn't have the correct title.");
|
||||
is(formDataScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsFormData"),
|
||||
"The form data scope doesn't have the correct title.");
|
||||
|
||||
is(paramsScope.querySelectorAll(".variables-view-variable .name")[0]
|
||||
.getAttribute("value"),
|
||||
queryStringParamName,
|
||||
"The first query string param name was incorrect.");
|
||||
is(paramsScope.querySelectorAll(".variables-view-variable .value")[0]
|
||||
.getAttribute("value"),
|
||||
queryStringParamValue,
|
||||
"The first query string param value was incorrect.");
|
||||
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .name")[0]
|
||||
.getAttribute("value"),
|
||||
formDataParamName,
|
||||
"The first form data param name was incorrect.");
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .value")[0]
|
||||
.getAttribute("value"),
|
||||
formDataParamValue,
|
||||
"The first form data param value was incorrect.");
|
||||
}
|
||||
|
||||
function* testParamsTab2(queryStringParamName, queryStringParamValue,
|
||||
requestPayload, editorMode) {
|
||||
let isJSON = editorMode == "js";
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
|
||||
"The number of param scopes displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, isJSON ? 4 : 1,
|
||||
"The number of param values displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The request params box should not be hidden.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), isJSON,
|
||||
"The request post data textarea box should be hidden.");
|
||||
|
||||
let paramsScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
let payloadScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
|
||||
|
||||
is(paramsScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsQueryString"),
|
||||
"The params scope doesn't have the correct title.");
|
||||
is(payloadScope.querySelector(".name").getAttribute("value"),
|
||||
isJSON ? L10N.getStr("jsonScopeName") : L10N.getStr("paramsPostPayload"),
|
||||
"The request payload scope doesn't have the correct title.");
|
||||
|
||||
is(paramsScope.querySelectorAll(".variables-view-variable .name")[0]
|
||||
.getAttribute("value"),
|
||||
queryStringParamName,
|
||||
"The first query string param name was incorrect.");
|
||||
is(paramsScope.querySelectorAll(".variables-view-variable .value")[0]
|
||||
.getAttribute("value"),
|
||||
queryStringParamValue,
|
||||
"The first query string param value was incorrect.");
|
||||
|
||||
if (isJSON) {
|
||||
let requestPayloadObject = JSON.parse(requestPayload);
|
||||
let requestPairs = Object.keys(requestPayloadObject)
|
||||
.map(k => [k, requestPayloadObject[k]]);
|
||||
let displayedNames = payloadScope.querySelectorAll(
|
||||
".variables-view-property.variable-or-property .name");
|
||||
let displayedValues = payloadScope.querySelectorAll(
|
||||
".variables-view-property.variable-or-property .value");
|
||||
for (let i = 0; i < requestPairs.length; i++) {
|
||||
let [requestPayloadName, requestPayloadValue] = requestPairs[i];
|
||||
is(requestPayloadName, displayedNames[i].getAttribute("value"),
|
||||
"JSON property name " + i + " should be displayed correctly");
|
||||
is('"' + requestPayloadValue + '"', displayedValues[i].getAttribute("value"),
|
||||
"JSON property value " + i + " should be displayed correctly");
|
||||
}
|
||||
} else {
|
||||
let editor = yield NetMonitorView.editor("#request-post-data-textarea");
|
||||
is(editor.getText(), requestPayload,
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(editor.getMode(), Editor.modes[editorMode],
|
||||
"The mode active in the source editor is incorrect.");
|
||||
}
|
||||
}
|
||||
|
||||
function testParamsTab3(queryStringParamName, queryStringParamValue) {
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 0,
|
||||
"The number of param scopes displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, 0,
|
||||
"The number of param values displayed in this tabpanel is incorrect.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 1,
|
||||
"The empty notice should be displayed in this tabpanel.");
|
||||
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The request params box should not be hidden.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The request post data textarea box should be hidden.");
|
||||
}
|
||||
});
|
||||
|
@ -1,255 +1,252 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if different response content types are handled correctly.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { document, L10N, Editor, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 7).then(() => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=xml", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "xml",
|
||||
fullMimeType: "text/xml; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 42),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=css", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "css",
|
||||
fullMimeType: "text/css; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 34),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(2),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=js", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "js",
|
||||
fullMimeType: "application/javascript; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 34),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(3),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "application/json; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(4),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=bogus", {
|
||||
status: 404,
|
||||
statusText: "Not Found",
|
||||
type: "html",
|
||||
fullMimeType: "text/html; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 24),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(5),
|
||||
"GET", TEST_IMAGE, {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "png",
|
||||
fullMimeType: "image/png",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 580),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(6),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=gzip", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 10.73),
|
||||
time: true
|
||||
});
|
||||
let wait = waitForNetworkEvents(monitor, 7);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
yield wait;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
|
||||
Task.spawn(function* () {
|
||||
yield waitForResponseBodyDisplayed();
|
||||
yield testResponseTab("xml");
|
||||
RequestsMenu.selectedIndex = 1;
|
||||
yield waitForTabUpdated();
|
||||
yield testResponseTab("css");
|
||||
RequestsMenu.selectedIndex = 2;
|
||||
yield waitForTabUpdated();
|
||||
yield testResponseTab("js");
|
||||
RequestsMenu.selectedIndex = 3;
|
||||
yield waitForTabUpdated();
|
||||
yield testResponseTab("json");
|
||||
RequestsMenu.selectedIndex = 4;
|
||||
yield waitForTabUpdated();
|
||||
yield testResponseTab("html");
|
||||
RequestsMenu.selectedIndex = 5;
|
||||
yield waitForTabUpdated();
|
||||
yield testResponseTab("png");
|
||||
RequestsMenu.selectedIndex = 6;
|
||||
yield waitForTabUpdated();
|
||||
yield testResponseTab("gzip");
|
||||
yield teardown(aMonitor);
|
||||
finish();
|
||||
});
|
||||
|
||||
function testResponseTab(aType) {
|
||||
let tab = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
function checkVisibility(aBox) {
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), aBox != "json",
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), aBox != "textarea",
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), aBox != "image",
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
}
|
||||
|
||||
switch (aType) {
|
||||
case "xml": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
return NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), "<label value='greeting'>Hello XML!</label>",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(aEditor.getMode(), Editor.modes.html,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
});
|
||||
}
|
||||
case "css": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
return NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), "body:pre { content: 'Hello CSS!' }",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(aEditor.getMode(), Editor.modes.css,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
});
|
||||
}
|
||||
case "js": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
return NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), "function() { return 'Hello JS!'; }",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(aEditor.getMode(), Editor.modes.js,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
});
|
||||
}
|
||||
case "json": {
|
||||
checkVisibility("json");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 json scope displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-property").length, 2,
|
||||
"There should be 2 json properties displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
|
||||
is(jsonScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("jsonScopeName"),
|
||||
"The json scope doesn't have the correct title.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"),
|
||||
"greeting", "The first json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"),
|
||||
"\"Hello JSON!\"", "The first json property value was incorrect.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"),
|
||||
"__proto__", "The second json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"),
|
||||
"Object", "The second json property value was incorrect.");
|
||||
|
||||
return promise.resolve();
|
||||
}
|
||||
case "html": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
return NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), "<blink>Not Found</blink>",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(aEditor.getMode(), Editor.modes.html,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
});
|
||||
}
|
||||
case "png": {
|
||||
checkVisibility("image");
|
||||
|
||||
let imageNode = tabpanel.querySelector("#response-content-image");
|
||||
let deferred = promise.defer();
|
||||
|
||||
imageNode.addEventListener("load", function onLoad() {
|
||||
imageNode.removeEventListener("load", onLoad);
|
||||
|
||||
is(tabpanel.querySelector("#response-content-image-name-value")
|
||||
.getAttribute("value"), "test-image.png",
|
||||
"The image name info isn't correct.");
|
||||
is(tabpanel.querySelector("#response-content-image-mime-value")
|
||||
.getAttribute("value"), "image/png",
|
||||
"The image mime info isn't correct.");
|
||||
is(tabpanel.querySelector("#response-content-image-dimensions-value")
|
||||
.getAttribute("value"), "16" + " \u00D7 " + "16",
|
||||
"The image dimensions info isn't correct.");
|
||||
|
||||
deferred.resolve();
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
case "gzip": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
let expected = new Array(1000).join("Hello gzip!");
|
||||
return NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), expected,
|
||||
"The text shown in the source editor is incorrect for the gzip request.");
|
||||
is(aEditor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect for the gzip request.");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function waitForTabUpdated() {
|
||||
return waitFor(aMonitor.panelWin, aMonitor.panelWin.EVENTS.TAB_UPDATED);
|
||||
}
|
||||
|
||||
function waitForResponseBodyDisplayed() {
|
||||
return waitFor(aMonitor.panelWin, aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
}
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=xml", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "xml",
|
||||
fullMimeType: "text/xml; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 42),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=css", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "css",
|
||||
fullMimeType: "text/css; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 34),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(2),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=js", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "js",
|
||||
fullMimeType: "application/javascript; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 34),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(3),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "application/json; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(4),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=bogus", {
|
||||
status: 404,
|
||||
statusText: "Not Found",
|
||||
type: "html",
|
||||
fullMimeType: "text/html; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 24),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(5),
|
||||
"GET", TEST_IMAGE, {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "png",
|
||||
fullMimeType: "image/png",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 580),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(6),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=gzip", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeKB", 10.73),
|
||||
time: true
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
});
|
||||
}
|
||||
let onEvent = waitForResponseBodyDisplayed();
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
yield onEvent;
|
||||
yield testResponseTab("xml");
|
||||
|
||||
yield selectIndexAndWaitForTabUpdated(1);
|
||||
yield testResponseTab("css");
|
||||
|
||||
yield selectIndexAndWaitForTabUpdated(2);
|
||||
yield testResponseTab("js");
|
||||
|
||||
yield selectIndexAndWaitForTabUpdated(3);
|
||||
yield testResponseTab("json");
|
||||
|
||||
yield selectIndexAndWaitForTabUpdated(4);
|
||||
yield testResponseTab("html");
|
||||
|
||||
yield selectIndexAndWaitForTabUpdated(5);
|
||||
yield testResponseTab("png");
|
||||
|
||||
yield selectIndexAndWaitForTabUpdated(6);
|
||||
yield testResponseTab("gzip");
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
function* testResponseTab(type) {
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
function checkVisibility(box) {
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), box != "json",
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), box != "textarea",
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), box != "image",
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case "xml": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
let editor = yield NetMonitorView.editor("#response-content-textarea");
|
||||
is(editor.getText(), "<label value='greeting'>Hello XML!</label>",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(editor.getMode(), Editor.modes.html,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
break;
|
||||
}
|
||||
case "css": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
let editor = yield NetMonitorView.editor("#response-content-textarea");
|
||||
is(editor.getText(), "body:pre { content: 'Hello CSS!' }",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(editor.getMode(), Editor.modes.css,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
break;
|
||||
}
|
||||
case "js": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
let editor = yield NetMonitorView.editor("#response-content-textarea");
|
||||
is(editor.getText(), "function() { return 'Hello JS!'; }",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(editor.getMode(), Editor.modes.js,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
break;
|
||||
}
|
||||
case "json": {
|
||||
checkVisibility("json");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 json scope displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-property").length, 2,
|
||||
"There should be 2 json properties displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
|
||||
is(jsonScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("jsonScopeName"),
|
||||
"The json scope doesn't have the correct title.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[0]
|
||||
.getAttribute("value"),
|
||||
"greeting", "The first json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[0]
|
||||
.getAttribute("value"),
|
||||
"\"Hello JSON!\"", "The first json property value was incorrect.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[1]
|
||||
.getAttribute("value"),
|
||||
"__proto__", "The second json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[1]
|
||||
.getAttribute("value"),
|
||||
"Object", "The second json property value was incorrect.");
|
||||
break;
|
||||
}
|
||||
case "html": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
let editor = yield NetMonitorView.editor("#response-content-textarea");
|
||||
is(editor.getText(), "<blink>Not Found</blink>",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(editor.getMode(), Editor.modes.html,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
break;
|
||||
}
|
||||
case "png": {
|
||||
checkVisibility("image");
|
||||
|
||||
let imageNode = tabpanel.querySelector("#response-content-image");
|
||||
yield once(imageNode, "load");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-image-name-value")
|
||||
.getAttribute("value"), "test-image.png",
|
||||
"The image name info isn't correct.");
|
||||
is(tabpanel.querySelector("#response-content-image-mime-value")
|
||||
.getAttribute("value"), "image/png",
|
||||
"The image mime info isn't correct.");
|
||||
is(tabpanel.querySelector("#response-content-image-dimensions-value")
|
||||
.getAttribute("value"), "16" + " \u00D7 " + "16",
|
||||
"The image dimensions info isn't correct.");
|
||||
break;
|
||||
}
|
||||
case "gzip": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
let expected = new Array(1000).join("Hello gzip!");
|
||||
let editor = yield NetMonitorView.editor("#response-content-textarea");
|
||||
is(editor.getText(), expected,
|
||||
"The text shown in the source editor is incorrect for the gzip request.");
|
||||
is(editor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect for the gzip request.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function selectIndexAndWaitForTabUpdated(index) {
|
||||
let onTabUpdated = monitor.panelWin.once(monitor.panelWin.EVENTS.TAB_UPDATED);
|
||||
RequestsMenu.selectedIndex = index;
|
||||
return onTabUpdated;
|
||||
}
|
||||
|
||||
function waitForResponseBodyDisplayed() {
|
||||
return monitor.panelWin.once(monitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
}
|
||||
});
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
let [tab, , monitor] = yield initNetMonitor(CURL_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(CURL_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
// Different quote chars are used for Windows and POSIX
|
||||
|
@ -1,30 +1,32 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if copying a request's request/response headers works.
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
|
||||
let [ aTab, aDebuggee, aMonitor ] = yield initNetMonitor(SIMPLE_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { NetMonitorView } = aMonitor.panelWin;
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
aDebuggee.location.reload();
|
||||
yield waitForNetworkEvents(aMonitor, 1);
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
tab.linkedBrowser.reload();
|
||||
yield wait;
|
||||
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
let clipboard = null;
|
||||
let { method, httpVersion, status, statusText } = requestItem.attachment;
|
||||
|
||||
const EXPECTED_REQUEST_HEADERS = [
|
||||
requestItem.attachment.method + " " + SIMPLE_URL + " " + requestItem.attachment.httpVersion,
|
||||
`${method} ${SIMPLE_URL} ${httpVersion}`,
|
||||
"Host: example.com",
|
||||
"User-Agent: " + navigator.userAgent + "",
|
||||
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||
@ -36,14 +38,17 @@ add_task(function* () {
|
||||
"Cache-Control: no-cache"
|
||||
].join("\n");
|
||||
|
||||
RequestsMenu.copyRequestHeaders();
|
||||
clipboard = SpecialPowers.getClipboardData("text/unicode");
|
||||
// Sometimes, a "Cookie" header is left over from other tests. Remove it:
|
||||
clipboard = clipboard.replace(/Cookie: [^\n]+\n/, "");
|
||||
is(clipboard, EXPECTED_REQUEST_HEADERS, "Clipboard contains the currently selected item's request headers.");
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyRequestHeaders();
|
||||
}, function validate(result) {
|
||||
// Sometimes, a "Cookie" header is left over from other tests. Remove it:
|
||||
result = String(result).replace(/Cookie: [^\n]+\n/, "");
|
||||
return result === EXPECTED_REQUEST_HEADERS;
|
||||
});
|
||||
info("Clipboard contains the currently selected item's request headers.");
|
||||
|
||||
const EXPECTED_RESPONSE_HEADERS = [
|
||||
requestItem.attachment.httpVersion + " " + requestItem.attachment.status + " " + requestItem.attachment.statusText,
|
||||
`${httpVersion} ${status} ${statusText}`,
|
||||
"Last-Modified: Sun, 3 May 2015 11:11:11 GMT",
|
||||
"Content-Type: text/html",
|
||||
"Content-Length: 465",
|
||||
@ -52,13 +57,16 @@ add_task(function* () {
|
||||
"Date: Sun, 3 May 2015 11:11:11 GMT"
|
||||
].join("\n");
|
||||
|
||||
RequestsMenu.copyResponseHeaders();
|
||||
clipboard = SpecialPowers.getClipboardData("text/unicode");
|
||||
// Fake the "Last-Modified" and "Date" headers because they will vary:
|
||||
clipboard = clipboard
|
||||
.replace(/Last-Modified: [^\n]+ GMT/, "Last-Modified: Sun, 3 May 2015 11:11:11 GMT")
|
||||
.replace(/Date: [^\n]+ GMT/, "Date: Sun, 3 May 2015 11:11:11 GMT");
|
||||
is(clipboard, EXPECTED_RESPONSE_HEADERS, "Clipboard contains the currently selected item's response headers.");
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyResponseHeaders();
|
||||
}, function validate(result) {
|
||||
// Fake the "Last-Modified" and "Date" headers because they will vary:
|
||||
result = String(result)
|
||||
.replace(/Last-Modified: [^\n]+ GMT/, "Last-Modified: Sun, 3 May 2015 11:11:11 GMT")
|
||||
.replace(/Date: [^\n]+ GMT/, "Date: Sun, 3 May 2015 11:11:11 GMT");
|
||||
return result === EXPECTED_RESPONSE_HEADERS;
|
||||
});
|
||||
info("Clipboard contains the currently selected item's response headers.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,38 +1,35 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if copying an image as data uri works.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 7).then(() => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(5);
|
||||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
waitForClipboard(TEST_IMAGE_DATA_URI, function setup() {
|
||||
RequestsMenu.copyImageAsDataUri();
|
||||
}, function onSuccess() {
|
||||
ok(true, "Clipboard contains the currently selected image as data uri.");
|
||||
cleanUp();
|
||||
}, function onFailure() {
|
||||
ok(false, "Copying the currently selected image as data uri was unsuccessful.");
|
||||
cleanUp();
|
||||
});
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
|
||||
function cleanUp() {
|
||||
teardown(aMonitor).then(finish);
|
||||
}
|
||||
let wait = waitForNetworkEvents(monitor, 7);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
let requestItem = RequestsMenu.getItemAtIndex(5);
|
||||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyImageAsDataUri();
|
||||
}, TEST_IMAGE_DATA_URI);
|
||||
|
||||
ok(true, "Clipboard contains the currently selected image as data uri.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,92 +1,94 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests whether copying a request item's parameters works.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(PARAMS_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(PARAMS_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, EVENTS, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
let { document, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
Task.spawn(function* () {
|
||||
yield waitForNetworkEvents(aMonitor, 1, 6);
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(0);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("{ \"foo\": \"bar\" }");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(1);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a=b");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("{ \"foo\": \"bar\" }");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(2);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a=b");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("foo=bar");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(3);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("{ \"foo\": \"bar\" }");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(4);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a=b");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("{ \"foo\": \"bar\" }");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(5);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a=b");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("?foo=bar");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(6);
|
||||
yield testCopyUrlParamsHidden(true);
|
||||
yield testCopyPostDataHidden(true);
|
||||
|
||||
yield teardown(aMonitor);
|
||||
finish();
|
||||
});
|
||||
|
||||
function testCopyUrlParamsHidden(aHidden) {
|
||||
RequestsMenu._onContextShowing();
|
||||
is(document.querySelector("#request-menu-context-copy-url-params").hidden,
|
||||
aHidden, "The \"Copy URL Parameters\" context menu item should" + (aHidden ? " " : " not ") + "be hidden.");
|
||||
}
|
||||
|
||||
function testCopyUrlParams(aQueryString) {
|
||||
RequestsMenu.copyUrlParams();
|
||||
is(SpecialPowers.getClipboardData("text/unicode"),
|
||||
aQueryString, "The url query string copied from the selected item is correct.");
|
||||
}
|
||||
|
||||
function testCopyPostDataHidden(aHidden) {
|
||||
RequestsMenu._onContextShowing();
|
||||
is(document.querySelector("#request-menu-context-copy-post-data").hidden,
|
||||
aHidden, "The \"Copy POST Data\" context menu item should" + (aHidden ? " " : " not ") + "be hidden.");
|
||||
}
|
||||
|
||||
function testCopyPostData(aPostData) {
|
||||
return RequestsMenu.copyPostData().then(() => {
|
||||
is(SpecialPowers.getClipboardData("text/unicode"),
|
||||
aPostData, "The post data string copied from the selected item is correct.");
|
||||
});
|
||||
}
|
||||
|
||||
aDebuggee.performRequests();
|
||||
let wait = waitForNetworkEvents(monitor, 1, 6);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(0);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("{ \"foo\": \"bar\" }");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(1);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a=b");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("{ \"foo\": \"bar\" }");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(2);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a=b");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("foo=bar");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(3);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("{ \"foo\": \"bar\" }");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(4);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a=b");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("{ \"foo\": \"bar\" }");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(5);
|
||||
yield testCopyUrlParamsHidden(false);
|
||||
yield testCopyUrlParams("a=b");
|
||||
yield testCopyPostDataHidden(false);
|
||||
yield testCopyPostData("?foo=bar");
|
||||
|
||||
RequestsMenu.selectedItem = RequestsMenu.getItemAtIndex(6);
|
||||
yield testCopyUrlParamsHidden(true);
|
||||
yield testCopyPostDataHidden(true);
|
||||
|
||||
return teardown(monitor);
|
||||
|
||||
function testCopyUrlParamsHidden(hidden) {
|
||||
RequestsMenu._onContextShowing();
|
||||
is(document.querySelector("#request-menu-context-copy-url-params").hidden, hidden,
|
||||
"The \"Copy URL Parameters\" context menu item should" + (hidden ? " " : " not ") +
|
||||
"be hidden.");
|
||||
}
|
||||
|
||||
function* testCopyUrlParams(queryString) {
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyUrlParams();
|
||||
}, queryString);
|
||||
ok(true, "The url query string copied from the selected item is correct.");
|
||||
}
|
||||
|
||||
function testCopyPostDataHidden(hidden) {
|
||||
RequestsMenu._onContextShowing();
|
||||
is(document.querySelector("#request-menu-context-copy-post-data").hidden, hidden,
|
||||
"The \"Copy POST Data\" context menu item should" + (hidden ? " " : " not ") +
|
||||
"be hidden.");
|
||||
}
|
||||
|
||||
function* testCopyPostData(postData) {
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyPostData();
|
||||
}, postData);
|
||||
ok(true, "The post data string copied from the selected item is correct.");
|
||||
}
|
||||
});
|
||||
|
@ -1,40 +1,35 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if copying a request's response works.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
const EXPECTED_RESULT = '{ "greeting": "Hello JSON!" }';
|
||||
const EXPECTED_RESULT = '{ "greeting": "Hello JSON!" }';
|
||||
|
||||
let { NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 7).then(() => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(3);
|
||||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
waitForClipboard(EXPECTED_RESULT, function setup() {
|
||||
RequestsMenu.copyResponse();
|
||||
}, function onSuccess() {
|
||||
ok(true, "Clipboard contains the currently selected item's response.");
|
||||
cleanUp();
|
||||
}, function onFailure() {
|
||||
ok(false, "Copying the currently selected item's response was unsuccessful.");
|
||||
cleanUp();
|
||||
});
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
|
||||
function cleanUp() {
|
||||
teardown(aMonitor).then(finish);
|
||||
}
|
||||
let wait = waitForNetworkEvents(monitor, 7);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
let requestItem = RequestsMenu.getItemAtIndex(3);
|
||||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyResponse();
|
||||
}, EXPECTED_RESULT);
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,41 +1,37 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if copying an image as data uri works.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
const SVG_URL = EXAMPLE_URL + "dropmarker.svg";
|
||||
initNetMonitor(CURL_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
const SVG_URL = EXAMPLE_URL + "dropmarker.svg";
|
||||
|
||||
let { NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CURL_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
RequestsMenu.selectedItem = requestItem;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForClipboard(function check(text) {
|
||||
return text.startsWith("data:") && !/undefined/.test(text);
|
||||
}, function setup() {
|
||||
RequestsMenu.copyImageAsDataUri();
|
||||
}, function onSuccess() {
|
||||
ok(true, "Clipboard contains a valid data: URI");
|
||||
cleanUp();
|
||||
}, function onFailure() {
|
||||
ok(false, "Clipboard contains an invalid data: URI");
|
||||
cleanUp();
|
||||
});
|
||||
});
|
||||
|
||||
aDebuggee.performRequest(SVG_URL);
|
||||
|
||||
function cleanUp() {
|
||||
teardown(aMonitor).then(finish);
|
||||
}
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, SVG_URL, function* (url) {
|
||||
content.wrappedJSObject.performRequest(url);
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyImageAsDataUri();
|
||||
}, function check(text) {
|
||||
return text.startsWith("data:") && !/undefined/.test(text);
|
||||
});
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,36 +1,31 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if copying a request's url works.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
waitForClipboard(requestItem.attachment.url, function setup() {
|
||||
RequestsMenu.copyUrl();
|
||||
}, function onSuccess() {
|
||||
ok(true, "Clipboard contains the currently selected item's url.");
|
||||
cleanUp();
|
||||
}, function onFailure() {
|
||||
ok(false, "Copying the currently selected item's url was unsuccessful.");
|
||||
cleanUp();
|
||||
});
|
||||
});
|
||||
|
||||
aDebuggee.performRequests(1);
|
||||
|
||||
function cleanUp() {
|
||||
teardown(aMonitor).then(finish);
|
||||
}
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests(1);
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
yield waitForClipboardPromise(function setup() {
|
||||
RequestsMenu.copyUrl();
|
||||
}, requestItem.attachment.url);
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
@ -8,22 +9,25 @@
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
let [, debuggee, monitor] = yield initNetMonitor(CORS_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(CORS_URL);
|
||||
let { RequestsMenu } = monitor.panelWin.NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
let wait = waitForNetworkEvents(monitor, 1, 1);
|
||||
|
||||
info("Performing a CORS request");
|
||||
let url = "http://test1.example.com" + CORS_SJS_PATH;
|
||||
debuggee.performRequests(url, "triggering/preflight", "post-data");
|
||||
let requestUrl = "http://test1.example.com" + CORS_SJS_PATH;
|
||||
yield ContentTask.spawn(tab.linkedBrowser, requestUrl, function* (url) {
|
||||
content.wrappedJSObject.performRequests(url, "triggering/preflight", "post-data");
|
||||
});
|
||||
|
||||
info("Waiting until the requests appear in netmonitor");
|
||||
yield waitForNetworkEvents(monitor, 1, 1);
|
||||
yield wait;
|
||||
|
||||
info("Checking the preflight and flight methods");
|
||||
["OPTIONS", "POST"].forEach((method, i) => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i), method, url);
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i), method, requestUrl);
|
||||
});
|
||||
|
||||
yield teardown(monitor);
|
||||
finish();
|
||||
});
|
||||
|
@ -9,69 +9,64 @@
|
||||
|
||||
const { CurlUtils } = require("devtools/client/shared/curl");
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CURL_UTILS_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CURL_UTILS_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { NetMonitorView, gNetwork } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { NetMonitorView, gNetwork } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1, 3).then(() => {
|
||||
let requests = {
|
||||
get: RequestsMenu.getItemAtIndex(0),
|
||||
post: RequestsMenu.getItemAtIndex(1),
|
||||
multipart: RequestsMenu.getItemAtIndex(2),
|
||||
multipartForm: RequestsMenu.getItemAtIndex(3)
|
||||
};
|
||||
|
||||
Task.spawn(function* () {
|
||||
yield createCurlData(requests.get.attachment, gNetwork).then((aData) => {
|
||||
test_findHeader(aData);
|
||||
});
|
||||
|
||||
yield createCurlData(requests.post.attachment, gNetwork).then((aData) => {
|
||||
test_isUrlEncodedRequest(aData);
|
||||
test_writePostDataTextParams(aData);
|
||||
});
|
||||
|
||||
yield createCurlData(requests.multipart.attachment, gNetwork).then((aData) => {
|
||||
test_isMultipartRequest(aData);
|
||||
test_getMultipartBoundary(aData);
|
||||
test_removeBinaryDataFromMultipartText(aData);
|
||||
});
|
||||
|
||||
yield createCurlData(requests.multipartForm.attachment, gNetwork).then((aData) => {
|
||||
test_getHeadersFromMultipartText(aData);
|
||||
});
|
||||
|
||||
if (Services.appinfo.OS != "WINNT") {
|
||||
test_escapeStringPosix();
|
||||
} else {
|
||||
test_escapeStringWin();
|
||||
}
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
});
|
||||
|
||||
aDebuggee.performRequests(SIMPLE_SJS);
|
||||
let wait = waitForNetworkEvents(monitor, 1, 3);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, SIMPLE_SJS, function* (url) {
|
||||
content.wrappedJSObject.performRequests(url);
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
function test_isUrlEncodedRequest(aData) {
|
||||
let isUrlEncoded = CurlUtils.isUrlEncodedRequest(aData);
|
||||
let requests = {
|
||||
get: RequestsMenu.getItemAtIndex(0),
|
||||
post: RequestsMenu.getItemAtIndex(1),
|
||||
multipart: RequestsMenu.getItemAtIndex(2),
|
||||
multipartForm: RequestsMenu.getItemAtIndex(3)
|
||||
};
|
||||
|
||||
let data = yield createCurlData(requests.get.attachment, gNetwork);
|
||||
testFindHeader(data);
|
||||
|
||||
data = yield createCurlData(requests.post.attachment, gNetwork);
|
||||
testIsUrlEncodedRequest(data);
|
||||
testWritePostDataTextParams(data);
|
||||
|
||||
data = yield createCurlData(requests.multipart.attachment, gNetwork);
|
||||
testIsMultipartRequest(data);
|
||||
testGetMultipartBoundary(data);
|
||||
testRemoveBinaryDataFromMultipartText(data);
|
||||
|
||||
data = yield createCurlData(requests.multipartForm.attachment, gNetwork);
|
||||
testGetHeadersFromMultipartText(data);
|
||||
|
||||
if (Services.appinfo.OS != "WINNT") {
|
||||
testEscapeStringPosix();
|
||||
} else {
|
||||
testEscapeStringWin();
|
||||
}
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
||||
function testIsUrlEncodedRequest(data) {
|
||||
let isUrlEncoded = CurlUtils.isUrlEncodedRequest(data);
|
||||
ok(isUrlEncoded, "Should return true for url encoded requests.");
|
||||
}
|
||||
|
||||
function test_isMultipartRequest(aData) {
|
||||
let isMultipart = CurlUtils.isMultipartRequest(aData);
|
||||
function testIsMultipartRequest(data) {
|
||||
let isMultipart = CurlUtils.isMultipartRequest(data);
|
||||
ok(isMultipart, "Should return true for multipart/form-data requests.");
|
||||
}
|
||||
|
||||
function test_findHeader(aData) {
|
||||
let headers = aData.headers;
|
||||
function testFindHeader(data) {
|
||||
let headers = data.headers;
|
||||
let hostName = CurlUtils.findHeader(headers, "Host");
|
||||
let requestedWithLowerCased = CurlUtils.findHeader(headers, "x-requested-with");
|
||||
let doesNotExist = CurlUtils.findHeader(headers, "X-Does-Not-Exist");
|
||||
@ -84,21 +79,21 @@ function test_findHeader(aData) {
|
||||
"Should return null when a header is not found.");
|
||||
}
|
||||
|
||||
function test_writePostDataTextParams(aData) {
|
||||
let params = CurlUtils.writePostDataTextParams(aData.postDataText);
|
||||
function testWritePostDataTextParams(data) {
|
||||
let params = CurlUtils.writePostDataTextParams(data.postDataText);
|
||||
is(params, "param1=value1¶m2=value2¶m3=value3",
|
||||
"Should return a serialized representation of the request parameters");
|
||||
}
|
||||
|
||||
function test_getMultipartBoundary(aData) {
|
||||
let boundary = CurlUtils.getMultipartBoundary(aData);
|
||||
function testGetMultipartBoundary(data) {
|
||||
let boundary = CurlUtils.getMultipartBoundary(data);
|
||||
ok(/-{3,}\w+/.test(boundary),
|
||||
"A boundary string should be found in a multipart request.");
|
||||
}
|
||||
|
||||
function test_removeBinaryDataFromMultipartText(aData) {
|
||||
let generatedBoundary = CurlUtils.getMultipartBoundary(aData);
|
||||
let text = aData.postDataText;
|
||||
function testRemoveBinaryDataFromMultipartText(data) {
|
||||
let generatedBoundary = CurlUtils.getMultipartBoundary(data);
|
||||
let text = data.postDataText;
|
||||
let binaryRemoved =
|
||||
CurlUtils.removeBinaryDataFromMultipartText(text, generatedBoundary);
|
||||
let boundary = "--" + generatedBoundary;
|
||||
@ -149,18 +144,15 @@ function test_removeBinaryDataFromMultipartText(aData) {
|
||||
}
|
||||
}
|
||||
|
||||
function test_getHeadersFromMultipartText(aData) {
|
||||
let headers = CurlUtils.getHeadersFromMultipartText(aData.postDataText);
|
||||
function testGetHeadersFromMultipartText(data) {
|
||||
let headers = CurlUtils.getHeadersFromMultipartText(data.postDataText);
|
||||
|
||||
ok(Array.isArray(headers),
|
||||
"Should return an array.");
|
||||
ok(headers.length > 0,
|
||||
"There should exist at least one request header.");
|
||||
is(headers[0].name, "Content-Type",
|
||||
"The first header name should be 'Content-Type'.");
|
||||
ok(Array.isArray(headers), "Should return an array.");
|
||||
ok(headers.length > 0, "There should exist at least one request header.");
|
||||
is(headers[0].name, "Content-Type", "The first header name should be 'Content-Type'.");
|
||||
}
|
||||
|
||||
function test_escapeStringPosix() {
|
||||
function testEscapeStringPosix() {
|
||||
let surroundedWithQuotes = "A simple string";
|
||||
is(CurlUtils.escapeStringPosix(surroundedWithQuotes), "'A simple string'",
|
||||
"The string should be surrounded with single quotes.");
|
||||
@ -184,7 +176,7 @@ function test_escapeStringPosix() {
|
||||
"Character codes outside of the decimal range 32 - 126 should be escaped.");
|
||||
}
|
||||
|
||||
function test_escapeStringWin() {
|
||||
function testEscapeStringWin() {
|
||||
let surroundedWithDoubleQuotes = "A simple string";
|
||||
is(CurlUtils.escapeStringWin(surroundedWithDoubleQuotes), '"A simple string"',
|
||||
"The string should be surrounded with double quotes.");
|
||||
@ -208,29 +200,29 @@ function test_escapeStringWin() {
|
||||
"Newlines should be escaped.");
|
||||
}
|
||||
|
||||
function createCurlData(aSelected, aNetwork) {
|
||||
return Task.spawn(function* () {
|
||||
// Create a sanitized object for the Curl command generator.
|
||||
let data = {
|
||||
url: aSelected.url,
|
||||
method: aSelected.method,
|
||||
headers: [],
|
||||
httpVersion: aSelected.httpVersion,
|
||||
postDataText: null
|
||||
};
|
||||
function* createCurlData(selected, network, controller) {
|
||||
let { url, method, httpVersion } = selected;
|
||||
|
||||
// Fetch header values.
|
||||
for (let { name, value } of aSelected.requestHeaders.headers) {
|
||||
let text = yield aNetwork.getString(value);
|
||||
data.headers.push({ name: name, value: text });
|
||||
}
|
||||
// Create a sanitized object for the Curl command generator.
|
||||
let data = {
|
||||
url,
|
||||
method,
|
||||
headers: [],
|
||||
httpVersion,
|
||||
postDataText: null
|
||||
};
|
||||
|
||||
// Fetch the request payload.
|
||||
if (aSelected.requestPostData) {
|
||||
let postData = aSelected.requestPostData.postData.text;
|
||||
data.postDataText = yield aNetwork.getString(postData);
|
||||
}
|
||||
// Fetch header values.
|
||||
for (let { name, value } of selected.requestHeaders.headers) {
|
||||
let text = yield network.getString(value);
|
||||
data.headers.push({ name: name, value: text });
|
||||
}
|
||||
|
||||
return data;
|
||||
});
|
||||
// Fetch the request payload.
|
||||
if (selected.requestPostData) {
|
||||
let postData = selected.requestPostData.postData.text;
|
||||
data.postDataText = yield network.getString(postData);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -1,44 +1,45 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if cyrillic text is rendered correctly in the source editor.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CYRILLIC_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CYRILLIC_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { document, EVENTS, Editor, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=txt", {
|
||||
status: 200,
|
||||
statusText: "DA DA DA"
|
||||
});
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
yield wait;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
|
||||
let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED;
|
||||
waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED).then(() =>
|
||||
NetMonitorView.editor("#response-content-textarea")
|
||||
).then((aEditor) => {
|
||||
is(aEditor.getText().indexOf("\u044F"), 26, // я
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=txt", {
|
||||
status: 200,
|
||||
statusText: "DA DA DA"
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
});
|
||||
}
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
|
||||
yield monitor.panelWin.once(EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
let editor = yield NetMonitorView.editor("#response-content-textarea");
|
||||
// u044F = я
|
||||
is(editor.getText().indexOf("\u044F"), 26,
|
||||
"The text shown in the source editor is correct.");
|
||||
is(editor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is correct.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,45 +1,44 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if cyrillic text is rendered correctly in the source editor
|
||||
* when loaded directly from an HTML page.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CYRILLIC_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CYRILLIC_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { document, EVENTS, Editor, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CYRILLIC_URL, {
|
||||
status: 200,
|
||||
statusText: "OK"
|
||||
});
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
tab.linkedBrowser.reload();
|
||||
yield wait;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
|
||||
let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED;
|
||||
waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED).then(() =>
|
||||
NetMonitorView.editor("#response-content-textarea")
|
||||
).then((aEditor) => {
|
||||
is(aEditor.getText().indexOf("\u044F"), 486, // я
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), Editor.modes.html,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CYRILLIC_URL, {
|
||||
status: 200,
|
||||
statusText: "OK"
|
||||
});
|
||||
|
||||
aDebuggee.location.reload();
|
||||
});
|
||||
}
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
|
||||
yield monitor.panelWin.once(EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
let editor = yield NetMonitorView.editor("#response-content-textarea");
|
||||
// u044F = я
|
||||
is(editor.getText().indexOf("\u044F"), 486,
|
||||
"The text shown in the source editor is correct.");
|
||||
is(editor.getMode(), Editor.modes.html,
|
||||
"The mode active in the source editor is correct.");
|
||||
|
||||
return teardown(monitor);
|
||||
});
|
||||
|
@ -1,13 +1,13 @@
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// A test to ensure that the content in details pane is not duplicated.
|
||||
|
||||
var test = Task.async(function* () {
|
||||
info("Initializing test");
|
||||
let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let panel = monitor.panelWin;
|
||||
let { NetMonitorView, EVENTS } = panel;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
@ -45,7 +45,7 @@ var test = Task.async(function* () {
|
||||
];
|
||||
|
||||
info("Adding a cookie for the \"Cookie\" tab test");
|
||||
debuggee.document.cookie = "a=b; path=" + COOKIE_UNIQUE_PATH;
|
||||
yield setDocCookie("a=b; path=" + COOKIE_UNIQUE_PATH);
|
||||
|
||||
info("Running tests");
|
||||
for (let spec of TEST_CASES) {
|
||||
@ -55,20 +55,29 @@ var test = Task.async(function* () {
|
||||
// Remove the cookie. If an error occurs the path of the cookie ensures it
|
||||
// doesn't mess with the other tests.
|
||||
info("Removing the added cookie.");
|
||||
debuggee.document.cookie = "a=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=" +
|
||||
COOKIE_UNIQUE_PATH;
|
||||
yield setDocCookie(
|
||||
"a=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=" + COOKIE_UNIQUE_PATH);
|
||||
|
||||
yield teardown(monitor);
|
||||
finish();
|
||||
|
||||
/**
|
||||
* Set a content document cookie
|
||||
*/
|
||||
function setDocCookie(cookie) {
|
||||
return ContentTask.spawn(tab.linkedBrowser, cookie, function* (cookieArg) {
|
||||
content.document.cookie = cookieArg;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper that handles the execution of each case.
|
||||
*/
|
||||
function* runTestCase(spec) {
|
||||
info("Running case: " + spec.desc);
|
||||
debuggee.content.location = spec.pageURI;
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
tab.linkedBrowser.loadURI(spec.pageURI);
|
||||
yield wait;
|
||||
|
||||
yield waitForNetworkEvents(monitor, 1);
|
||||
RequestsMenu.clear();
|
||||
yield waitForFinalDetailTabUpdate(spec.tabIndex, spec.isPost, spec.requestURI);
|
||||
|
||||
@ -84,20 +93,23 @@ var test = Task.async(function* () {
|
||||
* - waits for the final update to happen
|
||||
*/
|
||||
function* waitForFinalDetailTabUpdate(tabIndex, isPost, uri) {
|
||||
let onNetworkEvent = waitFor(panel, EVENTS.NETWORK_EVENT);
|
||||
let onDetailsPopulated = waitFor(panel, EVENTS.NETWORKDETAILSVIEW_POPULATED);
|
||||
let onNetworkEvent = panel.once(EVENTS.NETWORK_EVENT);
|
||||
let onDetailsPopulated = panel.once(EVENTS.NETWORKDETAILSVIEW_POPULATED);
|
||||
let onRequestFinished = isPost ?
|
||||
waitForNetworkEvents(monitor, 0, 1) : waitForNetworkEvents(monitor, 1);
|
||||
waitForNetworkEvents(monitor, 0, 1) :
|
||||
waitForNetworkEvents(monitor, 1);
|
||||
|
||||
info("Performing a request");
|
||||
debuggee.performRequests(1, uri);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, uri, function* (url) {
|
||||
content.wrappedJSObject.performRequests(1, url);
|
||||
});
|
||||
|
||||
info("Waiting for NETWORK_EVENT");
|
||||
yield onNetworkEvent;
|
||||
|
||||
if (!RequestsMenu.getItemAtIndex(0)) {
|
||||
info("Waiting for the request to be added to the view");
|
||||
yield monitor.panelWin.once(monitor.panelWin.EVENTS.REQUEST_ADDED);
|
||||
yield monitor.panelWin.once(EVENTS.REQUEST_ADDED);
|
||||
}
|
||||
|
||||
ok(true, "Received NETWORK_EVENT. Selecting the item.");
|
||||
@ -146,7 +158,7 @@ var test = Task.async(function* () {
|
||||
if (hasQueuedUpdates && hasRunningTabUpdate) {
|
||||
info("Waiting for updates to be flushed.");
|
||||
// _flushRequests calls .populate which emits the following event
|
||||
yield waitFor(panel, EVENTS.NETWORKDETAILSVIEW_POPULATED);
|
||||
yield panel.once(EVENTS.NETWORKDETAILSVIEW_POPULATED);
|
||||
|
||||
info("Requests flushed.");
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test if filtering items in the network table works correctly.
|
||||
*/
|
||||
@ -26,264 +28,239 @@ const REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS = REQUESTS_WITH_MEDIA_AND_FLASH.conca
|
||||
{ url: "sjs_content-type-test-server.sjs?fmt=ws" },
|
||||
]);
|
||||
|
||||
function test() {
|
||||
initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(FILTERING_URL);
|
||||
|
||||
function setFreetextFilter(value) {
|
||||
// Set the text and manually call all callbacks synchronously to avoid the timeout
|
||||
RequestsMenu.freetextFilterBox.value = value;
|
||||
RequestsMenu.requestsFreetextFilterEvent();
|
||||
RequestsMenu.userInputTimer.cancel();
|
||||
RequestsMenu.reFilterRequests();
|
||||
function setFreetextFilter(value) {
|
||||
// Set the text and manually call all callbacks synchronously to avoid the timeout
|
||||
RequestsMenu.freetextFilterBox.value = value;
|
||||
RequestsMenu.requestsFreetextFilterEvent();
|
||||
RequestsMenu.userInputTimer.cancel();
|
||||
RequestsMenu.reFilterRequests();
|
||||
}
|
||||
|
||||
info("Starting test... ");
|
||||
|
||||
let { $, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
let wait = waitForNetworkEvents(monitor, 9);
|
||||
loadCommonFrameScript();
|
||||
yield performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS);
|
||||
yield wait;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
|
||||
// First test with single filters...
|
||||
testFilterButtons(monitor, "all");
|
||||
testContents([1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
testFilterButtons(monitor, "html");
|
||||
testContents([1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
// Reset filters
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
|
||||
testFilterButtons(monitor, "css");
|
||||
testContents([0, 1, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-js-button"));
|
||||
testFilterButtons(monitor, "js");
|
||||
testContents([0, 0, 1, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-xhr-button"));
|
||||
testFilterButtons(monitor, "xhr");
|
||||
testContents([1, 1, 1, 1, 1, 1, 1, 1, 0]);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-fonts-button"));
|
||||
testFilterButtons(monitor, "fonts");
|
||||
testContents([0, 0, 0, 1, 0, 0, 0, 0, 0]);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-images-button"));
|
||||
testFilterButtons(monitor, "images");
|
||||
testContents([0, 0, 0, 0, 1, 0, 0, 0, 0]);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-media-button"));
|
||||
testFilterButtons(monitor, "media");
|
||||
testContents([0, 0, 0, 0, 0, 1, 1, 0, 0]);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button"));
|
||||
testFilterButtons(monitor, "flash");
|
||||
testContents([0, 0, 0, 0, 0, 0, 0, 1, 0]);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-ws-button"));
|
||||
testFilterButtons(monitor, "ws");
|
||||
testContents([0, 0, 0, 0, 0, 0, 0, 0, 1]);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
testFilterButtons(monitor, "all");
|
||||
testContents([1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
||||
|
||||
// Text in filter box that matches nothing should hide all.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
setFreetextFilter("foobar");
|
||||
testContents([0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
// Text in filter box that matches should filter out everything else.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
setFreetextFilter("sample");
|
||||
testContents([1, 1, 1, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
// Text in filter box that matches should filter out everything else.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
setFreetextFilter("SAMPLE");
|
||||
testContents([1, 1, 1, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
// Test negative filtering (only show unmatched items)
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
setFreetextFilter("-sample");
|
||||
testContents([0, 0, 0, 1, 1, 1, 1, 1, 1]);
|
||||
|
||||
// ...then combine multiple filters together.
|
||||
|
||||
// Enable filtering for html and css; should show request of both type.
|
||||
setFreetextFilter("");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
|
||||
testFilterButtonsCustom(monitor, [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
testContents([1, 1, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
// Html and css filter enabled and text filter should show just the html and css match.
|
||||
// Should not show both the items matching the button plus the items matching the text.
|
||||
setFreetextFilter("sample");
|
||||
testContents([1, 1, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button"));
|
||||
setFreetextFilter("");
|
||||
testFilterButtonsCustom(monitor, [0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0]);
|
||||
testContents([1, 1, 0, 0, 0, 0, 0, 1, 0]);
|
||||
|
||||
// Disable some filters. Only one left active.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button"));
|
||||
testFilterButtons(monitor, "html");
|
||||
testContents([1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
// Disable last active filter. Should toggle to all.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
testFilterButtons(monitor, "all");
|
||||
testContents([1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
||||
|
||||
// Enable few filters and click on all. Only "all" should be checked.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-ws-button"));
|
||||
testFilterButtonsCustom(monitor, [0, 1, 1, 0, 0, 0, 0, 0, 0, 1]);
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
testFilterButtons(monitor, "all");
|
||||
testContents([1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
function testContents(visibility) {
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should still be a selected item after filtering.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be still selected after filtering.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should still be visible after filtering.");
|
||||
|
||||
is(RequestsMenu.items.length, visibility.length,
|
||||
"There should be a specific amount of items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, visibility.filter(e => e).length,
|
||||
"There should be a specific amount of visbile items in the requests menu.");
|
||||
|
||||
for (let i = 0; i < visibility.length; i++) {
|
||||
is(RequestsMenu.getItemAtIndex(i).target.hidden, !visibility[i],
|
||||
"The item at index " + i + " doesn't have the correct hidden state.");
|
||||
}
|
||||
|
||||
info("Starting test... ");
|
||||
|
||||
let { $, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 9).then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
|
||||
// First test with single filters...
|
||||
testFilterButtons(aMonitor, "all");
|
||||
testContents([1, 1, 1, 1, 1, 1, 1, 1, 1])
|
||||
.then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
testFilterButtons(aMonitor, "html");
|
||||
return testContents([1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
// Reset filters
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
|
||||
testFilterButtons(aMonitor, "css");
|
||||
return testContents([0, 1, 0, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-js-button"));
|
||||
testFilterButtons(aMonitor, "js");
|
||||
return testContents([0, 0, 1, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-xhr-button"));
|
||||
testFilterButtons(aMonitor, "xhr");
|
||||
return testContents([1, 1, 1, 1, 1, 1, 1, 1, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-fonts-button"));
|
||||
testFilterButtons(aMonitor, "fonts");
|
||||
return testContents([0, 0, 0, 1, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-images-button"));
|
||||
testFilterButtons(aMonitor, "images");
|
||||
return testContents([0, 0, 0, 0, 1, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-media-button"));
|
||||
testFilterButtons(aMonitor, "media");
|
||||
return testContents([0, 0, 0, 0, 0, 1, 1, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button"));
|
||||
testFilterButtons(aMonitor, "flash");
|
||||
return testContents([0, 0, 0, 0, 0, 0, 0, 1, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-ws-button"));
|
||||
testFilterButtons(aMonitor, "ws");
|
||||
return testContents([0, 0, 0, 0, 0, 0, 0, 0, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
testFilterButtons(aMonitor, "all");
|
||||
return testContents([1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
// Text in filter box that matches nothing should hide all.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
setFreetextFilter("foobar");
|
||||
return testContents([0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
// Text in filter box that matches should filter out everything else.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
setFreetextFilter("sample");
|
||||
return testContents([1, 1, 1, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
// Text in filter box that matches should filter out everything else.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
setFreetextFilter("SAMPLE");
|
||||
return testContents([1, 1, 1, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
// Test negative filtering (only show unmatched items)
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
setFreetextFilter("-sample");
|
||||
return testContents([0, 0, 0, 1, 1, 1, 1, 1, 1]);
|
||||
})
|
||||
// ...then combine multiple filters together.
|
||||
.then(() => {
|
||||
// Enable filtering for html and css; should show request of both type.
|
||||
setFreetextFilter("");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
|
||||
testFilterButtonsCustom(aMonitor, [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
return testContents([1, 1, 0, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
// Html and css filter enabled and text filter should show just the html and css match.
|
||||
// Should not show both the items that match the button plus the items that match the text.
|
||||
setFreetextFilter("sample");
|
||||
return testContents([1, 1, 0, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
|
||||
.then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button"));
|
||||
setFreetextFilter("");
|
||||
testFilterButtonsCustom(aMonitor, [0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0]);
|
||||
return testContents([1, 1, 0, 0, 0, 0, 0, 1, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
// Disable some filters. Only one left active.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button"));
|
||||
testFilterButtons(aMonitor, "html");
|
||||
return testContents([1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
// Disable last active filter. Should toggle to all.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
testFilterButtons(aMonitor, "all");
|
||||
return testContents([1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
// Enable few filters and click on all. Only "all" should be checked.
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-ws-button"));
|
||||
testFilterButtonsCustom(aMonitor, [0, 1, 1, 0, 0, 0, 0, 0, 0, 1]);
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
testFilterButtons(aMonitor, "all");
|
||||
return testContents([1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
return teardown(aMonitor);
|
||||
})
|
||||
.then(finish);
|
||||
});
|
||||
|
||||
function testContents(aVisibility) {
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should still be a selected item after filtering.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be still selected after filtering.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should still be visible after filtering.");
|
||||
|
||||
is(RequestsMenu.items.length, aVisibility.length,
|
||||
"There should be a specific amount of items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, aVisibility.filter(e => e).length,
|
||||
"There should be a specific amount of visbile items in the requests menu.");
|
||||
|
||||
for (let i = 0; i < aVisibility.length; i++) {
|
||||
is(RequestsMenu.getItemAtIndex(i).target.hidden, !aVisibility[i],
|
||||
"The item at index " + i + " doesn't have the correct hidden state.");
|
||||
}
|
||||
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=html", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "html",
|
||||
fullMimeType: "text/html; charset=utf-8"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=css", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "css",
|
||||
fullMimeType: "text/css; charset=utf-8"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(2),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=js", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "js",
|
||||
fullMimeType: "application/javascript; charset=utf-8"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(3),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=font", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "woff",
|
||||
fullMimeType: "font/woff"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(4),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=image", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "png",
|
||||
fullMimeType: "image/png"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(5),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=audio", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "ogg",
|
||||
fullMimeType: "audio/ogg"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(6),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=video", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "webm",
|
||||
fullMimeType: "video/webm"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(7),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=flash", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "x-shockwave-flash",
|
||||
fullMimeType: "application/x-shockwave-flash"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(8),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=ws", {
|
||||
fuzzyUrl: true,
|
||||
status: 101,
|
||||
statusText: "Switching Protocols",
|
||||
});
|
||||
|
||||
return promise.resolve(null);
|
||||
}
|
||||
|
||||
loadCommonFrameScript();
|
||||
performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS);
|
||||
});
|
||||
}
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=html", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "html",
|
||||
fullMimeType: "text/html; charset=utf-8"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=css", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "css",
|
||||
fullMimeType: "text/css; charset=utf-8"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(2),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=js", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "js",
|
||||
fullMimeType: "application/javascript; charset=utf-8"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(3),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=font", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "woff",
|
||||
fullMimeType: "font/woff"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(4),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=image", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "png",
|
||||
fullMimeType: "image/png"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(5),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=audio", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "ogg",
|
||||
fullMimeType: "audio/ogg"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(6),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=video", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "webm",
|
||||
fullMimeType: "video/webm"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(7),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=flash", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "x-shockwave-flash",
|
||||
fullMimeType: "application/x-shockwave-flash"
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(8),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=ws", {
|
||||
fuzzyUrl: true,
|
||||
status: 101,
|
||||
statusText: "Switching Protocols",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,9 +1,12 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test if filtering items in the network table works correctly with new requests.
|
||||
*/
|
||||
|
||||
const BASIC_REQUESTS = [
|
||||
{ url: "sjs_content-type-test-server.sjs?fmt=html&res=undefined" },
|
||||
{ url: "sjs_content-type-test-server.sjs?fmt=css" },
|
||||
@ -26,179 +29,172 @@ const REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS = REQUESTS_WITH_MEDIA_AND_FLASH.conca
|
||||
{ url: "sjs_content-type-test-server.sjs?fmt=ws" },
|
||||
]);
|
||||
|
||||
function test() {
|
||||
initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(FILTERING_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
// It seems that this test may be slow on Ubuntu builds running on ec2.
|
||||
requestLongerTimeout(2);
|
||||
// It seems that this test may be slow on Ubuntu builds running on ec2.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
let { $, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { $, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 9).then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
let wait = waitForNetworkEvents(monitor, 9);
|
||||
loadCommonFrameScript();
|
||||
yield performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS);
|
||||
yield wait;
|
||||
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
|
||||
testFilterButtons(aMonitor, "all");
|
||||
testContents([1, 1, 1, 1, 1, 1, 1, 1, 1])
|
||||
.then(() => {
|
||||
info("Testing html filtering.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
testFilterButtons(aMonitor, "html");
|
||||
return testContents([1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Performing more requests.");
|
||||
performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS);
|
||||
return waitForNetworkEvents(aMonitor, 9);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing html filtering again.");
|
||||
testFilterButtons(aMonitor, "html");
|
||||
return testContents([1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Performing more requests.");
|
||||
performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS);
|
||||
return waitForNetworkEvents(aMonitor, 9);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing html filtering again.");
|
||||
testFilterButtons(aMonitor, "html");
|
||||
return testContents([1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Resetting filters.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
testFilterButtons(aMonitor, "all");
|
||||
return testContents([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
return teardown(aMonitor);
|
||||
})
|
||||
.then(finish);
|
||||
});
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
|
||||
function testContents(aVisibility) {
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should still be a selected item after filtering.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be still selected after filtering.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should still be visible after filtering.");
|
||||
testFilterButtons(monitor, "all");
|
||||
testContents([1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
||||
|
||||
is(RequestsMenu.items.length, aVisibility.length,
|
||||
"There should be a specific amount of items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, aVisibility.filter(e => e).length,
|
||||
"There should be a specific amount of visbile items in the requests menu.");
|
||||
info("Testing html filtering.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
testFilterButtons(monitor, "html");
|
||||
testContents([1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
for (let i = 0; i < aVisibility.length; i++) {
|
||||
is(RequestsMenu.getItemAtIndex(i).target.hidden, !aVisibility[i],
|
||||
"The item at index " + i + " doesn't have the correct hidden state.");
|
||||
}
|
||||
info("Performing more requests.");
|
||||
wait = waitForNetworkEvents(monitor, 9);
|
||||
yield performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS);
|
||||
yield wait;
|
||||
|
||||
for (let i = 0; i < aVisibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=html", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "html",
|
||||
fullMimeType: "text/html; charset=utf-8"
|
||||
});
|
||||
}
|
||||
for (let i = 1; i < aVisibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=css", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "css",
|
||||
fullMimeType: "text/css; charset=utf-8"
|
||||
});
|
||||
}
|
||||
for (let i = 2; i < aVisibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=js", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "js",
|
||||
fullMimeType: "application/javascript; charset=utf-8"
|
||||
});
|
||||
}
|
||||
for (let i = 3; i < aVisibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=font", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "woff",
|
||||
fullMimeType: "font/woff"
|
||||
});
|
||||
}
|
||||
for (let i = 4; i < aVisibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=image", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "png",
|
||||
fullMimeType: "image/png"
|
||||
});
|
||||
}
|
||||
for (let i = 5; i < aVisibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=audio", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "ogg",
|
||||
fullMimeType: "audio/ogg"
|
||||
});
|
||||
}
|
||||
for (let i = 6; i < aVisibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=video", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "webm",
|
||||
fullMimeType: "video/webm"
|
||||
});
|
||||
}
|
||||
for (let i = 7; i < aVisibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=flash", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "x-shockwave-flash",
|
||||
fullMimeType: "application/x-shockwave-flash"
|
||||
});
|
||||
}
|
||||
for (let i = 8; i < aVisibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=ws", {
|
||||
fuzzyUrl: true,
|
||||
status: 101,
|
||||
statusText: "Switching Protocols"
|
||||
});
|
||||
}
|
||||
info("Testing html filtering again.");
|
||||
testFilterButtons(monitor, "html");
|
||||
testContents([1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
return promise.resolve(null);
|
||||
info("Performing more requests.");
|
||||
wait = waitForNetworkEvents(monitor, 9);
|
||||
yield performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS);
|
||||
yield wait;
|
||||
|
||||
info("Testing html filtering again.");
|
||||
testFilterButtons(monitor, "html");
|
||||
testContents([1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
info("Resetting filters.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
|
||||
testFilterButtons(monitor, "all");
|
||||
testContents([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
function testContents(visibility) {
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should still be a selected item after filtering.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be still selected after filtering.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should still be visible after filtering.");
|
||||
|
||||
is(RequestsMenu.items.length, visibility.length,
|
||||
"There should be a specific amount of items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, visibility.filter(e => e).length,
|
||||
"There should be a specific amount of visbile items in the requests menu.");
|
||||
|
||||
for (let i = 0; i < visibility.length; i++) {
|
||||
is(RequestsMenu.getItemAtIndex(i).target.hidden, !visibility[i],
|
||||
"The item at index " + i + " doesn't have the correct hidden state.");
|
||||
}
|
||||
|
||||
loadCommonFrameScript();
|
||||
performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS);
|
||||
});
|
||||
}
|
||||
for (let i = 0; i < visibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=html", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "html",
|
||||
fullMimeType: "text/html; charset=utf-8"
|
||||
});
|
||||
}
|
||||
for (let i = 1; i < visibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=css", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "css",
|
||||
fullMimeType: "text/css; charset=utf-8"
|
||||
});
|
||||
}
|
||||
for (let i = 2; i < visibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=js", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "js",
|
||||
fullMimeType: "application/javascript; charset=utf-8"
|
||||
});
|
||||
}
|
||||
for (let i = 3; i < visibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=font", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "woff",
|
||||
fullMimeType: "font/woff"
|
||||
});
|
||||
}
|
||||
for (let i = 4; i < visibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=image", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "png",
|
||||
fullMimeType: "image/png"
|
||||
});
|
||||
}
|
||||
for (let i = 5; i < visibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=audio", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "ogg",
|
||||
fullMimeType: "audio/ogg"
|
||||
});
|
||||
}
|
||||
for (let i = 6; i < visibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=video", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "webm",
|
||||
fullMimeType: "video/webm"
|
||||
});
|
||||
}
|
||||
for (let i = 7; i < visibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=flash", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "x-shockwave-flash",
|
||||
fullMimeType: "application/x-shockwave-flash"
|
||||
});
|
||||
}
|
||||
for (let i = 8; i < visibility.length; i += 9) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(i),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=ws", {
|
||||
fuzzyUrl: true,
|
||||
status: 101,
|
||||
statusText: "Switching Protocols"
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,8 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test if filtering items in the network table works correctly with new requests
|
||||
* and while sorting is enabled.
|
||||
@ -18,180 +20,166 @@ const REQUESTS_WITH_MEDIA = BASIC_REQUESTS.concat([
|
||||
{ url: "sjs_content-type-test-server.sjs?fmt=video" },
|
||||
]);
|
||||
|
||||
const REQUESTS_WITH_MEDIA_AND_FLASH = REQUESTS_WITH_MEDIA.concat([
|
||||
{ url: "sjs_content-type-test-server.sjs?fmt=flash" },
|
||||
]);
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(FILTERING_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
function test() {
|
||||
initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
// It seems that this test may be slow on Ubuntu builds running on ec2.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
// It seems that this test may be slow on Ubuntu builds running on ec2.
|
||||
requestLongerTimeout(2);
|
||||
let { $, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
let { $, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
// The test assumes that the first HTML request here has a longer response
|
||||
// body than the other HTML requests performed later during the test.
|
||||
let requests = Cu.cloneInto(REQUESTS_WITH_MEDIA, {});
|
||||
let newres = "res=<p>" + new Array(10).join(Math.random(10)) + "</p>";
|
||||
requests[0].url = requests[0].url.replace("res=undefined", newres);
|
||||
|
||||
waitForNetworkEvents(aMonitor, 7).then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
loadCommonFrameScript();
|
||||
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
let wait = waitForNetworkEvents(monitor, 7);
|
||||
yield performRequestsInContent(requests);
|
||||
yield wait;
|
||||
|
||||
testFilterButtons(aMonitor, "all");
|
||||
testContents([0, 1, 2, 3, 4, 5, 6], 7, 0)
|
||||
.then(() => {
|
||||
info("Sorting by size, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
|
||||
testFilterButtons(aMonitor, "all");
|
||||
return testContents([6, 4, 5, 0, 1, 2, 3], 7, 6);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing html filtering.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
testFilterButtons(aMonitor, "html");
|
||||
return testContents([6, 4, 5, 0, 1, 2, 3], 1, 6);
|
||||
})
|
||||
.then(() => {
|
||||
info("Performing more requests.");
|
||||
performRequestsInContent(REQUESTS_WITH_MEDIA);
|
||||
return waitForNetworkEvents(aMonitor, 7);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing html filtering again.");
|
||||
resetSorting();
|
||||
testFilterButtons(aMonitor, "html");
|
||||
return testContents([8, 13, 9, 11, 10, 12, 0, 4, 1, 5, 2, 6, 3, 7], 2, 13);
|
||||
})
|
||||
.then(() => {
|
||||
info("Performing more requests.");
|
||||
performRequestsInContent(REQUESTS_WITH_MEDIA);
|
||||
return waitForNetworkEvents(aMonitor, 7);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing html filtering again.");
|
||||
resetSorting();
|
||||
testFilterButtons(aMonitor, "html");
|
||||
return testContents([12, 13, 20, 14, 16, 18, 15, 17, 19, 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11], 3, 20);
|
||||
})
|
||||
.then(() => {
|
||||
return teardown(aMonitor);
|
||||
})
|
||||
.then(finish);
|
||||
});
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
|
||||
function resetSorting() {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
|
||||
testFilterButtons(monitor, "all");
|
||||
testContents([0, 1, 2, 3, 4, 5, 6], 7, 0);
|
||||
|
||||
info("Sorting by size, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
|
||||
testFilterButtons(monitor, "all");
|
||||
testContents([6, 4, 5, 0, 1, 2, 3], 7, 6);
|
||||
|
||||
info("Testing html filtering.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
testFilterButtons(monitor, "html");
|
||||
testContents([6, 4, 5, 0, 1, 2, 3], 1, 6);
|
||||
|
||||
info("Performing more requests.");
|
||||
wait = waitForNetworkEvents(monitor, 7);
|
||||
performRequestsInContent(REQUESTS_WITH_MEDIA);
|
||||
yield wait;
|
||||
|
||||
info("Testing html filtering again.");
|
||||
resetSorting();
|
||||
testFilterButtons(monitor, "html");
|
||||
testContents([8, 13, 9, 11, 10, 12, 0, 4, 1, 5, 2, 6, 3, 7], 2, 13);
|
||||
|
||||
info("Performing more requests.");
|
||||
performRequestsInContent(REQUESTS_WITH_MEDIA);
|
||||
yield waitForNetworkEvents(monitor, 7);
|
||||
|
||||
info("Testing html filtering again.");
|
||||
resetSorting();
|
||||
testFilterButtons(monitor, "html");
|
||||
testContents([12, 13, 20, 14, 16, 18, 15, 17, 19, 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11],
|
||||
3, 20);
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
function resetSorting() {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
|
||||
}
|
||||
|
||||
function testContents(order, visible, selection) {
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should still be a selected item after filtering.");
|
||||
is(RequestsMenu.selectedIndex, selection,
|
||||
"The first item should be still selected after filtering.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should still be visible after filtering.");
|
||||
|
||||
is(RequestsMenu.items.length, order.length,
|
||||
"There should be a specific amount of items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, visible,
|
||||
"There should be a specific amount of visbile items in the requests menu.");
|
||||
|
||||
for (let i = 0; i < order.length; i++) {
|
||||
is(RequestsMenu.getItemAtIndex(i), RequestsMenu.items[i],
|
||||
"The requests menu items aren't ordered correctly. Misplaced item " + i + ".");
|
||||
}
|
||||
|
||||
function testContents(aOrder, aVisible, aSelection) {
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should still be a selected item after filtering.");
|
||||
is(RequestsMenu.selectedIndex, aSelection,
|
||||
"The first item should be still selected after filtering.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should still be visible after filtering.");
|
||||
|
||||
is(RequestsMenu.items.length, aOrder.length,
|
||||
"There should be a specific amount of items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, aVisible,
|
||||
"There should be a specific amount of visbile items in the requests menu.");
|
||||
|
||||
for (let i = 0; i < aOrder.length; i++) {
|
||||
is(RequestsMenu.getItemAtIndex(i), RequestsMenu.items[i],
|
||||
"The requests menu items aren't ordered correctly. Misplaced item " + i + ".");
|
||||
}
|
||||
|
||||
for (let i = 0, len = aOrder.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=html", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "html",
|
||||
fullMimeType: "text/html; charset=utf-8"
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = aOrder.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=css", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "css",
|
||||
fullMimeType: "text/css; charset=utf-8"
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = aOrder.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 2]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=js", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "js",
|
||||
fullMimeType: "application/javascript; charset=utf-8"
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = aOrder.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 3]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=font", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "woff",
|
||||
fullMimeType: "font/woff"
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = aOrder.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 4]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=image", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "png",
|
||||
fullMimeType: "image/png"
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = aOrder.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 5]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=audio", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "ogg",
|
||||
fullMimeType: "audio/ogg"
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = aOrder.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 6]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=video", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "webm",
|
||||
fullMimeType: "video/webm"
|
||||
});
|
||||
}
|
||||
|
||||
return promise.resolve(null);
|
||||
for (let i = 0, len = order.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=html", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "html",
|
||||
fullMimeType: "text/html; charset=utf-8"
|
||||
});
|
||||
}
|
||||
|
||||
// The test assumes that the first HTML request here has a longer response
|
||||
// body than the other HTML requests performed later during the test.
|
||||
let requests = Cu.cloneInto(REQUESTS_WITH_MEDIA, {});
|
||||
|
||||
let newres = "res=<p>" + new Array(10).join(Math.random(10)) + "</p>";
|
||||
requests[0].url = requests[0].url.replace("res=undefined", newres);
|
||||
|
||||
loadCommonFrameScript();
|
||||
performRequestsInContent(requests);
|
||||
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = order.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=css", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "css",
|
||||
fullMimeType: "text/css; charset=utf-8"
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = order.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len * 2]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=js", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "js",
|
||||
fullMimeType: "application/javascript; charset=utf-8"
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = order.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len * 3]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=font", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "woff",
|
||||
fullMimeType: "font/woff"
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = order.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len * 4]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=image", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "png",
|
||||
fullMimeType: "image/png"
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = order.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len * 5]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=audio", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "ogg",
|
||||
fullMimeType: "audio/ogg"
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = order.length / 7; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len * 6]),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=video", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "webm",
|
||||
fullMimeType: "video/webm"
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,8 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if invalid filter types are sanitized when loaded from the preferences.
|
||||
*/
|
||||
@ -27,38 +29,35 @@ const REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS = REQUESTS_WITH_MEDIA_AND_FLASH.conca
|
||||
{ url: "sjs_content-type-test-server.sjs?fmt=ws" },
|
||||
]);
|
||||
|
||||
function test() {
|
||||
add_task(function* () {
|
||||
Services.prefs.setCharPref("devtools.netmonitor.filters", '["js", "bogus"]');
|
||||
|
||||
initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
let { monitor } = yield initNetMonitor(FILTERING_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { Prefs, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { Prefs, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
is(Prefs.filters.length, 2,
|
||||
"All filter types were loaded as an array from the preferences.");
|
||||
is(Prefs.filters[0], "js",
|
||||
"The first filter type is correct.");
|
||||
is(Prefs.filters[1], "bogus",
|
||||
"The second filter type is invalid, but loaded anyway.");
|
||||
is(Prefs.filters.length, 2,
|
||||
"All filter types were loaded as an array from the preferences.");
|
||||
is(Prefs.filters[0], "js",
|
||||
"The first filter type is correct.");
|
||||
is(Prefs.filters[1], "bogus",
|
||||
"The second filter type is invalid, but loaded anyway.");
|
||||
|
||||
waitForNetworkEvents(aMonitor, 9).then(() => {
|
||||
testFilterButtons(aMonitor, "js");
|
||||
ok(true, "Only the correct filter type was taken into consideration.");
|
||||
let wait = waitForNetworkEvents(monitor, 9);
|
||||
loadCommonFrameScript();
|
||||
yield performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS);
|
||||
yield wait;
|
||||
|
||||
teardown(aMonitor).then(() => {
|
||||
let filters = Services.prefs.getCharPref("devtools.netmonitor.filters");
|
||||
is(filters, '["js"]',
|
||||
"The bogus filter type was ignored and removed from the preferences.");
|
||||
testFilterButtons(monitor, "js");
|
||||
ok(true, "Only the correct filter type was taken into consideration.");
|
||||
|
||||
finish();
|
||||
});
|
||||
});
|
||||
yield teardown(monitor);
|
||||
|
||||
loadCommonFrameScript();
|
||||
performRequestsInContent(REQUESTS_WITH_MEDIA_AND_FLASH_AND_WS);
|
||||
});
|
||||
}
|
||||
let filters = Services.prefs.getCharPref("devtools.netmonitor.filters");
|
||||
is(filters, '["js"]',
|
||||
"The bogus filter type was ignored and removed from the preferences.");
|
||||
});
|
||||
|
@ -1,116 +1,74 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test if the summary text displayed in the network requests menu footer
|
||||
* is correct.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
add_task(function* () {
|
||||
requestLongerTimeout(2);
|
||||
let { PluralForm } = Cu.import("resource://gre/modules/PluralForm.jsm", {});
|
||||
let { PluralForm } = require("devtools/shared/plural-form");
|
||||
|
||||
initNetMonitor(FILTERING_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
let { tab, monitor } = yield initNetMonitor(FILTERING_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { $, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { $, L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
testStatus();
|
||||
|
||||
for (let i = 0; i < 2; i++) {
|
||||
info(`Performing requests in batch #${i}`);
|
||||
let wait = waitForNetworkEvents(monitor, 8);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests('{ "getMedia": true, "getFlash": true }');
|
||||
});
|
||||
yield wait;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
testStatus();
|
||||
|
||||
waitForNetworkEvents(aMonitor, 8).then(() => {
|
||||
let buttons = ["html", "css", "js", "xhr", "fonts", "images", "media", "flash"];
|
||||
for (let button of buttons) {
|
||||
let buttonEl = $(`#requests-menu-filter-${button}-button`);
|
||||
EventUtils.sendMouseEvent({ type: "click" }, buttonEl);
|
||||
testStatus();
|
||||
}
|
||||
}
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
testStatus();
|
||||
yield teardown(monitor);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
|
||||
testStatus();
|
||||
function testStatus() {
|
||||
let summary = $("#requests-menu-network-summary-button");
|
||||
let value = summary.getAttribute("label");
|
||||
info("Current summary: " + value);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-js-button"));
|
||||
testStatus();
|
||||
let visibleItems = RequestsMenu.visibleItems;
|
||||
let visibleRequestsCount = visibleItems.length;
|
||||
let totalRequestsCount = RequestsMenu.itemCount;
|
||||
info("Current requests: " + visibleRequestsCount + " of " + totalRequestsCount + ".");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-xhr-button"));
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-fonts-button"));
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-images-button"));
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-media-button"));
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button"));
|
||||
testStatus();
|
||||
|
||||
info("Performing more requests.");
|
||||
aDebuggee.performRequests('{ "getMedia": true, "getFlash": true }');
|
||||
return waitForNetworkEvents(aMonitor, 8);
|
||||
})
|
||||
.then(() => {
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-html-button"));
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-css-button"));
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-js-button"));
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-xhr-button"));
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-fonts-button"));
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-images-button"));
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-media-button"));
|
||||
testStatus();
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-flash-button"));
|
||||
testStatus();
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
|
||||
function testStatus() {
|
||||
let summary = $("#requests-menu-network-summary-button");
|
||||
let value = summary.getAttribute("label");
|
||||
info("Current summary: " + value);
|
||||
|
||||
let visibleItems = RequestsMenu.visibleItems;
|
||||
let visibleRequestsCount = visibleItems.length;
|
||||
let totalRequestsCount = RequestsMenu.itemCount;
|
||||
info("Current requests: " + visibleRequestsCount + " of " + totalRequestsCount + ".");
|
||||
|
||||
if (!totalRequestsCount || !visibleRequestsCount) {
|
||||
is(value, L10N.getStr("networkMenu.empty"),
|
||||
"The current summary text is incorrect, expected an 'empty' label.");
|
||||
return;
|
||||
}
|
||||
|
||||
let totalBytes = RequestsMenu._getTotalBytesOfRequests(visibleItems);
|
||||
let totalMillis =
|
||||
RequestsMenu._getNewestRequest(visibleItems).attachment.endedMillis -
|
||||
RequestsMenu._getOldestRequest(visibleItems).attachment.startedMillis;
|
||||
|
||||
info("Computed total bytes: " + totalBytes);
|
||||
info("Computed total millis: " + totalMillis);
|
||||
|
||||
is(value, PluralForm.get(visibleRequestsCount, L10N.getStr("networkMenu.summary"))
|
||||
.replace("#1", visibleRequestsCount)
|
||||
.replace("#2", L10N.numberWithDecimals((totalBytes || 0) / 1024, 2))
|
||||
.replace("#3", L10N.numberWithDecimals((totalMillis || 0) / 1000, 2))
|
||||
, "The current summary text is incorrect.");
|
||||
if (!totalRequestsCount || !visibleRequestsCount) {
|
||||
is(value, L10N.getStr("networkMenu.empty"),
|
||||
"The current summary text is incorrect, expected an 'empty' label.");
|
||||
return;
|
||||
}
|
||||
|
||||
aDebuggee.performRequests('{ "getMedia": true, "getFlash": true }');
|
||||
});
|
||||
}
|
||||
let totalBytes = RequestsMenu._getTotalBytesOfRequests(visibleItems);
|
||||
let totalMillis =
|
||||
RequestsMenu._getNewestRequest(visibleItems).attachment.endedMillis -
|
||||
RequestsMenu._getOldestRequest(visibleItems).attachment.startedMillis;
|
||||
|
||||
info("Computed total bytes: " + totalBytes);
|
||||
info("Computed total millis: " + totalMillis);
|
||||
|
||||
is(value, PluralForm.get(visibleRequestsCount, L10N.getStr("networkMenu.summary"))
|
||||
.replace("#1", visibleRequestsCount)
|
||||
.replace("#2", L10N.numberWithDecimals((totalBytes || 0) / 1024, 2))
|
||||
.replace("#3", L10N.numberWithDecimals((totalMillis || 0) / 1000, 2))
|
||||
, "The current summary text is incorrect.");
|
||||
}
|
||||
});
|
||||
|
@ -153,7 +153,7 @@ add_task(function* () {
|
||||
// all the requests the page is making, not only the XHRs.
|
||||
// We can't use about:blank here, because initNetMonitor checks that the
|
||||
// page has actually made at least one request.
|
||||
let [ tab, , monitor ] = yield initNetMonitor(SIMPLE_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
@ -1,60 +1,62 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if html responses show and properly populate a "Preview" tab.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CONTENT_TYPE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CONTENT_TYPE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { $, document, EVENTS, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { $, document, EVENTS, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 6).then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
|
||||
is($("#event-details-pane").selectedIndex, 0,
|
||||
"The first tab in the details pane should be selected.");
|
||||
is($("#preview-tab").hidden, true,
|
||||
"The preview tab should be hidden for non html responses.");
|
||||
is($("#preview-tabpanel").hidden, false,
|
||||
"The preview tabpanel is not hidden for non html responses.");
|
||||
|
||||
RequestsMenu.selectedIndex = 4;
|
||||
NetMonitorView.toggleDetailsPane({ visible: true, animated: false }, 6);
|
||||
|
||||
is($("#event-details-pane").selectedIndex, 6,
|
||||
"The sixth tab in the details pane should be selected.");
|
||||
is($("#preview-tab").hidden, false,
|
||||
"The preview tab should be visible now.");
|
||||
|
||||
waitFor(aMonitor.panelWin, EVENTS.RESPONSE_HTML_PREVIEW_DISPLAYED).then(() => {
|
||||
let iframe = $("#response-preview");
|
||||
ok(iframe,
|
||||
"There should be a response preview iframe available.");
|
||||
ok(iframe.contentDocument,
|
||||
"The iframe's content document should be available.");
|
||||
is(iframe.contentDocument.querySelector("blink").textContent, "Not Found",
|
||||
"The iframe's content document should be loaded and correct.");
|
||||
|
||||
RequestsMenu.selectedIndex = 5;
|
||||
|
||||
is($("#event-details-pane").selectedIndex, 0,
|
||||
"The first tab in the details pane should be selected again.");
|
||||
is($("#preview-tab").hidden, true,
|
||||
"The preview tab should be hidden again for non html responses.");
|
||||
is($("#preview-tabpanel").hidden, false,
|
||||
"The preview tabpanel is not hidden again for non html responses.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
let wait = waitForNetworkEvents(monitor, 6);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
|
||||
is($("#event-details-pane").selectedIndex, 0,
|
||||
"The first tab in the details pane should be selected.");
|
||||
is($("#preview-tab").hidden, true,
|
||||
"The preview tab should be hidden for non html responses.");
|
||||
is($("#preview-tabpanel").hidden, false,
|
||||
"The preview tabpanel is not hidden for non html responses.");
|
||||
|
||||
RequestsMenu.selectedIndex = 4;
|
||||
NetMonitorView.toggleDetailsPane({ visible: true, animated: false }, 6);
|
||||
|
||||
is($("#event-details-pane").selectedIndex, 6,
|
||||
"The sixth tab in the details pane should be selected.");
|
||||
is($("#preview-tab").hidden, false,
|
||||
"The preview tab should be visible now.");
|
||||
|
||||
yield monitor.panelWin.once(EVENTS.RESPONSE_HTML_PREVIEW_DISPLAYED);
|
||||
let iframe = $("#response-preview");
|
||||
ok(iframe,
|
||||
"There should be a response preview iframe available.");
|
||||
ok(iframe.contentDocument,
|
||||
"The iframe's content document should be available.");
|
||||
is(iframe.contentDocument.querySelector("blink").textContent, "Not Found",
|
||||
"The iframe's content document should be loaded and correct.");
|
||||
|
||||
RequestsMenu.selectedIndex = 5;
|
||||
|
||||
is($("#event-details-pane").selectedIndex, 0,
|
||||
"The first tab in the details pane should be selected again.");
|
||||
is($("#preview-tab").hidden, true,
|
||||
"The preview tab should be hidden again for non html responses.");
|
||||
is($("#preview-tabpanel").hidden, false,
|
||||
"The preview tabpanel is not hidden again for non html responses.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,61 +1,69 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if image responses show a thumbnail in the requests menu.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { $, $all, EVENTS, ACTIVITY_TYPE, NetMonitorView, NetMonitorController } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { $, $all, EVENTS, ACTIVITY_TYPE, NetMonitorView, NetMonitorController } =
|
||||
monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
promise.all([
|
||||
waitForNetworkEvents(aMonitor, 7),
|
||||
waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED)
|
||||
]).then(() => {
|
||||
info("Checking the image thumbnail when all items are shown.");
|
||||
checkImageThumbnail();
|
||||
let wait = waitForEvents();
|
||||
yield performRequests();
|
||||
yield wait;
|
||||
|
||||
RequestsMenu.sortBy("size");
|
||||
info("Checking the image thumbnail when all items are sorted.");
|
||||
checkImageThumbnail();
|
||||
info("Checking the image thumbnail when all items are shown.");
|
||||
checkImageThumbnail();
|
||||
|
||||
RequestsMenu.filterOn("images");
|
||||
info("Checking the image thumbnail when only images are shown.");
|
||||
checkImageThumbnail();
|
||||
RequestsMenu.sortBy("size");
|
||||
info("Checking the image thumbnail when all items are sorted.");
|
||||
checkImageThumbnail();
|
||||
|
||||
info("Reloading the debuggee and performing all requests again...");
|
||||
reloadAndPerformRequests();
|
||||
RequestsMenu.filterOn("images");
|
||||
info("Checking the image thumbnail when only images are shown.");
|
||||
checkImageThumbnail();
|
||||
|
||||
return promise.all([
|
||||
waitForNetworkEvents(aMonitor, 7), // 6 + 1
|
||||
waitFor(aMonitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED)
|
||||
]);
|
||||
}).then(() => {
|
||||
info("Checking the image thumbnail after a reload.");
|
||||
checkImageThumbnail();
|
||||
info("Reloading the debuggee and performing all requests again...");
|
||||
wait = waitForEvents();
|
||||
yield reloadAndPerformRequests();
|
||||
yield wait;
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
info("Checking the image thumbnail after a reload.");
|
||||
checkImageThumbnail();
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
function waitForEvents() {
|
||||
return promise.all([
|
||||
waitForNetworkEvents(monitor, 7),
|
||||
monitor.panelWin.once(EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED)
|
||||
]);
|
||||
}
|
||||
|
||||
function performRequests() {
|
||||
return ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
|
||||
function reloadAndPerformRequests() {
|
||||
NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED).then(() => {
|
||||
aDebuggee.performRequests();
|
||||
});
|
||||
}
|
||||
function* reloadAndPerformRequests() {
|
||||
yield NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED);
|
||||
yield performRequests();
|
||||
}
|
||||
|
||||
function checkImageThumbnail() {
|
||||
is($all(".requests-menu-icon[type=thumbnail]").length, 1,
|
||||
"There should be only one image request with a thumbnail displayed.");
|
||||
is($(".requests-menu-icon[type=thumbnail]").src, TEST_IMAGE_DATA_URI,
|
||||
"The image requests-menu-icon thumbnail is displayed correctly.");
|
||||
is($(".requests-menu-icon[type=thumbnail]").hidden, false,
|
||||
"The image requests-menu-icon thumbnail should not be hidden.");
|
||||
}
|
||||
|
||||
aDebuggee.performRequests();
|
||||
});
|
||||
}
|
||||
function checkImageThumbnail() {
|
||||
is($all(".requests-menu-icon[type=thumbnail]").length, 1,
|
||||
"There should be only one image request with a thumbnail displayed.");
|
||||
is($(".requests-menu-icon[type=thumbnail]").src, TEST_IMAGE_DATA_URI,
|
||||
"The image requests-menu-icon thumbnail is displayed correctly.");
|
||||
is($(".requests-menu-icon[type=thumbnail]").hidden, false,
|
||||
"The image requests-menu-icon thumbnail should not be hidden.");
|
||||
}
|
||||
});
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Tests if image responses show a popup in the requests menu when hovered.
|
||||
*/
|
||||
add_task(function* test() {
|
||||
let [, debuggee, monitor] = yield initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(CONTENT_TYPE_WITHOUT_CACHE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { $, EVENTS, ACTIVITY_TYPE, NetMonitorView, NetMonitorController } =
|
||||
@ -16,9 +16,9 @@ add_task(function* test() {
|
||||
RequestsMenu.lazyUpdate = true;
|
||||
|
||||
let onEvents = waitForNetworkEvents(monitor, 7);
|
||||
let onThumbnail = waitFor(monitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED);
|
||||
let onThumbnail = monitor.panelWin.once(EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED);
|
||||
|
||||
debuggee.performRequests();
|
||||
yield performRequests();
|
||||
yield onEvents;
|
||||
yield onThumbnail;
|
||||
|
||||
@ -27,11 +27,11 @@ add_task(function* test() {
|
||||
|
||||
// 7 XHRs as before + 1 extra document reload
|
||||
onEvents = waitForNetworkEvents(monitor, 8);
|
||||
onThumbnail = waitFor(monitor.panelWin, EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED);
|
||||
onThumbnail = monitor.panelWin.once(EVENTS.RESPONSE_IMAGE_THUMBNAIL_DISPLAYED);
|
||||
|
||||
info("Reloading the debuggee and performing all requests again...");
|
||||
yield NetMonitorController.triggerActivity(ACTIVITY_TYPE.RELOAD.WITH_CACHE_ENABLED);
|
||||
debuggee.performRequests();
|
||||
yield performRequests();
|
||||
yield onEvents;
|
||||
yield onThumbnail;
|
||||
|
||||
@ -45,7 +45,12 @@ add_task(function* test() {
|
||||
yield onHidden;
|
||||
|
||||
yield teardown(monitor);
|
||||
finish();
|
||||
|
||||
function performRequests() {
|
||||
return ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a tooltip on the {requestItem} and verify that it was displayed
|
||||
|
@ -1,91 +1,96 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if very long JSON responses are handled correctly.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(JSON_LONG_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(JSON_LONG_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
// This is receiving over 80 KB of json and will populate over 6000 items
|
||||
// in a variables view instance. Debug builds are slow.
|
||||
requestLongerTimeout(4);
|
||||
// This is receiving over 80 KB of json and will populate over 6000 items
|
||||
// in a variables view instance. Debug builds are slow.
|
||||
requestLongerTimeout(4);
|
||||
|
||||
let { document, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { document, EVENTS, L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json-long", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "text/json; charset=utf-8",
|
||||
size: L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(85975 / 1024, 2)),
|
||||
time: true
|
||||
});
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
yield wait;
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED, () => {
|
||||
testResponseTab();
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
|
||||
function testResponseTab() {
|
||||
let tab = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 json scope displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-property").length, 6143,
|
||||
"There should be 6143 json properties displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
let names = ".variables-view-property > .title > .name";
|
||||
let values = ".variables-view-property > .title > .value";
|
||||
|
||||
is(jsonScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("jsonScopeName"),
|
||||
"The json scope doesn't have the correct title.");
|
||||
|
||||
is(jsonScope.querySelectorAll(names)[0].getAttribute("value"),
|
||||
"0", "The first json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(values)[0].getAttribute("value"),
|
||||
"Object", "The first json property value was incorrect.");
|
||||
|
||||
is(jsonScope.querySelectorAll(names)[1].getAttribute("value"),
|
||||
"greeting", "The second json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(values)[1].getAttribute("value"),
|
||||
"\"Hello long string JSON!\"", "The second json property value was incorrect.");
|
||||
}
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json-long", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "text/json; charset=utf-8",
|
||||
size: L10N.getFormatStr("networkMenu.sizeKB",
|
||||
L10N.numberWithDecimals(85975 / 1024, 2)),
|
||||
time: true
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
});
|
||||
}
|
||||
let onEvent = monitor.panelWin.once(EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
yield onEvent;
|
||||
|
||||
testResponseTab();
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
function testResponseTab() {
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 json scope displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-property").length, 6143,
|
||||
"There should be 6143 json properties displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
let names = ".variables-view-property > .title > .name";
|
||||
let values = ".variables-view-property > .title > .value";
|
||||
|
||||
is(jsonScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("jsonScopeName"),
|
||||
"The json scope doesn't have the correct title.");
|
||||
|
||||
is(jsonScope.querySelectorAll(names)[0].getAttribute("value"),
|
||||
"0", "The first json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(values)[0].getAttribute("value"),
|
||||
"Object", "The first json property value was incorrect.");
|
||||
|
||||
is(jsonScope.querySelectorAll(names)[1].getAttribute("value"),
|
||||
"greeting", "The second json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(values)[1].getAttribute("value"),
|
||||
"\"Hello long string JSON!\"", "The second json property value was incorrect.");
|
||||
}
|
||||
});
|
||||
|
@ -1,74 +1,77 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if malformed JSON responses are handled correctly.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(JSON_MALFORMED_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(JSON_MALFORMED_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { document, EVENTS, Editor, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json-malformed", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "text/json; charset=utf-8"
|
||||
});
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
yield wait;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
|
||||
let tab = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED;
|
||||
waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED).then(() => {
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.getAttribute("value"),
|
||||
"SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 40 of the JSON data",
|
||||
"The response info header doesn't have the intended value attribute.");
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.getAttribute("tooltiptext"),
|
||||
"SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 40 of the JSON data",
|
||||
"The response info header doesn't have the intended tooltiptext attribute.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
|
||||
NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), "{ \"greeting\": \"Hello malformed JSON!\" },",
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), Editor.modes.js,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json-malformed", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "text/json; charset=utf-8"
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
});
|
||||
}
|
||||
let onEvent = monitor.panelWin.once(EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
yield onEvent;
|
||||
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.getAttribute("value"),
|
||||
"SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data" +
|
||||
" at line 1 column 40 of the JSON data",
|
||||
"The response info header doesn't have the intended value attribute.");
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.getAttribute("tooltiptext"),
|
||||
"SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data" +
|
||||
" at line 1 column 40 of the JSON data",
|
||||
"The response info header doesn't have the intended tooltiptext attribute.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
|
||||
let editor = yield NetMonitorView.editor("#response-content-textarea");
|
||||
is(editor.getText(), "{ \"greeting\": \"Hello malformed JSON!\" },",
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(editor.getMode(), Editor.modes.js,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -1,81 +1,88 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if JSON responses with unusal/custom MIME types are handled correctly.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(JSON_CUSTOM_MIME_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(JSON_CUSTOM_MIME_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { document, EVENTS, L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json-custom-mime", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "x-bigcorp-json",
|
||||
fullMimeType: "text/x-bigcorp-json; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 41),
|
||||
time: true
|
||||
});
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
yield wait;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
|
||||
let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED;
|
||||
waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED)
|
||||
.then(testResponseTab)
|
||||
.then(() => teardown(aMonitor))
|
||||
.then(finish);
|
||||
|
||||
function testResponseTab() {
|
||||
let tab = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 json scope displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-property").length, 2,
|
||||
"There should be 2 json properties displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"),
|
||||
"greeting", "The first json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"),
|
||||
"\"Hello oddly-named JSON!\"", "The first json property value was incorrect.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"),
|
||||
"__proto__", "The second json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"),
|
||||
"Object", "The second json property value was incorrect.");
|
||||
}
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json-custom-mime", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "x-bigcorp-json",
|
||||
fullMimeType: "text/x-bigcorp-json; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 41),
|
||||
time: true
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
});
|
||||
}
|
||||
let onEvent = monitor.panelWin.once(EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
yield onEvent;
|
||||
|
||||
testResponseTab();
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
function testResponseTab() {
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 json scope displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-property").length, 2,
|
||||
"There should be 2 json properties displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[0]
|
||||
.getAttribute("value"),
|
||||
"greeting", "The first json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[0]
|
||||
.getAttribute("value"),
|
||||
"\"Hello oddly-named JSON!\"", "The first json property value was incorrect.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[1]
|
||||
.getAttribute("value"),
|
||||
"__proto__", "The second json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[1]
|
||||
.getAttribute("value"),
|
||||
"Object", "The second json property value was incorrect.");
|
||||
}
|
||||
});
|
||||
|
@ -1,81 +1,88 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if JSON responses with unusal/custom MIME types are handled correctly.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(JSON_TEXT_MIME_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(JSON_TEXT_MIME_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { document, EVENTS, L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json-text-mime", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 41),
|
||||
time: true
|
||||
});
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
yield wait;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
|
||||
let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED;
|
||||
waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED)
|
||||
.then(testResponseTab)
|
||||
.then(() => teardown(aMonitor))
|
||||
.then(finish);
|
||||
|
||||
function testResponseTab() {
|
||||
let tab = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 json scope displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-property").length, 2,
|
||||
"There should be 2 json properties displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"),
|
||||
"greeting", "The first json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"),
|
||||
"\"Hello third-party JSON!\"", "The first json property value was incorrect.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"),
|
||||
"__proto__", "The second json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"),
|
||||
"Object", "The second json property value was incorrect.");
|
||||
}
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json-text-mime", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 41),
|
||||
time: true
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
});
|
||||
}
|
||||
let onEvent = monitor.panelWin.once(EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
yield onEvent;
|
||||
|
||||
testResponseTab();
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
function testResponseTab() {
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 json scope displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-property").length, 2,
|
||||
"There should be 2 json properties displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[0]
|
||||
.getAttribute("value"),
|
||||
"greeting", "The first json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[0]
|
||||
.getAttribute("value"),
|
||||
"\"Hello third-party JSON!\"", "The first json property value was incorrect.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[1]
|
||||
.getAttribute("value"),
|
||||
"__proto__", "The second json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[1]
|
||||
.getAttribute("value"),
|
||||
"Object", "The second json property value was incorrect.");
|
||||
}
|
||||
});
|
||||
|
@ -1,105 +1,109 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if JSONP responses are handled correctly.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(JSONP_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(JSONP_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
let { document, EVENTS, L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
NetworkDetails._json.lazyEmpty = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
NetworkDetails._json.lazyEmpty = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 2).then(() => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=jsonp&jsonp=$_0123Fun", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "text/json; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 41),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=jsonp2&jsonp=$_4567Sad", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "text/json; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 54),
|
||||
time: true
|
||||
});
|
||||
let wait = waitForNetworkEvents(monitor, 2);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
yield wait;
|
||||
|
||||
Task.spawn(function* () {
|
||||
let RESPONSE_BODY_DISPLAYED = aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
|
||||
yield waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED);
|
||||
testResponseTab("$_0123Fun", "\"Hello JSONP!\"");
|
||||
|
||||
RequestsMenu.selectedIndex = 1;
|
||||
|
||||
yield waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED);
|
||||
testResponseTab("$_4567Sad", "\"Hello weird JSONP!\"");
|
||||
|
||||
yield teardown(aMonitor);
|
||||
finish();
|
||||
});
|
||||
|
||||
function testResponseTab(aFunction, aGreeting) {
|
||||
let tab = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 json scope displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-property").length, 2,
|
||||
"There should be 2 json properties displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
|
||||
is(jsonScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getFormatStr("jsonpScopeName", aFunction),
|
||||
"The json scope doesn't have the correct title.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"),
|
||||
"greeting", "The first json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"),
|
||||
aGreeting, "The first json property value was incorrect.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"),
|
||||
"__proto__", "The second json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"),
|
||||
"Object", "The second json property value was incorrect.");
|
||||
}
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=jsonp&jsonp=$_0123Fun", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "text/json; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 41),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=jsonp2&jsonp=$_4567Sad", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "text/json; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 54),
|
||||
time: true
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
});
|
||||
}
|
||||
let onEvent = monitor.panelWin.once(EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
yield onEvent;
|
||||
|
||||
testResponseTab("$_0123Fun", "\"Hello JSONP!\"");
|
||||
|
||||
onEvent = monitor.panelWin.once(EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
RequestsMenu.selectedIndex = 1;
|
||||
yield onEvent;
|
||||
|
||||
testResponseTab("$_4567Sad", "\"Hello weird JSONP!\"");
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
function testResponseTab(func, greeting) {
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content json box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content textarea box doesn't have the intended visibility.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box doesn't have the intended visibility.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 json scope displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-property").length, 2,
|
||||
"There should be 2 json properties displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
|
||||
is(jsonScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getFormatStr("jsonpScopeName", func),
|
||||
"The json scope doesn't have the correct title.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[0]
|
||||
.getAttribute("value"),
|
||||
"greeting", "The first json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[0]
|
||||
.getAttribute("value"),
|
||||
greeting, "The first json property value was incorrect.");
|
||||
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .name")[1]
|
||||
.getAttribute("value"),
|
||||
"__proto__", "The second json property name was incorrect.");
|
||||
is(jsonScope.querySelectorAll(".variables-view-property .value")[1]
|
||||
.getAttribute("value"),
|
||||
"Object", "The second json property value was incorrect.");
|
||||
}
|
||||
});
|
||||
|
@ -1,51 +1,55 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if very large response contents are just displayed as plain text.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
const HTML_LONG_URL = CONTENT_TYPE_SJS + "?fmt=html-long";
|
||||
|
||||
// This test could potentially be slow because over 100 KB of stuff
|
||||
// is going to be requested and displayed in the source editor.
|
||||
requestLongerTimeout(2);
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
// This test could potentially be slow because over 100 KB of stuff
|
||||
// is going to be requested and displayed in the source editor.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
let { document, EVENTS, Editor, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=html-long", {
|
||||
status: 200,
|
||||
statusText: "OK"
|
||||
});
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RESPONSE_BODY_DISPLAYED, () => {
|
||||
NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
ok(aEditor.getText().match(/^<p>/),
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, HTML_LONG_URL, function* (url) {
|
||||
content.wrappedJSObject.performRequests(1, url);
|
||||
});
|
||||
yield wait;
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
});
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=html-long", {
|
||||
status: 200,
|
||||
statusText: "OK"
|
||||
});
|
||||
|
||||
aDebuggee.performRequests(1, CONTENT_TYPE_SJS + "?fmt=html-long");
|
||||
});
|
||||
let onEvent = monitor.panelWin.once(EVENTS.RESPONSE_BODY_DISPLAYED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
yield onEvent;
|
||||
|
||||
let editor = yield NetMonitorView.editor("#response-content-textarea");
|
||||
ok(editor.getText().match(/^<p>/),
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(editor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
// This test uses a lot of memory, so force a GC to help fragmentation.
|
||||
info("Forcing GC after netmonitor test.");
|
||||
Cu.forceGC();
|
||||
}
|
||||
});
|
||||
|
@ -11,8 +11,7 @@ add_task(function* () {
|
||||
// Tell initNetMonitor to enable cache. Otherwise it will assert that there were more
|
||||
// than zero network requests during the page load. But when loading about:config,
|
||||
// there are none.
|
||||
let [,, monitor] = yield initNetMonitor("about:config", null, true);
|
||||
let { monitor } = yield initNetMonitor("about:config", null, true);
|
||||
ok(monitor, "The network monitor was opened");
|
||||
yield teardown(monitor);
|
||||
finish();
|
||||
});
|
||||
|
@ -1,40 +1,37 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if Open in new tab works.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
info("Starting test...");
|
||||
|
||||
initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test...");
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
let { NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
gBrowser.tabContainer.addEventListener("TabOpen", function onOpen(event) {
|
||||
ok(true, "A new tab has been opened ");
|
||||
gBrowser.tabContainer.removeEventListener("TabOpen", onOpen, false);
|
||||
cleanUp();
|
||||
}, false);
|
||||
|
||||
RequestsMenu.openRequestInTab();
|
||||
});
|
||||
|
||||
aDebuggee.performRequests(1);
|
||||
function cleanUp() {
|
||||
teardown(aMonitor).then(() => {
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
});
|
||||
}
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests(1);
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
RequestsMenu.selectedItem = requestItem;
|
||||
|
||||
let onTabOpen = once(gBrowser.tabContainer, "TabOpen", false);
|
||||
RequestsMenu.openRequestInTab();
|
||||
yield onTabOpen;
|
||||
|
||||
ok(true, "A new tab has been opened");
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
@ -1,68 +1,69 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if page navigation ("close", "navigate", etc.) triggers an appropriate
|
||||
* action in the network monitor.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
testNavigate(() => testNavigateBack(() => testClose(() => finish())));
|
||||
let { EVENTS } = monitor.panelWin;
|
||||
|
||||
function testNavigate(aCallback) {
|
||||
info("Navigating forward...");
|
||||
yield testNavigate();
|
||||
yield testNavigateBack();
|
||||
yield testClose();
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => {
|
||||
is(aDebuggee.location, SIMPLE_URL,
|
||||
"Target started navigating to the correct location.");
|
||||
function* testNavigate() {
|
||||
info("Navigating forward...");
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => {
|
||||
is(aDebuggee.location, NAVIGATE_URL,
|
||||
"Target finished navigating to the correct location.");
|
||||
let onWillNav = monitor.panelWin.once(EVENTS.TARGET_WILL_NAVIGATE);
|
||||
let onDidNav = monitor.panelWin.once(EVENTS.TARGET_DID_NAVIGATE);
|
||||
|
||||
aCallback();
|
||||
});
|
||||
});
|
||||
tab.linkedBrowser.loadURI(NAVIGATE_URL);
|
||||
yield onWillNav;
|
||||
|
||||
aDebuggee.location = NAVIGATE_URL;
|
||||
}
|
||||
is(tab.linkedBrowser.currentURI.spec, SIMPLE_URL,
|
||||
"Target started navigating to the correct location.");
|
||||
|
||||
function testNavigateBack(aCallback) {
|
||||
info("Navigating backward...");
|
||||
yield onDidNav;
|
||||
is(tab.linkedBrowser.currentURI.spec, NAVIGATE_URL,
|
||||
"Target finished navigating to the correct location.");
|
||||
}
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_WILL_NAVIGATE, () => {
|
||||
is(aDebuggee.location, NAVIGATE_URL,
|
||||
"Target started navigating back to the previous location.");
|
||||
function* testNavigateBack() {
|
||||
info("Navigating backward...");
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.TARGET_DID_NAVIGATE, () => {
|
||||
is(aDebuggee.location, SIMPLE_URL,
|
||||
"Target finished navigating back to the previous location.");
|
||||
let onWillNav = monitor.panelWin.once(EVENTS.TARGET_WILL_NAVIGATE);
|
||||
let onDidNav = monitor.panelWin.once(EVENTS.TARGET_DID_NAVIGATE);
|
||||
|
||||
aCallback();
|
||||
});
|
||||
});
|
||||
tab.linkedBrowser.loadURI(SIMPLE_URL);
|
||||
yield onWillNav;
|
||||
|
||||
aDebuggee.location = SIMPLE_URL;
|
||||
}
|
||||
is(tab.linkedBrowser.currentURI.spec, NAVIGATE_URL,
|
||||
"Target started navigating back to the previous location.");
|
||||
|
||||
function testClose(aCallback) {
|
||||
info("Closing...");
|
||||
yield onDidNav;
|
||||
is(tab.linkedBrowser.currentURI.spec, SIMPLE_URL,
|
||||
"Target finished navigating back to the previous location.");
|
||||
}
|
||||
|
||||
aMonitor.once("destroyed", () => {
|
||||
ok(!aMonitor._controller.client,
|
||||
"There shouldn't be a client available after destruction.");
|
||||
ok(!aMonitor._controller.tabClient,
|
||||
"There shouldn't be a tabClient available after destruction.");
|
||||
ok(!aMonitor._controller.webConsoleClient,
|
||||
"There shouldn't be a webConsoleClient available after destruction.");
|
||||
function* testClose() {
|
||||
info("Closing...");
|
||||
|
||||
aCallback();
|
||||
});
|
||||
let onDestroyed = monitor.once("destroyed");
|
||||
removeTab(tab);
|
||||
yield onDestroyed;
|
||||
|
||||
removeTab(aTab);
|
||||
}
|
||||
});
|
||||
}
|
||||
ok(!monitor._controller.client,
|
||||
"There shouldn't be a client available after destruction.");
|
||||
ok(!monitor._controller.tabClient,
|
||||
"There shouldn't be a tabClient available after destruction.");
|
||||
ok(!monitor._controller.webConsoleClient,
|
||||
"There shouldn't be a webConsoleClient available after destruction.");
|
||||
}
|
||||
});
|
||||
|
@ -1,66 +1,67 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if the network monitor panes collapse properly.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, Prefs, NetMonitorView } = aMonitor.panelWin;
|
||||
let detailsPane = document.getElementById("details-pane");
|
||||
let detailsPaneToggleButton = document.getElementById("details-pane-toggle");
|
||||
let { document, Prefs, NetMonitorView } = monitor.panelWin;
|
||||
let detailsPane = document.getElementById("details-pane");
|
||||
let detailsPaneToggleButton = document.getElementById("details-pane-toggle");
|
||||
|
||||
ok(detailsPane.classList.contains("pane-collapsed") &&
|
||||
detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should initially be hidden.");
|
||||
ok(detailsPane.classList.contains("pane-collapsed") &&
|
||||
detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should initially be hidden.");
|
||||
|
||||
NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
|
||||
NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
|
||||
|
||||
let width = ~~(detailsPane.getAttribute("width"));
|
||||
is(width, Prefs.networkDetailsWidth,
|
||||
"The details pane has an incorrect width.");
|
||||
is(detailsPane.style.marginLeft, "0px",
|
||||
"The details pane has an incorrect left margin.");
|
||||
is(detailsPane.style.marginRight, "0px",
|
||||
"The details pane has an incorrect right margin.");
|
||||
ok(!detailsPane.hasAttribute("animated"),
|
||||
"The details pane has an incorrect animated attribute.");
|
||||
ok(!detailsPane.classList.contains("pane-collapsed") &&
|
||||
!detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should at this point be visible.");
|
||||
let width = ~~(detailsPane.getAttribute("width"));
|
||||
is(width, Prefs.networkDetailsWidth,
|
||||
"The details pane has an incorrect width.");
|
||||
is(detailsPane.style.marginLeft, "0px",
|
||||
"The details pane has an incorrect left margin.");
|
||||
is(detailsPane.style.marginRight, "0px",
|
||||
"The details pane has an incorrect right margin.");
|
||||
ok(!detailsPane.hasAttribute("animated"),
|
||||
"The details pane has an incorrect animated attribute.");
|
||||
ok(!detailsPane.classList.contains("pane-collapsed") &&
|
||||
!detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should at this point be visible.");
|
||||
|
||||
NetMonitorView.toggleDetailsPane({ visible: false, animated: true });
|
||||
NetMonitorView.toggleDetailsPane({ visible: false, animated: true });
|
||||
|
||||
let margin = -(width + 1) + "px";
|
||||
is(width, Prefs.networkDetailsWidth,
|
||||
"The details pane has an incorrect width after collapsing.");
|
||||
is(detailsPane.style.marginLeft, margin,
|
||||
"The details pane has an incorrect left margin after collapsing.");
|
||||
is(detailsPane.style.marginRight, margin,
|
||||
"The details pane has an incorrect right margin after collapsing.");
|
||||
ok(detailsPane.hasAttribute("animated"),
|
||||
"The details pane has an incorrect attribute after an animated collapsing.");
|
||||
ok(detailsPane.classList.contains("pane-collapsed") &&
|
||||
detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should not be visible after collapsing.");
|
||||
let margin = -(width + 1) + "px";
|
||||
is(width, Prefs.networkDetailsWidth,
|
||||
"The details pane has an incorrect width after collapsing.");
|
||||
is(detailsPane.style.marginLeft, margin,
|
||||
"The details pane has an incorrect left margin after collapsing.");
|
||||
is(detailsPane.style.marginRight, margin,
|
||||
"The details pane has an incorrect right margin after collapsing.");
|
||||
ok(detailsPane.hasAttribute("animated"),
|
||||
"The details pane has an incorrect attribute after an animated collapsing.");
|
||||
ok(detailsPane.classList.contains("pane-collapsed") &&
|
||||
detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should not be visible after collapsing.");
|
||||
|
||||
NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
|
||||
NetMonitorView.toggleDetailsPane({ visible: true, animated: false });
|
||||
|
||||
is(width, Prefs.networkDetailsWidth,
|
||||
"The details pane has an incorrect width after uncollapsing.");
|
||||
is(detailsPane.style.marginLeft, "0px",
|
||||
"The details pane has an incorrect left margin after uncollapsing.");
|
||||
is(detailsPane.style.marginRight, "0px",
|
||||
"The details pane has an incorrect right margin after uncollapsing.");
|
||||
ok(!detailsPane.hasAttribute("animated"),
|
||||
"The details pane has an incorrect attribute after an unanimated uncollapsing.");
|
||||
ok(!detailsPane.classList.contains("pane-collapsed") &&
|
||||
!detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should be visible again after uncollapsing.");
|
||||
is(width, Prefs.networkDetailsWidth,
|
||||
"The details pane has an incorrect width after uncollapsing.");
|
||||
is(detailsPane.style.marginLeft, "0px",
|
||||
"The details pane has an incorrect left margin after uncollapsing.");
|
||||
is(detailsPane.style.marginRight, "0px",
|
||||
"The details pane has an incorrect right margin after uncollapsing.");
|
||||
ok(!detailsPane.hasAttribute("animated"),
|
||||
"The details pane has an incorrect attribute after an unanimated uncollapsing.");
|
||||
ok(!detailsPane.classList.contains("pane-collapsed") &&
|
||||
!detailsPaneToggleButton.classList.contains("pane-collapsed"),
|
||||
"The details pane should be visible again after uncollapsing.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
}
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
let [tab, , monitor] = yield initNetMonitor(SIMPLE_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { $, NetMonitorView } = monitor.panelWin;
|
||||
@ -29,9 +29,7 @@ add_task(function* () {
|
||||
"There should be no selected item in the requests menu.");
|
||||
|
||||
let networkEvent = monitor.panelWin.once(NETWORK_EVENT);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.location.reload();
|
||||
});
|
||||
tab.linkedBrowser.reload();
|
||||
yield networkEvent;
|
||||
|
||||
is(toggleButton.hasAttribute("disabled"), false,
|
||||
|
@ -1,53 +1,51 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if the network monitor leaks on initialization and sudden destruction.
|
||||
* You can also use this initialization format as a template for other tests.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
let monitor, reqMenu;
|
||||
initNetMonitor(SINGLE_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(SINGLE_GET_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
monitor = aMonitor;
|
||||
let { document, NetMonitorView, NetMonitorController } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
reqMenu = RequestsMenu;
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
Services.prefs.setBoolPref("devtools.webconsole.persistlog", false);
|
||||
content.location.reload(true);
|
||||
})
|
||||
.then(() => {
|
||||
return waitForNetworkEvents(monitor, 2);
|
||||
})
|
||||
.then(() => {
|
||||
is(reqMenu.itemCount, 2,
|
||||
"The request menu should have two items at this point.");
|
||||
})
|
||||
.then(() => {
|
||||
content.location.reload(true);
|
||||
return waitForNetworkEvents(monitor, 2);
|
||||
})
|
||||
.then(() => {
|
||||
// Since the reload clears the log, we still expect two requests in the log
|
||||
is(reqMenu.itemCount, 2,
|
||||
"The request menu should still have two items at this point.");
|
||||
})
|
||||
.then(() => {
|
||||
// Now we toggle the persistence logs on
|
||||
Services.prefs.setBoolPref("devtools.webconsole.persistlog", true);
|
||||
content.location.reload(true);
|
||||
return waitForNetworkEvents(monitor, 2);
|
||||
})
|
||||
.then(() => {
|
||||
// Since we togged the persistence logs, we expect four items after the reload
|
||||
is(reqMenu.itemCount, 4,
|
||||
"The request menu should now have four items at this point.");
|
||||
})
|
||||
.then(() => {
|
||||
Services.prefs.setBoolPref("devtools.webconsole.persistlog", false);
|
||||
return teardown(monitor).then(finish);
|
||||
});
|
||||
}
|
||||
Services.prefs.setBoolPref("devtools.webconsole.persistlog", false);
|
||||
|
||||
yield reloadAndWait();
|
||||
|
||||
is(RequestsMenu.itemCount, 2,
|
||||
"The request menu should have two items at this point.");
|
||||
|
||||
yield reloadAndWait();
|
||||
|
||||
// Since the reload clears the log, we still expect two requests in the log
|
||||
is(RequestsMenu.itemCount, 2,
|
||||
"The request menu should still have two items at this point.");
|
||||
|
||||
// Now we toggle the persistence logs on
|
||||
Services.prefs.setBoolPref("devtools.webconsole.persistlog", true);
|
||||
|
||||
yield reloadAndWait();
|
||||
|
||||
// Since we togged the persistence logs, we expect four items after the reload
|
||||
is(RequestsMenu.itemCount, 4,
|
||||
"The request menu should now have four items at this point.");
|
||||
|
||||
Services.prefs.setBoolPref("devtools.webconsole.persistlog", false);
|
||||
return teardown(monitor);
|
||||
|
||||
/**
|
||||
* Reload the page and wait for 2 GET requests. Race-free.
|
||||
*/
|
||||
function reloadAndWait() {
|
||||
let wait = waitForNetworkEvents(monitor, 2);
|
||||
tab.linkedBrowser.reload();
|
||||
return wait;
|
||||
}
|
||||
});
|
||||
|
@ -1,153 +1,164 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if the POST requests display the correct information in the UI.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(POST_DATA_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(POST_DATA_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
let { document, EVENTS, L10N, Editor, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
NetworkDetails._params.lazyEmpty = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
NetworkDetails._params.lazyEmpty = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 0, 2).then(() => {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"POST", SIMPLE_SJS + "?foo=bar&baz=42&type=urlencoded", {
|
||||
status: 200,
|
||||
statusText: "Och Aye",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 12),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1),
|
||||
"POST", SIMPLE_SJS + "?foo=bar&baz=42&type=multipart", {
|
||||
status: 200,
|
||||
statusText: "Och Aye",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 12),
|
||||
time: true
|
||||
});
|
||||
let wait = waitForNetworkEvents(monitor, 0, 2);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
yield wait;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[2]);
|
||||
|
||||
let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED;
|
||||
waitFor(aMonitor.panelWin, TAB_UPDATED).then(() =>
|
||||
testParamsTab("urlencoded")
|
||||
).then(() => {
|
||||
RequestsMenu.selectedIndex = 1;
|
||||
return waitFor(aMonitor.panelWin, TAB_UPDATED);
|
||||
}).then(() => testParamsTab("multipart"))
|
||||
.then(() => teardown(aMonitor))
|
||||
.then(finish);
|
||||
|
||||
function testParamsTab(aType) {
|
||||
let tab = document.querySelectorAll("#details-pane tab")[2];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The params tab in the network details pane should be selected.");
|
||||
|
||||
function checkVisibility(aBox) {
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), !aBox.includes("params"),
|
||||
"The request params box doesn't have the indended visibility.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), !aBox.includes("textarea"),
|
||||
"The request post data textarea box doesn't have the indended visibility.");
|
||||
}
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
|
||||
"There should be 2 param scopes displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let queryScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
let postScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
|
||||
|
||||
is(queryScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsQueryString"),
|
||||
"The query scope doesn't have the correct title.");
|
||||
|
||||
is(postScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr(aType == "urlencoded" ? "paramsFormData" : "paramsPostPayload"),
|
||||
"The post scope doesn't have the correct title.");
|
||||
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
"foo", "The first query param name was incorrect.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
"\"bar\"", "The first query param value was incorrect.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
|
||||
"baz", "The second query param name was incorrect.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
|
||||
"\"42\"", "The second query param value was incorrect.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .name")[2].getAttribute("value"),
|
||||
"type", "The third query param name was incorrect.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .value")[2].getAttribute("value"),
|
||||
"\"" + aType + "\"", "The third query param value was incorrect.");
|
||||
|
||||
if (aType == "urlencoded") {
|
||||
checkVisibility("params");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-variable").length, 5,
|
||||
"There should be 5 param values displayed in this tabpanel.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable").length, 3,
|
||||
"There should be 3 param values displayed in the query scope.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable").length, 2,
|
||||
"There should be 2 param values displayed in the post scope.");
|
||||
|
||||
is(postScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
"foo", "The first post param name was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
"\"bar\"", "The first post param value was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
|
||||
"baz", "The second post param name was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
|
||||
"\"123\"", "The second post param value was incorrect.");
|
||||
|
||||
return promise.resolve();
|
||||
}
|
||||
else {
|
||||
checkVisibility("params textarea");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-variable").length, 3,
|
||||
"There should be 3 param values displayed in this tabpanel.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable").length, 3,
|
||||
"There should be 3 param values displayed in the query scope.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable").length, 0,
|
||||
"There should be 0 param values displayed in the post scope.");
|
||||
|
||||
return NetMonitorView.editor("#request-post-data-textarea").then((aEditor) => {
|
||||
ok(aEditor.getText().includes("Content-Disposition: form-data; name=\"text\""),
|
||||
"The text shown in the source editor is incorrect (1.1).");
|
||||
ok(aEditor.getText().includes("Content-Disposition: form-data; name=\"email\""),
|
||||
"The text shown in the source editor is incorrect (2.1).");
|
||||
ok(aEditor.getText().includes("Content-Disposition: form-data; name=\"range\""),
|
||||
"The text shown in the source editor is incorrect (3.1).");
|
||||
ok(aEditor.getText().includes("Content-Disposition: form-data; name=\"Custom field\""),
|
||||
"The text shown in the source editor is incorrect (4.1).");
|
||||
ok(aEditor.getText().includes("Some text..."),
|
||||
"The text shown in the source editor is incorrect (2.2).");
|
||||
ok(aEditor.getText().includes("42"),
|
||||
"The text shown in the source editor is incorrect (3.2).");
|
||||
ok(aEditor.getText().includes("Extra data"),
|
||||
"The text shown in the source editor is incorrect (4.2).");
|
||||
is(aEditor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
});
|
||||
}
|
||||
}
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(0),
|
||||
"POST", SIMPLE_SJS + "?foo=bar&baz=42&type=urlencoded", {
|
||||
status: 200,
|
||||
statusText: "Och Aye",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 12),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(1),
|
||||
"POST", SIMPLE_SJS + "?foo=bar&baz=42&type=multipart", {
|
||||
status: 200,
|
||||
statusText: "Och Aye",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 12),
|
||||
time: true
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
});
|
||||
}
|
||||
let onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[2]);
|
||||
yield onEvent;
|
||||
yield testParamsTab("urlencoded");
|
||||
|
||||
onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
|
||||
RequestsMenu.selectedIndex = 1;
|
||||
yield onEvent;
|
||||
yield testParamsTab("multipart");
|
||||
|
||||
return teardown(monitor);
|
||||
|
||||
function* testParamsTab(type) {
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[2];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The params tab in the network details pane should be selected.");
|
||||
|
||||
function checkVisibility(box) {
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), !box.includes("params"),
|
||||
"The request params box doesn't have the indended visibility.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), !box.includes("textarea"),
|
||||
"The request post data textarea box doesn't have the indended visibility.");
|
||||
}
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
|
||||
"There should be 2 param scopes displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let queryScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
let postScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
|
||||
|
||||
is(queryScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsQueryString"),
|
||||
"The query scope doesn't have the correct title.");
|
||||
|
||||
is(postScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr(type == "urlencoded" ? "paramsFormData" : "paramsPostPayload"),
|
||||
"The post scope doesn't have the correct title.");
|
||||
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .name")[0]
|
||||
.getAttribute("value"),
|
||||
"foo", "The first query param name was incorrect.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .value")[0]
|
||||
.getAttribute("value"),
|
||||
"\"bar\"", "The first query param value was incorrect.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .name")[1]
|
||||
.getAttribute("value"),
|
||||
"baz", "The second query param name was incorrect.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .value")[1]
|
||||
.getAttribute("value"),
|
||||
"\"42\"", "The second query param value was incorrect.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .name")[2]
|
||||
.getAttribute("value"),
|
||||
"type", "The third query param name was incorrect.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable .value")[2]
|
||||
.getAttribute("value"),
|
||||
"\"" + type + "\"", "The third query param value was incorrect.");
|
||||
|
||||
if (type == "urlencoded") {
|
||||
checkVisibility("params");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-variable").length, 5,
|
||||
"There should be 5 param values displayed in this tabpanel.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable").length, 3,
|
||||
"There should be 3 param values displayed in the query scope.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable").length, 2,
|
||||
"There should be 2 param values displayed in the post scope.");
|
||||
|
||||
is(postScope.querySelectorAll(".variables-view-variable .name")[0]
|
||||
.getAttribute("value"),
|
||||
"foo", "The first post param name was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .value")[0]
|
||||
.getAttribute("value"),
|
||||
"\"bar\"", "The first post param value was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .name")[1]
|
||||
.getAttribute("value"),
|
||||
"baz", "The second post param name was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .value")[1]
|
||||
.getAttribute("value"),
|
||||
"\"123\"", "The second post param value was incorrect.");
|
||||
} else {
|
||||
checkVisibility("params textarea");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-variable").length, 3,
|
||||
"There should be 3 param values displayed in this tabpanel.");
|
||||
is(queryScope.querySelectorAll(".variables-view-variable").length, 3,
|
||||
"There should be 3 param values displayed in the query scope.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable").length, 0,
|
||||
"There should be 0 param values displayed in the post scope.");
|
||||
|
||||
let editor = yield NetMonitorView.editor("#request-post-data-textarea");
|
||||
let text = editor.getText();
|
||||
|
||||
ok(text.includes("Content-Disposition: form-data; name=\"text\""),
|
||||
"The text shown in the source editor is incorrect (1.1).");
|
||||
ok(text.includes("Content-Disposition: form-data; name=\"email\""),
|
||||
"The text shown in the source editor is incorrect (2.1).");
|
||||
ok(text.includes("Content-Disposition: form-data; name=\"range\""),
|
||||
"The text shown in the source editor is incorrect (3.1).");
|
||||
ok(text.includes("Content-Disposition: form-data; name=\"Custom field\""),
|
||||
"The text shown in the source editor is incorrect (4.1).");
|
||||
ok(text.includes("Some text..."),
|
||||
"The text shown in the source editor is incorrect (2.2).");
|
||||
ok(text.includes("42"),
|
||||
"The text shown in the source editor is incorrect (3.2).");
|
||||
ok(text.includes("Extra data"),
|
||||
"The text shown in the source editor is incorrect (4.2).");
|
||||
is(editor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,65 +1,71 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if the POST requests display the correct information in the UI,
|
||||
* for raw payloads with attached content-type headers.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(POST_RAW_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(POST_RAW_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
let { document, EVENTS, L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
NetworkDetails._params.lazyEmpty = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
NetworkDetails._params.lazyEmpty = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 0, 1).then(() => {
|
||||
NetMonitorView.toggleDetailsPane({ visible: true }, 2);
|
||||
RequestsMenu.selectedIndex = 0;
|
||||
|
||||
let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED;
|
||||
waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => {
|
||||
let tab = document.querySelectorAll("#event-details-pane tab")[2];
|
||||
let tabpanel = document.querySelectorAll("#event-details-pane tabpanel")[2];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The params tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The request params box doesn't have the indended visibility.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The request post data textarea box doesn't have the indended visibility.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 param scopes displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let postScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
is(postScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsFormData"),
|
||||
"The post scope doesn't have the correct title.");
|
||||
|
||||
is(postScope.querySelectorAll(".variables-view-variable").length, 2,
|
||||
"There should be 2 param values displayed in the post scope.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
"foo", "The first query param name was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
"\"bar\"", "The first query param value was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
|
||||
"baz", "The second query param name was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
|
||||
"\"123\"", "The second query param value was incorrect.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
let wait = waitForNetworkEvents(monitor, 0, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
let onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
|
||||
NetMonitorView.toggleDetailsPane({ visible: true }, 2);
|
||||
RequestsMenu.selectedIndex = 0;
|
||||
yield onEvent;
|
||||
|
||||
let tabEl = document.querySelectorAll("#event-details-pane tab")[2];
|
||||
let tabpanel = document.querySelectorAll("#event-details-pane tabpanel")[2];
|
||||
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The params tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The request params box doesn't have the indended visibility.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The request post data textarea box doesn't have the indended visibility.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 param scopes displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
let postScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
is(postScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsFormData"),
|
||||
"The post scope doesn't have the correct title.");
|
||||
|
||||
is(postScope.querySelectorAll(".variables-view-variable").length, 2,
|
||||
"There should be 2 param values displayed in the post scope.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .name")[0]
|
||||
.getAttribute("value"),
|
||||
"foo", "The first query param name was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .value")[0]
|
||||
.getAttribute("value"),
|
||||
"\"bar\"", "The first query param value was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .name")[1]
|
||||
.getAttribute("value"),
|
||||
"baz", "The second query param name was incorrect.");
|
||||
is(postScope.querySelectorAll(".variables-view-variable .value")[1]
|
||||
.getAttribute("value"),
|
||||
"\"123\"", "The second query param value was incorrect.");
|
||||
|
||||
return teardown(monitor);
|
||||
});
|
||||
|
@ -1,87 +1,96 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if the POST requests display the correct information in the UI,
|
||||
* for raw payloads with content-type headers attached to the upload stream.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(POST_RAW_WITH_HEADERS_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(POST_RAW_WITH_HEADERS_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
let { document, EVENTS, L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
Task.spawn(function* () {
|
||||
yield waitForNetworkEvents(aMonitor, 0, 1);
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
NetMonitorView.toggleDetailsPane({ visible: true });
|
||||
RequestsMenu.selectedIndex = 0;
|
||||
|
||||
yield waitFor(aMonitor.panelWin, TAB_UPDATED);
|
||||
|
||||
let tab = document.querySelectorAll("#details-pane tab")[0];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0];
|
||||
let requestFromUploadScope = tabpanel.querySelectorAll(".variables-view-scope")[2];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The headers tab in the network details pane should be selected.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 3,
|
||||
"There should be 3 header scopes displayed in this tabpanel.");
|
||||
|
||||
is(requestFromUploadScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("requestHeadersFromUpload") + " (" +
|
||||
L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(74 / 1024, 3)) + ")",
|
||||
"The request headers from upload scope doesn't have the correct title.");
|
||||
|
||||
is(requestFromUploadScope.querySelectorAll(".variables-view-variable").length, 2,
|
||||
"There should be 2 header values displayed in the request headers from upload scope.");
|
||||
|
||||
is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
"content-type", "The first request header name was incorrect.");
|
||||
is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
"\"application/x-www-form-urlencoded\"", "The first request header value was incorrect.");
|
||||
is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
|
||||
"custom-header", "The second request header name was incorrect.");
|
||||
is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
|
||||
"\"hello world!\"", "The second request header value was incorrect.");
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[2]);
|
||||
|
||||
yield waitFor(aMonitor.panelWin, TAB_UPDATED);
|
||||
|
||||
tab = document.querySelectorAll("#details-pane tab")[2];
|
||||
tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
let formDataScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 header scope displayed in this tabpanel.");
|
||||
|
||||
is(formDataScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsFormData"),
|
||||
"The form data scope doesn't have the correct title.");
|
||||
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable").length, 2,
|
||||
"There should be 2 payload values displayed in the form data scope.");
|
||||
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
"foo", "The first payload param name was incorrect.");
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
"\"bar\"", "The first payload param value was incorrect.");
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
|
||||
"baz", "The second payload param name was incorrect.");
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
|
||||
"\"123\"", "The second payload param value was incorrect.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
let wait = waitForNetworkEvents(monitor, 0, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
let onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
|
||||
NetMonitorView.toggleDetailsPane({ visible: true });
|
||||
RequestsMenu.selectedIndex = 0;
|
||||
yield onEvent;
|
||||
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[0];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0];
|
||||
let requestFromUploadScope = tabpanel.querySelectorAll(".variables-view-scope")[2];
|
||||
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The headers tab in the network details pane should be selected.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 3,
|
||||
"There should be 3 header scopes displayed in this tabpanel.");
|
||||
|
||||
is(requestFromUploadScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("requestHeadersFromUpload") + " (" +
|
||||
L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(74 / 1024, 3)) + ")",
|
||||
"The request headers from upload scope doesn't have the correct title.");
|
||||
|
||||
is(requestFromUploadScope.querySelectorAll(".variables-view-variable").length, 2,
|
||||
"There should be 2 headers displayed in the request headers from upload scope.");
|
||||
|
||||
is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[0]
|
||||
.getAttribute("value"),
|
||||
"content-type", "The first request header name was incorrect.");
|
||||
is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[0]
|
||||
.getAttribute("value"), "\"application/x-www-form-urlencoded\"",
|
||||
"The first request header value was incorrect.");
|
||||
is(requestFromUploadScope.querySelectorAll(".variables-view-variable .name")[1]
|
||||
.getAttribute("value"),
|
||||
"custom-header", "The second request header name was incorrect.");
|
||||
is(requestFromUploadScope.querySelectorAll(".variables-view-variable .value")[1]
|
||||
.getAttribute("value"),
|
||||
"\"hello world!\"", "The second request header value was incorrect.");
|
||||
|
||||
onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[2]);
|
||||
yield onEvent;
|
||||
|
||||
tabEl = document.querySelectorAll("#details-pane tab")[2];
|
||||
tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
let formDataScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 1,
|
||||
"There should be 1 header scope displayed in this tabpanel.");
|
||||
|
||||
is(formDataScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("paramsFormData"),
|
||||
"The form data scope doesn't have the correct title.");
|
||||
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable").length, 2,
|
||||
"There should be 2 payload values displayed in the form data scope.");
|
||||
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .name")[0]
|
||||
.getAttribute("value"),
|
||||
"foo", "The first payload param name was incorrect.");
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .value")[0]
|
||||
.getAttribute("value"),
|
||||
"\"bar\"", "The first payload param value was incorrect.");
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .name")[1]
|
||||
.getAttribute("value"),
|
||||
"baz", "The second payload param name was incorrect.");
|
||||
is(formDataScope.querySelectorAll(".variables-view-variable .value")[1]
|
||||
.getAttribute("value"),
|
||||
"\"123\"", "The second payload param value was incorrect.");
|
||||
|
||||
return teardown(monitor);
|
||||
});
|
||||
|
@ -7,50 +7,49 @@
|
||||
* Tests if the preferences and localization objects work correctly.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
ok(aMonitor.panelWin.L10N,
|
||||
"Should have a localization object available on the panel window.");
|
||||
ok(aMonitor.panelWin.Prefs,
|
||||
"Should have a preferences object available on the panel window.");
|
||||
ok(monitor.panelWin.L10N,
|
||||
"Should have a localization object available on the panel window.");
|
||||
ok(monitor.panelWin.Prefs,
|
||||
"Should have a preferences object available on the panel window.");
|
||||
|
||||
function testL10N() {
|
||||
let { L10N } = aMonitor.panelWin;
|
||||
is(typeof L10N.getStr("netmonitor.label"), "string",
|
||||
"The getStr() method didn't return a valid string.");
|
||||
is(typeof L10N.getFormatStr("networkMenu.totalMS", "foo"), "string",
|
||||
"The getFormatStr() method didn't return a valid string.");
|
||||
}
|
||||
testL10N();
|
||||
testPrefs();
|
||||
|
||||
function testPrefs() {
|
||||
let { Prefs } = aMonitor.panelWin;
|
||||
return teardown(monitor);
|
||||
|
||||
is(Prefs.networkDetailsWidth,
|
||||
Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
|
||||
"Getting a pref should work correctly.");
|
||||
function testL10N() {
|
||||
let { L10N } = monitor.panelWin;
|
||||
is(typeof L10N.getStr("netmonitor.label"), "string",
|
||||
"The getStr() method didn't return a valid string.");
|
||||
is(typeof L10N.getFormatStr("networkMenu.totalMS", "foo"), "string",
|
||||
"The getFormatStr() method didn't return a valid string.");
|
||||
}
|
||||
|
||||
let previousValue = Prefs.networkDetailsWidth;
|
||||
let bogusValue = ~~(Math.random() * 100);
|
||||
Prefs.networkDetailsWidth = bogusValue;
|
||||
is(Prefs.networkDetailsWidth,
|
||||
Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
|
||||
"Getting a pref after it has been modified should work correctly.");
|
||||
is(Prefs.networkDetailsWidth, bogusValue,
|
||||
"The pref wasn't updated correctly in the preferences object.");
|
||||
function testPrefs() {
|
||||
let { Prefs } = monitor.panelWin;
|
||||
|
||||
Prefs.networkDetailsWidth = previousValue;
|
||||
is(Prefs.networkDetailsWidth,
|
||||
Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
|
||||
"Getting a pref after it has been modified again should work correctly.");
|
||||
is(Prefs.networkDetailsWidth, previousValue,
|
||||
"The pref wasn't updated correctly again in the preferences object.");
|
||||
}
|
||||
is(Prefs.networkDetailsWidth,
|
||||
Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
|
||||
"Getting a pref should work correctly.");
|
||||
|
||||
testL10N();
|
||||
testPrefs();
|
||||
let previousValue = Prefs.networkDetailsWidth;
|
||||
let bogusValue = ~~(Math.random() * 100);
|
||||
Prefs.networkDetailsWidth = bogusValue;
|
||||
is(Prefs.networkDetailsWidth,
|
||||
Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
|
||||
"Getting a pref after it has been modified should work correctly.");
|
||||
is(Prefs.networkDetailsWidth, bogusValue,
|
||||
"The pref wasn't updated correctly in the preferences object.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
}
|
||||
Prefs.networkDetailsWidth = previousValue;
|
||||
is(Prefs.networkDetailsWidth,
|
||||
Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
|
||||
"Getting a pref after it has been modified again should work correctly.");
|
||||
is(Prefs.networkDetailsWidth, previousValue,
|
||||
"The pref wasn't updated correctly again in the preferences object.");
|
||||
}
|
||||
});
|
||||
|
@ -1,233 +1,212 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if the prefs that should survive across tool reloads work.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
// This test reopens the network monitor a bunch of times, for different
|
||||
// hosts (bottom, side, window). This seems to be slow on debug builds.
|
||||
requestLongerTimeout(3);
|
||||
// This test reopens the network monitor a bunch of times, for different
|
||||
// hosts (bottom, side, window). This seems to be slow on debug builds.
|
||||
requestLongerTimeout(3);
|
||||
|
||||
// Use these getters instead of caching instances inside the panel win,
|
||||
// since the tool is reopened a bunch of times during this test
|
||||
// and the instances will differ.
|
||||
let getView = () => aMonitor.panelWin.NetMonitorView;
|
||||
let getController = () => aMonitor.panelWin.NetMonitorController;
|
||||
// Use these getters instead of caching instances inside the panel win,
|
||||
// since the tool is reopened a bunch of times during this test
|
||||
// and the instances will differ.
|
||||
let getView = () => monitor.panelWin.NetMonitorView;
|
||||
|
||||
let prefsToCheck = {
|
||||
filters: {
|
||||
// A custom new value to be used for the verified preference.
|
||||
newValue: ["html", "css"],
|
||||
// Getter used to retrieve the current value from the frontend, in order
|
||||
// to verify that the pref was applied properly.
|
||||
validateValue: ($) => getView().RequestsMenu._activeFilters,
|
||||
// Predicate used to modify the frontend when setting the new pref value,
|
||||
// before trying to validate the changes.
|
||||
modifyFrontend: ($, aValue) => aValue.forEach(e => getView().RequestsMenu.filterOn(e))
|
||||
},
|
||||
networkDetailsWidth: {
|
||||
newValue: ~~(Math.random() * 200 + 100),
|
||||
validateValue: ($) => ~~$("#details-pane").getAttribute("width"),
|
||||
modifyFrontend: ($, aValue) => $("#details-pane").setAttribute("width", aValue)
|
||||
},
|
||||
networkDetailsHeight: {
|
||||
newValue: ~~(Math.random() * 300 + 100),
|
||||
validateValue: ($) => ~~$("#details-pane").getAttribute("height"),
|
||||
modifyFrontend: ($, aValue) => $("#details-pane").setAttribute("height", aValue)
|
||||
}
|
||||
/* add more prefs here... */
|
||||
};
|
||||
|
||||
function storeFirstPrefValues() {
|
||||
info("Caching initial pref values.");
|
||||
|
||||
for (let name in prefsToCheck) {
|
||||
let currentValue = aMonitor.panelWin.Prefs[name];
|
||||
prefsToCheck[name].firstValue = currentValue;
|
||||
}
|
||||
let prefsToCheck = {
|
||||
filters: {
|
||||
// A custom new value to be used for the verified preference.
|
||||
newValue: ["html", "css"],
|
||||
// Getter used to retrieve the current value from the frontend, in order
|
||||
// to verify that the pref was applied properly.
|
||||
validateValue: ($) => getView().RequestsMenu._activeFilters,
|
||||
// Predicate used to modify the frontend when setting the new pref value,
|
||||
// before trying to validate the changes.
|
||||
modifyFrontend: ($, value) => value.forEach(e => getView().RequestsMenu.filterOn(e))
|
||||
},
|
||||
networkDetailsWidth: {
|
||||
newValue: ~~(Math.random() * 200 + 100),
|
||||
validateValue: ($) => ~~$("#details-pane").getAttribute("width"),
|
||||
modifyFrontend: ($, value) => $("#details-pane").setAttribute("width", value)
|
||||
},
|
||||
networkDetailsHeight: {
|
||||
newValue: ~~(Math.random() * 300 + 100),
|
||||
validateValue: ($) => ~~$("#details-pane").getAttribute("height"),
|
||||
modifyFrontend: ($, value) => $("#details-pane").setAttribute("height", value)
|
||||
}
|
||||
/* add more prefs here... */
|
||||
};
|
||||
|
||||
function validateFirstPrefValues() {
|
||||
info("Validating current pref values to the UI elements.");
|
||||
yield testBottom();
|
||||
yield testSide();
|
||||
yield testWindow();
|
||||
|
||||
for (let name in prefsToCheck) {
|
||||
let currentValue = aMonitor.panelWin.Prefs[name];
|
||||
let firstValue = prefsToCheck[name].firstValue;
|
||||
let validateValue = prefsToCheck[name].validateValue;
|
||||
info("Moving toolbox back to the bottom...");
|
||||
yield monitor._toolbox.switchHost(Toolbox.HostType.BOTTOM);
|
||||
return teardown(monitor);
|
||||
|
||||
is(currentValue.toSource(), firstValue.toSource(),
|
||||
"Pref " + name + " should be equal to first value: " + firstValue);
|
||||
is(currentValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(),
|
||||
"Pref " + name + " should validate: " + currentValue);
|
||||
}
|
||||
function storeFirstPrefValues() {
|
||||
info("Caching initial pref values.");
|
||||
|
||||
for (let name in prefsToCheck) {
|
||||
let currentValue = monitor.panelWin.Prefs[name];
|
||||
prefsToCheck[name].firstValue = currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
function modifyFrontend() {
|
||||
info("Modifying UI elements to the specified new values.");
|
||||
function validateFirstPrefValues() {
|
||||
info("Validating current pref values to the UI elements.");
|
||||
|
||||
for (let name in prefsToCheck) {
|
||||
let currentValue = aMonitor.panelWin.Prefs[name];
|
||||
let firstValue = prefsToCheck[name].firstValue;
|
||||
let newValue = prefsToCheck[name].newValue;
|
||||
let validateValue = prefsToCheck[name].validateValue;
|
||||
let modifyFrontend = prefsToCheck[name].modifyFrontend;
|
||||
for (let name in prefsToCheck) {
|
||||
let currentValue = monitor.panelWin.Prefs[name];
|
||||
let firstValue = prefsToCheck[name].firstValue;
|
||||
let validateValue = prefsToCheck[name].validateValue;
|
||||
|
||||
modifyFrontend(aMonitor.panelWin.$, newValue);
|
||||
info("Modified UI element affecting " + name + " to: " + newValue);
|
||||
|
||||
is(currentValue.toSource(), firstValue.toSource(),
|
||||
"Pref " + name + " should still be equal to first value: " + firstValue);
|
||||
isnot(currentValue.toSource(), newValue.toSource(),
|
||||
"Pref " + name + " should't yet be equal to second value: " + newValue);
|
||||
is(newValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(),
|
||||
"The UI element affecting " + name + " should validate: " + newValue);
|
||||
}
|
||||
is(currentValue.toSource(), firstValue.toSource(),
|
||||
"Pref " + name + " should be equal to first value: " + firstValue);
|
||||
is(currentValue.toSource(), validateValue(monitor.panelWin.$).toSource(),
|
||||
"Pref " + name + " should validate: " + currentValue);
|
||||
}
|
||||
}
|
||||
|
||||
function validateNewPrefValues() {
|
||||
info("Invalidating old pref values to the modified UI elements.");
|
||||
function modifyFrontend() {
|
||||
info("Modifying UI elements to the specified new values.");
|
||||
|
||||
for (let name in prefsToCheck) {
|
||||
let currentValue = aMonitor.panelWin.Prefs[name];
|
||||
let firstValue = prefsToCheck[name].firstValue;
|
||||
let newValue = prefsToCheck[name].newValue;
|
||||
let validateValue = prefsToCheck[name].validateValue;
|
||||
for (let name in prefsToCheck) {
|
||||
let currentValue = monitor.panelWin.Prefs[name];
|
||||
let firstValue = prefsToCheck[name].firstValue;
|
||||
let newValue = prefsToCheck[name].newValue;
|
||||
let validateValue = prefsToCheck[name].validateValue;
|
||||
let modFrontend = prefsToCheck[name].modifyFrontend;
|
||||
|
||||
isnot(currentValue.toSource(), firstValue.toSource(),
|
||||
"Pref " + name + " should't be equal to first value: " + firstValue);
|
||||
is(currentValue.toSource(), newValue.toSource(),
|
||||
"Pref " + name + " should now be equal to second value: " + newValue);
|
||||
is(newValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(),
|
||||
"The UI element affecting " + name + " should validate: " + newValue);
|
||||
}
|
||||
modFrontend(monitor.panelWin.$, newValue);
|
||||
info("Modified UI element affecting " + name + " to: " + newValue);
|
||||
|
||||
is(currentValue.toSource(), firstValue.toSource(),
|
||||
"Pref " + name + " should still be equal to first value: " + firstValue);
|
||||
isnot(currentValue.toSource(), newValue.toSource(),
|
||||
"Pref " + name + " should't yet be equal to second value: " + newValue);
|
||||
is(newValue.toSource(), validateValue(monitor.panelWin.$).toSource(),
|
||||
"The UI element affecting " + name + " should validate: " + newValue);
|
||||
}
|
||||
}
|
||||
|
||||
function resetFrontend() {
|
||||
info("Resetting UI elements to the cached initial pref values.");
|
||||
function validateNewPrefValues() {
|
||||
info("Invalidating old pref values to the modified UI elements.");
|
||||
|
||||
for (let name in prefsToCheck) {
|
||||
let currentValue = aMonitor.panelWin.Prefs[name];
|
||||
let firstValue = prefsToCheck[name].firstValue;
|
||||
let newValue = prefsToCheck[name].newValue;
|
||||
let validateValue = prefsToCheck[name].validateValue;
|
||||
let modifyFrontend = prefsToCheck[name].modifyFrontend;
|
||||
for (let name in prefsToCheck) {
|
||||
let currentValue = monitor.panelWin.Prefs[name];
|
||||
let firstValue = prefsToCheck[name].firstValue;
|
||||
let newValue = prefsToCheck[name].newValue;
|
||||
let validateValue = prefsToCheck[name].validateValue;
|
||||
|
||||
modifyFrontend(aMonitor.panelWin.$, firstValue);
|
||||
info("Modified UI element affecting " + name + " to: " + firstValue);
|
||||
|
||||
isnot(currentValue.toSource(), firstValue.toSource(),
|
||||
"Pref " + name + " should't yet be equal to first value: " + firstValue);
|
||||
is(currentValue.toSource(), newValue.toSource(),
|
||||
"Pref " + name + " should still be equal to second value: " + newValue);
|
||||
is(firstValue.toSource(), validateValue(aMonitor.panelWin.$).toSource(),
|
||||
"The UI element affecting " + name + " should validate: " + firstValue);
|
||||
}
|
||||
isnot(currentValue.toSource(), firstValue.toSource(),
|
||||
"Pref " + name + " should't be equal to first value: " + firstValue);
|
||||
is(currentValue.toSource(), newValue.toSource(),
|
||||
"Pref " + name + " should now be equal to second value: " + newValue);
|
||||
is(newValue.toSource(), validateValue(monitor.panelWin.$).toSource(),
|
||||
"The UI element affecting " + name + " should validate: " + newValue);
|
||||
}
|
||||
}
|
||||
|
||||
function testBottom() {
|
||||
info("Testing prefs reload for a bottom host.");
|
||||
storeFirstPrefValues();
|
||||
function resetFrontend() {
|
||||
info("Resetting UI elements to the cached initial pref values.");
|
||||
|
||||
// Validate and modify while toolbox is on the bottom.
|
||||
validateFirstPrefValues();
|
||||
modifyFrontend();
|
||||
for (let name in prefsToCheck) {
|
||||
let currentValue = monitor.panelWin.Prefs[name];
|
||||
let firstValue = prefsToCheck[name].firstValue;
|
||||
let newValue = prefsToCheck[name].newValue;
|
||||
let validateValue = prefsToCheck[name].validateValue;
|
||||
let modFrontend = prefsToCheck[name].modifyFrontend;
|
||||
|
||||
return restartNetMonitor(aMonitor)
|
||||
.then(([,, aNewMonitor]) => {
|
||||
aMonitor = aNewMonitor;
|
||||
modFrontend(monitor.panelWin.$, firstValue);
|
||||
info("Modified UI element affecting " + name + " to: " + firstValue);
|
||||
|
||||
// Revalidate and reset frontend while toolbox is on the bottom.
|
||||
validateNewPrefValues();
|
||||
resetFrontend();
|
||||
|
||||
return restartNetMonitor(aMonitor);
|
||||
})
|
||||
.then(([,, aNewMonitor]) => {
|
||||
aMonitor = aNewMonitor;
|
||||
|
||||
// Revalidate.
|
||||
validateFirstPrefValues();
|
||||
});
|
||||
isnot(currentValue.toSource(), firstValue.toSource(),
|
||||
"Pref " + name + " should't yet be equal to first value: " + firstValue);
|
||||
is(currentValue.toSource(), newValue.toSource(),
|
||||
"Pref " + name + " should still be equal to second value: " + newValue);
|
||||
is(firstValue.toSource(), validateValue(monitor.panelWin.$).toSource(),
|
||||
"The UI element affecting " + name + " should validate: " + firstValue);
|
||||
}
|
||||
}
|
||||
|
||||
function testSide() {
|
||||
info("Moving toolbox to the side...");
|
||||
function* testBottom() {
|
||||
info("Testing prefs reload for a bottom host.");
|
||||
storeFirstPrefValues();
|
||||
|
||||
return aMonitor._toolbox.switchHost(Toolbox.HostType.SIDE)
|
||||
.then(() => {
|
||||
info("Testing prefs reload for a side host.");
|
||||
storeFirstPrefValues();
|
||||
// Validate and modify while toolbox is on the bottom.
|
||||
validateFirstPrefValues();
|
||||
modifyFrontend();
|
||||
|
||||
// Validate and modify frontend while toolbox is on the side.
|
||||
validateFirstPrefValues();
|
||||
modifyFrontend();
|
||||
let newMonitor = yield restartNetMonitor(monitor);
|
||||
monitor = newMonitor.monitor;
|
||||
|
||||
return restartNetMonitor(aMonitor);
|
||||
})
|
||||
.then(([,, aNewMonitor]) => {
|
||||
aMonitor = aNewMonitor;
|
||||
// Revalidate and reset frontend while toolbox is on the bottom.
|
||||
validateNewPrefValues();
|
||||
resetFrontend();
|
||||
|
||||
// Revalidate and reset frontend while toolbox is on the side.
|
||||
validateNewPrefValues();
|
||||
resetFrontend();
|
||||
newMonitor = yield restartNetMonitor(monitor);
|
||||
monitor = newMonitor.monitor;
|
||||
|
||||
return restartNetMonitor(aMonitor);
|
||||
})
|
||||
.then(([,, aNewMonitor]) => {
|
||||
aMonitor = aNewMonitor;
|
||||
// Revalidate.
|
||||
validateFirstPrefValues();
|
||||
}
|
||||
|
||||
// Revalidate.
|
||||
validateFirstPrefValues();
|
||||
});
|
||||
}
|
||||
function* testSide() {
|
||||
info("Moving toolbox to the side...");
|
||||
|
||||
function testWindow() {
|
||||
info("Moving toolbox into a window...");
|
||||
yield monitor._toolbox.switchHost(Toolbox.HostType.SIDE);
|
||||
info("Testing prefs reload for a side host.");
|
||||
storeFirstPrefValues();
|
||||
|
||||
return aMonitor._toolbox.switchHost(Toolbox.HostType.WINDOW)
|
||||
.then(() => {
|
||||
info("Testing prefs reload for a window host.");
|
||||
storeFirstPrefValues();
|
||||
// Validate and modify frontend while toolbox is on the side.
|
||||
validateFirstPrefValues();
|
||||
modifyFrontend();
|
||||
|
||||
// Validate and modify frontend while toolbox is in a window.
|
||||
validateFirstPrefValues();
|
||||
modifyFrontend();
|
||||
let newMonitor = yield restartNetMonitor(monitor);
|
||||
monitor = newMonitor.monitor;
|
||||
|
||||
return restartNetMonitor(aMonitor);
|
||||
})
|
||||
.then(([,, aNewMonitor]) => {
|
||||
aMonitor = aNewMonitor;
|
||||
// Revalidate and reset frontend while toolbox is on the side.
|
||||
validateNewPrefValues();
|
||||
resetFrontend();
|
||||
|
||||
// Revalidate and reset frontend while toolbox is in a window.
|
||||
validateNewPrefValues();
|
||||
resetFrontend();
|
||||
newMonitor = yield restartNetMonitor(monitor);
|
||||
monitor = newMonitor.monitor;
|
||||
|
||||
return restartNetMonitor(aMonitor);
|
||||
})
|
||||
.then(([,, aNewMonitor]) => {
|
||||
aMonitor = aNewMonitor;
|
||||
// Revalidate.
|
||||
validateFirstPrefValues();
|
||||
}
|
||||
|
||||
// Revalidate.
|
||||
validateFirstPrefValues();
|
||||
});
|
||||
}
|
||||
function* testWindow() {
|
||||
info("Moving toolbox into a window...");
|
||||
|
||||
function cleanupAndFinish() {
|
||||
info("Moving toolbox back to the bottom...");
|
||||
yield monitor._toolbox.switchHost(Toolbox.HostType.WINDOW);
|
||||
info("Testing prefs reload for a window host.");
|
||||
storeFirstPrefValues();
|
||||
|
||||
aMonitor._toolbox.switchHost(Toolbox.HostType.BOTTOM)
|
||||
.then(() => teardown(aMonitor))
|
||||
.then(finish);
|
||||
}
|
||||
// Validate and modify frontend while toolbox is in a window.
|
||||
validateFirstPrefValues();
|
||||
modifyFrontend();
|
||||
|
||||
testBottom()
|
||||
.then(testSide)
|
||||
.then(testWindow)
|
||||
.then(cleanupAndFinish);
|
||||
});
|
||||
}
|
||||
let newMonitor = yield restartNetMonitor(monitor);
|
||||
monitor = newMonitor.monitor;
|
||||
|
||||
// Revalidate and reset frontend while toolbox is in a window.
|
||||
validateNewPrefValues();
|
||||
resetFrontend();
|
||||
|
||||
newMonitor = yield restartNetMonitor(monitor);
|
||||
monitor = newMonitor.monitor;
|
||||
|
||||
// Revalidate.
|
||||
validateFirstPrefValues();
|
||||
}
|
||||
});
|
||||
|
@ -1,72 +1,70 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
var gPanelWin;
|
||||
var gPanelDoc;
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if showing raw headers works.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(POST_DATA_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(POST_DATA_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
gPanelWin = aMonitor.panelWin;
|
||||
gPanelDoc = gPanelWin.document;
|
||||
let { document, EVENTS, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
let { document, Editor, NetMonitorView } = gPanelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let TAB_UPDATED = gPanelWin.EVENTS.TAB_UPDATED;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 0, 2).then(() => {
|
||||
let origItem = RequestsMenu.getItemAtIndex(0);
|
||||
RequestsMenu.selectedItem = origItem;
|
||||
|
||||
waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "click" }, document.getElementById("toggle-raw-headers"));
|
||||
testShowRawHeaders(origItem.attachment);
|
||||
EventUtils.sendMouseEvent({ type: "click" }, document.getElementById("toggle-raw-headers"));
|
||||
testHideRawHeaders(document);
|
||||
finishUp(aMonitor);
|
||||
});
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
let wait = waitForNetworkEvents(monitor, 0, 2);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
/*
|
||||
* Tests that raw headers were displayed correctly
|
||||
*/
|
||||
function testShowRawHeaders(aData) {
|
||||
let requestHeaders = gPanelDoc.getElementById("raw-request-headers-textarea").value;
|
||||
for (let header of aData.requestHeaders.headers) {
|
||||
ok(requestHeaders.indexOf(header.name + ": " + header.value) >= 0, "textarea contains request headers");
|
||||
let origItem = RequestsMenu.getItemAtIndex(0);
|
||||
|
||||
let onTabEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
|
||||
RequestsMenu.selectedItem = origItem;
|
||||
yield onTabEvent;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
document.getElementById("toggle-raw-headers"));
|
||||
|
||||
testShowRawHeaders(origItem.attachment);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
document.getElementById("toggle-raw-headers"));
|
||||
|
||||
testHideRawHeaders(document);
|
||||
|
||||
return teardown(monitor);
|
||||
|
||||
/*
|
||||
* Tests that raw headers were displayed correctly
|
||||
*/
|
||||
function testShowRawHeaders(data) {
|
||||
let requestHeaders = document.getElementById("raw-request-headers-textarea").value;
|
||||
for (let header of data.requestHeaders.headers) {
|
||||
ok(requestHeaders.indexOf(header.name + ": " + header.value) >= 0,
|
||||
"textarea contains request headers");
|
||||
}
|
||||
let responseHeaders = document.getElementById("raw-response-headers-textarea").value;
|
||||
for (let header of data.responseHeaders.headers) {
|
||||
ok(responseHeaders.indexOf(header.name + ": " + header.value) >= 0,
|
||||
"textarea contains response headers");
|
||||
}
|
||||
}
|
||||
let responseHeaders = gPanelDoc.getElementById("raw-response-headers-textarea").value;
|
||||
for (let header of aData.responseHeaders.headers) {
|
||||
ok(responseHeaders.indexOf(header.name + ": " + header.value) >= 0, "textarea contains response headers");
|
||||
|
||||
/*
|
||||
* Tests that raw headers textareas are hidden and empty
|
||||
*/
|
||||
function testHideRawHeaders() {
|
||||
let rawHeadersHidden = document.getElementById("raw-headers").getAttribute("hidden");
|
||||
let requestTextarea = document.getElementById("raw-request-headers-textarea");
|
||||
let responseTextarea = document.getElementById("raw-response-headers-textarea");
|
||||
ok(rawHeadersHidden, "raw headers textareas are hidden");
|
||||
ok(requestTextarea.value == "", "raw request headers textarea is empty");
|
||||
ok(responseTextarea.value == "", "raw response headers textarea is empty");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests that raw headers textareas are hidden and empty
|
||||
*/
|
||||
function testHideRawHeaders(document) {
|
||||
let rawHeadersHidden = document.getElementById("raw-headers").getAttribute("hidden");
|
||||
let requestTextarea = document.getElementById("raw-request-headers-textarea");
|
||||
let responseTextare = document.getElementById("raw-response-headers-textarea");
|
||||
ok(rawHeadersHidden, "raw headers textareas are hidden");
|
||||
ok(requestTextarea.value == "", "raw request headers textarea is empty");
|
||||
ok(responseTextare.value == "", "raw response headers textarea is empty");
|
||||
}
|
||||
|
||||
function finishUp(aMonitor) {
|
||||
gPanelWin = null;
|
||||
gPanelDoc = null;
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
}
|
||||
});
|
||||
|
@ -1,31 +1,25 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if the empty-requests reload button works.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
let monitor, reqMenu;
|
||||
initNetMonitor(SINGLE_GET_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SINGLE_GET_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
monitor = aMonitor;
|
||||
let { document, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
reqMenu = RequestsMenu;
|
||||
let { document, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
let button = document.querySelector("#requests-menu-reload-notice-button");
|
||||
button.click();
|
||||
})
|
||||
.then(() => {
|
||||
return waitForNetworkEvents(monitor, 2);
|
||||
})
|
||||
.then(() => {
|
||||
is(reqMenu.itemCount, 2,
|
||||
"The request menu should have two items after reloading");
|
||||
})
|
||||
.then(() => {
|
||||
return teardown(monitor).then(finish);
|
||||
});
|
||||
}
|
||||
let wait = waitForNetworkEvents(monitor, 2);
|
||||
let button = document.querySelector("#requests-menu-reload-notice-button");
|
||||
button.click();
|
||||
yield wait;
|
||||
|
||||
is(RequestsMenu.itemCount, 2, "The request menu should have two items after reloading");
|
||||
|
||||
return teardown(monitor);
|
||||
});
|
||||
|
@ -1,45 +1,35 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if the empty-requests reload button works.
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
let [tab, debuggee, monitor] = yield initNetMonitor(SINGLE_GET_URL);
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SINGLE_GET_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, EVENTS, NetworkEventsHandler } = monitor.panelWin;
|
||||
let button = document.querySelector("#requests-menu-reload-notice-button");
|
||||
button.click();
|
||||
let { document, EVENTS } = monitor.panelWin;
|
||||
let button = document.querySelector("#requests-menu-reload-notice-button");
|
||||
button.click();
|
||||
|
||||
let deferred = promise.defer();
|
||||
let markers = [];
|
||||
let markers = [];
|
||||
|
||||
monitor.panelWin.on(EVENTS.TIMELINE_EVENT, (_, marker) => {
|
||||
markers.push(marker);
|
||||
});
|
||||
monitor.panelWin.on(EVENTS.TIMELINE_EVENT, (_, marker) => {
|
||||
markers.push(marker);
|
||||
});
|
||||
|
||||
yield waitForNetworkEvents(monitor, 2);
|
||||
yield waitUntil(() => markers.length == 2);
|
||||
yield waitForNetworkEvents(monitor, 2);
|
||||
yield waitUntil(() => markers.length == 2);
|
||||
|
||||
ok(true, "Reloading finished");
|
||||
ok(true, "Reloading finished");
|
||||
|
||||
is(markers[0].name, "document::DOMContentLoaded",
|
||||
is(markers[0].name, "document::DOMContentLoaded",
|
||||
"The first received marker is correct.");
|
||||
is(markers[1].name, "document::Load",
|
||||
is(markers[1].name, "document::Load",
|
||||
"The second received marker is correct.");
|
||||
|
||||
teardown(monitor).then(finish);
|
||||
});
|
||||
|
||||
function waitUntil(predicate, interval = 10) {
|
||||
if (predicate()) {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
setTimeout(function () {
|
||||
waitUntil(predicate).then(() => resolve(true));
|
||||
}, interval);
|
||||
});
|
||||
}
|
||||
return teardown(monitor);
|
||||
});
|
||||
|
@ -1,60 +1,66 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test if request and response body logging stays on after opening the console.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(JSON_LONG_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(JSON_LONG_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
function verifyRequest(aOffset) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOffset),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json-long", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "text/json; charset=utf-8",
|
||||
size: L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(85975 / 1024, 2)),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
verifyRequest(0);
|
||||
|
||||
aMonitor._toolbox.once("webconsole-selected", () => {
|
||||
aMonitor._toolbox.once("netmonitor-selected", () => {
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
verifyRequest(1);
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
|
||||
// Perform another batch of requests.
|
||||
aDebuggee.performRequests();
|
||||
});
|
||||
|
||||
// Reload debugee.
|
||||
aDebuggee.location.reload();
|
||||
});
|
||||
|
||||
// Switch back to the netmonitor.
|
||||
aMonitor._toolbox.selectTool("netmonitor");
|
||||
});
|
||||
|
||||
// Switch to the webconsole.
|
||||
aMonitor._toolbox.selectTool("webconsole");
|
||||
});
|
||||
|
||||
// Perform first batch of requests.
|
||||
aDebuggee.performRequests();
|
||||
// Perform first batch of requests.
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
verifyRequest(0);
|
||||
|
||||
// Switch to the webconsole.
|
||||
let onWebConsole = monitor._toolbox.once("webconsole-selected");
|
||||
monitor._toolbox.selectTool("webconsole");
|
||||
yield onWebConsole;
|
||||
|
||||
// Switch back to the netmonitor.
|
||||
let onNetMonitor = monitor._toolbox.once("netmonitor-selected");
|
||||
monitor._toolbox.selectTool("netmonitor");
|
||||
yield onNetMonitor;
|
||||
|
||||
// Reload debugee.
|
||||
wait = waitForNetworkEvents(monitor, 1);
|
||||
tab.linkedBrowser.reload();
|
||||
yield wait;
|
||||
|
||||
// Perform another batch of requests.
|
||||
wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
yield wait;
|
||||
|
||||
verifyRequest(1);
|
||||
|
||||
return teardown(monitor);
|
||||
|
||||
function verifyRequest(offset) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(offset),
|
||||
"GET", CONTENT_TYPE_SJS + "?fmt=json-long", {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
type: "json",
|
||||
fullMimeType: "text/json; charset=utf-8",
|
||||
size: L10N.getFormatStr("networkMenu.sizeKB",
|
||||
L10N.numberWithDecimals(85975 / 1024, 2)),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,178 +1,162 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
var gPanelWin;
|
||||
var gPanelDoc;
|
||||
|
||||
const ADD_QUERY = "t1=t2";
|
||||
const ADD_HEADER = "Test-header: true";
|
||||
const ADD_POSTDATA = "t3=t4";
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if resending a request works.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(POST_DATA_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
const ADD_QUERY = "t1=t2";
|
||||
const ADD_HEADER = "Test-header: true";
|
||||
const ADD_POSTDATA = "&t3=t4";
|
||||
|
||||
gPanelWin = aMonitor.panelWin;
|
||||
gPanelDoc = gPanelWin.document;
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(POST_DATA_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { NetMonitorView } = gPanelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED;
|
||||
let CUSTOMREQUESTVIEW_POPULATED = aMonitor.panelWin.EVENTS.CUSTOMREQUESTVIEW_POPULATED;
|
||||
let { panelWin } = monitor;
|
||||
let { document, EVENTS, NetMonitorView } = panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 0, 2).then(() => {
|
||||
let origItem = RequestsMenu.getItemAtIndex(0);
|
||||
RequestsMenu.selectedItem = origItem;
|
||||
|
||||
waitFor(aMonitor.panelWin, TAB_UPDATED).then(() => {
|
||||
// add a new custom request cloned from selected request
|
||||
RequestsMenu.cloneSelectedRequest();
|
||||
return waitFor(aMonitor.panelWin, CUSTOMREQUESTVIEW_POPULATED);
|
||||
}).then(() => {
|
||||
testCustomForm(origItem.attachment);
|
||||
|
||||
let customItem = RequestsMenu.selectedItem;
|
||||
testCustomItem(customItem, origItem);
|
||||
|
||||
// edit the custom request
|
||||
editCustomForm(() => {
|
||||
testCustomItemChanged(customItem, origItem);
|
||||
|
||||
waitForNetworkEvents(aMonitor, 0, 1).then(() => {
|
||||
let sentItem = RequestsMenu.selectedItem;
|
||||
testSentRequest(sentItem.attachment, origItem.attachment);
|
||||
finishUp(aMonitor);
|
||||
});
|
||||
// send the new request
|
||||
RequestsMenu.sendCustomRequest();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
aDebuggee.performRequests();
|
||||
let wait = waitForNetworkEvents(monitor, 0, 2);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
function testCustomItem(aItem, aOrigItem) {
|
||||
let method = aItem.target.querySelector(".requests-menu-method").value;
|
||||
let origMethod = aOrigItem.target.querySelector(".requests-menu-method").value;
|
||||
is(method, origMethod, "menu item is showing the same method as original request");
|
||||
let origItem = RequestsMenu.getItemAtIndex(0);
|
||||
|
||||
let file = aItem.target.querySelector(".requests-menu-file").value;
|
||||
let origFile = aOrigItem.target.querySelector(".requests-menu-file").value;
|
||||
is(file, origFile, "menu item is showing the same file name as original request");
|
||||
let onTabUpdated = panelWin.once(EVENTS.TAB_UPDATED);
|
||||
RequestsMenu.selectedItem = origItem;
|
||||
yield onTabUpdated;
|
||||
|
||||
let domain = aItem.target.querySelector(".requests-menu-domain").value;
|
||||
let origDomain = aOrigItem.target.querySelector(".requests-menu-domain").value;
|
||||
is(domain, origDomain, "menu item is showing the same domain as original request");
|
||||
}
|
||||
// add a new custom request cloned from selected request
|
||||
let onPopulated = panelWin.once(EVENTS.CUSTOMREQUESTVIEW_POPULATED);
|
||||
RequestsMenu.cloneSelectedRequest();
|
||||
yield onPopulated;
|
||||
|
||||
function testCustomItemChanged(aItem, aOrigItem) {
|
||||
let file = aItem.target.querySelector(".requests-menu-file").value;
|
||||
let expectedFile = aOrigItem.target.querySelector(".requests-menu-file").value + "&" + ADD_QUERY;
|
||||
testCustomForm(origItem.attachment);
|
||||
|
||||
is(file, expectedFile, "menu item is updated to reflect url entered in form");
|
||||
}
|
||||
let customItem = RequestsMenu.selectedItem;
|
||||
testCustomItem(customItem, origItem);
|
||||
|
||||
/*
|
||||
* Test that the New Request form was populated correctly
|
||||
*/
|
||||
function testCustomForm(aData) {
|
||||
is(gPanelDoc.getElementById("custom-method-value").value, aData.method,
|
||||
"new request form showing correct method");
|
||||
// edit the custom request
|
||||
yield editCustomForm();
|
||||
testCustomItemChanged(customItem, origItem);
|
||||
|
||||
is(gPanelDoc.getElementById("custom-url-value").value, aData.url,
|
||||
"new request form showing correct url");
|
||||
// send the new request
|
||||
wait = waitForNetworkEvents(monitor, 0, 1);
|
||||
RequestsMenu.sendCustomRequest();
|
||||
yield wait;
|
||||
|
||||
let query = gPanelDoc.getElementById("custom-query-value");
|
||||
is(query.value, "foo=bar\nbaz=42\ntype=urlencoded",
|
||||
"new request form showing correct query string");
|
||||
let sentItem = RequestsMenu.selectedItem;
|
||||
testSentRequest(sentItem.attachment, origItem.attachment);
|
||||
|
||||
let headers = gPanelDoc.getElementById("custom-headers-value").value.split("\n");
|
||||
for (let {name, value} of aData.requestHeaders.headers) {
|
||||
ok(headers.indexOf(name + ": " + value) >= 0, "form contains header from request");
|
||||
return teardown(monitor);
|
||||
|
||||
function testCustomItem(item, orig) {
|
||||
let method = item.target.querySelector(".requests-menu-method").value;
|
||||
let origMethod = orig.target.querySelector(".requests-menu-method").value;
|
||||
is(method, origMethod, "menu item is showing the same method as original request");
|
||||
|
||||
let file = item.target.querySelector(".requests-menu-file").value;
|
||||
let origFile = orig.target.querySelector(".requests-menu-file").value;
|
||||
is(file, origFile, "menu item is showing the same file name as original request");
|
||||
|
||||
let domain = item.target.querySelector(".requests-menu-domain").value;
|
||||
let origDomain = orig.target.querySelector(".requests-menu-domain").value;
|
||||
is(domain, origDomain, "menu item is showing the same domain as original request");
|
||||
}
|
||||
|
||||
let postData = gPanelDoc.getElementById("custom-postdata-value");
|
||||
is(postData.value, aData.requestPostData.postData.text,
|
||||
"new request form showing correct post data");
|
||||
}
|
||||
function testCustomItemChanged(item, orig) {
|
||||
let file = item.target.querySelector(".requests-menu-file").value;
|
||||
let expectedFile = orig.target.querySelector(".requests-menu-file").value +
|
||||
"&" + ADD_QUERY;
|
||||
|
||||
/*
|
||||
* Add some params and headers to the request form
|
||||
*/
|
||||
function editCustomForm(callback) {
|
||||
gPanelWin.focus();
|
||||
is(file, expectedFile, "menu item is updated to reflect url entered in form");
|
||||
}
|
||||
|
||||
let query = gPanelDoc.getElementById("custom-query-value");
|
||||
query.addEventListener("focus", function onFocus() {
|
||||
query.removeEventListener("focus", onFocus, false);
|
||||
/*
|
||||
* Test that the New Request form was populated correctly
|
||||
*/
|
||||
function testCustomForm(data) {
|
||||
is(document.getElementById("custom-method-value").value, data.method,
|
||||
"new request form showing correct method");
|
||||
|
||||
is(document.getElementById("custom-url-value").value, data.url,
|
||||
"new request form showing correct url");
|
||||
|
||||
let query = document.getElementById("custom-query-value");
|
||||
is(query.value, "foo=bar\nbaz=42\ntype=urlencoded",
|
||||
"new request form showing correct query string");
|
||||
|
||||
let headers = document.getElementById("custom-headers-value").value.split("\n");
|
||||
for (let {name, value} of data.requestHeaders.headers) {
|
||||
ok(headers.indexOf(name + ": " + value) >= 0, "form contains header from request");
|
||||
}
|
||||
|
||||
let postData = document.getElementById("custom-postdata-value");
|
||||
is(postData.value, data.requestPostData.postData.text,
|
||||
"new request form showing correct post data");
|
||||
}
|
||||
|
||||
/*
|
||||
* Add some params and headers to the request form
|
||||
*/
|
||||
function* editCustomForm() {
|
||||
panelWin.focus();
|
||||
|
||||
let query = document.getElementById("custom-query-value");
|
||||
let queryFocus = once(query, "focus", false);
|
||||
// Bug 1195825: Due to some unexplained dark-matter with promise,
|
||||
// focus only works if delayed by one tick.
|
||||
executeSoon(() => query.focus());
|
||||
yield queryFocus;
|
||||
|
||||
// add params to url query string field
|
||||
type(["VK_RETURN"]);
|
||||
type(ADD_QUERY);
|
||||
|
||||
let headers = gPanelDoc.getElementById("custom-headers-value");
|
||||
headers.addEventListener("focus", function onFocus() {
|
||||
headers.removeEventListener("focus", onFocus, false);
|
||||
|
||||
// add a header
|
||||
type(["VK_RETURN"]);
|
||||
type(ADD_HEADER);
|
||||
|
||||
let postData = gPanelDoc.getElementById("custom-postdata-value");
|
||||
postData.addEventListener("focus", function onFocus() {
|
||||
postData.removeEventListener("focus", onFocus, false);
|
||||
|
||||
// add to POST data
|
||||
type(ADD_POSTDATA);
|
||||
callback();
|
||||
}, false);
|
||||
postData.focus();
|
||||
}, false);
|
||||
let headers = document.getElementById("custom-headers-value");
|
||||
let headersFocus = once(headers, "focus", false);
|
||||
headers.focus();
|
||||
}, false);
|
||||
yield headersFocus;
|
||||
|
||||
// Bug 1195825: Due to some unexplained dark-matter with promise,
|
||||
// focus only works if delayed by one tick.
|
||||
executeSoon(() => {
|
||||
query.focus();
|
||||
});
|
||||
}
|
||||
// add a header
|
||||
type(["VK_RETURN"]);
|
||||
type(ADD_HEADER);
|
||||
|
||||
/*
|
||||
* Make sure newly created event matches expected request
|
||||
*/
|
||||
function testSentRequest(aData, aOrigData) {
|
||||
is(aData.method, aOrigData.method, "correct method in sent request");
|
||||
is(aData.url, aOrigData.url + "&" + ADD_QUERY, "correct url in sent request");
|
||||
let postData = document.getElementById("custom-postdata-value");
|
||||
let postFocus = once(postData, "focus", false);
|
||||
postData.focus();
|
||||
yield postFocus;
|
||||
|
||||
let hasHeader = aData.requestHeaders.headers.some((header) => {
|
||||
return (header.name + ": " + header.value) == ADD_HEADER;
|
||||
});
|
||||
ok(hasHeader, "new header added to sent request");
|
||||
|
||||
is(aData.requestPostData.postData.text,
|
||||
aOrigData.requestPostData.postData.text + ADD_POSTDATA,
|
||||
"post data added to sent request");
|
||||
}
|
||||
|
||||
|
||||
function type(aString) {
|
||||
for (let ch of aString) {
|
||||
EventUtils.synthesizeKey(ch, {}, gPanelWin);
|
||||
// add to POST data
|
||||
type(ADD_POSTDATA);
|
||||
}
|
||||
}
|
||||
|
||||
function finishUp(aMonitor) {
|
||||
gPanelWin = null;
|
||||
gPanelDoc = null;
|
||||
/*
|
||||
* Make sure newly created event matches expected request
|
||||
*/
|
||||
function testSentRequest(data, origData) {
|
||||
is(data.method, origData.method, "correct method in sent request");
|
||||
is(data.url, origData.url + "&" + ADD_QUERY, "correct url in sent request");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
}
|
||||
let { headers } = data.requestHeaders;
|
||||
let hasHeader = headers.some(h => `${h.name}: ${h.value}` == ADD_HEADER);
|
||||
ok(hasHeader, "new header added to sent request");
|
||||
|
||||
is(data.requestPostData.postData.text,
|
||||
origData.requestPostData.postData.text + ADD_POSTDATA,
|
||||
"post data added to sent request");
|
||||
}
|
||||
|
||||
function type(string) {
|
||||
for (let ch of string) {
|
||||
EventUtils.synthesizeKey(ch, {}, panelWin);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -8,15 +8,18 @@
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { $, EVENTS, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
info("Performing a secure request.");
|
||||
debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH);
|
||||
|
||||
yield waitForNetworkEvents(monitor, 1);
|
||||
const REQUESTS_URL = "https://example.com" + CORS_SJS_PATH;
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, REQUESTS_URL, function* (url) {
|
||||
content.wrappedJSObject.performRequests(1, url);
|
||||
});
|
||||
yield wait;
|
||||
|
||||
info("Selecting the request.");
|
||||
RequestsMenu.selectedIndex = 0;
|
||||
|
@ -8,15 +8,18 @@
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { $, EVENTS, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
info("Requesting a resource that has a certificate problem.");
|
||||
debuggee.performRequests(1, "https://nocert.example.com");
|
||||
|
||||
yield waitForSecurityBrokenNetworkEvent();
|
||||
let wait = waitForSecurityBrokenNetworkEvent();
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests(1, "https://nocert.example.com");
|
||||
});
|
||||
yield wait;
|
||||
|
||||
info("Selecting the request.");
|
||||
RequestsMenu.selectedIndex = 0;
|
||||
@ -39,7 +42,7 @@ add_task(function* () {
|
||||
|
||||
isnot(errormsg.value, "", "Error message is not empty.");
|
||||
|
||||
yield teardown(monitor);
|
||||
return teardown(monitor);
|
||||
|
||||
/**
|
||||
* Returns a promise that's resolved once a request with security issues is
|
||||
|
@ -8,17 +8,14 @@
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { $, EVENTS, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
info("Requesting a resource over HTTPS.");
|
||||
debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH + "?request_2");
|
||||
yield waitForNetworkEvents(monitor, 1);
|
||||
|
||||
debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH + "?request_1");
|
||||
yield waitForNetworkEvents(monitor, 1);
|
||||
yield performRequestAndWait("https://example.com" + CORS_SJS_PATH + "?request_2");
|
||||
yield performRequestAndWait("https://example.com" + CORS_SJS_PATH + "?request_1");
|
||||
|
||||
is(RequestsMenu.itemCount, 2, "Two events event logged.");
|
||||
|
||||
@ -34,7 +31,15 @@ add_task(function* () {
|
||||
info("Testing that security icon can be clicked after the items were sorted.");
|
||||
yield clickAndTestSecurityIcon();
|
||||
|
||||
yield teardown(monitor);
|
||||
return teardown(monitor);
|
||||
|
||||
function* performRequestAndWait(url) {
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, { url }, function* (args) {
|
||||
content.wrappedJSObject.performRequests(1, args.url);
|
||||
});
|
||||
return wait;
|
||||
}
|
||||
|
||||
function* clickAndTestSecurityIcon() {
|
||||
let item = RequestsMenu.items[0];
|
||||
@ -49,5 +54,4 @@ add_task(function* () {
|
||||
is(NetworkDetails.widget.selectedPanel, $("#security-tabpanel"),
|
||||
"Security tab is selected.");
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -9,13 +9,16 @@
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { $, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
debuggee.performRequests(1, HTTPS_REDIRECT_SJS);
|
||||
yield waitForNetworkEvents(monitor, 2);
|
||||
let wait = waitForNetworkEvents(monitor, 2);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, HTTPS_REDIRECT_SJS, function* (url) {
|
||||
content.wrappedJSObject.performRequests(1, url);
|
||||
});
|
||||
yield wait;
|
||||
|
||||
is(RequestsMenu.itemCount, 2, "There were two requests due to redirect.");
|
||||
|
||||
|
@ -16,7 +16,7 @@ add_task(function* () {
|
||||
"localhost": "security-state-local",
|
||||
};
|
||||
|
||||
let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { $, EVENTS, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
@ -37,7 +37,7 @@ add_task(function* () {
|
||||
ok(classes.contains(expectedClass), "Icon contained the correct class name.");
|
||||
}
|
||||
|
||||
yield teardown(monitor);
|
||||
return teardown(monitor);
|
||||
|
||||
/**
|
||||
* A helper that performs requests to
|
||||
@ -48,12 +48,18 @@ add_task(function* () {
|
||||
* and waits until NetworkMonitor has handled all packets sent by the server.
|
||||
*/
|
||||
function* performRequests() {
|
||||
function executeRequests(count, url) {
|
||||
return ContentTask.spawn(tab.linkedBrowser, {count, url}, function* (args) {
|
||||
content.wrappedJSObject.performRequests(args.count, args.url);
|
||||
});
|
||||
}
|
||||
|
||||
// waitForNetworkEvents does not work for requests with security errors as
|
||||
// those only emit 9/13 events of a successful request.
|
||||
let done = waitForSecurityBrokenNetworkEvent();
|
||||
|
||||
info("Requesting a resource that has a certificate problem.");
|
||||
debuggee.performRequests(1, "https://nocert.example.com");
|
||||
yield executeRequests(1, "https://nocert.example.com");
|
||||
|
||||
// Wait for the request to complete before firing another request. Otherwise
|
||||
// the request with security issues interfere with waitForNetworkEvents.
|
||||
@ -64,17 +70,17 @@ add_task(function* () {
|
||||
// occasionally hangs waiting for event timings that don't seem to appear...
|
||||
done = waitForNetworkEvents(monitor, 1);
|
||||
info("Requesting a resource over HTTP.");
|
||||
debuggee.performRequests(1, "http://test1.example.com" + CORS_SJS_PATH);
|
||||
yield executeRequests(1, "http://test1.example.com" + CORS_SJS_PATH);
|
||||
yield done;
|
||||
|
||||
done = waitForNetworkEvents(monitor, 1);
|
||||
info("Requesting a resource over HTTPS.");
|
||||
debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH);
|
||||
yield executeRequests(1, "https://example.com" + CORS_SJS_PATH);
|
||||
yield done;
|
||||
|
||||
done = waitForSecurityBrokenNetworkEvent(true);
|
||||
info("Requesting a resource over HTTP to localhost.");
|
||||
debuggee.performRequests(1, "http://localhost" + CORS_SJS_PATH);
|
||||
yield executeRequests(1, "http://localhost" + CORS_SJS_PATH);
|
||||
yield done;
|
||||
|
||||
const expectedCount = Object.keys(EXPECTED_SECURITY_STATES).length;
|
||||
@ -101,7 +107,7 @@ add_task(function* () {
|
||||
// If the reason for breakage is a network error, then the
|
||||
// STARTED_RECEIVING_RESPONSE event does not fire.
|
||||
if (networkError) {
|
||||
awaitedEvents.splice(4, 1);
|
||||
awaitedEvents = awaitedEvents.filter(e => e !== "STARTED_RECEIVING_RESPONSE");
|
||||
}
|
||||
|
||||
let promises = awaitedEvents.map((event) => {
|
||||
|
@ -9,15 +9,23 @@
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { $, EVENTS, NetMonitorView } = monitor.panelWin;
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { EVENTS, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
info("Performing requests.");
|
||||
debuggee.performRequests(1, "https://example.com" + CORS_SJS_PATH);
|
||||
debuggee.performRequests(1, "http://example.com" + CORS_SJS_PATH);
|
||||
yield waitForNetworkEvents(monitor, 2);
|
||||
let wait = waitForNetworkEvents(monitor, 2);
|
||||
const REQUEST_URLS = [
|
||||
"https://example.com" + CORS_SJS_PATH,
|
||||
"http://example.com" + CORS_SJS_PATH,
|
||||
];
|
||||
yield ContentTask.spawn(tab.linkedBrowser, REQUEST_URLS, function* (urls) {
|
||||
for (let url of urls) {
|
||||
content.wrappedJSObject.performRequests(1, url);
|
||||
}
|
||||
});
|
||||
yield wait;
|
||||
|
||||
info("Selecting secure request.");
|
||||
RequestsMenu.selectedIndex = 0;
|
||||
@ -34,5 +42,5 @@ add_task(function* () {
|
||||
is(NetworkDetails.widget.selectedIndex, 0,
|
||||
"Selected tab was reset when selected security tab was hidden.");
|
||||
|
||||
yield teardown(monitor);
|
||||
return teardown(monitor);
|
||||
});
|
||||
|
@ -31,7 +31,7 @@ add_task(function* () {
|
||||
}
|
||||
];
|
||||
|
||||
let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { $, EVENTS, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
@ -44,11 +44,13 @@ add_task(function* () {
|
||||
waitForSecurityBrokenNetworkEvent() :
|
||||
waitForNetworkEvents(monitor, 1);
|
||||
|
||||
let tab = $("#security-tab");
|
||||
let tabEl = $("#security-tab");
|
||||
let tabpanel = $("#security-tabpanel");
|
||||
|
||||
info("Performing a request to " + testcase.uri);
|
||||
debuggee.performRequests(1, testcase.uri);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, testcase.uri, function* (url) {
|
||||
content.wrappedJSObject.performRequests(1, url);
|
||||
});
|
||||
|
||||
info("Waiting for new network event.");
|
||||
yield onNewItem;
|
||||
@ -58,7 +60,7 @@ add_task(function* () {
|
||||
|
||||
is(RequestsMenu.selectedItem.attachment.securityState, undefined,
|
||||
"Security state has not yet arrived.");
|
||||
is(tab.hidden, !testcase.visibleOnNewEvent,
|
||||
is(tabEl.hidden, !testcase.visibleOnNewEvent,
|
||||
"Security tab is " +
|
||||
(testcase.visibleOnNewEvent ? "visible" : "hidden") +
|
||||
" after new request was added to the menu.");
|
||||
@ -70,7 +72,7 @@ add_task(function* () {
|
||||
|
||||
ok(RequestsMenu.selectedItem.attachment.securityState,
|
||||
"Security state arrived.");
|
||||
is(tab.hidden, !testcase.visibleOnSecurityInfo,
|
||||
is(tabEl.hidden, !testcase.visibleOnSecurityInfo,
|
||||
"Security tab is " +
|
||||
(testcase.visibleOnSecurityInfo ? "visible" : "hidden") +
|
||||
" after security information arrived.");
|
||||
@ -79,7 +81,8 @@ add_task(function* () {
|
||||
|
||||
info("Waiting for request to complete.");
|
||||
yield onComplete;
|
||||
is(tab.hidden, !testcase.visibleOnceComplete,
|
||||
|
||||
is(tabEl.hidden, !testcase.visibleOnceComplete,
|
||||
"Security tab is " +
|
||||
(testcase.visibleOnceComplete ? "visible" : "hidden") +
|
||||
" after request has been completed.");
|
||||
@ -90,7 +93,7 @@ add_task(function* () {
|
||||
RequestsMenu.clear();
|
||||
}
|
||||
|
||||
yield teardown(monitor);
|
||||
return teardown(monitor);
|
||||
|
||||
/**
|
||||
* Returns a promise that's resolved once a request with security issues is
|
||||
|
@ -16,7 +16,7 @@ const TEST_CASES = [
|
||||
];
|
||||
|
||||
add_task(function* () {
|
||||
let [tab, debuggee, monitor] = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { tab, monitor } = yield initNetMonitor(CUSTOM_GET_URL);
|
||||
let { $, EVENTS, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
@ -27,8 +27,11 @@ add_task(function* () {
|
||||
info("Testing site with " + test.desc);
|
||||
|
||||
info("Performing request to " + test.uri);
|
||||
debuggee.performRequests(1, test.uri);
|
||||
yield waitForNetworkEvents(monitor, 1);
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, test.uri, function* (url) {
|
||||
content.wrappedJSObject.performRequests(1, url);
|
||||
});
|
||||
yield wait;
|
||||
|
||||
info("Selecting the request.");
|
||||
RequestsMenu.selectedIndex = 0;
|
||||
@ -47,9 +50,7 @@ add_task(function* () {
|
||||
is(cipher.hidden, !test.warnCipher, "Cipher suite warning is hidden.");
|
||||
|
||||
RequestsMenu.clear();
|
||||
|
||||
}
|
||||
|
||||
yield teardown(monitor);
|
||||
|
||||
return teardown(monitor);
|
||||
});
|
||||
|
@ -1,31 +1,34 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if beacons from other tabs are properly ignored.
|
||||
*/
|
||||
|
||||
var test = Task.async(function* () {
|
||||
let [, debuggee, monitor] = yield initNetMonitor(SIMPLE_URL);
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
let { RequestsMenu } = monitor.panelWin.NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
let tab = yield addTab(SEND_BEACON_URL);
|
||||
let beaconDebuggee = tab.linkedBrowser.contentWindow.wrappedJSObject;
|
||||
let beaconTab = yield addTab(SEND_BEACON_URL);
|
||||
info("Beacon tab added successfully.");
|
||||
|
||||
is(RequestsMenu.itemCount, 0, "The requests menu should be empty.");
|
||||
|
||||
beaconDebuggee.performRequest();
|
||||
debuggee.location.reload();
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(beaconTab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequest();
|
||||
});
|
||||
tab.linkedBrowser.reload();
|
||||
yield wait;
|
||||
|
||||
yield waitForNetworkEvents(monitor, 1);
|
||||
is(RequestsMenu.itemCount, 1, "Only the reload should be recorded.");
|
||||
let request = RequestsMenu.getItemAtIndex(0);
|
||||
is(request.attachment.method, "GET", "The method is correct.");
|
||||
is(request.attachment.status, "200", "The status is correct.");
|
||||
|
||||
yield teardown(monitor);
|
||||
removeTab(tab);
|
||||
finish();
|
||||
yield removeTab(beaconTab);
|
||||
return teardown(monitor);
|
||||
});
|
||||
|
@ -1,27 +1,31 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if beacons are handled correctly.
|
||||
*/
|
||||
|
||||
var test = Task.async(function* () {
|
||||
let [, debuggee, monitor] = yield initNetMonitor(SEND_BEACON_URL);
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(SEND_BEACON_URL);
|
||||
let { RequestsMenu } = monitor.panelWin.NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
is(RequestsMenu.itemCount, 0, "The requests menu should be empty.");
|
||||
|
||||
debuggee.performRequest();
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequest();
|
||||
});
|
||||
yield wait;
|
||||
|
||||
yield waitForNetworkEvents(monitor, 1);
|
||||
is(RequestsMenu.itemCount, 1, "The beacon should be recorded.");
|
||||
let request = RequestsMenu.getItemAtIndex(0);
|
||||
is(request.attachment.method, "POST", "The method is correct.");
|
||||
ok(request.attachment.url.endsWith("beacon_request"), "The URL is correct.");
|
||||
is(request.attachment.status, "404", "The status is correct.");
|
||||
|
||||
yield teardown(monitor);
|
||||
finish();
|
||||
return teardown(monitor);
|
||||
});
|
||||
|
@ -13,7 +13,7 @@ const URL = EXAMPLE_URL.replace("http:", "https:");
|
||||
const TEST_URL = URL + "service-workers/status-codes.html";
|
||||
|
||||
add_task(function* () {
|
||||
let [tab, , monitor] = yield initNetMonitor(TEST_URL, null, true);
|
||||
let { tab, monitor } = yield initNetMonitor(TEST_URL, null, true);
|
||||
info("Starting test... ");
|
||||
|
||||
let { NetMonitorView } = monitor.panelWin;
|
||||
|
@ -1,6 +1,8 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Simple check if the network monitor starts up and shuts down properly.
|
||||
*/
|
||||
@ -11,66 +13,64 @@ function test() {
|
||||
let gInfo = info;
|
||||
let gOk = ok;
|
||||
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
initNetMonitor(SIMPLE_URL).then(({ tab, monitor }) => {
|
||||
info("Starting test... ");
|
||||
|
||||
is(aTab.linkedBrowser.contentWindow.wrappedJSObject.location, SIMPLE_URL,
|
||||
is(tab.linkedBrowser.currentURI.spec, SIMPLE_URL,
|
||||
"The current tab's location is the correct one.");
|
||||
is(aDebuggee.location, SIMPLE_URL,
|
||||
"The current debuggee's location is the correct one.");
|
||||
|
||||
function checkIfInitialized(aTag) {
|
||||
info("Checking if initialization is ok (" + aTag + ").");
|
||||
function checkIfInitialized(tag) {
|
||||
info(`Checking if initialization is ok (${tag}).`);
|
||||
|
||||
ok(aMonitor._view,
|
||||
"The network monitor view object exists (" + aTag + ").");
|
||||
ok(aMonitor._controller,
|
||||
"The network monitor controller object exists (" + aTag + ").");
|
||||
ok(aMonitor._controller._startup,
|
||||
"The network monitor controller object exists and is initialized (" + aTag + ").");
|
||||
ok(monitor._view,
|
||||
`The network monitor view object exists (${tag}).`);
|
||||
ok(monitor._controller,
|
||||
`The network monitor controller object exists (${tag}).`);
|
||||
ok(monitor._controller._startup,
|
||||
`The network monitor controller object exists and is initialized (${tag}).`);
|
||||
|
||||
ok(aMonitor.isReady,
|
||||
"The network monitor panel appears to be ready (" + aTag + ").");
|
||||
ok(monitor.isReady,
|
||||
`The network monitor panel appears to be ready (${tag}).`);
|
||||
|
||||
ok(aMonitor._controller.tabClient,
|
||||
"There should be a tabClient available at this point (" + aTag + ").");
|
||||
ok(aMonitor._controller.webConsoleClient,
|
||||
"There should be a webConsoleClient available at this point (" + aTag + ").");
|
||||
ok(aMonitor._controller.timelineFront,
|
||||
"There should be a timelineFront available at this point (" + aTag + ").");
|
||||
ok(monitor._controller.tabClient,
|
||||
`There should be a tabClient available at this point (${tag}).`);
|
||||
ok(monitor._controller.webConsoleClient,
|
||||
`There should be a webConsoleClient available at this point (${tag}).`);
|
||||
ok(monitor._controller.timelineFront,
|
||||
`There should be a timelineFront available at this point (${tag}).`);
|
||||
}
|
||||
|
||||
function checkIfDestroyed(aTag) {
|
||||
function checkIfDestroyed(tag) {
|
||||
gInfo("Checking if destruction is ok.");
|
||||
|
||||
gOk(aMonitor._view,
|
||||
"The network monitor view object still exists (" + aTag + ").");
|
||||
gOk(aMonitor._controller,
|
||||
"The network monitor controller object still exists (" + aTag + ").");
|
||||
gOk(aMonitor._controller._shutdown,
|
||||
"The network monitor controller object still exists and is destroyed (" + aTag + ").");
|
||||
gOk(monitor._view,
|
||||
`The network monitor view object still exists (${tag}).`);
|
||||
gOk(monitor._controller,
|
||||
`The network monitor controller object still exists (${tag}).`);
|
||||
gOk(monitor._controller._shutdown,
|
||||
`The network monitor controller object still exists and is destroyed (${tag}).`);
|
||||
|
||||
gOk(!aMonitor._controller.tabClient,
|
||||
"There shouldn't be a tabClient available after destruction (" + aTag + ").");
|
||||
gOk(!aMonitor._controller.webConsoleClient,
|
||||
"There shouldn't be a webConsoleClient available after destruction (" + aTag + ").");
|
||||
gOk(!aMonitor._controller.timelineFront,
|
||||
"There shouldn't be a timelineFront available after destruction (" + aTag + ").");
|
||||
gOk(!monitor._controller.tabClient,
|
||||
`There shouldn't be a tabClient available after destruction (${tag}).`);
|
||||
gOk(!monitor._controller.webConsoleClient,
|
||||
`There shouldn't be a webConsoleClient available after destruction (${tag}).`);
|
||||
gOk(!monitor._controller.timelineFront,
|
||||
`There shouldn't be a timelineFront available after destruction (${tag}).`);
|
||||
}
|
||||
|
||||
executeSoon(() => {
|
||||
checkIfInitialized(1);
|
||||
|
||||
aMonitor._controller.startupNetMonitor()
|
||||
monitor._controller.startupNetMonitor()
|
||||
.then(() => {
|
||||
info("Starting up again shouldn't do anything special.");
|
||||
checkIfInitialized(2);
|
||||
return aMonitor._controller.connect();
|
||||
return monitor._controller.connect();
|
||||
})
|
||||
.then(() => {
|
||||
info("Connecting again shouldn't do anything special.");
|
||||
checkIfInitialized(3);
|
||||
return teardown(aMonitor);
|
||||
return teardown(monitor);
|
||||
})
|
||||
.then(finish);
|
||||
});
|
||||
@ -78,11 +78,11 @@ function test() {
|
||||
registerCleanupFunction(() => {
|
||||
checkIfDestroyed(1);
|
||||
|
||||
aMonitor._controller.shutdownNetMonitor()
|
||||
monitor._controller.shutdownNetMonitor()
|
||||
.then(() => {
|
||||
gInfo("Shutting down again shouldn't do anything special.");
|
||||
checkIfDestroyed(2);
|
||||
return aMonitor._controller.disconnect();
|
||||
return monitor._controller.disconnect();
|
||||
})
|
||||
.then(() => {
|
||||
gInfo("Disconnecting again shouldn't do anything special.");
|
||||
|
@ -1,24 +1,26 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if requests render correct information in the menu UI.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_SJS).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
initNetMonitor(SIMPLE_SJS).then(({ tab, monitor }) => {
|
||||
info("Starting test... ");
|
||||
|
||||
let { L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1)
|
||||
.then(() => teardown(aMonitor))
|
||||
waitForNetworkEvents(monitor, 1)
|
||||
.then(() => teardown(monitor))
|
||||
.then(finish);
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.NETWORK_EVENT, () => {
|
||||
monitor.panelWin.once(monitor.panelWin.EVENTS.NETWORK_EVENT, () => {
|
||||
is(RequestsMenu.selectedItem, null,
|
||||
"There shouldn't be any selected item in the requests menu.");
|
||||
is(RequestsMenu.itemCount, 1,
|
||||
@ -27,7 +29,6 @@ function test() {
|
||||
"The details pane should still be hidden after the first request.");
|
||||
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
let target = requestItem.target;
|
||||
|
||||
is(typeof requestItem.value, "string",
|
||||
"The attached request id is incorrect.");
|
||||
@ -83,7 +84,7 @@ function test() {
|
||||
verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS);
|
||||
});
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_REQUEST_HEADERS, () => {
|
||||
monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_REQUEST_HEADERS, () => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
|
||||
ok(requestItem.attachment.requestHeaders,
|
||||
@ -98,7 +99,7 @@ function test() {
|
||||
verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS);
|
||||
});
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_REQUEST_COOKIES, () => {
|
||||
monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_REQUEST_COOKIES, () => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
|
||||
ok(requestItem.attachment.requestCookies,
|
||||
@ -109,11 +110,11 @@ function test() {
|
||||
verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS);
|
||||
});
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_REQUEST_POST_DATA, () => {
|
||||
monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_REQUEST_POST_DATA, () => {
|
||||
ok(false, "Trap listener: this request doesn't have any post data.");
|
||||
});
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_RESPONSE_HEADERS, () => {
|
||||
monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_RESPONSE_HEADERS, () => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
|
||||
ok(requestItem.attachment.responseHeaders,
|
||||
@ -126,7 +127,7 @@ function test() {
|
||||
verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS);
|
||||
});
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_RESPONSE_COOKIES, () => {
|
||||
monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_RESPONSE_COOKIES, () => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
|
||||
ok(requestItem.attachment.responseCookies,
|
||||
@ -137,7 +138,7 @@ function test() {
|
||||
verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS);
|
||||
});
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.STARTED_RECEIVING_RESPONSE, () => {
|
||||
monitor.panelWin.once(monitor.panelWin.EVENTS.STARTED_RECEIVING_RESPONSE, () => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
|
||||
is(requestItem.attachment.httpVersion, "HTTP/1.1",
|
||||
@ -155,7 +156,7 @@ function test() {
|
||||
});
|
||||
});
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.UPDATING_RESPONSE_CONTENT, () => {
|
||||
monitor.panelWin.once(monitor.panelWin.EVENTS.UPDATING_RESPONSE_CONTENT, () => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
|
||||
is(requestItem.attachment.transferredSize, "12",
|
||||
@ -173,16 +174,19 @@ function test() {
|
||||
});
|
||||
});
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_RESPONSE_CONTENT, () => {
|
||||
monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_RESPONSE_CONTENT, () => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
|
||||
ok(requestItem.attachment.responseContent,
|
||||
"There should be a responseContent attachment available.");
|
||||
is(requestItem.attachment.responseContent.content.mimeType, "text/plain; charset=utf-8",
|
||||
is(requestItem.attachment.responseContent.content.mimeType,
|
||||
"text/plain; charset=utf-8",
|
||||
"The responseContent attachment has an incorrect |content.mimeType| property.");
|
||||
is(requestItem.attachment.responseContent.content.text, "Hello world!",
|
||||
is(requestItem.attachment.responseContent.content.text,
|
||||
"Hello world!",
|
||||
"The responseContent attachment has an incorrect |content.text| property.");
|
||||
is(requestItem.attachment.responseContent.content.size, 12,
|
||||
is(requestItem.attachment.responseContent.content.size,
|
||||
12,
|
||||
"The responseContent attachment has an incorrect |content.size| property.");
|
||||
|
||||
verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, {
|
||||
@ -193,7 +197,7 @@ function test() {
|
||||
});
|
||||
});
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.UPDATING_EVENT_TIMINGS, () => {
|
||||
monitor.panelWin.once(monitor.panelWin.EVENTS.UPDATING_EVENT_TIMINGS, () => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
|
||||
is(typeof requestItem.attachment.totalTime, "number",
|
||||
@ -211,7 +215,7 @@ function test() {
|
||||
});
|
||||
});
|
||||
|
||||
aMonitor.panelWin.once(aMonitor.panelWin.EVENTS.RECEIVED_EVENT_TIMINGS, () => {
|
||||
monitor.panelWin.once(monitor.panelWin.EVENTS.RECEIVED_EVENT_TIMINGS, () => {
|
||||
let requestItem = RequestsMenu.getItemAtIndex(0);
|
||||
|
||||
ok(requestItem.attachment.eventTimings,
|
||||
@ -236,6 +240,6 @@ function test() {
|
||||
});
|
||||
});
|
||||
|
||||
aDebuggee.location.reload();
|
||||
tab.linkedBrowser.reload();
|
||||
});
|
||||
}
|
||||
|
@ -1,244 +1,259 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Tests if requests render correct information in the details UI.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_SJS).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(SIMPLE_SJS);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
let TAB_UPDATED = aMonitor.panelWin.EVENTS.TAB_UPDATED;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
let { document, EVENTS, L10N, Editor, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
Task.spawn(function* () {
|
||||
yield waitForNetworkEvents(aMonitor, 1);
|
||||
is(RequestsMenu.selectedItem, null,
|
||||
"There shouldn't be any selected item in the requests menu.");
|
||||
is(RequestsMenu.itemCount, 1,
|
||||
"The requests menu should not be empty after the first request.");
|
||||
is(NetMonitorView.detailsPaneHidden, true,
|
||||
"The details pane should still be hidden after the first request.");
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
tab.linkedBrowser.reload();
|
||||
yield wait;
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
is(RequestsMenu.selectedItem, null,
|
||||
"There shouldn't be any selected item in the requests menu.");
|
||||
is(RequestsMenu.itemCount, 1,
|
||||
"The requests menu should not be empty after the first request.");
|
||||
is(NetMonitorView.detailsPaneHidden, true,
|
||||
"The details pane should still be hidden after the first request.");
|
||||
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
let onTabUpdated = monitor.panelWin.once(EVENTS.TAB_UPDATED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.getElementById("details-pane-toggle"));
|
||||
yield onTabUpdated;
|
||||
|
||||
yield waitFor(aMonitor.panelWin, TAB_UPDATED);
|
||||
testHeadersTab();
|
||||
yield testCookiesTab();
|
||||
testParamsTab();
|
||||
yield testResponseTab();
|
||||
testTimingsTab();
|
||||
yield teardown(aMonitor);
|
||||
finish();
|
||||
});
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
|
||||
function testHeadersTab() {
|
||||
let tab = document.querySelectorAll("#details-pane tab")[0];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0];
|
||||
testHeadersTab();
|
||||
yield testCookiesTab();
|
||||
testParamsTab();
|
||||
yield testResponseTab();
|
||||
testTimingsTab();
|
||||
return teardown(monitor);
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The headers tab in the network details pane should be selected.");
|
||||
function testHeadersTab() {
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[0];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[0];
|
||||
|
||||
is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("value"),
|
||||
SIMPLE_SJS, "The url summary value is incorrect.");
|
||||
is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("tooltiptext"),
|
||||
SIMPLE_SJS, "The url summary tooltiptext is incorrect.");
|
||||
is(tabpanel.querySelector("#headers-summary-method-value").getAttribute("value"),
|
||||
"GET", "The method summary value is incorrect.");
|
||||
is(tabpanel.querySelector("#headers-summary-address-value").getAttribute("value"),
|
||||
"127.0.0.1:8888", "The remote address summary value is incorrect.");
|
||||
is(tabpanel.querySelector("#headers-summary-status-circle").getAttribute("code"),
|
||||
"200", "The status summary code is incorrect.");
|
||||
is(tabpanel.querySelector("#headers-summary-status-value").getAttribute("value"),
|
||||
"200 Och Aye", "The status summary value is incorrect.");
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The headers tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
|
||||
"There should be 2 header scopes displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, 19,
|
||||
"There should be 19 header values displayed in this tabpanel.");
|
||||
is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("value"),
|
||||
SIMPLE_SJS, "The url summary value is incorrect.");
|
||||
is(tabpanel.querySelector("#headers-summary-url-value").getAttribute("tooltiptext"),
|
||||
SIMPLE_SJS, "The url summary tooltiptext is incorrect.");
|
||||
is(tabpanel.querySelector("#headers-summary-method-value").getAttribute("value"),
|
||||
"GET", "The method summary value is incorrect.");
|
||||
is(tabpanel.querySelector("#headers-summary-address-value").getAttribute("value"),
|
||||
"127.0.0.1:8888", "The remote address summary value is incorrect.");
|
||||
is(tabpanel.querySelector("#headers-summary-status-circle").getAttribute("code"),
|
||||
"200", "The status summary code is incorrect.");
|
||||
is(tabpanel.querySelector("#headers-summary-status-value").getAttribute("value"),
|
||||
"200 Och Aye", "The status summary value is incorrect.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
|
||||
"There should be 2 header scopes displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, 19,
|
||||
"There should be 19 header values displayed in this tabpanel.");
|
||||
|
||||
let responseScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
let requestScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
||||
is(responseScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("responseHeaders") + " (" +
|
||||
L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(330 / 1024, 3)) + ")",
|
||||
"The response headers scope doesn't have the correct title.");
|
||||
let responseScope = tabpanel.querySelectorAll(".variables-view-scope")[0];
|
||||
let requestScope = tabpanel.querySelectorAll(".variables-view-scope")[1];
|
||||
|
||||
ok(requestScope.querySelector(".name").getAttribute("value").includes(
|
||||
L10N.getStr("requestHeaders") + " (0"),
|
||||
"The request headers scope doesn't have the correct title.");
|
||||
// Can't test for full request headers title because the size may
|
||||
// vary across platforms ("User-Agent" header differs). We're pretty
|
||||
// sure it's smaller than 1 MB though, so it starts with a 0.
|
||||
is(responseScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("responseHeaders") + " (" +
|
||||
L10N.getFormatStr("networkMenu.sizeKB",
|
||||
L10N.numberWithDecimals(330 / 1024, 3)) + ")",
|
||||
"The response headers scope doesn't have the correct title.");
|
||||
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
"Cache-Control", "The first response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
"\"no-cache, no-store, must-revalidate\"", "The first response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
|
||||
"Connection", "The second response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
|
||||
"\"close\"", "The second response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[2].getAttribute("value"),
|
||||
"Content-Length", "The third response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[2].getAttribute("value"),
|
||||
"\"12\"", "The third response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[3].getAttribute("value"),
|
||||
"Content-Type", "The fourth response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[3].getAttribute("value"),
|
||||
"\"text/plain; charset=utf-8\"", "The fourth response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[9].getAttribute("value"),
|
||||
"foo-bar", "The last response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[9].getAttribute("value"),
|
||||
"\"baz\"", "The last response header value was incorrect.");
|
||||
ok(requestScope.querySelector(".name").getAttribute("value").includes(
|
||||
L10N.getStr("requestHeaders") + " (0"),
|
||||
"The request headers scope doesn't have the correct title.");
|
||||
// Can't test for full request headers title because the size may
|
||||
// vary across platforms ("User-Agent" header differs). We're pretty
|
||||
// sure it's smaller than 1 MB though, so it starts with a 0.
|
||||
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
"Host", "The first request header name was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
"\"example.com\"", "The first request header value was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[6].getAttribute("value"),
|
||||
"Connection", "The ante-penultimate request header name was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .value")[6].getAttribute("value"),
|
||||
"\"keep-alive\"", "The ante-penultimate request header value was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[7].getAttribute("value"),
|
||||
"Pragma", "The penultimate request header name was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .value")[7].getAttribute("value"),
|
||||
"\"no-cache\"", "The penultimate request header value was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[8].getAttribute("value"),
|
||||
"Cache-Control", "The last request header name was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .value")[8].getAttribute("value"),
|
||||
"\"no-cache\"", "The last request header value was incorrect.");
|
||||
}
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[0]
|
||||
.getAttribute("value"),
|
||||
"Cache-Control", "The first response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[0]
|
||||
.getAttribute("value"),
|
||||
"\"no-cache, no-store, must-revalidate\"",
|
||||
"The first response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[1]
|
||||
.getAttribute("value"),
|
||||
"Connection", "The second response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[1]
|
||||
.getAttribute("value"),
|
||||
"\"close\"", "The second response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[2]
|
||||
.getAttribute("value"),
|
||||
"Content-Length", "The third response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[2]
|
||||
.getAttribute("value"),
|
||||
"\"12\"", "The third response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[3]
|
||||
.getAttribute("value"),
|
||||
"Content-Type", "The fourth response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[3]
|
||||
.getAttribute("value"),
|
||||
"\"text/plain; charset=utf-8\"", "The fourth response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[9]
|
||||
.getAttribute("value"),
|
||||
"foo-bar", "The last response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[9]
|
||||
.getAttribute("value"),
|
||||
"\"baz\"", "The last response header value was incorrect.");
|
||||
|
||||
function testCookiesTab() {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[1]);
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[0]
|
||||
.getAttribute("value"),
|
||||
"Host", "The first request header name was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .value")[0]
|
||||
.getAttribute("value"),
|
||||
"\"example.com\"", "The first request header value was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[6]
|
||||
.getAttribute("value"),
|
||||
"Connection", "The ante-penultimate request header name was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .value")[6]
|
||||
.getAttribute("value"),
|
||||
"\"keep-alive\"", "The ante-penultimate request header value was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[7]
|
||||
.getAttribute("value"),
|
||||
"Pragma", "The penultimate request header name was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .value")[7]
|
||||
.getAttribute("value"),
|
||||
"\"no-cache\"", "The penultimate request header value was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[8]
|
||||
.getAttribute("value"),
|
||||
"Cache-Control", "The last request header name was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .value")[8]
|
||||
.getAttribute("value"),
|
||||
"\"no-cache\"", "The last request header value was incorrect.");
|
||||
}
|
||||
|
||||
return Task.spawn(function* () {
|
||||
yield waitFor(aMonitor.panelWin, TAB_UPDATED);
|
||||
function* testCookiesTab() {
|
||||
let onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[1]);
|
||||
yield onEvent;
|
||||
|
||||
let tab = document.querySelectorAll("#details-pane tab")[1];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[1];
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[1];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[1];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The cookies tab in the network details pane should be selected.");
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The cookies tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
|
||||
"There should be 2 cookie scopes displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, 6,
|
||||
"There should be 6 cookie values displayed in this tabpanel.");
|
||||
});
|
||||
}
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
|
||||
"There should be 2 cookie scopes displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, 6,
|
||||
"There should be 6 cookie values displayed in this tabpanel.");
|
||||
}
|
||||
|
||||
function testParamsTab() {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[2]);
|
||||
function testParamsTab() {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[2]);
|
||||
|
||||
let tab = document.querySelectorAll("#details-pane tab")[2];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[2];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[2];
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The params tab in the network details pane should be selected.");
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The params tab in the network details pane should be selected.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 0,
|
||||
"There should be no param scopes displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, 0,
|
||||
"There should be no param values displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 1,
|
||||
"The empty notice should be displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 0,
|
||||
"There should be no param scopes displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, 0,
|
||||
"There should be no param values displayed in this tabpanel.");
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 1,
|
||||
"The empty notice should be displayed in this tabpanel.");
|
||||
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The request params box should not be hidden.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The request post data textarea box should be hidden.");
|
||||
}
|
||||
is(tabpanel.querySelector("#request-params-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The request params box should not be hidden.");
|
||||
is(tabpanel.querySelector("#request-post-data-textarea-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The request post data textarea box should be hidden.");
|
||||
}
|
||||
|
||||
function testResponseTab() {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
function* testResponseTab() {
|
||||
let onEvent = monitor.panelWin.once(EVENTS.TAB_UPDATED);
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[3]);
|
||||
yield onEvent;
|
||||
|
||||
return Task.spawn(function* () {
|
||||
yield waitFor(aMonitor.panelWin, TAB_UPDATED);
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
|
||||
let tab = document.querySelectorAll("#details-pane tab")[3];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[3];
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The response tab in the network details pane should be selected.");
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header should be hidden.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content json box should be hidden.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content textarea box should not be hidden.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box should be hidden.");
|
||||
|
||||
is(tabpanel.querySelector("#response-content-info-header")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response info header should be hidden.");
|
||||
is(tabpanel.querySelector("#response-content-json-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content json box should be hidden.");
|
||||
is(tabpanel.querySelector("#response-content-textarea-box")
|
||||
.hasAttribute("hidden"), false,
|
||||
"The response content textarea box should not be hidden.");
|
||||
is(tabpanel.querySelector("#response-content-image-box")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The response content image box should be hidden.");
|
||||
let editor = yield NetMonitorView.editor("#response-content-textarea");
|
||||
is(editor.getText(), "Hello world!",
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(editor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
}
|
||||
|
||||
let aEditor = yield NetMonitorView.editor("#response-content-textarea");
|
||||
is(aEditor.getText(), "Hello world!",
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
});
|
||||
}
|
||||
function testTimingsTab() {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[4]);
|
||||
|
||||
function testTimingsTab() {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelectorAll("#details-pane tab")[4]);
|
||||
let tabEl = document.querySelectorAll("#details-pane tab")[4];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[4];
|
||||
|
||||
let tab = document.querySelectorAll("#details-pane tab")[4];
|
||||
let tabpanel = document.querySelectorAll("#details-pane tabpanel")[4];
|
||||
is(tabEl.getAttribute("selected"), "true",
|
||||
"The timings tab in the network details pane should be selected.");
|
||||
|
||||
is(tab.getAttribute("selected"), "true",
|
||||
"The timings tab in the network details pane should be selected.");
|
||||
ok(tabpanel.querySelector("#timings-summary-blocked .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The blocked timing info does not appear to be correct.");
|
||||
|
||||
ok(tabpanel.querySelector("#timings-summary-blocked .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The blocked timing info does not appear to be correct.");
|
||||
ok(tabpanel.querySelector("#timings-summary-dns .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The dns timing info does not appear to be correct.");
|
||||
|
||||
ok(tabpanel.querySelector("#timings-summary-dns .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The dns timing info does not appear to be correct.");
|
||||
ok(tabpanel.querySelector("#timings-summary-connect .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The connect timing info does not appear to be correct.");
|
||||
|
||||
ok(tabpanel.querySelector("#timings-summary-connect .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The connect timing info does not appear to be correct.");
|
||||
ok(tabpanel.querySelector("#timings-summary-send .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The send timing info does not appear to be correct.");
|
||||
|
||||
ok(tabpanel.querySelector("#timings-summary-send .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The send timing info does not appear to be correct.");
|
||||
ok(tabpanel.querySelector("#timings-summary-wait .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The wait timing info does not appear to be correct.");
|
||||
|
||||
ok(tabpanel.querySelector("#timings-summary-wait .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The wait timing info does not appear to be correct.");
|
||||
|
||||
ok(tabpanel.querySelector("#timings-summary-receive .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The receive timing info does not appear to be correct.");
|
||||
}
|
||||
|
||||
aDebuggee.location.reload();
|
||||
});
|
||||
}
|
||||
ok(tabpanel.querySelector("#timings-summary-receive .requests-menu-timings-total")
|
||||
.getAttribute("value").match(/[0-9]+/),
|
||||
"The receive timing info does not appear to be correct.");
|
||||
}
|
||||
});
|
||||
|
@ -11,69 +11,62 @@
|
||||
* 3) Empty user message visibility
|
||||
* 4) Number of requests displayed
|
||||
*/
|
||||
function test() {
|
||||
initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(SIMPLE_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { document, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
is(document.querySelector("#details-pane-toggle")
|
||||
.hasAttribute("disabled"), true,
|
||||
"The pane toggle button should be disabled when the frontend is opened.");
|
||||
is(document.querySelector("#requests-menu-empty-notice")
|
||||
.hasAttribute("hidden"), false,
|
||||
"An empty notice should be displayed when the frontend is opened.");
|
||||
is(RequestsMenu.itemCount, 0,
|
||||
"The requests menu should be empty when the frontend is opened.");
|
||||
is(NetMonitorView.detailsPaneHidden, true,
|
||||
"The details pane should be hidden when the frontend is opened.");
|
||||
is(document.querySelector("#details-pane-toggle").hasAttribute("disabled"), true,
|
||||
"The pane toggle button should be disabled when the frontend is opened.");
|
||||
is(document.querySelector("#requests-menu-empty-notice").hasAttribute("hidden"), false,
|
||||
"An empty notice should be displayed when the frontend is opened.");
|
||||
is(RequestsMenu.itemCount, 0,
|
||||
"The requests menu should be empty when the frontend is opened.");
|
||||
is(NetMonitorView.detailsPaneHidden, true,
|
||||
"The details pane should be hidden when the frontend is opened.");
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
is(document.querySelector("#details-pane-toggle")
|
||||
.hasAttribute("disabled"), false,
|
||||
"The pane toggle button should be enabled after the first request.");
|
||||
is(document.querySelector("#requests-menu-empty-notice")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The empty notice should be hidden after the first request.");
|
||||
is(RequestsMenu.itemCount, 1,
|
||||
"The requests menu should not be empty after the first request.");
|
||||
is(NetMonitorView.detailsPaneHidden, true,
|
||||
"The details pane should still be hidden after the first request.");
|
||||
yield reloadAndWait();
|
||||
|
||||
waitForNetworkEvents(aMonitor, 1).then(() => {
|
||||
is(document.querySelector("#details-pane-toggle")
|
||||
.hasAttribute("disabled"), false,
|
||||
"The pane toggle button should be still be enabled after a reload.");
|
||||
is(document.querySelector("#requests-menu-empty-notice")
|
||||
.hasAttribute("hidden"), true,
|
||||
"The empty notice should be still hidden after a reload.");
|
||||
is(RequestsMenu.itemCount, 1,
|
||||
"The requests menu should not be empty after a reload.");
|
||||
is(NetMonitorView.detailsPaneHidden, true,
|
||||
"The details pane should still be hidden after a reload.");
|
||||
is(document.querySelector("#details-pane-toggle").hasAttribute("disabled"), false,
|
||||
"The pane toggle button should be enabled after the first request.");
|
||||
is(document.querySelector("#requests-menu-empty-notice").hasAttribute("hidden"), true,
|
||||
"The empty notice should be hidden after the first request.");
|
||||
is(RequestsMenu.itemCount, 1,
|
||||
"The requests menu should not be empty after the first request.");
|
||||
is(NetMonitorView.detailsPaneHidden, true,
|
||||
"The details pane should still be hidden after the first request.");
|
||||
|
||||
RequestsMenu.clear();
|
||||
yield reloadAndWait();
|
||||
|
||||
is(document.querySelector("#details-pane-toggle")
|
||||
.hasAttribute("disabled"), true,
|
||||
"The pane toggle button should be disabled when after clear.");
|
||||
is(document.querySelector("#requests-menu-empty-notice")
|
||||
.hasAttribute("hidden"), false,
|
||||
"An empty notice should be displayed again after clear.");
|
||||
is(RequestsMenu.itemCount, 0,
|
||||
"The requests menu should be empty after clear.");
|
||||
is(NetMonitorView.detailsPaneHidden, true,
|
||||
"The details pane should be hidden after clear.");
|
||||
is(document.querySelector("#details-pane-toggle").hasAttribute("disabled"), false,
|
||||
"The pane toggle button should be still be enabled after a reload.");
|
||||
is(document.querySelector("#requests-menu-empty-notice").hasAttribute("hidden"), true,
|
||||
"The empty notice should be still hidden after a reload.");
|
||||
is(RequestsMenu.itemCount, 1,
|
||||
"The requests menu should not be empty after a reload.");
|
||||
is(NetMonitorView.detailsPaneHidden, true,
|
||||
"The details pane should still be hidden after a reload.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
});
|
||||
RequestsMenu.clear();
|
||||
|
||||
aDebuggee.location.reload();
|
||||
});
|
||||
is(document.querySelector("#details-pane-toggle").hasAttribute("disabled"), true,
|
||||
"The pane toggle button should be disabled when after clear.");
|
||||
is(document.querySelector("#requests-menu-empty-notice").hasAttribute("hidden"), false,
|
||||
"An empty notice should be displayed again after clear.");
|
||||
is(RequestsMenu.itemCount, 0,
|
||||
"The requests menu should be empty after clear.");
|
||||
is(NetMonitorView.detailsPaneHidden, true,
|
||||
"The details pane should be hidden after clear.");
|
||||
|
||||
aDebuggee.location.reload();
|
||||
});
|
||||
}
|
||||
return teardown(monitor);
|
||||
|
||||
function* reloadAndWait() {
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
tab.linkedBrowser.reload();
|
||||
return wait;
|
||||
}
|
||||
});
|
||||
|
@ -1,255 +1,228 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test if the sorting mechanism works correctly.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(STATUS_CODES_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { tab, monitor } = yield initNetMonitor(STATUS_CODES_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { $all, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { $all, L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 5).then(() => {
|
||||
testContents([0, 1, 2, 3, 4])
|
||||
.then(() => {
|
||||
info("Testing swap(0, 0)");
|
||||
RequestsMenu.swapItemsAtIndices(0, 0);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(0, 1)");
|
||||
RequestsMenu.swapItemsAtIndices(0, 1);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([1, 0, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(0, 2)");
|
||||
RequestsMenu.swapItemsAtIndices(0, 2);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([1, 2, 0, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(0, 3)");
|
||||
RequestsMenu.swapItemsAtIndices(0, 3);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([1, 2, 3, 0, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(0, 4)");
|
||||
RequestsMenu.swapItemsAtIndices(0, 4);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([1, 2, 3, 4, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(1, 0)");
|
||||
RequestsMenu.swapItemsAtIndices(1, 0);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([0, 2, 3, 4, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(1, 1)");
|
||||
RequestsMenu.swapItemsAtIndices(1, 1);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([0, 2, 3, 4, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(1, 2)");
|
||||
RequestsMenu.swapItemsAtIndices(1, 2);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([0, 1, 3, 4, 2]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(1, 3)");
|
||||
RequestsMenu.swapItemsAtIndices(1, 3);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([0, 3, 1, 4, 2]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(1, 4)");
|
||||
RequestsMenu.swapItemsAtIndices(1, 4);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([0, 3, 4, 1, 2]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(2, 0)");
|
||||
RequestsMenu.swapItemsAtIndices(2, 0);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([2, 3, 4, 1, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(2, 1)");
|
||||
RequestsMenu.swapItemsAtIndices(2, 1);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([1, 3, 4, 2, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(2, 2)");
|
||||
RequestsMenu.swapItemsAtIndices(2, 2);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([1, 3, 4, 2, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(2, 3)");
|
||||
RequestsMenu.swapItemsAtIndices(2, 3);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([1, 2, 4, 3, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(2, 4)");
|
||||
RequestsMenu.swapItemsAtIndices(2, 4);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([1, 4, 2, 3, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(3, 0)");
|
||||
RequestsMenu.swapItemsAtIndices(3, 0);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([1, 4, 2, 0, 3]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(3, 1)");
|
||||
RequestsMenu.swapItemsAtIndices(3, 1);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([3, 4, 2, 0, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(3, 2)");
|
||||
RequestsMenu.swapItemsAtIndices(3, 2);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([2, 4, 3, 0, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(3, 3)");
|
||||
RequestsMenu.swapItemsAtIndices(3, 3);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([2, 4, 3, 0, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(3, 4)");
|
||||
RequestsMenu.swapItemsAtIndices(3, 4);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([2, 3, 4, 0, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(4, 0)");
|
||||
RequestsMenu.swapItemsAtIndices(4, 0);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([2, 3, 0, 4, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(4, 1)");
|
||||
RequestsMenu.swapItemsAtIndices(4, 1);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([2, 3, 0, 1, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(4, 2)");
|
||||
RequestsMenu.swapItemsAtIndices(4, 2);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([4, 3, 0, 1, 2]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(4, 3)");
|
||||
RequestsMenu.swapItemsAtIndices(4, 3);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([3, 4, 0, 1, 2]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing swap(4, 4)");
|
||||
RequestsMenu.swapItemsAtIndices(4, 4);
|
||||
RequestsMenu.refreshZebra();
|
||||
return testContents([3, 4, 0, 1, 2]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Clearing sort.");
|
||||
RequestsMenu.sortBy();
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
return teardown(aMonitor);
|
||||
})
|
||||
.then(finish);
|
||||
});
|
||||
|
||||
function testContents([a, b, c, d, e]) {
|
||||
is(RequestsMenu.items.length, 5,
|
||||
"There should be a total of 5 items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, 5,
|
||||
"There should be a total of 5 visbile items in the requests menu.");
|
||||
is($all(".side-menu-widget-item").length, 5,
|
||||
"The visible items in the requests menu are, in fact, visible!");
|
||||
|
||||
is(RequestsMenu.getItemAtIndex(0), RequestsMenu.items[0],
|
||||
"The requests menu items aren't ordered correctly. First item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(1), RequestsMenu.items[1],
|
||||
"The requests menu items aren't ordered correctly. Second item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(2), RequestsMenu.items[2],
|
||||
"The requests menu items aren't ordered correctly. Third item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(3), RequestsMenu.items[3],
|
||||
"The requests menu items aren't ordered correctly. Fourth item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(4), RequestsMenu.items[4],
|
||||
"The requests menu items aren't ordered correctly. Fifth item is misplaced.");
|
||||
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(a),
|
||||
"GET", STATUS_CODES_SJS + "?sts=100", {
|
||||
status: 101,
|
||||
statusText: "Switching Protocols",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
transferred: L10N.getStr("networkMenu.sizeUnavailable"),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(b),
|
||||
"GET", STATUS_CODES_SJS + "?sts=200", {
|
||||
status: 202,
|
||||
statusText: "Created",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(c),
|
||||
"GET", STATUS_CODES_SJS + "?sts=300", {
|
||||
status: 303,
|
||||
statusText: "See Other",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(d),
|
||||
"GET", STATUS_CODES_SJS + "?sts=400", {
|
||||
status: 404,
|
||||
statusText: "Not Found",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(e),
|
||||
"GET", STATUS_CODES_SJS + "?sts=500", {
|
||||
status: 501,
|
||||
statusText: "Not Implemented",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
time: true
|
||||
});
|
||||
|
||||
return promise.resolve(null);
|
||||
}
|
||||
|
||||
aDebuggee.performRequests();
|
||||
let wait = waitForNetworkEvents(monitor, 5);
|
||||
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
}
|
||||
yield wait;
|
||||
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing swap(0, 0)");
|
||||
RequestsMenu.swapItemsAtIndices(0, 0);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing swap(0, 1)");
|
||||
RequestsMenu.swapItemsAtIndices(0, 1);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([1, 0, 2, 3, 4]);
|
||||
|
||||
info("Testing swap(0, 2)");
|
||||
RequestsMenu.swapItemsAtIndices(0, 2);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([1, 2, 0, 3, 4]);
|
||||
|
||||
info("Testing swap(0, 3)");
|
||||
RequestsMenu.swapItemsAtIndices(0, 3);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([1, 2, 3, 0, 4]);
|
||||
|
||||
info("Testing swap(0, 4)");
|
||||
RequestsMenu.swapItemsAtIndices(0, 4);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([1, 2, 3, 4, 0]);
|
||||
|
||||
info("Testing swap(1, 0)");
|
||||
RequestsMenu.swapItemsAtIndices(1, 0);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([0, 2, 3, 4, 1]);
|
||||
|
||||
info("Testing swap(1, 1)");
|
||||
RequestsMenu.swapItemsAtIndices(1, 1);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([0, 2, 3, 4, 1]);
|
||||
|
||||
info("Testing swap(1, 2)");
|
||||
RequestsMenu.swapItemsAtIndices(1, 2);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([0, 1, 3, 4, 2]);
|
||||
|
||||
info("Testing swap(1, 3)");
|
||||
RequestsMenu.swapItemsAtIndices(1, 3);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([0, 3, 1, 4, 2]);
|
||||
|
||||
info("Testing swap(1, 4)");
|
||||
RequestsMenu.swapItemsAtIndices(1, 4);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([0, 3, 4, 1, 2]);
|
||||
|
||||
info("Testing swap(2, 0)");
|
||||
RequestsMenu.swapItemsAtIndices(2, 0);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([2, 3, 4, 1, 0]);
|
||||
|
||||
info("Testing swap(2, 1)");
|
||||
RequestsMenu.swapItemsAtIndices(2, 1);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([1, 3, 4, 2, 0]);
|
||||
|
||||
info("Testing swap(2, 2)");
|
||||
RequestsMenu.swapItemsAtIndices(2, 2);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([1, 3, 4, 2, 0]);
|
||||
|
||||
info("Testing swap(2, 3)");
|
||||
RequestsMenu.swapItemsAtIndices(2, 3);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([1, 2, 4, 3, 0]);
|
||||
|
||||
info("Testing swap(2, 4)");
|
||||
RequestsMenu.swapItemsAtIndices(2, 4);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([1, 4, 2, 3, 0]);
|
||||
|
||||
info("Testing swap(3, 0)");
|
||||
RequestsMenu.swapItemsAtIndices(3, 0);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([1, 4, 2, 0, 3]);
|
||||
|
||||
info("Testing swap(3, 1)");
|
||||
RequestsMenu.swapItemsAtIndices(3, 1);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([3, 4, 2, 0, 1]);
|
||||
|
||||
info("Testing swap(3, 2)");
|
||||
RequestsMenu.swapItemsAtIndices(3, 2);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([2, 4, 3, 0, 1]);
|
||||
|
||||
info("Testing swap(3, 3)");
|
||||
RequestsMenu.swapItemsAtIndices(3, 3);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([2, 4, 3, 0, 1]);
|
||||
|
||||
info("Testing swap(3, 4)");
|
||||
RequestsMenu.swapItemsAtIndices(3, 4);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([2, 3, 4, 0, 1]);
|
||||
|
||||
info("Testing swap(4, 0)");
|
||||
RequestsMenu.swapItemsAtIndices(4, 0);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([2, 3, 0, 4, 1]);
|
||||
|
||||
info("Testing swap(4, 1)");
|
||||
RequestsMenu.swapItemsAtIndices(4, 1);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([2, 3, 0, 1, 4]);
|
||||
|
||||
info("Testing swap(4, 2)");
|
||||
RequestsMenu.swapItemsAtIndices(4, 2);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([4, 3, 0, 1, 2]);
|
||||
|
||||
info("Testing swap(4, 3)");
|
||||
RequestsMenu.swapItemsAtIndices(4, 3);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([3, 4, 0, 1, 2]);
|
||||
|
||||
info("Testing swap(4, 4)");
|
||||
RequestsMenu.swapItemsAtIndices(4, 4);
|
||||
RequestsMenu.refreshZebra();
|
||||
testContents([3, 4, 0, 1, 2]);
|
||||
|
||||
info("Clearing sort.");
|
||||
RequestsMenu.sortBy();
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
return teardown(monitor);
|
||||
|
||||
function testContents([a, b, c, d, e]) {
|
||||
is(RequestsMenu.items.length, 5,
|
||||
"There should be a total of 5 items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, 5,
|
||||
"There should be a total of 5 visbile items in the requests menu.");
|
||||
is($all(".side-menu-widget-item").length, 5,
|
||||
"The visible items in the requests menu are, in fact, visible!");
|
||||
|
||||
is(RequestsMenu.getItemAtIndex(0), RequestsMenu.items[0],
|
||||
"The requests menu items aren't ordered correctly. First item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(1), RequestsMenu.items[1],
|
||||
"The requests menu items aren't ordered correctly. Second item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(2), RequestsMenu.items[2],
|
||||
"The requests menu items aren't ordered correctly. Third item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(3), RequestsMenu.items[3],
|
||||
"The requests menu items aren't ordered correctly. Fourth item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(4), RequestsMenu.items[4],
|
||||
"The requests menu items aren't ordered correctly. Fifth item is misplaced.");
|
||||
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(a),
|
||||
"GET", STATUS_CODES_SJS + "?sts=100", {
|
||||
status: 101,
|
||||
statusText: "Switching Protocols",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
transferred: L10N.getStr("networkMenu.sizeUnavailable"),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(b),
|
||||
"GET", STATUS_CODES_SJS + "?sts=200", {
|
||||
status: 202,
|
||||
statusText: "Created",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(c),
|
||||
"GET", STATUS_CODES_SJS + "?sts=300", {
|
||||
status: 303,
|
||||
statusText: "See Other",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(d),
|
||||
"GET", STATUS_CODES_SJS + "?sts=400", {
|
||||
status: 404,
|
||||
statusText: "Not Found",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(e),
|
||||
"GET", STATUS_CODES_SJS + "?sts=500", {
|
||||
status: 501,
|
||||
statusText: "Not Implemented",
|
||||
type: "plain",
|
||||
fullMimeType: "text/plain; charset=utf-8",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 22),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,296 +1,270 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test if sorting columns in the network table works correctly.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SORTING_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SORTING_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
// It seems that this test may be slow on debug builds. This could be because
|
||||
// of the heavy dom manipulation associated with sorting.
|
||||
requestLongerTimeout(2);
|
||||
// It seems that this test may be slow on debug builds. This could be because
|
||||
// of the heavy dom manipulation associated with sorting.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
let { $, $all, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { $, $all, L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
// Loading the frame script and preparing the xhr request URLs so we can
|
||||
// generate some requests later.
|
||||
loadCommonFrameScript();
|
||||
let requests = [{
|
||||
url: "sjs_sorting-test-server.sjs?index=1&" + Math.random(),
|
||||
method: "GET1"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=5&" + Math.random(),
|
||||
method: "GET5"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=2&" + Math.random(),
|
||||
method: "GET2"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=4&" + Math.random(),
|
||||
method: "GET4"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=3&" + Math.random(),
|
||||
method: "GET3"
|
||||
}];
|
||||
// Loading the frame script and preparing the xhr request URLs so we can
|
||||
// generate some requests later.
|
||||
loadCommonFrameScript();
|
||||
let requests = [{
|
||||
url: "sjs_sorting-test-server.sjs?index=1&" + Math.random(),
|
||||
method: "GET1"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=5&" + Math.random(),
|
||||
method: "GET5"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=2&" + Math.random(),
|
||||
method: "GET2"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=4&" + Math.random(),
|
||||
method: "GET4"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=3&" + Math.random(),
|
||||
method: "GET3"
|
||||
}];
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 5).then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
let wait = waitForNetworkEvents(monitor, 5);
|
||||
yield performRequestsInContent(requests);
|
||||
yield wait;
|
||||
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
|
||||
testHeaders();
|
||||
testContents([0, 2, 4, 3, 1])
|
||||
.then(() => {
|
||||
info("Testing status sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing status sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "descending");
|
||||
return testContents([4, 3, 2, 1, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing status sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing method sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
|
||||
testHeaders("method", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing method sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
|
||||
testHeaders("method", "descending");
|
||||
return testContents([4, 3, 2, 1, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing method sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
|
||||
testHeaders("method", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing file sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
|
||||
testHeaders("file", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing file sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
|
||||
testHeaders("file", "descending");
|
||||
return testContents([4, 3, 2, 1, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing file sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
|
||||
testHeaders("file", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing type sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
|
||||
testHeaders("type", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing type sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
|
||||
testHeaders("type", "descending");
|
||||
return testContents([4, 3, 2, 1, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing type sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
|
||||
testHeaders("type", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing transferred sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
|
||||
testHeaders("transferred", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing transferred sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
|
||||
testHeaders("transferred", "descending");
|
||||
return testContents([4, 3, 2, 1, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing transferred sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
|
||||
testHeaders("transferred", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing size sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
|
||||
testHeaders("size", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing size sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
|
||||
testHeaders("size", "descending");
|
||||
return testContents([4, 3, 2, 1, 0]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing size sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
|
||||
testHeaders("size", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing waterfall sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
|
||||
testHeaders("waterfall", "ascending");
|
||||
return testContents([0, 2, 4, 3, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing waterfall sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
|
||||
testHeaders("waterfall", "descending");
|
||||
return testContents([4, 2, 0, 1, 3]);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing waterfall sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
|
||||
testHeaders("waterfall", "ascending");
|
||||
return testContents([0, 2, 4, 3, 1]);
|
||||
})
|
||||
.then(() => {
|
||||
return teardown(aMonitor);
|
||||
})
|
||||
.then(finish);
|
||||
});
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
|
||||
function testHeaders(aSortType, aDirection) {
|
||||
let doc = aMonitor.panelWin.document;
|
||||
let target = doc.querySelector("#requests-menu-" + aSortType + "-button");
|
||||
let headers = doc.querySelectorAll(".requests-menu-header-button");
|
||||
testHeaders();
|
||||
testContents([0, 2, 4, 3, 1]);
|
||||
|
||||
for (let header of headers) {
|
||||
if (header != target) {
|
||||
is(header.hasAttribute("sorted"), false,
|
||||
"The " + header.id + " header should not have a 'sorted' attribute.");
|
||||
is(header.hasAttribute("tooltiptext"), false,
|
||||
"The " + header.id + " header should not have a 'tooltiptext' attribute.");
|
||||
} else {
|
||||
is(header.getAttribute("sorted"), aDirection,
|
||||
"The " + header.id + " header has an incorrect 'sorted' attribute.");
|
||||
is(header.getAttribute("tooltiptext"), aDirection == "ascending"
|
||||
? L10N.getStr("networkMenu.sortedAsc")
|
||||
: L10N.getStr("networkMenu.sortedDesc"),
|
||||
"The " + header.id + " has an incorrect 'tooltiptext' attribute.");
|
||||
}
|
||||
info("Testing status sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing status sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "descending");
|
||||
testContents([4, 3, 2, 1, 0]);
|
||||
|
||||
info("Testing status sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing method sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
|
||||
testHeaders("method", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing method sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
|
||||
testHeaders("method", "descending");
|
||||
testContents([4, 3, 2, 1, 0]);
|
||||
|
||||
info("Testing method sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
|
||||
testHeaders("method", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing file sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
|
||||
testHeaders("file", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing file sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
|
||||
testHeaders("file", "descending");
|
||||
testContents([4, 3, 2, 1, 0]);
|
||||
|
||||
info("Testing file sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
|
||||
testHeaders("file", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing type sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
|
||||
testHeaders("type", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing type sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
|
||||
testHeaders("type", "descending");
|
||||
testContents([4, 3, 2, 1, 0]);
|
||||
|
||||
info("Testing type sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
|
||||
testHeaders("type", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing transferred sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
|
||||
testHeaders("transferred", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing transferred sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
|
||||
testHeaders("transferred", "descending");
|
||||
testContents([4, 3, 2, 1, 0]);
|
||||
|
||||
info("Testing transferred sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-transferred-button"));
|
||||
testHeaders("transferred", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing size sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
|
||||
testHeaders("size", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing size sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
|
||||
testHeaders("size", "descending");
|
||||
testContents([4, 3, 2, 1, 0]);
|
||||
|
||||
info("Testing size sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
|
||||
testHeaders("size", "ascending");
|
||||
testContents([0, 1, 2, 3, 4]);
|
||||
|
||||
info("Testing waterfall sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
|
||||
testHeaders("waterfall", "ascending");
|
||||
testContents([0, 2, 4, 3, 1]);
|
||||
|
||||
info("Testing waterfall sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
|
||||
testHeaders("waterfall", "descending");
|
||||
testContents([4, 2, 0, 1, 3]);
|
||||
|
||||
info("Testing waterfall sort, ascending. Checking sort loops correctly.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
|
||||
testHeaders("waterfall", "ascending");
|
||||
testContents([0, 2, 4, 3, 1]);
|
||||
|
||||
return teardown(monitor);
|
||||
|
||||
function testHeaders(sortType, direction) {
|
||||
let doc = monitor.panelWin.document;
|
||||
let target = doc.querySelector("#requests-menu-" + sortType + "-button");
|
||||
let headers = doc.querySelectorAll(".requests-menu-header-button");
|
||||
|
||||
for (let header of headers) {
|
||||
if (header != target) {
|
||||
is(header.hasAttribute("sorted"), false,
|
||||
"The " + header.id + " header should not have a 'sorted' attribute.");
|
||||
is(header.hasAttribute("tooltiptext"), false,
|
||||
"The " + header.id + " header should not have a 'tooltiptext' attribute.");
|
||||
} else {
|
||||
is(header.getAttribute("sorted"), direction,
|
||||
"The " + header.id + " header has an incorrect 'sorted' attribute.");
|
||||
is(header.getAttribute("tooltiptext"), direction == "ascending"
|
||||
? L10N.getStr("networkMenu.sortedAsc")
|
||||
: L10N.getStr("networkMenu.sortedDesc"),
|
||||
"The " + header.id + " has an incorrect 'tooltiptext' attribute.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testContents([a, b, c, d, e]) {
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should still be a selected item after sorting.");
|
||||
is(RequestsMenu.selectedIndex, a,
|
||||
"The first item should be still selected after sorting.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should still be visible after sorting.");
|
||||
function testContents([a, b, c, d, e]) {
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should still be a selected item after sorting.");
|
||||
is(RequestsMenu.selectedIndex, a,
|
||||
"The first item should be still selected after sorting.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should still be visible after sorting.");
|
||||
|
||||
is(RequestsMenu.items.length, 5,
|
||||
"There should be a total of 5 items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, 5,
|
||||
"There should be a total of 5 visbile items in the requests menu.");
|
||||
is($all(".side-menu-widget-item").length, 5,
|
||||
"The visible items in the requests menu are, in fact, visible!");
|
||||
is(RequestsMenu.items.length, 5,
|
||||
"There should be a total of 5 items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, 5,
|
||||
"There should be a total of 5 visbile items in the requests menu.");
|
||||
is($all(".side-menu-widget-item").length, 5,
|
||||
"The visible items in the requests menu are, in fact, visible!");
|
||||
|
||||
is(RequestsMenu.getItemAtIndex(0), RequestsMenu.items[0],
|
||||
"The requests menu items aren't ordered correctly. First item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(1), RequestsMenu.items[1],
|
||||
"The requests menu items aren't ordered correctly. Second item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(2), RequestsMenu.items[2],
|
||||
"The requests menu items aren't ordered correctly. Third item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(3), RequestsMenu.items[3],
|
||||
"The requests menu items aren't ordered correctly. Fourth item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(4), RequestsMenu.items[4],
|
||||
"The requests menu items aren't ordered correctly. Fifth item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(0), RequestsMenu.items[0],
|
||||
"The requests menu items aren't ordered correctly. First item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(1), RequestsMenu.items[1],
|
||||
"The requests menu items aren't ordered correctly. Second item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(2), RequestsMenu.items[2],
|
||||
"The requests menu items aren't ordered correctly. Third item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(3), RequestsMenu.items[3],
|
||||
"The requests menu items aren't ordered correctly. Fourth item is misplaced.");
|
||||
is(RequestsMenu.getItemAtIndex(4), RequestsMenu.items[4],
|
||||
"The requests menu items aren't ordered correctly. Fifth item is misplaced.");
|
||||
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(a),
|
||||
"GET1", SORTING_SJS + "?index=1", {
|
||||
fuzzyUrl: true,
|
||||
status: 101,
|
||||
statusText: "Meh",
|
||||
type: "1",
|
||||
fullMimeType: "text/1",
|
||||
transferred: L10N.getStr("networkMenu.sizeUnavailable"),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(b),
|
||||
"GET2", SORTING_SJS + "?index=2", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "Meh",
|
||||
type: "2",
|
||||
fullMimeType: "text/2",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(c),
|
||||
"GET3", SORTING_SJS + "?index=3", {
|
||||
fuzzyUrl: true,
|
||||
status: 300,
|
||||
statusText: "Meh",
|
||||
type: "3",
|
||||
fullMimeType: "text/3",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(d),
|
||||
"GET4", SORTING_SJS + "?index=4", {
|
||||
fuzzyUrl: true,
|
||||
status: 400,
|
||||
statusText: "Meh",
|
||||
type: "4",
|
||||
fullMimeType: "text/4",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(e),
|
||||
"GET5", SORTING_SJS + "?index=5", {
|
||||
fuzzyUrl: true,
|
||||
status: 500,
|
||||
statusText: "Meh",
|
||||
type: "5",
|
||||
fullMimeType: "text/5",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
|
||||
time: true
|
||||
});
|
||||
|
||||
return promise.resolve(null);
|
||||
}
|
||||
|
||||
performRequestsInContent(requests).then(null, e => {
|
||||
ok(false, e);
|
||||
});
|
||||
});
|
||||
}
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(a),
|
||||
"GET1", SORTING_SJS + "?index=1", {
|
||||
fuzzyUrl: true,
|
||||
status: 101,
|
||||
statusText: "Meh",
|
||||
type: "1",
|
||||
fullMimeType: "text/1",
|
||||
transferred: L10N.getStr("networkMenu.sizeUnavailable"),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(b),
|
||||
"GET2", SORTING_SJS + "?index=2", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "Meh",
|
||||
type: "2",
|
||||
fullMimeType: "text/2",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(c),
|
||||
"GET3", SORTING_SJS + "?index=3", {
|
||||
fuzzyUrl: true,
|
||||
status: 300,
|
||||
statusText: "Meh",
|
||||
type: "3",
|
||||
fullMimeType: "text/3",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(d),
|
||||
"GET4", SORTING_SJS + "?index=4", {
|
||||
fuzzyUrl: true,
|
||||
status: 400,
|
||||
statusText: "Meh",
|
||||
type: "4",
|
||||
fullMimeType: "text/4",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
|
||||
time: true
|
||||
});
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(e),
|
||||
"GET5", SORTING_SJS + "?index=5", {
|
||||
fuzzyUrl: true,
|
||||
status: 500,
|
||||
statusText: "Meh",
|
||||
type: "5",
|
||||
fullMimeType: "text/5",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,220 +1,207 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test if sorting columns in the network table works correctly with new requests.
|
||||
*/
|
||||
|
||||
function test() {
|
||||
initNetMonitor(SORTING_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
add_task(function* () {
|
||||
let { monitor } = yield initNetMonitor(SORTING_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
// It seems that this test may be slow on debug builds. This could be because
|
||||
// of the heavy dom manipulation associated with sorting.
|
||||
requestLongerTimeout(2);
|
||||
// It seems that this test may be slow on debug builds. This could be because
|
||||
// of the heavy dom manipulation associated with sorting.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
let { $, $all, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
let { $, $all, L10N, NetMonitorView } = monitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
// Loading the frame script and preparing the xhr request URLs so we can
|
||||
// generate some requests later.
|
||||
loadCommonFrameScript();
|
||||
let requests = [{
|
||||
url: "sjs_sorting-test-server.sjs?index=1&" + Math.random(),
|
||||
method: "GET1"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=5&" + Math.random(),
|
||||
method: "GET5"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=2&" + Math.random(),
|
||||
method: "GET2"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=4&" + Math.random(),
|
||||
method: "GET4"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=3&" + Math.random(),
|
||||
method: "GET3"
|
||||
}];
|
||||
// Loading the frame script and preparing the xhr request URLs so we can
|
||||
// generate some requests later.
|
||||
loadCommonFrameScript();
|
||||
let requests = [{
|
||||
url: "sjs_sorting-test-server.sjs?index=1&" + Math.random(),
|
||||
method: "GET1"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=5&" + Math.random(),
|
||||
method: "GET5"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=2&" + Math.random(),
|
||||
method: "GET2"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=4&" + Math.random(),
|
||||
method: "GET4"
|
||||
}, {
|
||||
url: "sjs_sorting-test-server.sjs?index=3&" + Math.random(),
|
||||
method: "GET3"
|
||||
}];
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
||||
waitForNetworkEvents(aMonitor, 5).then(() => {
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
let wait = waitForNetworkEvents(monitor, 5);
|
||||
yield performRequestsInContent(requests);
|
||||
yield wait;
|
||||
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle"));
|
||||
|
||||
testHeaders();
|
||||
testContents([0, 2, 4, 3, 1], 0)
|
||||
.then(() => {
|
||||
info("Testing status sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4], 0);
|
||||
})
|
||||
.then(() => {
|
||||
info("Performing more requests.");
|
||||
performRequestsInContent(requests);
|
||||
return waitForNetworkEvents(aMonitor, 5);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing status sort again, ascending.");
|
||||
testHeaders("status", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing status sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "descending");
|
||||
return testContents([9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 9);
|
||||
})
|
||||
.then(() => {
|
||||
info("Performing more requests.");
|
||||
performRequestsInContent(requests);
|
||||
return waitForNetworkEvents(aMonitor, 5);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing status sort again, descending.");
|
||||
testHeaders("status", "descending");
|
||||
return testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing status sort yet again, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "ascending");
|
||||
return testContents([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], 0);
|
||||
})
|
||||
.then(() => {
|
||||
info("Testing status sort yet again, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "descending");
|
||||
return testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14);
|
||||
})
|
||||
.then(() => {
|
||||
return teardown(aMonitor);
|
||||
})
|
||||
.then(finish, e => {
|
||||
ok(false, e);
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should be a selected item in the requests menu.");
|
||||
is(RequestsMenu.selectedIndex, 0,
|
||||
"The first item should be selected in the requests menu.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should not be hidden after toggle button was pressed.");
|
||||
|
||||
testHeaders();
|
||||
testContents([0, 2, 4, 3, 1], 0);
|
||||
|
||||
info("Testing status sort, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "ascending");
|
||||
testContents([0, 1, 2, 3, 4], 0);
|
||||
|
||||
info("Performing more requests.");
|
||||
wait = waitForNetworkEvents(monitor, 5);
|
||||
yield performRequestsInContent(requests);
|
||||
yield wait;
|
||||
|
||||
info("Testing status sort again, ascending.");
|
||||
testHeaders("status", "ascending");
|
||||
testContents([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 0);
|
||||
|
||||
info("Testing status sort, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "descending");
|
||||
testContents([9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 9);
|
||||
|
||||
info("Performing more requests.");
|
||||
wait = waitForNetworkEvents(monitor, 5);
|
||||
yield performRequestsInContent(requests);
|
||||
yield wait;
|
||||
|
||||
info("Testing status sort again, descending.");
|
||||
testHeaders("status", "descending");
|
||||
testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14);
|
||||
|
||||
info("Testing status sort yet again, ascending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "ascending");
|
||||
testContents([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], 0);
|
||||
|
||||
info("Testing status sort yet again, descending.");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
|
||||
testHeaders("status", "descending");
|
||||
testContents([14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 14);
|
||||
|
||||
return teardown(monitor);
|
||||
|
||||
function testHeaders(sortType, direction) {
|
||||
let doc = monitor.panelWin.document;
|
||||
let target = doc.querySelector("#requests-menu-" + sortType + "-button");
|
||||
let headers = doc.querySelectorAll(".requests-menu-header-button");
|
||||
|
||||
for (let header of headers) {
|
||||
if (header != target) {
|
||||
is(header.hasAttribute("sorted"), false,
|
||||
"The " + header.id + " header should not have a 'sorted' attribute.");
|
||||
is(header.hasAttribute("tooltiptext"), false,
|
||||
"The " + header.id + " header should not have a 'tooltiptext' attribute.");
|
||||
} else {
|
||||
is(header.getAttribute("sorted"), direction,
|
||||
"The " + header.id + " header has an incorrect 'sorted' attribute.");
|
||||
is(header.getAttribute("tooltiptext"), direction == "ascending"
|
||||
? L10N.getStr("networkMenu.sortedAsc")
|
||||
: L10N.getStr("networkMenu.sortedDesc"),
|
||||
"The " + header.id + " has an incorrect 'tooltiptext' attribute.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testContents(order, selection) {
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should still be a selected item after sorting.");
|
||||
is(RequestsMenu.selectedIndex, selection,
|
||||
"The first item should be still selected after sorting.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should still be visible after sorting.");
|
||||
|
||||
is(RequestsMenu.items.length, order.length,
|
||||
"There should be a specific number of items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, order.length,
|
||||
"There should be a specific number of visbile items in the requests menu.");
|
||||
is($all(".side-menu-widget-item").length, order.length,
|
||||
"The visible items in the requests menu are, in fact, visible!");
|
||||
|
||||
for (let i = 0; i < order.length; i++) {
|
||||
is(RequestsMenu.getItemAtIndex(i), RequestsMenu.items[i],
|
||||
"The requests menu items aren't ordered correctly. Misplaced item " + i + ".");
|
||||
}
|
||||
|
||||
for (let i = 0, len = order.length / 5; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i]),
|
||||
"GET1", SORTING_SJS + "?index=1", {
|
||||
fuzzyUrl: true,
|
||||
status: 101,
|
||||
statusText: "Meh",
|
||||
type: "1",
|
||||
fullMimeType: "text/1",
|
||||
transferred: L10N.getStr("networkMenu.sizeUnavailable"),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
|
||||
time: true
|
||||
});
|
||||
}, e => {
|
||||
ok(false, e);
|
||||
});
|
||||
|
||||
function testHeaders(aSortType, aDirection) {
|
||||
let doc = aMonitor.panelWin.document;
|
||||
let target = doc.querySelector("#requests-menu-" + aSortType + "-button");
|
||||
let headers = doc.querySelectorAll(".requests-menu-header-button");
|
||||
|
||||
for (let header of headers) {
|
||||
if (header != target) {
|
||||
is(header.hasAttribute("sorted"), false,
|
||||
"The " + header.id + " header should not have a 'sorted' attribute.");
|
||||
is(header.hasAttribute("tooltiptext"), false,
|
||||
"The " + header.id + " header should not have a 'tooltiptext' attribute.");
|
||||
} else {
|
||||
is(header.getAttribute("sorted"), aDirection,
|
||||
"The " + header.id + " header has an incorrect 'sorted' attribute.");
|
||||
is(header.getAttribute("tooltiptext"), aDirection == "ascending"
|
||||
? L10N.getStr("networkMenu.sortedAsc")
|
||||
: L10N.getStr("networkMenu.sortedDesc"),
|
||||
"The " + header.id + " has an incorrect 'tooltiptext' attribute.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testContents(aOrder, aSelection) {
|
||||
isnot(RequestsMenu.selectedItem, null,
|
||||
"There should still be a selected item after sorting.");
|
||||
is(RequestsMenu.selectedIndex, aSelection,
|
||||
"The first item should be still selected after sorting.");
|
||||
is(NetMonitorView.detailsPaneHidden, false,
|
||||
"The details pane should still be visible after sorting.");
|
||||
|
||||
is(RequestsMenu.items.length, aOrder.length,
|
||||
"There should be a specific number of items in the requests menu.");
|
||||
is(RequestsMenu.visibleItems.length, aOrder.length,
|
||||
"There should be a specific number of visbile items in the requests menu.");
|
||||
is($all(".side-menu-widget-item").length, aOrder.length,
|
||||
"The visible items in the requests menu are, in fact, visible!");
|
||||
|
||||
for (let i = 0; i < aOrder.length; i++) {
|
||||
is(RequestsMenu.getItemAtIndex(i), RequestsMenu.items[i],
|
||||
"The requests menu items aren't ordered correctly. Misplaced item " + i + ".");
|
||||
}
|
||||
|
||||
for (let i = 0, len = aOrder.length / 5; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i]),
|
||||
"GET1", SORTING_SJS + "?index=1", {
|
||||
fuzzyUrl: true,
|
||||
status: 101,
|
||||
statusText: "Meh",
|
||||
type: "1",
|
||||
fullMimeType: "text/1",
|
||||
transferred: L10N.getStr("networkMenu.sizeUnavailable"),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 0),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = aOrder.length / 5; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len]),
|
||||
"GET2", SORTING_SJS + "?index=2", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "Meh",
|
||||
type: "2",
|
||||
fullMimeType: "text/2",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = aOrder.length / 5; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 2]),
|
||||
"GET3", SORTING_SJS + "?index=3", {
|
||||
fuzzyUrl: true,
|
||||
status: 300,
|
||||
statusText: "Meh",
|
||||
type: "3",
|
||||
fullMimeType: "text/3",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = aOrder.length / 5; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 3]),
|
||||
"GET4", SORTING_SJS + "?index=4", {
|
||||
fuzzyUrl: true,
|
||||
status: 400,
|
||||
statusText: "Meh",
|
||||
type: "4",
|
||||
fullMimeType: "text/4",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = aOrder.length / 5; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(aOrder[i + len * 4]),
|
||||
"GET5", SORTING_SJS + "?index=5", {
|
||||
fuzzyUrl: true,
|
||||
status: 500,
|
||||
statusText: "Meh",
|
||||
type: "5",
|
||||
fullMimeType: "text/5",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
|
||||
return promise.resolve(null);
|
||||
for (let i = 0, len = order.length / 5; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len]),
|
||||
"GET2", SORTING_SJS + "?index=2", {
|
||||
fuzzyUrl: true,
|
||||
status: 200,
|
||||
statusText: "Meh",
|
||||
type: "2",
|
||||
fullMimeType: "text/2",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 19),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
|
||||
performRequestsInContent(requests).then(null, e => console.error(e));
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = order.length / 5; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len * 2]),
|
||||
"GET3", SORTING_SJS + "?index=3", {
|
||||
fuzzyUrl: true,
|
||||
status: 300,
|
||||
statusText: "Meh",
|
||||
type: "3",
|
||||
fullMimeType: "text/3",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 29),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = order.length / 5; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len * 3]),
|
||||
"GET4", SORTING_SJS + "?index=4", {
|
||||
fuzzyUrl: true,
|
||||
status: 400,
|
||||
statusText: "Meh",
|
||||
type: "4",
|
||||
fullMimeType: "text/4",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 39),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
for (let i = 0, len = order.length / 5; i < len; i++) {
|
||||
verifyRequestItemTarget(RequestsMenu.getItemAtIndex(order[i + len * 4]),
|
||||
"GET5", SORTING_SJS + "?index=5", {
|
||||
fuzzyUrl: true,
|
||||
status: 500,
|
||||
statusText: "Meh",
|
||||
type: "5",
|
||||
fullMimeType: "text/5",
|
||||
transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
|
||||
size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 49),
|
||||
time: true
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
add_task(function* () {
|
||||
let [,, monitor] = yield initNetMonitor(STATISTICS_URL);
|
||||
let { monitor } = yield initNetMonitor(STATISTICS_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let panel = monitor.panelWin;
|
||||
@ -22,10 +22,10 @@ add_task(function* () {
|
||||
"There should be no empty cache chart created yet.");
|
||||
|
||||
let onChartDisplayed = Promise.all([
|
||||
waitFor(panel, EVENTS.PRIMED_CACHE_CHART_DISPLAYED),
|
||||
waitFor(panel, EVENTS.EMPTY_CACHE_CHART_DISPLAYED)
|
||||
panel.once(EVENTS.PRIMED_CACHE_CHART_DISPLAYED),
|
||||
panel.once(EVENTS.EMPTY_CACHE_CHART_DISPLAYED)
|
||||
]);
|
||||
let onPlaceholderDisplayed = waitFor(panel, EVENTS.PLACEHOLDER_CHARTS_DISPLAYED);
|
||||
let onPlaceholderDisplayed = panel.once(EVENTS.PLACEHOLDER_CHARTS_DISPLAYED);
|
||||
|
||||
info("Displaying statistics view");
|
||||
NetMonitorView.toggleFrontendMode();
|
||||
@ -51,25 +51,13 @@ add_task(function* () {
|
||||
is($("#empty-cache-chart").childNodes.length, 1,
|
||||
"There should be a real empty cache chart created now.");
|
||||
|
||||
yield until(() => $all(".pie-chart-container:not([placeholder=true])").length == 2);
|
||||
yield waitUntil(
|
||||
() => $all(".pie-chart-container:not([placeholder=true])").length == 2);
|
||||
ok(true, "Two real pie charts appear to be rendered correctly.");
|
||||
|
||||
yield until(() => $all(".table-chart-container:not([placeholder=true])").length == 2);
|
||||
yield waitUntil(
|
||||
() => $all(".table-chart-container:not([placeholder=true])").length == 2);
|
||||
ok(true, "Two real table charts appear to be rendered correctly.");
|
||||
|
||||
yield teardown(monitor);
|
||||
});
|
||||
|
||||
function waitForTick() {
|
||||
let deferred = promise.defer();
|
||||
executeSoon(deferred.resolve);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function until(predicate) {
|
||||
return Task.spawn(function* () {
|
||||
while (!predicate()) {
|
||||
yield waitForTick();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user