Chromium Code Reviews| Index: LayoutTests/inspector/agents-enable-disable.html |
| diff --git a/LayoutTests/inspector/agents-enable-disable.html b/LayoutTests/inspector/agents-enable-disable.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ca6e49d277723d57b8d5571bcc5ec3bf8973ddd6 |
| --- /dev/null |
| +++ b/LayoutTests/inspector/agents-enable-disable.html |
| @@ -0,0 +1,60 @@ |
| +<html> |
| +<head> |
| +<script src="../http/tests/inspector/inspector-test.js"></script> |
| +<script type="text/javascript"> |
| + |
| +var test = function() |
| +{ |
| + var requestsSent = 0; |
| + var responsesReceived = 0; |
| + |
| + InspectorTest.startDumpingProtocolMessages(); |
| + |
| + function finishWhenDone(agentName, action, errorString) |
| + { |
| + if (action === "enable") |
| + InspectorTest.addResult(""); |
| + if (errorString) |
| + InspectorTest.addResult(agentName + "." + action + " finished with error " + errorString); |
| + else |
| + InspectorTest.addResult(agentName + "." + action + " finished successfully"); |
| + |
| + ++responsesReceived; |
| + if (responsesReceived === requestsSent) |
| + InspectorTest.completeTest(); |
| + } |
| + |
| + var targets = WebInspector.targetManager.targets(); |
| + targets.forEach(function(target) { |
|
yurys
2014/10/15 14:12:37
style: { should go on the next line. Here and belo
|
| + var agentNames = Object.keys(target._agentsMap).filter(function(agentName) { |
| + var agent = target._agentsMap[agentName]; |
| + return agent["enable"] && agent["disable"]; |
| + }).sort(); |
| + |
| + function disableAgent(agentName) |
| + { |
| + ++requestsSent; |
| + target._agentsMap[agentName].disable(finishWhenDone.bind(null, agentName, "disable")); |
| + } |
| + |
| + function enableAgent(agentName) |
| + { |
| + ++requestsSent; |
| + target._agentsMap[agentName].enable(finishWhenDone.bind(null, agentName, "enable")); |
| + } |
| + |
| + agentNames.forEach(disableAgent); |
| + |
| + agentNames.forEach(function(agentName) { |
| + enableAgent(agentName); |
| + disableAgent(agentName); |
| + }); |
| + }); |
| +} |
| + |
| +</script> |
| +</head> |
| +<body onload="runTest()"> |
| +<p>Test that each agent could be enabled/disabled separately.</p> |
| +</body> |
| +</html> |