Commit 091c8281 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

2010-02-25 Pavel Feldman <pfeldman@chromium.org>

        Reviewed by Dimitri Glazkov.

        Web Inspector: make script lines count calculation lazy.

        https://bugs.webkit.org/show_bug.cgi?id=35392

        * inspector/front-end/Script.js:
        (WebInspector.Script):
        (WebInspector.Script.prototype.get linesCount):
        * inspector/front-end/ScriptsPanel.js:
        * inspector/front-end/SourceView.js:
        (WebInspector.SourceView.prototype._addBreakpoint):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55241 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8a929be4
2010-02-25 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Dimitri Glazkov.
Web Inspector: make script lines count calculation lazy.
https://bugs.webkit.org/show_bug.cgi?id=35392
* inspector/front-end/Script.js:
(WebInspector.Script):
(WebInspector.Script.prototype.get linesCount):
* inspector/front-end/ScriptsPanel.js:
* inspector/front-end/SourceView.js:
(WebInspector.SourceView.prototype._addBreakpoint):
2010-02-25 James Choi <jchoi42@pha.jhu.edu>
Reviewed by David Levin.
......
......@@ -32,13 +32,6 @@ WebInspector.Script = function(sourceID, sourceURL, source, startingLine, errorL
this.errorLine = errorLine;
this.errorMessage = errorMessage;
this.linesCount = 0;
var lastIndex = source.indexOf("\n");
while (lastIndex !== -1) {
lastIndex = source.indexOf("\n", lastIndex + 1)
this.linesCount++;
}
// if no URL, look for "//@ sourceURL=" decorator
// note that this sourceURL comment decorator is behavior that FireBug added
// in it's 1.1 release as noted in the release notes:
......@@ -54,4 +47,15 @@ WebInspector.Script = function(sourceID, sourceURL, source, startingLine, errorL
}
WebInspector.Script.prototype = {
get linesCount()
{
if (!this.source)
return 0;
this._linesCount = 0;
var lastIndex = this.source.indexOf("\n");
while (lastIndex !== -1) {
lastIndex = this.source.indexOf("\n", lastIndex + 1)
this._linesCount++;
}
}
}
......@@ -677,7 +677,7 @@ WebInspector.ScriptsPanel.prototype = {
option.representedObject = script.resource || script;
option.url = displayName;
option.startingLine = script.startingLine;
option.text = script.resource ? displayName : String.sprintf("%s (%d - %d)", displayName, script.startingLine, script.startingLine + script.linesCount);
option.text = script.resource ? displayName : String.sprintf("%s:%d", displayName, script.startingLine);
function optionCompare(a, b)
{
......
......@@ -92,12 +92,13 @@ WebInspector.SourceView.prototype = {
_addBreakpoint: function(line)
{
var sourceID = null;
var closestStartingLine = 0;
var scripts = this.resource.scripts;
for (var i = 0; i < scripts.length; ++i) {
var script = scripts[i];
if (script.startingLine <= line && script.startingLine + script.linesCount > line) {
if (script.startingLine <= line && script.startingLine >= closestStartingLine) {
closestStartingLine = script.startingLine;
sourceID = script.sourceID;
break;
}
}
......
2010-02-25 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Dimitri Glazkov.
Web Inspector: make script lines count calculation lazy.
https://bugs.webkit.org/show_bug.cgi?id=35392
* src/js/Tests.js:
(.TestSuite.prototype.testScriptsTabIsPopulatedOnInspectedPageRefresh.waitUntilScriptIsParsed):
(.TestSuite.prototype.testScriptsTabIsPopulatedOnInspectedPageRefresh.checkScriptsPanel):
(.TestSuite.prototype.testScriptsTabIsPopulatedOnInspectedPageRefresh):
(.TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch.checkScriptsPanel):
(.TestSuite.prototype.testAutoContinueOnSyntaxError.checkScriptsList):
(.TestSuite.prototype._executeFunctionForStepTest):
2010-02-24 Darin Fisher <darin@chromium.org>
Reviewed by David Levin.
......
......@@ -295,7 +295,7 @@ TestSuite.prototype.testResourceContentLength = function()
var resource = WebInspector.resources[identifier];
if (!resource || !resource.url)
return;
if (resource.url.search("image.html$") !== -1) {
if (resource.url.search("image.html") !== -1) {
var expectedLength = 87;
test.assertTrue(
resource.contentLength <= expectedLength,
......@@ -470,7 +470,7 @@ TestSuite.prototype.testShowScriptsTab = function()
this.showPanel("scripts");
var test = this;
// There should be at least main page script.
this._waitUntilScriptsAreParsed(["debugger_test_page.html$"],
this._waitUntilScriptsAreParsed(["debugger_test_page.html"],
function() {
test.releaseControl();
});
......@@ -502,7 +502,7 @@ TestSuite.prototype.testScriptsTabIsPopulatedOnInspectedPageRefresh = function()
var parsed = devtools.tools.getDebuggerAgent().parsedScripts_;
for (var id in parsed) {
var url = parsed[id].getUrl();
if (url && url.search("debugger_test_page.html$") !== -1) {
if (url && url.search("debugger_test_page.html") !== -1) {
checkScriptsPanel();
return;
}
......@@ -512,7 +512,7 @@ TestSuite.prototype.testScriptsTabIsPopulatedOnInspectedPageRefresh = function()
function checkScriptsPanel() {
test.showPanel("scripts");
test.assertTrue(test._scriptsAreParsed(["debugger_test_page.html$"]), "Inspected script not found in the scripts list");
test.assertTrue(test._scriptsAreParsed(["debugger_test_page.html"]), "Inspected script not found in the scripts list");
test.releaseControl();
}
......@@ -530,7 +530,7 @@ TestSuite.prototype.testContentScriptIsPresent = function()
var test = this;
test._waitUntilScriptsAreParsed(
["page_with_content_script.html$", "simple_content_script.js$"],
["page_with_content_script.html", "simple_content_script.js"],
function() {
test.releaseControl();
});
......@@ -568,7 +568,7 @@ TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch = function()
function checkScriptsPanel() {
test.assertTrue(!!WebInspector.panels.scripts.visibleView, "No visible script view.");
test.assertTrue(test._scriptsAreParsed(["debugger_test_page.html$"]), "Some scripts are missing.");
test.assertTrue(test._scriptsAreParsed(["debugger_test_page.html"]), "Some scripts are missing.");
checkNoDuplicates();
test.releaseControl();
}
......@@ -584,7 +584,7 @@ TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch = function()
}
test._waitUntilScriptsAreParsed(
["debugger_test_page.html$"],
["debugger_test_page.html"],
function() {
checkNoDuplicates();
setTimeout(switchToElementsTab, 0);
......@@ -643,7 +643,7 @@ TestSuite.prototype.testPauseOnException = function()
WebInspector.currentPanel.pauseOnExceptionButton.element.click();
}
this._executeCodeWhenScriptsAreParsed("handleClick()", ["pause_on_exception.html$"]);
this._executeCodeWhenScriptsAreParsed("handleClick()", ["pause_on_exception.html"]);
this._waitForScriptPause(
{
......@@ -913,7 +913,7 @@ TestSuite.prototype.testCompletionOnPause = function()
{
this.showPanel("scripts");
var test = this;
this._executeCodeWhenScriptsAreParsed("handleClick()", ["completion_on_pause.html$"]);
this._executeCodeWhenScriptsAreParsed("handleClick()", ["completion_on_pause.html"]);
this._waitForScriptPause(
{
......@@ -974,7 +974,7 @@ TestSuite.prototype.testAutoContinueOnSyntaxError = function()
// InjectedScript._ensureCommandLineAPIInstalled) since the page script
// contains a syntax error.
for (var i = 0 ; i < options.length; i++) {
if (options[i].text.search("script_syntax_error.html$") !== -1)
if (options[i].text.search("script_syntax_error.html") !== -1)
test.fail("Script with syntax error should not be in the list of parsed scripts.");
}
}
......@@ -1173,7 +1173,7 @@ TestSuite.prototype._waitUntilScriptsAreParsed = function(expectedScripts, callb
*/
TestSuite.prototype._executeFunctionForStepTest = function()
{
this._executeCodeWhenScriptsAreParsed("a()", ["debugger_step.html$", "debugger_step.js$"]);
this._executeCodeWhenScriptsAreParsed("a()", ["debugger_step.html", "debugger_step.js"]);
};
......@@ -1437,7 +1437,7 @@ TestSuite.prototype.testExpandScope = function()
this.showPanel("scripts");
var test = this;
this._executeCodeWhenScriptsAreParsed("handleClick()", ["debugger_closure.html$"]);
this._executeCodeWhenScriptsAreParsed("handleClick()", ["debugger_closure.html"]);
this._waitForScriptPause(
{
......@@ -1551,7 +1551,7 @@ TestSuite.prototype.testDebugIntrinsicProperties = function()
this.showPanel("scripts");
var test = this;
this._executeCodeWhenScriptsAreParsed("handleClick()", ["debugger_intrinsic_properties.html$"]);
this._executeCodeWhenScriptsAreParsed("handleClick()", ["debugger_intrinsic_properties.html"]);
this._waitForScriptPause(
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment