Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* vim:set ts=2 sw=2 sts=2 et: */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Any copyright is dedicated to the Public Domain.
4 * http://creativecommons.org/publicdomain/zero/1.0/
5 *
6 * Contributor(s):
7 * Mihai Șucan <mihai.sucan@gmail.com>
8 *
9 * ***** END LICENSE BLOCK ***** */
11 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug-599725-response-headers.sjs";
13 let loads = 0;
14 function performTest(aRequest, aConsole)
15 {
16 loads++;
17 ok(aRequest, "page load was logged");
18 if (loads != 2) {
19 return;
20 }
22 let headers = null;
24 function readHeader(aName)
25 {
26 for (let header of headers) {
27 if (header.name == aName) {
28 return header.value;
29 }
30 }
31 return null;
32 }
34 aConsole.webConsoleClient.getResponseHeaders(aRequest.actor,
35 function (aResponse) {
36 headers = aResponse.headers;
37 ok(headers, "we have the response headers for reload");
39 let contentType = readHeader("Content-Type");
40 let contentLength = readHeader("Content-Length");
42 ok(!contentType, "we do not have the Content-Type header");
43 isnot(contentLength, 60, "Content-Length != 60");
45 if (contentType || contentLength == 60) {
46 console.debug("lastFinishedRequest", lastFinishedRequest,
47 "request", lastFinishedRequest.request,
48 "response", lastFinishedRequest.response,
49 "updates", lastFinishedRequest.updates,
50 "response headers", headers);
51 }
53 executeSoon(finishTest);
54 });
56 HUDService.lastFinishedRequest.callback = null;
57 }
59 function test()
60 {
61 addTab("data:text/plain;charset=utf8,hello world");
63 browser.addEventListener("load", function onLoad() {
64 browser.removeEventListener("load", onLoad, true);
65 openConsole(null, () => {
66 HUDService.lastFinishedRequest.callback = performTest;
68 browser.addEventListener("load", function onReload() {
69 browser.removeEventListener("load", onReload, true);
70 executeSoon(() => content.location.reload());
71 }, true);
73 executeSoon(() => content.location = TEST_URI);
74 });
75 }, true);
76 }