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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 /* | 765 /* |
766 * Evaluates the code in the console as if user typed it manually and invokes | 766 * Evaluates the code in the console as if user typed it manually and invokes |
767 * the callback when the result message is received and added to the console. | 767 * the callback when the result message is received and added to the console. |
768 * @param {string} code | 768 * @param {string} code |
769 * @param {function(string)} callback | 769 * @param {function(string)} callback |
770 */ | 770 */ |
771 TestSuite.prototype.evaluateInConsole_ = function(code, callback) | 771 TestSuite.prototype.evaluateInConsole_ = function(code, callback) |
772 { | 772 { |
773 function innerEvaluate() | 773 function innerEvaluate() |
774 { | 774 { |
| 775 WebInspector.context.removeFlavorChangeListener(WebInspector.ExecutionCo
ntext, showConsoleAndEvaluate, this); |
775 var consoleView = WebInspector.ConsolePanel._view(); | 776 var consoleView = WebInspector.ConsolePanel._view(); |
776 consoleView._prompt.text = code; | 777 consoleView._prompt.text = code; |
777 consoleView._promptElement.dispatchEvent(TestSuite.createKeyEvent("Enter
")); | 778 consoleView._promptElement.dispatchEvent(TestSuite.createKeyEvent("Enter
")); |
778 | 779 |
779 this.addSniffer(WebInspector.ConsoleView.prototype, "_consoleMessageAdde
dForTest", | 780 this.addSniffer(WebInspector.ConsoleView.prototype, "_consoleMessageAdde
dForTest", |
780 function(viewMessage) { | 781 function(viewMessage) { |
781 callback(viewMessage.toMessageElement().textContent); | 782 callback(viewMessage.toMessageElement().textContent); |
782 }.bind(this)); | 783 }.bind(this)); |
783 } | 784 } |
784 | 785 |
| 786 function showConsoleAndEvaluate() |
| 787 { |
| 788 WebInspector.console.showPromise().then(innerEvaluate.bind(this)); |
| 789 } |
| 790 |
785 if (!WebInspector.context.flavor(WebInspector.ExecutionContext)) { | 791 if (!WebInspector.context.flavor(WebInspector.ExecutionContext)) { |
786 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionConte
xt, innerEvaluate, this); | 792 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionConte
xt, showConsoleAndEvaluate, this); |
787 return; | 793 return; |
788 } | 794 } |
789 | 795 showConsoleAndEvaluate.call(this); |
790 WebInspector.console.showPromise().then(innerEvaluate.bind(this)); | |
791 }; | 796 }; |
792 | 797 |
793 /** | 798 /** |
794 * Checks that all expected scripts are present in the scripts list | 799 * Checks that all expected scripts are present in the scripts list |
795 * in the Scripts panel. | 800 * in the Scripts panel. |
796 * @param {!Array.<string>} expected Regular expressions describing | 801 * @param {!Array.<string>} expected Regular expressions describing |
797 * expected script names. | 802 * expected script names. |
798 * @return {boolean} Whether all the scripts are in "scripts-files" select | 803 * @return {boolean} Whether all the scripts are in "scripts-files" select |
799 * box | 804 * box |
800 */ | 805 */ |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 delete uiTests._pendingTestName; | 925 delete uiTests._pendingTestName; |
921 if (name) | 926 if (name) |
922 new TestSuite().runTest(name); | 927 new TestSuite().runTest(name); |
923 } | 928 } |
924 | 929 |
925 WebInspector.notifications.addEventListener(WebInspector.NotificationService.Eve
nts.InspectorAgentEnabledForTests, runTests); | 930 WebInspector.notifications.addEventListener(WebInspector.NotificationService.Eve
nts.InspectorAgentEnabledForTests, runTests); |
926 | 931 |
927 })(); | 932 })(); |
928 | 933 |
929 } | 934 } |
OLD | NEW |