| 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 490 |
| 491 // Reload inspected page to sniff network events | 491 // Reload inspected page to sniff network events |
| 492 test.evaluateInConsole_("window.location.reload(true);", function(resultText
) {}); | 492 test.evaluateInConsole_("window.location.reload(true);", function(resultText
) {}); |
| 493 | 493 |
| 494 this.takeControl(); | 494 this.takeControl(); |
| 495 }; | 495 }; |
| 496 | 496 |
| 497 | 497 |
| 498 TestSuite.prototype.testConsoleOnNavigateBack = function() | 498 TestSuite.prototype.testConsoleOnNavigateBack = function() |
| 499 { | 499 { |
| 500 if (WebInspector.consoleModel.messages.length === 1) | 500 if (WebInspector.multitargetConsoleModel.messages().length === 1) |
| 501 firstConsoleMessageReceived.call(this); | 501 firstConsoleMessageReceived.call(this); |
| 502 else | 502 else |
| 503 WebInspector.consoleModel.addEventListener(WebInspector.ConsoleModel.Eve
nts.MessageAdded, firstConsoleMessageReceived, this); | 503 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso
leModel.Events.MessageAdded, firstConsoleMessageReceived, this); |
| 504 | 504 |
| 505 function firstConsoleMessageReceived() { | 505 function firstConsoleMessageReceived() { |
| 506 WebInspector.consoleModel.removeEventListener(WebInspector.ConsoleModel.
Events.MessageAdded, firstConsoleMessageReceived, this); | 506 WebInspector.multitargetConsoleModel.removeEventListener(WebInspector.Co
nsoleModel.Events.MessageAdded, firstConsoleMessageReceived, this); |
| 507 this.evaluateInConsole_("clickLink();", didClickLink.bind(this)); | 507 this.evaluateInConsole_("clickLink();", didClickLink.bind(this)); |
| 508 } | 508 } |
| 509 | 509 |
| 510 function didClickLink() { | 510 function didClickLink() { |
| 511 // Check that there are no new messages(command is not a message). | 511 // Check that there are no new messages(command is not a message). |
| 512 this.assertEquals(3, WebInspector.consoleModel.messages.length); | 512 this.assertEquals(3, WebInspector.multitargetConsoleModel.messages().len
gth); |
| 513 this.evaluateInConsole_("history.back();", didNavigateBack.bind(this)); | 513 this.evaluateInConsole_("history.back();", didNavigateBack.bind(this)); |
| 514 } | 514 } |
| 515 | 515 |
| 516 function didNavigateBack() | 516 function didNavigateBack() |
| 517 { | 517 { |
| 518 // Make sure navigation completed and possible console messages were pus
hed. | 518 // Make sure navigation completed and possible console messages were pus
hed. |
| 519 this.evaluateInConsole_("void 0;", didCompleteNavigation.bind(this)); | 519 this.evaluateInConsole_("void 0;", didCompleteNavigation.bind(this)); |
| 520 } | 520 } |
| 521 | 521 |
| 522 function didCompleteNavigation() { | 522 function didCompleteNavigation() { |
| 523 this.assertEquals(7, WebInspector.consoleModel.messages.length); | 523 this.assertEquals(7, WebInspector.multitargetConsoleModel.messages().len
gth); |
| 524 this.releaseControl(); | 524 this.releaseControl(); |
| 525 } | 525 } |
| 526 | 526 |
| 527 this.takeControl(); | 527 this.takeControl(); |
| 528 }; | 528 }; |
| 529 | 529 |
| 530 TestSuite.prototype.testReattachAfterCrash = function() | 530 TestSuite.prototype.testReattachAfterCrash = function() |
| 531 { | 531 { |
| 532 PageAgent.navigate("about:crash"); | 532 PageAgent.navigate("about:crash"); |
| 533 PageAgent.navigate("about:blank"); | 533 PageAgent.navigate("about:blank"); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 test.assertTrue(frameCount >= 5, "Not enough frames"); | 590 test.assertTrue(frameCount >= 5, "Not enough frames"); |
| 591 test.releaseControl(); | 591 test.releaseControl(); |
| 592 } | 592 } |
| 593 | 593 |
| 594 step1(); | 594 step1(); |
| 595 test.takeControl(); | 595 test.takeControl(); |
| 596 } | 596 } |
| 597 | 597 |
| 598 TestSuite.prototype.enableTouchEmulation = function() | 598 TestSuite.prototype.enableTouchEmulation = function() |
| 599 { | 599 { |
| 600 WebInspector.targetManager.activeTarget().domModel.emulateTouchEventObjects(
true); | 600 WebInspector.targetManager.mainTarget().domModel.emulateTouchEventObjects(tr
ue); |
| 601 }; | 601 }; |
| 602 | 602 |
| 603 // Regression test for http://webk.it/97466 | 603 // Regression test for http://webk.it/97466 |
| 604 TestSuite.prototype.testPageOverlayUpdate = function() | 604 TestSuite.prototype.testPageOverlayUpdate = function() |
| 605 { | 605 { |
| 606 var test = this; | 606 var test = this; |
| 607 WebInspector.inspectorView.panel("elements"); | 607 WebInspector.inspectorView.panel("elements"); |
| 608 | 608 |
| 609 function populatePage() | 609 function populatePage() |
| 610 { | 610 { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 } | 758 } |
| 759 | 759 |
| 760 | 760 |
| 761 TestSuite.prototype.stopTimeline = function() | 761 TestSuite.prototype.stopTimeline = function() |
| 762 { | 762 { |
| 763 this.evaluateInConsole_("console.timeStamp('ready')", function() {}); | 763 this.evaluateInConsole_("console.timeStamp('ready')", function() {}); |
| 764 } | 764 } |
| 765 | 765 |
| 766 TestSuite.prototype.waitForTestResultsInConsole = function() | 766 TestSuite.prototype.waitForTestResultsInConsole = function() |
| 767 { | 767 { |
| 768 var messages = WebInspector.consoleModel.messages; | 768 var messages = WebInspector.multitargetConsoleModel.messages(); |
| 769 for (var i = 0; i < messages.length; ++i) { | 769 for (var i = 0; i < messages.length; ++i) { |
| 770 var text = messages[i].messageText; | 770 var text = messages[i].messageText; |
| 771 if (text === "PASS") | 771 if (text === "PASS") |
| 772 return; | 772 return; |
| 773 else if (/^FAIL/.test(text)) | 773 else if (/^FAIL/.test(text)) |
| 774 this.fail(text); // This will throw. | 774 this.fail(text); // This will throw. |
| 775 } | 775 } |
| 776 // Neither PASS nor FAIL, so wait for more messages. | 776 // Neither PASS nor FAIL, so wait for more messages. |
| 777 function onConsoleMessage(event) | 777 function onConsoleMessage(event) |
| 778 { | 778 { |
| 779 var text = event.data.messageText; | 779 var text = event.data.messageText; |
| 780 if (text === "PASS") | 780 if (text === "PASS") |
| 781 this.releaseControl(); | 781 this.releaseControl(); |
| 782 else if (/^FAIL/.test(text)) | 782 else if (/^FAIL/.test(text)) |
| 783 this.fail(text); | 783 this.fail(text); |
| 784 } | 784 } |
| 785 | 785 |
| 786 WebInspector.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.
MessageAdded, onConsoleMessage, this); | 786 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo
del.Events.MessageAdded, onConsoleMessage, this); |
| 787 this.takeControl(); | 787 this.takeControl(); |
| 788 }; | 788 }; |
| 789 | 789 |
| 790 TestSuite.prototype.checkLogAndErrorMessages = function() | 790 TestSuite.prototype.checkLogAndErrorMessages = function() |
| 791 { | 791 { |
| 792 var messages = WebInspector.consoleModel.messages; | 792 var messages = WebInspector.multitargetConsoleModel.messages(); |
| 793 | 793 |
| 794 var matchesCount = 0; | 794 var matchesCount = 0; |
| 795 function validMessage(message) | 795 function validMessage(message) |
| 796 { | 796 { |
| 797 if (message.text === "log" && message.level === WebInspector.ConsoleMess
age.MessageLevel.Log) { | 797 if (message.text === "log" && message.level === WebInspector.ConsoleMess
age.MessageLevel.Log) { |
| 798 ++matchesCount; | 798 ++matchesCount; |
| 799 return true; | 799 return true; |
| 800 } | 800 } |
| 801 | 801 |
| 802 if (message.text === "error" && message.level === WebInspector.ConsoleMe
ssage.MessageLevel.Error) { | 802 if (message.text === "error" && message.level === WebInspector.ConsoleMe
ssage.MessageLevel.Error) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 821 var message = event.data; | 821 var message = event.data; |
| 822 if (validMessage(message)) { | 822 if (validMessage(message)) { |
| 823 if (matchesCount === 2) { | 823 if (matchesCount === 2) { |
| 824 this.releaseControl(); | 824 this.releaseControl(); |
| 825 return; | 825 return; |
| 826 } | 826 } |
| 827 } else | 827 } else |
| 828 this.fail(message.text + ":" + messages[i].level); | 828 this.fail(message.text + ":" + messages[i].level); |
| 829 } | 829 } |
| 830 | 830 |
| 831 WebInspector.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.
MessageAdded, onConsoleMessage, this); | 831 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo
del.Events.MessageAdded, onConsoleMessage, this); |
| 832 this.takeControl(); | 832 this.takeControl(); |
| 833 }; | 833 }; |
| 834 | 834 |
| 835 /** | 835 /** |
| 836 * Serializes array of uiSourceCodes to string. | 836 * Serializes array of uiSourceCodes to string. |
| 837 * @param {!Array.<!WebInspectorUISourceCode>} uiSourceCodes | 837 * @param {!Array.<!WebInspectorUISourceCode>} uiSourceCodes |
| 838 * @return {string} | 838 * @return {string} |
| 839 */ | 839 */ |
| 840 TestSuite.prototype.uiSourceCodesToString_ = function(uiSourceCodes) | 840 TestSuite.prototype.uiSourceCodesToString_ = function(uiSourceCodes) |
| 841 { | 841 { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 871 /* | 871 /* |
| 872 * Evaluates the code in the console as if user typed it manually and invokes | 872 * Evaluates the code in the console as if user typed it manually and invokes |
| 873 * the callback when the result message is received and added to the console. | 873 * the callback when the result message is received and added to the console. |
| 874 * @param {string} code | 874 * @param {string} code |
| 875 * @param {function(string)} callback | 875 * @param {function(string)} callback |
| 876 */ | 876 */ |
| 877 TestSuite.prototype.evaluateInConsole_ = function(code, callback) | 877 TestSuite.prototype.evaluateInConsole_ = function(code, callback) |
| 878 { | 878 { |
| 879 function innerEvaluate() | 879 function innerEvaluate() |
| 880 { | 880 { |
| 881 WebInspector.consoleModel.show(); | 881 WebInspector.console.show(); |
| 882 var consoleView = WebInspector.ConsolePanel._view(); | 882 var consoleView = WebInspector.ConsolePanel._view(); |
| 883 consoleView._prompt.text = code; | 883 consoleView._prompt.text = code; |
| 884 consoleView._promptElement.dispatchEvent(TestSuite.createKeyEvent("Enter
")); | 884 consoleView._promptElement.dispatchEvent(TestSuite.createKeyEvent("Enter
")); |
| 885 | 885 |
| 886 this.addSniffer(WebInspector.ConsoleView.prototype, "_showConsoleMessage
", | 886 this.addSniffer(WebInspector.ConsoleView.prototype, "_showConsoleMessage
", |
| 887 function(viewMessage) { | 887 function(viewMessage) { |
| 888 callback(viewMessage.toMessageElement().textContent); | 888 callback(viewMessage.toMessageElement().textContent); |
| 889 }.bind(this)); | 889 }.bind(this)); |
| 890 } | 890 } |
| 891 | 891 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 var oldLoadCompleted = InspectorFrontendAPI.loadCompleted; | 1032 var oldLoadCompleted = InspectorFrontendAPI.loadCompleted; |
| 1033 InspectorFrontendAPI.loadCompleted = function() | 1033 InspectorFrontendAPI.loadCompleted = function() |
| 1034 { | 1034 { |
| 1035 oldLoadCompleted.call(InspectorFrontendAPI); | 1035 oldLoadCompleted.call(InspectorFrontendAPI); |
| 1036 runTests(); | 1036 runTests(); |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 })(); | 1039 })(); |
| 1040 | 1040 |
| 1041 } | 1041 } |
| OLD | NEW |