browser/devtools/webconsole/test/browser_webconsole_bug_599725_response_headers.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial