Index: third_party/WebKit/Source/devtools/front_end/Tests.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/Tests.js b/third_party/WebKit/Source/devtools/front_end/Tests.js |
index a8bfc3eadf8afea927e221972c71a440ec117243..268f62c932c955791f0e865e38a48117adb0d2ee 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/Tests.js |
+++ b/third_party/WebKit/Source/devtools/front_end/Tests.js |
@@ -717,6 +717,59 @@ TestSuite.prototype.testDeviceMetricsOverrides = function() |
step1(); |
}; |
+TestSuite.prototype.testEmulateNetworkConditions = function() |
+{ |
+ var test = this; |
+ |
+ function testPreset(preset, messages, next) |
+ { |
+ function onConsoleMessage(event) |
+ { |
+ var index = messages.indexOf(event.data.messageText); |
+ if (index === -1) { |
+ test.fail("Unexpected message: " + event.data.messageText); |
+ return; |
+ } |
+ |
+ messages.splice(index, 1); |
+ if (!messages.length) { |
+ WebInspector.multitargetConsoleModel.removeEventListener(WebInspector.ConsoleModel.Events.MessageAdded, onConsoleMessage, this); |
+ next(); |
+ } |
+ } |
+ |
+ WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, onConsoleMessage, this); |
+ WebInspector.multitargetNetworkManager.setNetworkConditions(preset); |
+ } |
+ |
+ test.takeControl(); |
+ step1(); |
+ |
+ function step1() |
+ { |
+ testPreset( |
+ WebInspector.NetworkConditionsSelector._presets[0], |
+ ["offline event: online = false", "connection change event: type = none; downlinkMax = 0"], |
+ step2); |
+ } |
+ |
+ function step2() |
+ { |
+ testPreset( |
+ WebInspector.NetworkConditionsSelector._presets[2], |
+ ["online event: online = true", "connection change event: type = cellular; downlinkMax = 0.244140625"], |
+ step3); |
+ } |
+ |
+ function step3() |
+ { |
+ testPreset( |
+ WebInspector.NetworkConditionsSelector._presets[8], |
+ ["connection change event: type = wifi; downlinkMax = 30"], |
+ test.releaseControl.bind(test)); |
+ } |
+}; |
+ |
TestSuite.prototype.testScreenshotRecording = function() |
{ |
var test = this; |