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.
michael@0 | 1 | /* vim:set ts=2 sw=2 sts=2 et: */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | // Tests that the network panel works. |
michael@0 | 7 | |
michael@0 | 8 | const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; |
michael@0 | 9 | const TEST_IMG = "http://example.com/browser/browser/devtools/webconsole/test/test-image.png"; |
michael@0 | 10 | const TEST_ENCODING_ISO_8859_1 = "http://example.com/browser/browser/devtools/webconsole/test/test-encoding-ISO-8859-1.html"; |
michael@0 | 11 | |
michael@0 | 12 | const TEST_IMG_BASE64 = |
michael@0 | 13 | "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAVRJREFU" + |
michael@0 | 14 | "OI2lk7FLw0AUxr+YpC1CBqcMWfsvCCLdXFzqEJCgDl1EQRGxg9AhSBEJONhFhG52UCuFDjq5dxD8" + |
michael@0 | 15 | "FwoO0qGDOBQkl7vLOeWa2EQDffDBvTu+373Hu1OEEJgntGgxGD6J+7fLXKbt5VNUyhsKAChRBQcP" + |
michael@0 | 16 | "FVFeWskFGH694mZroCQqCLlAwPxcgJBP254CmAD5B7C7dgHLMLF3uzoL4DQEod+Z5sP1FizDxGgy" + |
michael@0 | 17 | "BqfhLID9AahX29J89bwPFgMsSEAQglAf9WobhPpScbPXr4FQHyzIADTsDizDRMPuIOC+zEeTMZo9" + |
michael@0 | 18 | "BwH3EfAMACccbtfGaDKGZZg423yUZrdrg3EqxQlPr0BTdTR7joREN2uqnlBmCwW1hIJagtev4f3z" + |
michael@0 | 19 | "A16/JvfiigMSYyzqJXlw/XKUyOORMUaBor6YavgdjKa8xGOnidadmwtwsnMu18q83/kHSou+bFND" + |
michael@0 | 20 | "Dr4AAAAASUVORK5CYII="; |
michael@0 | 21 | |
michael@0 | 22 | let testDriver; |
michael@0 | 23 | |
michael@0 | 24 | function test() { |
michael@0 | 25 | addTab(TEST_URI); |
michael@0 | 26 | browser.addEventListener("load", function onLoad() { |
michael@0 | 27 | browser.removeEventListener("load", onLoad, true); |
michael@0 | 28 | openConsole(null, testNetworkPanel); |
michael@0 | 29 | }, true); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function testNetworkPanel() { |
michael@0 | 33 | testDriver = testGen(); |
michael@0 | 34 | testDriver.next(); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | function checkIsVisible(aPanel, aList) { |
michael@0 | 38 | for (let id in aList) { |
michael@0 | 39 | let node = aPanel.document.getElementById(id); |
michael@0 | 40 | let isVisible = aList[id]; |
michael@0 | 41 | is(node.style.display, (isVisible ? "block" : "none"), id + " isVisible=" + isVisible); |
michael@0 | 42 | } |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function checkNodeContent(aPanel, aId, aContent) { |
michael@0 | 46 | let node = aPanel.document.getElementById(aId); |
michael@0 | 47 | if (node == null) { |
michael@0 | 48 | ok(false, "Tried to access node " + aId + " that doesn't exist!"); |
michael@0 | 49 | } |
michael@0 | 50 | else if (node.textContent.indexOf(aContent) != -1) { |
michael@0 | 51 | ok(true, "checking content of " + aId); |
michael@0 | 52 | } |
michael@0 | 53 | else { |
michael@0 | 54 | ok(false, "Got false value for " + aId + ": " + node.textContent + " doesn't have " + aContent); |
michael@0 | 55 | } |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function checkNodeKeyValue(aPanel, aId, aKey, aValue) { |
michael@0 | 59 | let node = aPanel.document.getElementById(aId); |
michael@0 | 60 | |
michael@0 | 61 | let headers = node.querySelectorAll("th"); |
michael@0 | 62 | for (let i = 0; i < headers.length; i++) { |
michael@0 | 63 | if (headers[i].textContent == (aKey + ":")) { |
michael@0 | 64 | is(headers[i].nextElementSibling.textContent, aValue, |
michael@0 | 65 | "checking content of " + aId + " for key " + aKey); |
michael@0 | 66 | return; |
michael@0 | 67 | } |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | ok(false, "content check failed for " + aId + ", key " + aKey); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function testGen() { |
michael@0 | 74 | let hud = HUDService.getHudByWindow(content); |
michael@0 | 75 | let filterBox = hud.ui.filterBox; |
michael@0 | 76 | |
michael@0 | 77 | let httpActivity = { |
michael@0 | 78 | updates: [], |
michael@0 | 79 | discardRequestBody: true, |
michael@0 | 80 | discardResponseBody: true, |
michael@0 | 81 | startedDateTime: (new Date()).toISOString(), |
michael@0 | 82 | request: { |
michael@0 | 83 | url: "http://www.testpage.com", |
michael@0 | 84 | method: "GET", |
michael@0 | 85 | cookies: [], |
michael@0 | 86 | headers: [ |
michael@0 | 87 | { name: "foo", value: "bar" }, |
michael@0 | 88 | ], |
michael@0 | 89 | }, |
michael@0 | 90 | response: { |
michael@0 | 91 | headers: [], |
michael@0 | 92 | content: {}, |
michael@0 | 93 | cookies: [], |
michael@0 | 94 | }, |
michael@0 | 95 | timings: {}, |
michael@0 | 96 | }; |
michael@0 | 97 | |
michael@0 | 98 | let networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity); |
michael@0 | 99 | |
michael@0 | 100 | is(filterBox._netPanel, networkPanel, |
michael@0 | 101 | "Network panel stored on the anchor object"); |
michael@0 | 102 | |
michael@0 | 103 | networkPanel._onUpdate = function() { |
michael@0 | 104 | networkPanel._onUpdate = null; |
michael@0 | 105 | executeSoon(function() { |
michael@0 | 106 | testDriver.next(); |
michael@0 | 107 | }); |
michael@0 | 108 | }; |
michael@0 | 109 | |
michael@0 | 110 | yield undefined; |
michael@0 | 111 | |
michael@0 | 112 | info("test 1"); |
michael@0 | 113 | |
michael@0 | 114 | checkIsVisible(networkPanel, { |
michael@0 | 115 | requestCookie: false, |
michael@0 | 116 | requestFormData: false, |
michael@0 | 117 | requestBody: false, |
michael@0 | 118 | responseContainer: false, |
michael@0 | 119 | responseBody: false, |
michael@0 | 120 | responseNoBody: false, |
michael@0 | 121 | responseImage: false, |
michael@0 | 122 | responseImageCached: false |
michael@0 | 123 | }); |
michael@0 | 124 | |
michael@0 | 125 | checkNodeContent(networkPanel, "header", "http://www.testpage.com"); |
michael@0 | 126 | checkNodeContent(networkPanel, "header", "GET"); |
michael@0 | 127 | checkNodeKeyValue(networkPanel, "requestHeadersContent", "foo", "bar"); |
michael@0 | 128 | |
michael@0 | 129 | // Test request body. |
michael@0 | 130 | info("test 2: request body"); |
michael@0 | 131 | httpActivity.discardRequestBody = false; |
michael@0 | 132 | httpActivity.request.postData = { text: "hello world" }; |
michael@0 | 133 | networkPanel.update(); |
michael@0 | 134 | |
michael@0 | 135 | checkIsVisible(networkPanel, { |
michael@0 | 136 | requestBody: true, |
michael@0 | 137 | requestFormData: false, |
michael@0 | 138 | requestCookie: false, |
michael@0 | 139 | responseContainer: false, |
michael@0 | 140 | responseBody: false, |
michael@0 | 141 | responseNoBody: false, |
michael@0 | 142 | responseImage: false, |
michael@0 | 143 | responseImageCached: false |
michael@0 | 144 | }); |
michael@0 | 145 | checkNodeContent(networkPanel, "requestBodyContent", "hello world"); |
michael@0 | 146 | |
michael@0 | 147 | // Test response header. |
michael@0 | 148 | info("test 3: response header"); |
michael@0 | 149 | httpActivity.timings.wait = 10; |
michael@0 | 150 | httpActivity.response.httpVersion = "HTTP/3.14"; |
michael@0 | 151 | httpActivity.response.status = 999; |
michael@0 | 152 | httpActivity.response.statusText = "earthquake win"; |
michael@0 | 153 | httpActivity.response.content.mimeType = "text/html"; |
michael@0 | 154 | httpActivity.response.headers.push( |
michael@0 | 155 | { name: "Content-Type", value: "text/html" }, |
michael@0 | 156 | { name: "leaveHouses", value: "true" } |
michael@0 | 157 | ); |
michael@0 | 158 | |
michael@0 | 159 | networkPanel.update(); |
michael@0 | 160 | |
michael@0 | 161 | checkIsVisible(networkPanel, { |
michael@0 | 162 | requestBody: true, |
michael@0 | 163 | requestFormData: false, |
michael@0 | 164 | requestCookie: false, |
michael@0 | 165 | responseContainer: true, |
michael@0 | 166 | responseBody: false, |
michael@0 | 167 | responseNoBody: false, |
michael@0 | 168 | responseImage: false, |
michael@0 | 169 | responseImageCached: false |
michael@0 | 170 | }); |
michael@0 | 171 | |
michael@0 | 172 | checkNodeContent(networkPanel, "header", "HTTP/3.14 999 earthquake win"); |
michael@0 | 173 | checkNodeKeyValue(networkPanel, "responseHeadersContent", "leaveHouses", "true"); |
michael@0 | 174 | checkNodeContent(networkPanel, "responseHeadersInfo", "10ms"); |
michael@0 | 175 | |
michael@0 | 176 | info("test 4"); |
michael@0 | 177 | |
michael@0 | 178 | httpActivity.discardResponseBody = false; |
michael@0 | 179 | httpActivity.timings.receive = 2; |
michael@0 | 180 | networkPanel.update(); |
michael@0 | 181 | |
michael@0 | 182 | checkIsVisible(networkPanel, { |
michael@0 | 183 | requestBody: true, |
michael@0 | 184 | requestCookie: false, |
michael@0 | 185 | requestFormData: false, |
michael@0 | 186 | responseContainer: true, |
michael@0 | 187 | responseBody: false, |
michael@0 | 188 | responseNoBody: false, |
michael@0 | 189 | responseImage: false, |
michael@0 | 190 | responseImageCached: false |
michael@0 | 191 | }); |
michael@0 | 192 | |
michael@0 | 193 | info("test 5"); |
michael@0 | 194 | |
michael@0 | 195 | httpActivity.updates.push("responseContent", "eventTimings"); |
michael@0 | 196 | networkPanel.update(); |
michael@0 | 197 | |
michael@0 | 198 | checkNodeContent(networkPanel, "responseNoBodyInfo", "2ms"); |
michael@0 | 199 | checkIsVisible(networkPanel, { |
michael@0 | 200 | requestBody: true, |
michael@0 | 201 | requestCookie: false, |
michael@0 | 202 | responseContainer: true, |
michael@0 | 203 | responseBody: false, |
michael@0 | 204 | responseNoBody: true, |
michael@0 | 205 | responseImage: false, |
michael@0 | 206 | responseImageCached: false |
michael@0 | 207 | }); |
michael@0 | 208 | |
michael@0 | 209 | networkPanel.panel.hidePopup(); |
michael@0 | 210 | |
michael@0 | 211 | // Second run: Test for cookies and response body. |
michael@0 | 212 | info("test 6: cookies and response body"); |
michael@0 | 213 | httpActivity.request.cookies.push( |
michael@0 | 214 | { name: "foo", value: "bar" }, |
michael@0 | 215 | { name: "hello", value: "world" } |
michael@0 | 216 | ); |
michael@0 | 217 | httpActivity.response.content.text = "get out here"; |
michael@0 | 218 | |
michael@0 | 219 | networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity); |
michael@0 | 220 | is(filterBox._netPanel, networkPanel, |
michael@0 | 221 | "Network panel stored on httpActivity object"); |
michael@0 | 222 | |
michael@0 | 223 | networkPanel._onUpdate = function() { |
michael@0 | 224 | networkPanel._onUpdate = null; |
michael@0 | 225 | executeSoon(function() { |
michael@0 | 226 | testDriver.next(); |
michael@0 | 227 | }); |
michael@0 | 228 | }; |
michael@0 | 229 | |
michael@0 | 230 | yield undefined; |
michael@0 | 231 | |
michael@0 | 232 | checkIsVisible(networkPanel, { |
michael@0 | 233 | requestBody: true, |
michael@0 | 234 | requestFormData: false, |
michael@0 | 235 | requestCookie: true, |
michael@0 | 236 | responseContainer: true, |
michael@0 | 237 | responseCookie: false, |
michael@0 | 238 | responseBody: true, |
michael@0 | 239 | responseNoBody: false, |
michael@0 | 240 | responseImage: false, |
michael@0 | 241 | responseImageCached: false |
michael@0 | 242 | }); |
michael@0 | 243 | |
michael@0 | 244 | checkNodeKeyValue(networkPanel, "requestCookieContent", "foo", "bar"); |
michael@0 | 245 | checkNodeKeyValue(networkPanel, "requestCookieContent", "hello", "world"); |
michael@0 | 246 | checkNodeContent(networkPanel, "responseBodyContent", "get out here"); |
michael@0 | 247 | checkNodeContent(networkPanel, "responseBodyInfo", "2ms"); |
michael@0 | 248 | |
michael@0 | 249 | networkPanel.panel.hidePopup(); |
michael@0 | 250 | |
michael@0 | 251 | // Third run: Test for response cookies. |
michael@0 | 252 | info("test 6b: response cookies"); |
michael@0 | 253 | httpActivity.response.cookies.push( |
michael@0 | 254 | { name: "foobar", value: "boom" }, |
michael@0 | 255 | { name: "foobaz", value: "omg" } |
michael@0 | 256 | ); |
michael@0 | 257 | |
michael@0 | 258 | networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity); |
michael@0 | 259 | is(filterBox._netPanel, networkPanel, |
michael@0 | 260 | "Network panel stored on httpActivity object"); |
michael@0 | 261 | |
michael@0 | 262 | networkPanel._onUpdate = function() { |
michael@0 | 263 | networkPanel._onUpdate = null; |
michael@0 | 264 | executeSoon(function() { |
michael@0 | 265 | testDriver.next(); |
michael@0 | 266 | }); |
michael@0 | 267 | }; |
michael@0 | 268 | |
michael@0 | 269 | yield undefined; |
michael@0 | 270 | |
michael@0 | 271 | checkIsVisible(networkPanel, { |
michael@0 | 272 | requestBody: true, |
michael@0 | 273 | requestFormData: false, |
michael@0 | 274 | requestCookie: true, |
michael@0 | 275 | responseContainer: true, |
michael@0 | 276 | responseCookie: true, |
michael@0 | 277 | responseBody: true, |
michael@0 | 278 | responseNoBody: false, |
michael@0 | 279 | responseImage: false, |
michael@0 | 280 | responseImageCached: false, |
michael@0 | 281 | responseBodyFetchLink: false, |
michael@0 | 282 | }); |
michael@0 | 283 | |
michael@0 | 284 | checkNodeKeyValue(networkPanel, "responseCookieContent", "foobar", "boom"); |
michael@0 | 285 | checkNodeKeyValue(networkPanel, "responseCookieContent", "foobaz", "omg"); |
michael@0 | 286 | |
michael@0 | 287 | networkPanel.panel.hidePopup(); |
michael@0 | 288 | |
michael@0 | 289 | // Check image request. |
michael@0 | 290 | info("test 7: image request"); |
michael@0 | 291 | httpActivity.response.headers[1].value = "image/png"; |
michael@0 | 292 | httpActivity.response.content.mimeType = "image/png"; |
michael@0 | 293 | httpActivity.response.content.text = TEST_IMG_BASE64; |
michael@0 | 294 | httpActivity.request.url = TEST_IMG; |
michael@0 | 295 | |
michael@0 | 296 | networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity); |
michael@0 | 297 | networkPanel._onUpdate = function() { |
michael@0 | 298 | networkPanel._onUpdate = null; |
michael@0 | 299 | executeSoon(function() { |
michael@0 | 300 | testDriver.next(); |
michael@0 | 301 | }); |
michael@0 | 302 | }; |
michael@0 | 303 | |
michael@0 | 304 | yield undefined; |
michael@0 | 305 | |
michael@0 | 306 | checkIsVisible(networkPanel, { |
michael@0 | 307 | requestBody: true, |
michael@0 | 308 | requestFormData: false, |
michael@0 | 309 | requestCookie: true, |
michael@0 | 310 | responseContainer: true, |
michael@0 | 311 | responseBody: false, |
michael@0 | 312 | responseNoBody: false, |
michael@0 | 313 | responseImage: true, |
michael@0 | 314 | responseImageCached: false, |
michael@0 | 315 | responseBodyFetchLink: false, |
michael@0 | 316 | }); |
michael@0 | 317 | |
michael@0 | 318 | let imgNode = networkPanel.document.getElementById("responseImageNode"); |
michael@0 | 319 | is(imgNode.getAttribute("src"), "data:image/png;base64," + TEST_IMG_BASE64, |
michael@0 | 320 | "Displayed image is correct"); |
michael@0 | 321 | |
michael@0 | 322 | function checkImageResponseInfo() { |
michael@0 | 323 | checkNodeContent(networkPanel, "responseImageInfo", "2ms"); |
michael@0 | 324 | checkNodeContent(networkPanel, "responseImageInfo", "16x16px"); |
michael@0 | 325 | } |
michael@0 | 326 | |
michael@0 | 327 | // Check if the image is loaded already. |
michael@0 | 328 | imgNode.addEventListener("load", function onLoad() { |
michael@0 | 329 | imgNode.removeEventListener("load", onLoad, false); |
michael@0 | 330 | checkImageResponseInfo(); |
michael@0 | 331 | networkPanel.panel.hidePopup(); |
michael@0 | 332 | testDriver.next(); |
michael@0 | 333 | }, false); |
michael@0 | 334 | yield undefined; |
michael@0 | 335 | |
michael@0 | 336 | // Check cached image request. |
michael@0 | 337 | info("test 8: cached image request"); |
michael@0 | 338 | httpActivity.response.httpVersion = "HTTP/1.1"; |
michael@0 | 339 | httpActivity.response.status = 304; |
michael@0 | 340 | httpActivity.response.statusText = "Not Modified"; |
michael@0 | 341 | |
michael@0 | 342 | networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity); |
michael@0 | 343 | networkPanel._onUpdate = function() { |
michael@0 | 344 | networkPanel._onUpdate = null; |
michael@0 | 345 | executeSoon(function() { |
michael@0 | 346 | testDriver.next(); |
michael@0 | 347 | }); |
michael@0 | 348 | }; |
michael@0 | 349 | |
michael@0 | 350 | yield undefined; |
michael@0 | 351 | |
michael@0 | 352 | checkIsVisible(networkPanel, { |
michael@0 | 353 | requestBody: true, |
michael@0 | 354 | requestFormData: false, |
michael@0 | 355 | requestCookie: true, |
michael@0 | 356 | responseContainer: true, |
michael@0 | 357 | responseBody: false, |
michael@0 | 358 | responseNoBody: false, |
michael@0 | 359 | responseImage: false, |
michael@0 | 360 | responseImageCached: true |
michael@0 | 361 | }); |
michael@0 | 362 | |
michael@0 | 363 | let imgNode = networkPanel.document.getElementById("responseImageCachedNode"); |
michael@0 | 364 | is(imgNode.getAttribute("src"), "data:image/png;base64," + TEST_IMG_BASE64, |
michael@0 | 365 | "Displayed image is correct"); |
michael@0 | 366 | |
michael@0 | 367 | networkPanel.panel.hidePopup(); |
michael@0 | 368 | |
michael@0 | 369 | // Test sent form data. |
michael@0 | 370 | info("test 9: sent form data"); |
michael@0 | 371 | httpActivity.request.postData.text = [ |
michael@0 | 372 | "Content-Type: application/x-www-form-urlencoded", |
michael@0 | 373 | "Content-Length: 59", |
michael@0 | 374 | "name=rob&age=20" |
michael@0 | 375 | ].join("\n"); |
michael@0 | 376 | |
michael@0 | 377 | networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity); |
michael@0 | 378 | networkPanel._onUpdate = function() { |
michael@0 | 379 | networkPanel._onUpdate = null; |
michael@0 | 380 | executeSoon(function() { |
michael@0 | 381 | testDriver.next(); |
michael@0 | 382 | }); |
michael@0 | 383 | }; |
michael@0 | 384 | |
michael@0 | 385 | yield undefined; |
michael@0 | 386 | |
michael@0 | 387 | checkIsVisible(networkPanel, { |
michael@0 | 388 | requestBody: false, |
michael@0 | 389 | requestFormData: true, |
michael@0 | 390 | requestCookie: true, |
michael@0 | 391 | responseContainer: true, |
michael@0 | 392 | responseBody: false, |
michael@0 | 393 | responseNoBody: false, |
michael@0 | 394 | responseImage: false, |
michael@0 | 395 | responseImageCached: true |
michael@0 | 396 | }); |
michael@0 | 397 | |
michael@0 | 398 | checkNodeKeyValue(networkPanel, "requestFormDataContent", "name", "rob"); |
michael@0 | 399 | checkNodeKeyValue(networkPanel, "requestFormDataContent", "age", "20"); |
michael@0 | 400 | networkPanel.panel.hidePopup(); |
michael@0 | 401 | |
michael@0 | 402 | // Test no space after Content-Type: |
michael@0 | 403 | info("test 10: no space after Content-Type header in post data"); |
michael@0 | 404 | httpActivity.request.postData.text = "Content-Type:application/x-www-form-urlencoded\n"; |
michael@0 | 405 | |
michael@0 | 406 | networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity); |
michael@0 | 407 | networkPanel._onUpdate = function() { |
michael@0 | 408 | networkPanel._onUpdate = null; |
michael@0 | 409 | executeSoon(function() { |
michael@0 | 410 | testDriver.next(); |
michael@0 | 411 | }); |
michael@0 | 412 | }; |
michael@0 | 413 | |
michael@0 | 414 | yield undefined; |
michael@0 | 415 | |
michael@0 | 416 | checkIsVisible(networkPanel, { |
michael@0 | 417 | requestBody: false, |
michael@0 | 418 | requestFormData: true, |
michael@0 | 419 | requestCookie: true, |
michael@0 | 420 | responseContainer: true, |
michael@0 | 421 | responseBody: false, |
michael@0 | 422 | responseNoBody: false, |
michael@0 | 423 | responseImage: false, |
michael@0 | 424 | responseImageCached: true |
michael@0 | 425 | }); |
michael@0 | 426 | |
michael@0 | 427 | networkPanel.panel.hidePopup(); |
michael@0 | 428 | |
michael@0 | 429 | // Test cached data. |
michael@0 | 430 | |
michael@0 | 431 | info("test 11: cached data"); |
michael@0 | 432 | |
michael@0 | 433 | httpActivity.request.url = TEST_ENCODING_ISO_8859_1; |
michael@0 | 434 | httpActivity.response.headers[1].value = "application/json"; |
michael@0 | 435 | httpActivity.response.content.mimeType = "application/json"; |
michael@0 | 436 | httpActivity.response.content.text = "my cached data is here!"; |
michael@0 | 437 | |
michael@0 | 438 | networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity); |
michael@0 | 439 | networkPanel._onUpdate = function() { |
michael@0 | 440 | networkPanel._onUpdate = null; |
michael@0 | 441 | executeSoon(function() { |
michael@0 | 442 | testDriver.next(); |
michael@0 | 443 | }); |
michael@0 | 444 | }; |
michael@0 | 445 | |
michael@0 | 446 | yield undefined; |
michael@0 | 447 | |
michael@0 | 448 | checkIsVisible(networkPanel, { |
michael@0 | 449 | requestBody: false, |
michael@0 | 450 | requestFormData: true, |
michael@0 | 451 | requestCookie: true, |
michael@0 | 452 | responseContainer: true, |
michael@0 | 453 | responseBody: false, |
michael@0 | 454 | responseBodyCached: true, |
michael@0 | 455 | responseNoBody: false, |
michael@0 | 456 | responseImage: false, |
michael@0 | 457 | responseImageCached: false |
michael@0 | 458 | }); |
michael@0 | 459 | |
michael@0 | 460 | checkNodeContent(networkPanel, "responseBodyCachedContent", |
michael@0 | 461 | "my cached data is here!"); |
michael@0 | 462 | |
michael@0 | 463 | networkPanel.panel.hidePopup(); |
michael@0 | 464 | |
michael@0 | 465 | // Test a response with a content type that can't be displayed in the |
michael@0 | 466 | // NetworkPanel. |
michael@0 | 467 | info("test 12: unknown content type"); |
michael@0 | 468 | httpActivity.response.headers[1].value = "application/x-shockwave-flash"; |
michael@0 | 469 | httpActivity.response.content.mimeType = "application/x-shockwave-flash"; |
michael@0 | 470 | |
michael@0 | 471 | networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity); |
michael@0 | 472 | networkPanel._onUpdate = function() { |
michael@0 | 473 | networkPanel._onUpdate = null; |
michael@0 | 474 | executeSoon(function() { |
michael@0 | 475 | testDriver.next(); |
michael@0 | 476 | }); |
michael@0 | 477 | }; |
michael@0 | 478 | |
michael@0 | 479 | yield undefined; |
michael@0 | 480 | |
michael@0 | 481 | checkIsVisible(networkPanel, { |
michael@0 | 482 | requestBody: false, |
michael@0 | 483 | requestFormData: true, |
michael@0 | 484 | requestCookie: true, |
michael@0 | 485 | responseContainer: true, |
michael@0 | 486 | responseBody: false, |
michael@0 | 487 | responseBodyCached: false, |
michael@0 | 488 | responseBodyUnknownType: true, |
michael@0 | 489 | responseNoBody: false, |
michael@0 | 490 | responseImage: false, |
michael@0 | 491 | responseImageCached: false |
michael@0 | 492 | }); |
michael@0 | 493 | |
michael@0 | 494 | let responseString = |
michael@0 | 495 | WCU_l10n.getFormatStr("NetworkPanel.responseBodyUnableToDisplay.content", |
michael@0 | 496 | ["application/x-shockwave-flash"]); |
michael@0 | 497 | checkNodeContent(networkPanel, "responseBodyUnknownTypeContent", responseString); |
michael@0 | 498 | networkPanel.panel.hidePopup(); |
michael@0 | 499 | |
michael@0 | 500 | /* |
michael@0 | 501 | |
michael@0 | 502 | // This test disabled. See bug 603620. |
michael@0 | 503 | |
michael@0 | 504 | // Test if the NetworkPanel figures out the content type based on an URL as |
michael@0 | 505 | // well. |
michael@0 | 506 | delete httpActivity.response.header["Content-Type"]; |
michael@0 | 507 | httpActivity.url = "http://www.test.com/someCrazyFile.swf?done=right&ending=txt"; |
michael@0 | 508 | |
michael@0 | 509 | networkPanel = hud.ui.openNetworkPanel(filterBox, httpActivity); |
michael@0 | 510 | networkPanel.isDoneCallback = function NP_doneCallback() { |
michael@0 | 511 | networkPanel.isDoneCallback = null; |
michael@0 | 512 | testDriver.next(); |
michael@0 | 513 | } |
michael@0 | 514 | |
michael@0 | 515 | yield undefined; |
michael@0 | 516 | |
michael@0 | 517 | checkIsVisible(networkPanel, { |
michael@0 | 518 | requestBody: false, |
michael@0 | 519 | requestFormData: true, |
michael@0 | 520 | requestCookie: true, |
michael@0 | 521 | responseContainer: true, |
michael@0 | 522 | responseBody: false, |
michael@0 | 523 | responseBodyCached: false, |
michael@0 | 524 | responseBodyUnknownType: true, |
michael@0 | 525 | responseNoBody: false, |
michael@0 | 526 | responseImage: false, |
michael@0 | 527 | responseImageCached: false |
michael@0 | 528 | }); |
michael@0 | 529 | |
michael@0 | 530 | // Systems without Flash installed will return an empty string here. Ignore. |
michael@0 | 531 | if (networkPanel.document.getElementById("responseBodyUnknownTypeContent").textContent !== "") |
michael@0 | 532 | checkNodeContent(networkPanel, "responseBodyUnknownTypeContent", responseString); |
michael@0 | 533 | else |
michael@0 | 534 | ok(true, "Flash not installed"); |
michael@0 | 535 | |
michael@0 | 536 | networkPanel.panel.hidePopup(); */ |
michael@0 | 537 | |
michael@0 | 538 | // All done! |
michael@0 | 539 | testDriver = null; |
michael@0 | 540 | executeSoon(finishTest); |
michael@0 | 541 | |
michael@0 | 542 | yield undefined; |
michael@0 | 543 | } |