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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/Tests.js

Issue 2087293003: [DevTools] Network.emulateNetworkConditions now affects NetworkStateNotifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dcheck Created 4 years, 5 months 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
OLDNEW
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
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 ["connection change event: type = wifi; 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 /** 1156 /**
1104 * Key event with given key identifier. 1157 * Key event with given key identifier.
1105 */ 1158 */
1106 TestSuite.createKeyEvent = function(key) 1159 TestSuite.createKeyEvent = function(key)
1107 { 1160 {
1108 return new KeyboardEvent("keydown", {bubbles: true, cancelable:true, key: ke y}); 1161 return new KeyboardEvent("keydown", {bubbles: true, cancelable:true, key: ke y});
1109 }; 1162 };
1110 1163
1111 window.uiTests = new TestSuite(window.domAutomationController); 1164 window.uiTests = new TestSuite(window.domAutomationController);
1112 })(window); 1165 })(window);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698