| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 | 710 |
| 711 function finish() | 711 function finish() |
| 712 { | 712 { |
| 713 test.releaseControl(); | 713 test.releaseControl(); |
| 714 } | 714 } |
| 715 | 715 |
| 716 test.takeControl(); | 716 test.takeControl(); |
| 717 step1(); | 717 step1(); |
| 718 }; | 718 }; |
| 719 | 719 |
| 720 TestSuite.prototype.testEmulateNetworkConditions = function() |
| 721 { |
| 722 var test = this; |
| 723 |
| 724 function testPreset(preset, messages, next) |
| 725 { |
| 726 function onConsoleMessage(event) |
| 727 { |
| 728 var index = messages.indexOf(event.data.messageText); |
| 729 if (index === -1) { |
| 730 test.fail("Unexpected message: " + event.data.messageText); |
| 731 return; |
| 732 } |
| 733 |
| 734 messages.splice(index, 1); |
| 735 if (!messages.length) { |
| 736 WebInspector.multitargetConsoleModel.removeEventListener(WebInsp
ector.ConsoleModel.Events.MessageAdded, onConsoleMessage, this); |
| 737 next(); |
| 738 } |
| 739 } |
| 740 |
| 741 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso
leModel.Events.MessageAdded, onConsoleMessage, this); |
| 742 WebInspector.multitargetNetworkManager.setNetworkConditions(preset); |
| 743 } |
| 744 |
| 745 test.takeControl(); |
| 746 step1(); |
| 747 |
| 748 function step1() |
| 749 { |
| 750 testPreset( |
| 751 WebInspector.NetworkConditionsSelector._presets[0], |
| 752 ["offline event: online = false", "connection change event: type = n
one; downlinkMax = 0"], |
| 753 step2); |
| 754 } |
| 755 |
| 756 function step2() |
| 757 { |
| 758 testPreset( |
| 759 WebInspector.NetworkConditionsSelector._presets[2], |
| 760 ["online event: online = true", "connection change event: type = cel
lular; downlinkMax = 0.244140625"], |
| 761 step3); |
| 762 } |
| 763 |
| 764 function step3() |
| 765 { |
| 766 testPreset( |
| 767 WebInspector.NetworkConditionsSelector._presets[8], |
| 768 ["online event: online = true", "connection change event: type = wif
i; downlinkMax = 30"], |
| 769 test.releaseControl.bind(test)); |
| 770 } |
| 771 }; |
| 772 |
| 720 TestSuite.prototype.testScreenshotRecording = function() | 773 TestSuite.prototype.testScreenshotRecording = function() |
| 721 { | 774 { |
| 722 var test = this; | 775 var test = this; |
| 723 | 776 |
| 724 function performActionsInPage(callback) | 777 function performActionsInPage(callback) |
| 725 { | 778 { |
| 726 var count = 0; | 779 var count = 0; |
| 727 var div = document.createElement("div"); | 780 var div = document.createElement("div"); |
| 728 div.setAttribute("style", "left: 0px; top: 0px; width: 100px; height: 10
0px; position: absolute;"); | 781 div.setAttribute("style", "left: 0px; top: 0px; width: 100px; height: 10
0px; position: absolute;"); |
| 729 document.body.appendChild(div); | 782 document.body.appendChild(div); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 */ | 1158 */ |
| 1106 TestSuite.createKeyEvent = function(keyIdentifier) | 1159 TestSuite.createKeyEvent = function(keyIdentifier) |
| 1107 { | 1160 { |
| 1108 var evt = document.createEvent("KeyboardEvent"); | 1161 var evt = document.createEvent("KeyboardEvent"); |
| 1109 evt.initKeyboardEvent("keydown", true /* can bubble */, true /* can cancel *
/, null /* view */, keyIdentifier, ""); | 1162 evt.initKeyboardEvent("keydown", true /* can bubble */, true /* can cancel *
/, null /* view */, keyIdentifier, ""); |
| 1110 return evt; | 1163 return evt; |
| 1111 }; | 1164 }; |
| 1112 | 1165 |
| 1113 window.uiTests = new TestSuite(window.domAutomationController); | 1166 window.uiTests = new TestSuite(window.domAutomationController); |
| 1114 })(window); | 1167 })(window); |
| OLD | NEW |