|
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 ***** */ |
|
10 |
|
11 const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug-599725-response-headers.sjs"; |
|
12 |
|
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 } |
|
21 |
|
22 let headers = null; |
|
23 |
|
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 } |
|
33 |
|
34 aConsole.webConsoleClient.getResponseHeaders(aRequest.actor, |
|
35 function (aResponse) { |
|
36 headers = aResponse.headers; |
|
37 ok(headers, "we have the response headers for reload"); |
|
38 |
|
39 let contentType = readHeader("Content-Type"); |
|
40 let contentLength = readHeader("Content-Length"); |
|
41 |
|
42 ok(!contentType, "we do not have the Content-Type header"); |
|
43 isnot(contentLength, 60, "Content-Length != 60"); |
|
44 |
|
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 } |
|
52 |
|
53 executeSoon(finishTest); |
|
54 }); |
|
55 |
|
56 HUDService.lastFinishedRequest.callback = null; |
|
57 } |
|
58 |
|
59 function test() |
|
60 { |
|
61 addTab("data:text/plain;charset=utf8,hello world"); |
|
62 |
|
63 browser.addEventListener("load", function onLoad() { |
|
64 browser.removeEventListener("load", onLoad, true); |
|
65 openConsole(null, () => { |
|
66 HUDService.lastFinishedRequest.callback = performTest; |
|
67 |
|
68 browser.addEventListener("load", function onReload() { |
|
69 browser.removeEventListener("load", onReload, true); |
|
70 executeSoon(() => content.location.reload()); |
|
71 }, true); |
|
72 |
|
73 executeSoon(() => content.location = TEST_URI); |
|
74 }); |
|
75 }, true); |
|
76 } |