Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: webkit/glue/devtools/js/tests.js

Issue 295041: DevTools: report correct content length for resources (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 /** 6 /**
7 * @fileoverview This file contains small testing framework along with the 7 * @fileoverview This file contains small testing framework along with the
8 * test suite for the frontend. These tests are a part of the continues build 8 * test suite for the frontend. These tests are a part of the continues build
9 * and are executed by the devtools_sanity_unittest.cc as a part of the 9 * and are executed by the devtools_sanity_unittest.cc as a part of the
10 * Interactive UI Test suite. 10 * Interactive UI Test suite.
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Following call should lead to reload that we capture in the 239 // Following call should lead to reload that we capture in the
240 // addResource override. 240 // addResource override.
241 WebInspector.panels.resources._enableResourceTracking(); 241 WebInspector.panels.resources._enableResourceTracking();
242 242
243 // We now have some time to report results to controller. 243 // We now have some time to report results to controller.
244 this.takeControl(); 244 this.takeControl();
245 }; 245 };
246 246
247 247
248 /** 248 /**
249 * Tests that correct content length is reported for resources.
250 */
251 TestSuite.prototype.testResourceContentLength = function() {
252 this.showPanel('resources');
253 var test = this;
254
255 var png = false;
256 var html = false;
257 this.addSniffer(WebInspector, 'updateResource',
258 function(identifier, payload) {
259 if (!payload.didLengthChange)
260 return;
261 var resource = WebInspector.resources[identifier];
262 if (!resource || !resource.url)
263 return;
264 if (resource.url.search('image.html$') != -1) {
265 var expectedLength = 93;
266 test.assertTrue(
267 resource.contentLength <= expectedLength,
268 'image.html content length is greater thatn expected.');
269 if (expectedLength == resource.contentLength) {
270 html = true;
271 }
272 } else if (resource.url.search('image.png') != -1) {
273 var expectedLength = 257796;
274 test.assertTrue(
275 resource.contentLength <= expectedLength,
276 'image.png content length is greater than expected.');
277 if (expectedLength == resource.contentLength) {
278 png = true;
279 }
280 }
281 if (html && png) {
282 // Wait 1 second before releasing control to check that the content
283 // lengths are not updated anymore.
284 setTimeout(function() {
285 test.releaseControl();
286 }, 1000);
287 }
288 }, true);
289
290 // Make sure resource tracking is on.
291 WebInspector.panels.resources._enableResourceTracking();
292 // Reload inspected page to update all resources.
293 test.evaluateInConsole_(
294 'window.location.reload(true);',
295 function(resultText) {
296 test.assertEquals('undefined', resultText,
297 'Unexpected result of reload().');
298 });
299
300 // We now have some time to report results to controller.
301 this.takeControl();
302 };
303
304
305 /**
249 * Tests resource headers. 306 * Tests resource headers.
250 */ 307 */
251 TestSuite.prototype.testResourceHeaders = function() { 308 TestSuite.prototype.testResourceHeaders = function() {
252 this.showPanel('resources'); 309 this.showPanel('resources');
253 310
254 var test = this; 311 var test = this;
255 312
256 var requestOk = false; 313 var requestOk = false;
257 var responseOk = false; 314 var responseOk = false;
258 var timingOk = false; 315 var timingOk = false;
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 /** 1753 /**
1697 * Run specified test on a fresh instance of the test suite. 1754 * Run specified test on a fresh instance of the test suite.
1698 * @param {string} name Name of a test method from TestSuite class. 1755 * @param {string} name Name of a test method from TestSuite class.
1699 */ 1756 */
1700 uiTests.runTest = function(name) { 1757 uiTests.runTest = function(name) {
1701 new TestSuite().runTest(name); 1758 new TestSuite().runTest(name);
1702 }; 1759 };
1703 1760
1704 1761
1705 } 1762 }
OLDNEW
« no previous file with comments | « webkit/api/src/ResourceHandle.cpp ('k') | webkit/glue/ftp_directory_listing_response_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698