diff options
Diffstat (limited to 'Source/WebKit/chromium/src/js/Tests.js')
-rw-r--r-- | Source/WebKit/chromium/src/js/Tests.js | 100 |
1 files changed, 99 insertions, 1 deletions
diff --git a/Source/WebKit/chromium/src/js/Tests.js b/Source/WebKit/chromium/src/js/Tests.js index 1d98656..220cf89 100644 --- a/Source/WebKit/chromium/src/js/Tests.js +++ b/Source/WebKit/chromium/src/js/Tests.js @@ -81,7 +81,6 @@ TestSuite.prototype.assertEquals = function(expected, actual, opt_message) } }; - /** * True assertion tests that value == true. * @param {Object} value Actual object. @@ -522,6 +521,105 @@ TestSuite.prototype.testPauseWhenScriptIsRunning = function() /** + * Tests network size. + */ +TestSuite.prototype.testNetworkSize = function() +{ + var test = this; + + function finishResource(resource, finishTime) + { + test.assertEquals(221, resource.transferSize, "Incorrect total encoded data length"); + test.assertEquals(25, resource.resourceSize, "Incorrect total data length"); + test.releaseControl(); + } + + this.addSniffer(WebInspector.NetworkDispatcher.prototype, "_finishResource", finishResource); + + // Reload inspected page to sniff network events + test.evaluateInConsole_("window.location.reload(true);", function(resultText) {}); + + this.takeControl(); +}; + + +/** + * Tests network sync size. + */ +TestSuite.prototype.testNetworkSyncSize = function() +{ + var test = this; + + function finishResource(resource, finishTime) + { + test.assertEquals(221, resource.transferSize, "Incorrect total encoded data length"); + test.assertEquals(25, resource.resourceSize, "Incorrect total data length"); + test.releaseControl(); + } + + this.addSniffer(WebInspector.NetworkDispatcher.prototype, "_finishResource", finishResource); + + // Send synchronous XHR to sniff network events + test.evaluateInConsole_("var xhr = new XMLHttpRequest(); xhr.open(\"GET\", \"chunked\", false); xhr.send(null);", function() {}); + + this.takeControl(); +}; + + +/** + * Tests network raw headers text. + */ +TestSuite.prototype.testNetworkRawHeadersText = function() +{ + var test = this; + + function finishResource(resource, finishTime) + { + var rawResponseHeadersText = resource.rawResponseHeadersText + if (!rawResponseHeadersText) + test.fail("Failure: resource does not have raw response header text"); + test.assertEquals(166, resource.rawResponseHeadersText.length, "Incorrect raw response header text length"); + test.releaseControl(); + } + + this.addSniffer(WebInspector.NetworkDispatcher.prototype, "_finishResource", finishResource); + + // Reload inspected page to sniff network events + test.evaluateInConsole_("window.location.reload(true);", function(resultText) {}); + + this.takeControl(); +}; + + +/** + * Tests network timing. + */ +TestSuite.prototype.testNetworkTiming = function() +{ + var test = this; + + function finishResource(resource, finishTime) + { + test.assertTrue(resource.timing.receiveHeadersEnd - resource.timing.connectStart >= 100, + "Time between receiveHeadersEnd and connectStart should be >=100ms, but was " + + "receiveHeadersEnd=" + resource.timing.receiveHeadersEnd + ", connectStart=" + resource.timing.connectStart + "."); + test.assertTrue(resource.endTime - resource.startTime >= 0.2, + "Time between endTime and startTime should be >=200ms, but was " + + "endtime=" + resource.endTime + ", startTime=" + resource.startTime + "."); + + test.releaseControl(); + } + + this.addSniffer(WebInspector.NetworkDispatcher.prototype, "_finishResource", finishResource); + + // Reload inspected page to sniff network events + test.evaluateInConsole_("window.location.reload(true);", function(resultText) {}); + + this.takeControl(); +}; + + +/** * Serializes options collection to string. * @param {HTMLOptionsCollection} options * @return {string} |