2010-10-11 09:57:56 -07:00
|
|
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-10-11 09:57:56 -07:00
|
|
|
|
|
|
|
// Tests that the network panel works.
|
|
|
|
|
2012-01-17 06:04:23 -08:00
|
|
|
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
|
|
|
|
const TEST_IMG = "http://example.com/browser/browser/devtools/webconsole/test/test-image.png";
|
|
|
|
const TEST_ENCODING_ISO_8859_1 = "http://example.com/browser/browser/devtools/webconsole/test/test-encoding-ISO-8859-1.html";
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-11-05 08:41:59 -08:00
|
|
|
const TEST_IMG_BASE64 =
|
|
|
|
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAVRJREFU" +
|
|
|
|
"OI2lk7FLw0AUxr+YpC1CBqcMWfsvCCLdXFzqEJCgDl1EQRGxg9AhSBEJONhFhG52UCuFDjq5dxD8" +
|
|
|
|
"FwoO0qGDOBQkl7vLOeWa2EQDffDBvTu+373Hu1OEEJgntGgxGD6J+7fLXKbt5VNUyhsKAChRBQcP" +
|
|
|
|
"FVFeWskFGH694mZroCQqCLlAwPxcgJBP254CmAD5B7C7dgHLMLF3uzoL4DQEod+Z5sP1FizDxGgy" +
|
|
|
|
"BqfhLID9AahX29J89bwPFgMsSEAQglAf9WobhPpScbPXr4FQHyzIADTsDizDRMPuIOC+zEeTMZo9" +
|
|
|
|
"BwH3EfAMACccbtfGaDKGZZg423yUZrdrg3EqxQlPr0BTdTR7joREN2uqnlBmCwW1hIJagtev4f3z" +
|
|
|
|
"A16/JvfiigMSYyzqJXlw/XKUyOORMUaBor6YavgdjKa8xGOnidadmwtwsnMu18q83/kHSou+bFND" +
|
|
|
|
"Dr4AAAAASUVORK5CYII=";
|
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
let testDriver;
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
addTab(TEST_URI);
|
2012-05-10 08:01:37 -07:00
|
|
|
browser.addEventListener("load", function onLoad() {
|
|
|
|
browser.removeEventListener("load", onLoad, true);
|
|
|
|
openConsole(null, testNetworkPanel);
|
|
|
|
}, true);
|
2010-10-11 09:57:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function testNetworkPanel() {
|
|
|
|
testDriver = testGen();
|
|
|
|
testDriver.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkIsVisible(aPanel, aList) {
|
|
|
|
for (let id in aList) {
|
|
|
|
let node = aPanel.document.getElementById(id);
|
|
|
|
let isVisible = aList[id];
|
|
|
|
is(node.style.display, (isVisible ? "block" : "none"), id + " isVisible=" + isVisible);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkNodeContent(aPanel, aId, aContent) {
|
|
|
|
let node = aPanel.document.getElementById(aId);
|
|
|
|
if (node == null) {
|
|
|
|
ok(false, "Tried to access node " + aId + " that doesn't exist!");
|
|
|
|
}
|
|
|
|
else if (node.textContent.indexOf(aContent) != -1) {
|
|
|
|
ok(true, "checking content of " + aId);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ok(false, "Got false value for " + aId + ": " + node.textContent + " doesn't have " + aContent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkNodeKeyValue(aPanel, aId, aKey, aValue) {
|
|
|
|
let node = aPanel.document.getElementById(aId);
|
|
|
|
|
2011-01-04 09:47:34 -08:00
|
|
|
let headers = node.querySelectorAll("th");
|
|
|
|
for (let i = 0; i < headers.length; i++) {
|
|
|
|
if (headers[i].textContent == (aKey + ":")) {
|
|
|
|
is(headers[i].nextElementSibling.textContent, aValue,
|
|
|
|
"checking content of " + aId + " for key " + aKey);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(false, "content check failed for " + aId + ", key " + aKey);
|
2010-10-11 09:57:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function testGen() {
|
2012-07-26 08:06:04 -07:00
|
|
|
let hud = HUDService.getHudByWindow(content);
|
|
|
|
let filterBox = hud.ui.filterBox;
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-05-29 05:48:05 -07:00
|
|
|
let httpActivity = {
|
2012-10-05 04:54:43 -07:00
|
|
|
updates: [],
|
|
|
|
discardRequestBody: true,
|
|
|
|
discardResponseBody: true,
|
|
|
|
startedDateTime: (new Date()).toISOString(),
|
|
|
|
request: {
|
|
|
|
url: "http://www.testpage.com",
|
|
|
|
method: "GET",
|
|
|
|
cookies: [],
|
|
|
|
headers: [
|
|
|
|
{ name: "foo", value: "bar" },
|
|
|
|
],
|
2012-05-29 05:48:05 -07:00
|
|
|
},
|
2012-10-05 04:54:43 -07:00
|
|
|
response: {
|
|
|
|
headers: [],
|
|
|
|
content: {},
|
2012-11-05 08:41:59 -08:00
|
|
|
cookies: [],
|
2010-10-11 09:57:56 -07:00
|
|
|
},
|
2012-10-05 04:54:43 -07:00
|
|
|
timings: {},
|
2010-10-11 09:57:56 -07:00
|
|
|
};
|
|
|
|
|
2012-07-26 08:06:04 -07:00
|
|
|
let networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity);
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-05-29 05:48:05 -07:00
|
|
|
is(filterBox._netPanel, networkPanel,
|
|
|
|
"Network panel stored on the anchor object");
|
|
|
|
|
2012-10-05 04:54:43 -07:00
|
|
|
networkPanel._onUpdate = function() {
|
|
|
|
networkPanel._onUpdate = null;
|
|
|
|
executeSoon(function() {
|
|
|
|
testDriver.next();
|
|
|
|
});
|
|
|
|
};
|
2010-10-13 05:05:51 -07:00
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
yield;
|
|
|
|
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 1");
|
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestCookie: false,
|
|
|
|
requestFormData: false,
|
|
|
|
requestBody: false,
|
|
|
|
responseContainer: false,
|
|
|
|
responseBody: false,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: false
|
|
|
|
});
|
|
|
|
|
|
|
|
checkNodeContent(networkPanel, "header", "http://www.testpage.com");
|
|
|
|
checkNodeContent(networkPanel, "header", "GET");
|
|
|
|
checkNodeKeyValue(networkPanel, "requestHeadersContent", "foo", "bar");
|
|
|
|
|
|
|
|
// Test request body.
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 2: request body");
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.discardRequestBody = false;
|
|
|
|
httpActivity.request.postData = { text: "hello world" };
|
2010-10-11 09:57:56 -07:00
|
|
|
networkPanel.update();
|
2012-05-29 05:48:05 -07:00
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: true,
|
|
|
|
requestFormData: false,
|
|
|
|
requestCookie: false,
|
|
|
|
responseContainer: false,
|
|
|
|
responseBody: false,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: false
|
|
|
|
});
|
|
|
|
checkNodeContent(networkPanel, "requestBodyContent", "hello world");
|
|
|
|
|
|
|
|
// Test response header.
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 3: response header");
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.timings.wait = 10;
|
|
|
|
httpActivity.response.httpVersion = "HTTP/3.14";
|
|
|
|
httpActivity.response.status = 999;
|
|
|
|
httpActivity.response.statusText = "earthquake win";
|
|
|
|
httpActivity.response.content.mimeType = "text/html";
|
|
|
|
httpActivity.response.headers.push(
|
2012-05-29 05:48:05 -07:00
|
|
|
{ name: "Content-Type", value: "text/html" },
|
|
|
|
{ name: "leaveHouses", value: "true" }
|
|
|
|
);
|
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
networkPanel.update();
|
2012-05-29 05:48:05 -07:00
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: true,
|
|
|
|
requestFormData: false,
|
|
|
|
requestCookie: false,
|
|
|
|
responseContainer: true,
|
|
|
|
responseBody: false,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: false
|
|
|
|
});
|
|
|
|
|
2012-05-29 05:48:05 -07:00
|
|
|
checkNodeContent(networkPanel, "header", "HTTP/3.14 999 earthquake win");
|
2010-10-11 09:57:56 -07:00
|
|
|
checkNodeKeyValue(networkPanel, "responseHeadersContent", "leaveHouses", "true");
|
2012-05-29 05:48:05 -07:00
|
|
|
checkNodeContent(networkPanel, "responseHeadersInfo", "10ms");
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 4");
|
|
|
|
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.discardResponseBody = false;
|
|
|
|
httpActivity.timings.receive = 2;
|
2010-10-11 09:57:56 -07:00
|
|
|
networkPanel.update();
|
|
|
|
|
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: true,
|
|
|
|
requestCookie: false,
|
|
|
|
requestFormData: false,
|
|
|
|
responseContainer: true,
|
|
|
|
responseBody: false,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: false
|
|
|
|
});
|
|
|
|
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 5");
|
|
|
|
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.updates.push("responseContent", "eventTimings");
|
2010-10-11 09:57:56 -07:00
|
|
|
networkPanel.update();
|
|
|
|
|
|
|
|
checkNodeContent(networkPanel, "responseNoBodyInfo", "2ms");
|
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: true,
|
|
|
|
requestCookie: false,
|
|
|
|
responseContainer: true,
|
|
|
|
responseBody: false,
|
|
|
|
responseNoBody: true,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: false
|
|
|
|
});
|
|
|
|
|
|
|
|
networkPanel.panel.hidePopup();
|
|
|
|
|
|
|
|
// Second run: Test for cookies and response body.
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 6: cookies and response body");
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.request.cookies.push(
|
2012-05-29 05:48:05 -07:00
|
|
|
{ name: "foo", value: "bar" },
|
|
|
|
{ name: "hello", value: "world" }
|
|
|
|
);
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.response.content.text = "get out here";
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-07-26 08:06:04 -07:00
|
|
|
networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity);
|
2012-05-29 05:48:05 -07:00
|
|
|
is(filterBox._netPanel, networkPanel,
|
|
|
|
"Network panel stored on httpActivity object");
|
|
|
|
|
2012-10-05 04:54:43 -07:00
|
|
|
networkPanel._onUpdate = function() {
|
|
|
|
networkPanel._onUpdate = null;
|
|
|
|
executeSoon(function() {
|
|
|
|
testDriver.next();
|
|
|
|
});
|
|
|
|
};
|
2010-10-13 05:05:51 -07:00
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
yield;
|
|
|
|
|
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: true,
|
|
|
|
requestFormData: false,
|
|
|
|
requestCookie: true,
|
|
|
|
responseContainer: true,
|
2012-11-05 08:41:59 -08:00
|
|
|
responseCookie: false,
|
2010-10-11 09:57:56 -07:00
|
|
|
responseBody: true,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: false
|
|
|
|
});
|
|
|
|
|
|
|
|
checkNodeKeyValue(networkPanel, "requestCookieContent", "foo", "bar");
|
|
|
|
checkNodeKeyValue(networkPanel, "requestCookieContent", "hello", "world");
|
|
|
|
checkNodeContent(networkPanel, "responseBodyContent", "get out here");
|
|
|
|
checkNodeContent(networkPanel, "responseBodyInfo", "2ms");
|
|
|
|
|
|
|
|
networkPanel.panel.hidePopup();
|
|
|
|
|
2012-11-05 08:41:59 -08:00
|
|
|
// Third run: Test for response cookies.
|
|
|
|
info("test 6b: response cookies");
|
|
|
|
httpActivity.response.cookies.push(
|
|
|
|
{ name: "foobar", value: "boom" },
|
|
|
|
{ name: "foobaz", value: "omg" }
|
|
|
|
);
|
|
|
|
|
|
|
|
networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity);
|
|
|
|
is(filterBox._netPanel, networkPanel,
|
|
|
|
"Network panel stored on httpActivity object");
|
|
|
|
|
|
|
|
networkPanel._onUpdate = function() {
|
|
|
|
networkPanel._onUpdate = null;
|
|
|
|
executeSoon(function() {
|
|
|
|
testDriver.next();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
yield;
|
|
|
|
|
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: true,
|
|
|
|
requestFormData: false,
|
|
|
|
requestCookie: true,
|
|
|
|
responseContainer: true,
|
|
|
|
responseCookie: true,
|
|
|
|
responseBody: true,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: false,
|
|
|
|
responseBodyFetchLink: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
checkNodeKeyValue(networkPanel, "responseCookieContent", "foobar", "boom");
|
|
|
|
checkNodeKeyValue(networkPanel, "responseCookieContent", "foobaz", "omg");
|
|
|
|
|
|
|
|
networkPanel.panel.hidePopup();
|
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
// Check image request.
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 7: image request");
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.response.headers[1].value = "image/png";
|
|
|
|
httpActivity.response.content.mimeType = "image/png";
|
2012-11-05 08:41:59 -08:00
|
|
|
httpActivity.response.content.text = TEST_IMG_BASE64;
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.request.url = TEST_IMG;
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-07-26 08:06:04 -07:00
|
|
|
networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity);
|
2012-10-05 04:54:43 -07:00
|
|
|
networkPanel._onUpdate = function() {
|
|
|
|
networkPanel._onUpdate = null;
|
|
|
|
executeSoon(function() {
|
|
|
|
testDriver.next();
|
|
|
|
});
|
|
|
|
};
|
2010-10-13 05:05:51 -07:00
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
yield;
|
|
|
|
|
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: true,
|
|
|
|
requestFormData: false,
|
|
|
|
requestCookie: true,
|
|
|
|
responseContainer: true,
|
|
|
|
responseBody: false,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: true,
|
2012-11-05 08:41:59 -08:00
|
|
|
responseImageCached: false,
|
|
|
|
responseBodyFetchLink: false,
|
2010-10-11 09:57:56 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
let imgNode = networkPanel.document.getElementById("responseImageNode");
|
2012-11-05 08:41:59 -08:00
|
|
|
is(imgNode.getAttribute("src"), "data:image/png;base64," + TEST_IMG_BASE64,
|
|
|
|
"Displayed image is correct");
|
2010-10-11 09:57:56 -07:00
|
|
|
|
|
|
|
function checkImageResponseInfo() {
|
|
|
|
checkNodeContent(networkPanel, "responseImageInfo", "2ms");
|
|
|
|
checkNodeContent(networkPanel, "responseImageInfo", "16x16px");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the image is loaded already.
|
2012-11-05 08:41:59 -08:00
|
|
|
imgNode.addEventListener("load", function onLoad() {
|
|
|
|
imgNode.removeEventListener("load", onLoad, false);
|
2010-10-11 09:57:56 -07:00
|
|
|
checkImageResponseInfo();
|
|
|
|
networkPanel.panel.hidePopup();
|
2012-11-05 08:41:59 -08:00
|
|
|
testDriver.next();
|
|
|
|
}, false);
|
|
|
|
yield;
|
2010-10-11 09:57:56 -07:00
|
|
|
|
|
|
|
// Check cached image request.
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 8: cached image request");
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.response.httpVersion = "HTTP/1.1";
|
|
|
|
httpActivity.response.status = 304;
|
|
|
|
httpActivity.response.statusText = "Not Modified";
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-07-26 08:06:04 -07:00
|
|
|
networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity);
|
2012-10-05 04:54:43 -07:00
|
|
|
networkPanel._onUpdate = function() {
|
|
|
|
networkPanel._onUpdate = null;
|
|
|
|
executeSoon(function() {
|
|
|
|
testDriver.next();
|
|
|
|
});
|
|
|
|
};
|
2010-10-13 05:05:51 -07:00
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
yield;
|
|
|
|
|
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: true,
|
|
|
|
requestFormData: false,
|
|
|
|
requestCookie: true,
|
|
|
|
responseContainer: true,
|
|
|
|
responseBody: false,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: true
|
|
|
|
});
|
|
|
|
|
|
|
|
let imgNode = networkPanel.document.getElementById("responseImageCachedNode");
|
2012-11-05 08:41:59 -08:00
|
|
|
is(imgNode.getAttribute("src"), "data:image/png;base64," + TEST_IMG_BASE64,
|
|
|
|
"Displayed image is correct");
|
2010-10-11 09:57:56 -07:00
|
|
|
|
|
|
|
networkPanel.panel.hidePopup();
|
|
|
|
|
|
|
|
// Test sent form data.
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 9: sent form data");
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.request.postData.text = [
|
2012-05-29 05:48:05 -07:00
|
|
|
"Content-Type: application/x-www-form-urlencoded",
|
|
|
|
"Content-Length: 59",
|
2010-10-11 09:57:56 -07:00
|
|
|
"name=rob&age=20"
|
2012-05-29 05:48:05 -07:00
|
|
|
].join("\n");
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-07-26 08:06:04 -07:00
|
|
|
networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity);
|
2012-10-05 04:54:43 -07:00
|
|
|
networkPanel._onUpdate = function() {
|
|
|
|
networkPanel._onUpdate = null;
|
|
|
|
executeSoon(function() {
|
|
|
|
testDriver.next();
|
|
|
|
});
|
|
|
|
};
|
2010-10-13 05:05:51 -07:00
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
yield;
|
|
|
|
|
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: false,
|
|
|
|
requestFormData: true,
|
|
|
|
requestCookie: true,
|
|
|
|
responseContainer: true,
|
|
|
|
responseBody: false,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: true
|
|
|
|
});
|
|
|
|
|
|
|
|
checkNodeKeyValue(networkPanel, "requestFormDataContent", "name", "rob");
|
|
|
|
checkNodeKeyValue(networkPanel, "requestFormDataContent", "age", "20");
|
|
|
|
networkPanel.panel.hidePopup();
|
|
|
|
|
|
|
|
// Test no space after Content-Type:
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 10: no space after Content-Type header in post data");
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.request.postData.text = "Content-Type:application/x-www-form-urlencoded\n";
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-07-26 08:06:04 -07:00
|
|
|
networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity);
|
2012-10-05 04:54:43 -07:00
|
|
|
networkPanel._onUpdate = function() {
|
|
|
|
networkPanel._onUpdate = null;
|
|
|
|
executeSoon(function() {
|
|
|
|
testDriver.next();
|
|
|
|
});
|
|
|
|
};
|
2010-10-13 05:05:51 -07:00
|
|
|
|
2010-10-11 09:57:56 -07:00
|
|
|
yield;
|
|
|
|
|
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: false,
|
|
|
|
requestFormData: true,
|
|
|
|
requestCookie: true,
|
|
|
|
responseContainer: true,
|
|
|
|
responseBody: false,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: true
|
|
|
|
});
|
|
|
|
|
|
|
|
networkPanel.panel.hidePopup();
|
|
|
|
|
|
|
|
// Test cached data.
|
|
|
|
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 11: cached data");
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.request.url = TEST_ENCODING_ISO_8859_1;
|
|
|
|
httpActivity.response.headers[1].value = "application/json";
|
|
|
|
httpActivity.response.content.mimeType = "application/json";
|
|
|
|
httpActivity.response.content.text = "my cached data is here!";
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2012-07-26 08:06:04 -07:00
|
|
|
networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity);
|
2012-10-05 04:54:43 -07:00
|
|
|
networkPanel._onUpdate = function() {
|
|
|
|
networkPanel._onUpdate = null;
|
|
|
|
executeSoon(function() {
|
|
|
|
testDriver.next();
|
|
|
|
});
|
|
|
|
};
|
2010-10-11 09:57:56 -07:00
|
|
|
|
2010-10-13 05:05:51 -07:00
|
|
|
yield;
|
|
|
|
|
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: false,
|
|
|
|
requestFormData: true,
|
|
|
|
requestCookie: true,
|
|
|
|
responseContainer: true,
|
|
|
|
responseBody: false,
|
|
|
|
responseBodyCached: true,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: false
|
|
|
|
});
|
|
|
|
|
2012-05-29 05:48:05 -07:00
|
|
|
checkNodeContent(networkPanel, "responseBodyCachedContent",
|
|
|
|
"my cached data is here!");
|
|
|
|
|
2010-10-13 05:05:51 -07:00
|
|
|
networkPanel.panel.hidePopup();
|
|
|
|
|
|
|
|
// Test a response with a content type that can't be displayed in the
|
|
|
|
// NetworkPanel.
|
2012-05-29 05:48:05 -07:00
|
|
|
info("test 12: unknown content type");
|
2012-10-05 04:54:43 -07:00
|
|
|
httpActivity.response.headers[1].value = "application/x-shockwave-flash";
|
|
|
|
httpActivity.response.content.mimeType = "application/x-shockwave-flash";
|
2010-10-13 05:05:51 -07:00
|
|
|
|
2012-07-26 08:06:04 -07:00
|
|
|
networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity);
|
2012-10-05 04:54:43 -07:00
|
|
|
networkPanel._onUpdate = function() {
|
|
|
|
networkPanel._onUpdate = null;
|
|
|
|
executeSoon(function() {
|
|
|
|
testDriver.next();
|
|
|
|
});
|
|
|
|
};
|
2010-10-11 09:57:56 -07:00
|
|
|
|
|
|
|
yield;
|
|
|
|
|
2010-10-13 05:05:51 -07:00
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: false,
|
|
|
|
requestFormData: true,
|
|
|
|
requestCookie: true,
|
|
|
|
responseContainer: true,
|
|
|
|
responseBody: false,
|
|
|
|
responseBodyCached: false,
|
|
|
|
responseBodyUnknownType: true,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: false
|
|
|
|
});
|
|
|
|
|
2012-05-10 06:15:10 -07:00
|
|
|
let responseString =
|
2012-09-26 10:07:57 -07:00
|
|
|
WCU_l10n.getFormatStr("NetworkPanel.responseBodyUnableToDisplay.content",
|
2012-05-10 06:15:10 -07:00
|
|
|
["application/x-shockwave-flash"]);
|
2010-10-13 05:05:51 -07:00
|
|
|
checkNodeContent(networkPanel, "responseBodyUnknownTypeContent", responseString);
|
|
|
|
networkPanel.panel.hidePopup();
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
// This test disabled. See bug 603620.
|
|
|
|
|
|
|
|
// Test if the NetworkPanel figures out the content type based on an URL as
|
|
|
|
// well.
|
|
|
|
delete httpActivity.response.header["Content-Type"];
|
|
|
|
httpActivity.url = "http://www.test.com/someCrazyFile.swf?done=right&ending=txt";
|
|
|
|
|
2012-07-26 08:06:04 -07:00
|
|
|
networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity);
|
2010-10-13 05:05:51 -07:00
|
|
|
networkPanel.isDoneCallback = function NP_doneCallback() {
|
|
|
|
networkPanel.isDoneCallback = null;
|
|
|
|
testDriver.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
yield;
|
|
|
|
|
|
|
|
checkIsVisible(networkPanel, {
|
|
|
|
requestBody: false,
|
|
|
|
requestFormData: true,
|
|
|
|
requestCookie: true,
|
|
|
|
responseContainer: true,
|
|
|
|
responseBody: false,
|
|
|
|
responseBodyCached: false,
|
|
|
|
responseBodyUnknownType: true,
|
|
|
|
responseNoBody: false,
|
|
|
|
responseImage: false,
|
|
|
|
responseImageCached: false
|
|
|
|
});
|
|
|
|
|
|
|
|
// Systems without Flash installed will return an empty string here. Ignore.
|
|
|
|
if (networkPanel.document.getElementById("responseBodyUnknownTypeContent").textContent !== "")
|
|
|
|
checkNodeContent(networkPanel, "responseBodyUnknownTypeContent", responseString);
|
|
|
|
else
|
|
|
|
ok(true, "Flash not installed");
|
|
|
|
|
|
|
|
networkPanel.panel.hidePopup(); */
|
|
|
|
|
|
|
|
// All done!
|
2012-05-10 08:01:37 -07:00
|
|
|
testDriver = null;
|
|
|
|
executeSoon(finishTest);
|
2012-05-29 05:48:05 -07:00
|
|
|
|
|
|
|
yield;
|
2010-10-13 05:05:51 -07:00
|
|
|
}
|