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

Side by Side Diff: webkit/glue/devtools/js/tests.js

Issue 295020: DevTools: test that content scripts are visible in the debugger scripts list (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/devtools/extensions/simple_content_script/simple_content_script.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 /** 6 /**
7 * @fileoverview This file contains small testing framework along with the 7 * @fileoverview This file contains small testing framework along with the
8 * test suite for the frontend. These tests are a part of the continues build 8 * test suite for the frontend. These tests are a part of the continues build
9 * and are executed by the devtools_sanity_unittest.cc as a part of the 9 * and are executed by the devtools_sanity_unittest.cc as a part of the
10 * Interactive UI Test suite. 10 * Interactive UI Test suite.
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 }, true /* sticky */); 387 }, true /* sticky */);
388 388
389 this.showPanel('scripts'); 389 this.showPanel('scripts');
390 390
391 // Wait until all scripts are added to the debugger. 391 // Wait until all scripts are added to the debugger.
392 this.takeControl(); 392 this.takeControl();
393 }; 393 };
394 394
395 395
396 /** 396 /**
397 * Tests that scripts list contains content scripts.
398 */
399 TestSuite.prototype.testContentScriptIsPresent = function() {
400 this.showPanel('scripts');
401 var test = this;
402
403 test._waitUntilScriptsAreParsed(
404 ['page_with_content_script.html$', 'simple_content_script.js$'],
405 function() {
406 test.releaseControl();
407 });
408
409 // Wait until all scripts are added to the debugger.
410 this.takeControl();
411 };
412
413
414 /**
397 * Tests that scripts are not duplicaed on Scripts tab switch. 415 * Tests that scripts are not duplicaed on Scripts tab switch.
398 */ 416 */
399 TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch = function() { 417 TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch = function() {
400 var test = this; 418 var test = this;
401 419
402 // There should be two scripts: one for the main page and another 420 // There should be two scripts: one for the main page and another
403 // one which is source of console API(see 421 // one which is source of console API(see
404 // InjectedScript._ensureCommandLineAPIInstalled). 422 // InjectedScript._ensureCommandLineAPIInstalled).
405 var expectedScriptsCount = 2; 423 var expectedScriptsCount = 2;
406 var parsedScripts = []; 424 var parsedScripts = [];
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 931
914 932
915 /** 933 /**
916 * Waits until all the scripts are parsed and asynchronously executes the code 934 * Waits until all the scripts are parsed and asynchronously executes the code
917 * in the inspected page. 935 * in the inspected page.
918 */ 936 */
919 TestSuite.prototype._executeCodeWhenScriptsAreParsed = function( 937 TestSuite.prototype._executeCodeWhenScriptsAreParsed = function(
920 code, expectedScripts) { 938 code, expectedScripts) {
921 var test = this; 939 var test = this;
922 940
923 function waitForAllScripts() {
924 if (test._scriptsAreParsed(expectedScripts)) {
925 executeFunctionInInspectedPage();
926 } else {
927 test.addSniffer(WebInspector, 'parsedScriptSource', waitForAllScripts);
928 }
929 }
930
931 function executeFunctionInInspectedPage() { 941 function executeFunctionInInspectedPage() {
932 // Since breakpoints are ignored in evals' calculate() function is 942 // Since breakpoints are ignored in evals' calculate() function is
933 // execute after zero-timeout so that the breakpoint is hit. 943 // execute after zero-timeout so that the breakpoint is hit.
934 test.evaluateInConsole_( 944 test.evaluateInConsole_(
935 'setTimeout("' + code + '" , 0)', 945 'setTimeout("' + code + '" , 0)',
936 function(resultText) { 946 function(resultText) {
937 test.assertTrue(!isNaN(resultText), 947 test.assertTrue(!isNaN(resultText),
938 'Failed to get timer id: ' + resultText); 948 'Failed to get timer id: ' + resultText);
939 }); 949 });
940 } 950 }
941 951
952 test._waitUntilScriptsAreParsed(
953 expectedScripts, executeFunctionInInspectedPage);
954 };
955
956
957 /**
958 * Waits until all the scripts are parsed and invokes the callback.
959 */
960 TestSuite.prototype._waitUntilScriptsAreParsed = function(
961 expectedScripts, callback) {
962 var test = this;
963
964 function waitForAllScripts() {
965 if (test._scriptsAreParsed(expectedScripts)) {
966 callback();
967 } else {
968 test.addSniffer(WebInspector, 'parsedScriptSource', waitForAllScripts);
969 }
970 }
971
942 waitForAllScripts(); 972 waitForAllScripts();
943 }; 973 };
944 974
945 975
946 /** 976 /**
947 * Waits until all debugger scripts are parsed and executes 'a()' in the 977 * Waits until all debugger scripts are parsed and executes 'a()' in the
948 * inspected page. 978 * inspected page.
949 */ 979 */
950 TestSuite.prototype._executeFunctionForStepTest = function() { 980 TestSuite.prototype._executeFunctionForStepTest = function() {
951 this._executeCodeWhenScriptsAreParsed( 981 this._executeCodeWhenScriptsAreParsed(
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 /** 1648 /**
1619 * Run specified test on a fresh instance of the test suite. 1649 * Run specified test on a fresh instance of the test suite.
1620 * @param {string} name Name of a test method from TestSuite class. 1650 * @param {string} name Name of a test method from TestSuite class.
1621 */ 1651 */
1622 uiTests.runTest = function(name) { 1652 uiTests.runTest = function(name) {
1623 new TestSuite().runTest(name); 1653 new TestSuite().runTest(name);
1624 }; 1654 };
1625 1655
1626 1656
1627 } 1657 }
OLDNEW
« no previous file with comments | « chrome/test/data/devtools/extensions/simple_content_script/simple_content_script.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698