- Revision
- 92105
- Author
- [email protected]
- Date
- 2011-08-01 01:17:05 -0700 (Mon, 01 Aug 2011)
Log Message
Web Inspector: group scripts by folder in the scripts selector.
https://bugs.webkit.org/show_bug.cgi?id=65321
Reviewed by Yury Semikhatsky.
Source/WebCore:
Test: inspector/debugger/scripts-sorting.html
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._sourceFileAdded.get if):
(WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect.insertOrdered.optionCompare):
(WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect.insertOrdered):
(WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect):
(WebInspector.ScriptsPanel.prototype._folderAndDisplayNameForScriptURL):
(WebInspector.ScriptsPanel.prototype.reset):
(WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName):
LayoutTests:
* http/tests/inspector/debugger-test.js:
(initialize_DebuggerTest):
* inspector/debugger/scripts-sorting-expected.txt: Added.
* inspector/debugger/scripts-sorting.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (92104 => 92105)
--- trunk/LayoutTests/ChangeLog 2011-08-01 08:13:55 UTC (rev 92104)
+++ trunk/LayoutTests/ChangeLog 2011-08-01 08:17:05 UTC (rev 92105)
@@ -1,3 +1,15 @@
+2011-08-01 Pavel Feldman <[email protected]>
+
+ Web Inspector: group scripts by folder in the scripts selector.
+ https://bugs.webkit.org/show_bug.cgi?id=65321
+
+ Reviewed by Yury Semikhatsky.
+
+ * http/tests/inspector/debugger-test.js:
+ (initialize_DebuggerTest):
+ * inspector/debugger/scripts-sorting-expected.txt: Added.
+ * inspector/debugger/scripts-sorting.html: Added.
+
2011-07-28 Pavel Feldman <[email protected]>
Web Inspector: [protocol] methods where all parameters are optional should not require empty params object.
Modified: trunk/LayoutTests/http/tests/inspector/debugger-test.js (92104 => 92105)
--- trunk/LayoutTests/http/tests/inspector/debugger-test.js 2011-08-01 08:13:55 UTC (rev 92104)
+++ trunk/LayoutTests/http/tests/inspector/debugger-test.js 2011-08-01 08:17:05 UTC (rev 92105)
@@ -159,7 +159,7 @@
{
var filesSelect = document.getElementById("scripts-files");
for (var i = 0; i < filesSelect.length; ++i) {
- if (filesSelect[i].text === scriptName) {
+ if (filesSelect[i].scriptNameForTest === scriptName) {
filesSelect.selectedIndex = i;
WebInspector.panels.scripts._filesSelectChanged();
var sourceFrame = WebInspector.panels.scripts.visibleView;
Added: trunk/LayoutTests/inspector/debugger/scripts-sorting-expected.txt (0 => 92105)
--- trunk/LayoutTests/inspector/debugger/scripts-sorting-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/debugger/scripts-sorting-expected.txt 2011-08-01 08:17:05 UTC (rev 92105)
@@ -0,0 +1,23 @@
+Tests scripts sorting in the scripts panel.
+
+Debugger was enabled.
+ *Non*URL*path
+ block.js?block=foo
+ ga.js
+ lenta.ban?pg=4883&ifr=1
+ lenta.ban?pg=5309&ifr=1
+ top100.jcn?80674
+/_js/production
+ motor.js?1308927432
+/i
+ xgemius.js
+/i/js
+ jquery-1.5.1.min.js
+ jquery.cookie.js
+…cal/google/code/chromium/src/third_party/WebKit/LayoutTests/http/tests/inspector
+ debugger-test.js
+ inspector-test.js
+…local/google/code/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger
+ scripts-sorting.html
+Debugger was disabled.
+
Property changes on: trunk/LayoutTests/inspector/debugger/scripts-sorting-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/debugger/scripts-sorting.html (0 => 92105)
--- trunk/LayoutTests/inspector/debugger/scripts-sorting.html (rev 0)
+++ trunk/LayoutTests/inspector/debugger/scripts-sorting.html 2011-08-01 08:17:05 UTC (rev 92105)
@@ -0,0 +1,48 @@
+<html>
+<head>
+<script src=""
+<script src=""
+
+<script>
+var scripts = [
+ "block.js?block=foo",
+ "ga.js",
+ "lenta.ban?pg=4883&ifr=1",
+ "lenta.ban?pg=5309&ifr=1",
+ "top100.jcn?80674",
+ "_js/production/motor.js?1308927432",
+ "i/xgemius.js",
+ "i/js/jquery-1.5.1.min.js",
+ "i/js/jquery.cookie.js" ];
+
+for (var i = 0; i < scripts.length; ++i)
+ window.eval("function func" + i + "() {} //@ sourceURL=http://foo.com/" + scripts[i]);
+
+window.eval("function funcNonURL() {} //@ sourceURL=*Non*URL*path");
+
+</script>
+
+<script>
+function test()
+{
+ var scripts = [];
+ InspectorTest.startDebuggerTest(step1);
+
+ function step1()
+ {
+ var select = WebInspector.panels.scripts._filesSelectElement;
+ for (var i = 0; i < select.length; ++i)
+ InspectorTest.addResult(select[i].textContent.replace(/\u00a0/g, " "));
+ InspectorTest.completeDebuggerTest();
+ }
+}
+</script>
+
+</head>
+<body _onload_="runTest()">
+<p>
+Tests scripts sorting in the scripts panel.
+</p>
+</body>
+
+</html>
Property changes on: trunk/LayoutTests/inspector/debugger/scripts-sorting.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (92104 => 92105)
--- trunk/Source/WebCore/ChangeLog 2011-08-01 08:13:55 UTC (rev 92104)
+++ trunk/Source/WebCore/ChangeLog 2011-08-01 08:17:05 UTC (rev 92105)
@@ -1,3 +1,21 @@
+2011-08-01 Pavel Feldman <[email protected]>
+
+ Web Inspector: group scripts by folder in the scripts selector.
+ https://bugs.webkit.org/show_bug.cgi?id=65321
+
+ Reviewed by Yury Semikhatsky.
+
+ Test: inspector/debugger/scripts-sorting.html
+
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype._sourceFileAdded.get if):
+ (WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect.insertOrdered.optionCompare):
+ (WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect.insertOrdered):
+ (WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect):
+ (WebInspector.ScriptsPanel.prototype._folderAndDisplayNameForScriptURL):
+ (WebInspector.ScriptsPanel.prototype.reset):
+ (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName):
+
2011-07-28 Pavel Feldman <[email protected]>
Web Inspector: [protocol] methods where all parameters are optional should not require empty params object.
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (92104 => 92105)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-08-01 08:13:55 UTC (rev 92104)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-08-01 08:17:05 UTC (rev 92105)
@@ -240,7 +240,8 @@
this._addOptionToFilesSelect(sourceFile);
var lastViewedURL = WebInspector.settings.lastViewedScriptFile.get();
- if (this._filesSelectElement.length === 1) {
+ if (!this._filesSelectElement.initialSelectionProcessed) {
+ this._filesSelectElement.initialSelectionProcessed = true;
// Option we just added is the only option in files select.
// We have to show corresponding source frame immediately.
this._showSourceFrameAndAddToHistory(sourceFile.id);
@@ -254,59 +255,77 @@
_addOptionToFilesSelect: function(sourceFile)
{
var select = this._filesSelectElement;
+ if (!select.folderOptions)
+ select.folderOptions = {};
+
var option = document.createElement("option");
- option.text = this._displayNameForScriptURL(sourceFile.url) || WebInspector.UIString("(program)");
+ var parsedURL = sourceFile.url.asParsedURL();
+
+ var names = this._folderAndDisplayNameForScriptURL(sourceFile.url);
+ option.text = names.displayName ? "\u00a0\u00a0\u00a0\u00a0" + names.displayName : WebInspector.UIString("(program)");
+ option.scriptNameForTest = names.displayName;
+ var folderNameForSorting = (sourceFile.isContentScript ? "2" : "0") + names.folderName;
+ option.nameForSorting = folderNameForSorting + "\t/\t" + names.displayName; // Use '\t' to make files stick to their folder.
option.title = sourceFile.url;
- option.isContentScript = sourceFile.isContentScript;
if (sourceFile.isContentScript)
option.addStyleClass("extension-script");
- function compare(a, b)
+
+ function insertOrdered(option)
{
- return a < b ? -1 : (a > b ? 1 : 0);
+ function optionCompare(a, b)
+ {
+ return a.nameForSorting.localeCompare(b.nameForSorting);
+ }
+ var insertionIndex = insertionIndexForObjectInListSortedByFunction(option, select.childNodes, optionCompare);
+ select.insertBefore(option, insertionIndex < 0 ? null : select.childNodes.item(insertionIndex));
}
- function optionCompare(a, b)
- {
- if (a === select.contentScriptSection)
- return b.isContentScript ? -1 : 1;
- if (b === select.contentScriptSection)
- return a.isContentScript ? 1 : -1;
- if (a.isContentScript && !b.isContentScript)
- return 1;
- if (!a.isContentScript && b.isContentScript)
- return -1;
+ insertOrdered(option);
- return compare(a.text, b.text) || compare(a.title, b.title);
- }
-
- var insertionIndex = insertionIndexForObjectInListSortedByFunction(option, select.childNodes, optionCompare);
- select.insertBefore(option, insertionIndex < 0 ? null : select.childNodes.item(insertionIndex));
-
if (sourceFile.isContentScript && !select.contentScriptSection) {
var contentScriptSection = document.createElement("option");
contentScriptSection.text = WebInspector.UIString("Content scripts");
contentScriptSection.disabled = true;
+ option.nameForSorting = "1/ContentScriptSeparator";
select.contentScriptSection = contentScriptSection;
+ insertOrdered(contentScriptSection);
+ }
- var insertionIndex = insertionIndexForObjectInListSortedByFunction(contentScriptSection, select.childNodes, optionCompare);
- select.insertBefore(contentScriptSection, insertionIndex < 0 ? null : select.childNodes.item(insertionIndex));
+ if (names.folderName && !select.folderOptions[names.folderName]) {
+ var folderOption = document.createElement("option");
+ folderOption.text = names.folderName;
+ folderOption.nameForSorting = folderNameForSorting;
+ folderOption.disabled = true;
+ select.folderOptions[names.folderName] = folderOption;
+ insertOrdered(folderOption);
}
+
option._sourceFileId = sourceFile.id;
this._sourceFileIdToFilesSelectOption[sourceFile.id] = option;
},
- _displayNameForScriptURL: function(url)
+ _folderAndDisplayNameForScriptURL: function(url)
{
+ var parsedURL = url.asParsedURL();
+ if (parsedURL)
+ url = ""
+
+ var folderName = "";
var displayName = url;
- var indexOfQuery = displayName.indexOf("?");
- if (indexOfQuery > 0)
- displayName = displayName.substring(0, indexOfQuery);
+
var fromIndex = displayName.lastIndexOf("/", displayName.length - 2);
- if (fromIndex !== -1)
+ if (fromIndex !== -1) {
+ folderName = displayName.substring(0, fromIndex);
displayName = displayName.substring(fromIndex + 1);
- if (displayName.length > 100)
- displayName = displayName.substring(0, 80) + "...";
- return displayName;
+ }
+
+ if (displayName.length > 80)
+ displayName = "\u2026" + displayName.substring(displayName.length - 80);
+
+ if (folderName.length > 80)
+ folderName = "\u2026" + folderName.substring(folderName.length - 80);
+
+ return { folderName: folderName, displayName: displayName};
},
setScriptSourceIsBeingEdited: function(sourceFileId, inEditMode)
@@ -495,6 +514,11 @@
this._sourceFileIdToSourceFrame = {};
this._sourceFileIdToFilesSelectOption = {};
this._filesSelectElement.removeChildren();
+ this._filesSelectElement.removeChildren();
+ this._filesSelectElement.folderOptions = {};
+ delete this._filesSelectElement.initialSelectionProcessed;
+ delete this._filesSelectElement.contentScriptSection;
+
this.functionsSelectElement.removeChildren();
this.viewsContainerElement.removeChildren();
@@ -1181,7 +1205,8 @@
suggestedFileName: function()
{
var sourceFile = this._model.sourceFile(this._sourceFileId);
- return WebInspector.panels.scripts._displayNameForScriptURL(sourceFile.url) || "untitled.js";
+ var names = WebInspector.panels.scripts._folderAndDisplayNameForScriptURL(sourceFile.url);
+ return names.displayName || "untitled.js";
}
}