Skip to content
Browse files

Merge pull request #52 from fflorent/issue5878_pull

issue5878: proposal for a command line method: include(url)
  • Loading branch information...
2 parents c6ec803 + 9c7a1b4 commit 9fd5d8370eb0cfd2a7c13ff92bbd61ba3e8d84c6 @janodvarko janodvarko committed
View
13 extension/content/firebug/chrome/tableRep.js
@@ -19,10 +19,10 @@ with (Domplate) {
FirebugReps.Table = domplate(Firebug.Rep,
{
className: "table",
-
+ tableClassName: "dataTable",
tag:
DIV({"class": "dataTableSizer", "tabindex": "-1" },
- TABLE({"class": "dataTable", cellspacing: 0, cellpadding: 0, width: "100%",
+ TABLE({"class": "$tableClassName", cellspacing: 0, cellpadding: 0, width: "100%",
"role": "grid"},
THEAD({"class": "dataTableThead", "role": "presentation"},
TR({"class": "headerRow focusRow dataTableRow subFocusRow", "role": "row",
@@ -194,7 +194,7 @@ FirebugReps.Table = domplate(Firebug.Rep,
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Console logging
- log: function(data, cols, context)
+ log: function(data, cols, context, object)
{
// No arguments passed into console.table method, bail out for now,
// but some error message could be displayed in the future.
@@ -211,7 +211,12 @@ FirebugReps.Table = domplate(Firebug.Rep,
try
{
this.columns = columns;
- var row = Firebug.Console.log({data: data, columns: columns}, context, "table", this, true);
+
+ var object = object || {};
+ object.data = data;
+ object.columns = columns;
+
+ var row = Firebug.Console.log(object, context, "table", this, true);
// Set vertical height for scroll bar.
var tBody = row.querySelector(".dataTableTbody");
View
3 extension/content/firebug/console/commandEditor.js
@@ -159,9 +159,6 @@ Firebug.CommandEditor = Obj.extend(Firebug.Module,
var popup = document.getElementById("fbCommandEditorPopup");
Dom.eraseNode(popup);
- var browserWindow = Firebug.chrome.window;
- var commandDispatcher = browserWindow.document.commandDispatcher;
-
var items = Firebug.CommandEditor.getContextMenuItems();
for (var i=0; i<items.length; i++)
Menu.createMenuItem(popup, items[i]);
View
9 extension/content/firebug/console/commandLine.js
@@ -21,13 +21,14 @@ define([
"firebug/lib/keywords",
"firebug/console/console",
"firebug/console/commandLineHelp",
+ "firebug/console/commandLineInclude",
"firebug/console/commandLineExposed",
"firebug/console/autoCompleter",
"firebug/console/commandHistory"
],
function(Obj, Firebug, FirebugReps, Locale, Events, Wrapper, Url, Css, Dom, Firefox, Win, System,
Xpath, Str, Xml, Arr, Persist, Keywords, Console, CommandLineHelp,
- CommandLineExposed) {
+ CommandLineInclude, CommandLineExposed) {
// ********************************************************************************************* //
// Constants
@@ -351,7 +352,8 @@ Firebug.CommandLine = Obj.extend(Firebug.Module,
evaluateInWebPage: function(expr, context, targetWindow)
{
- var win = targetWindow || context.window;
+ var win = targetWindow ? targetWindow :
+ (context.baseWindow ? context.baseWindow : context.window);
var element = Dom.addScript(win.document, "_firebugInWebPage", expr);
if (!element)
return;
@@ -1124,7 +1126,7 @@ function FirebugCommandLineAPI(context)
case "node":
XPathResultType = XPathResult.FIRST_ORDERED_NODE_TYPE;
break;
-
+
case "nodes":
XPathResultType = XPathResult.UNORDERED_NODE_ITERATOR_TYPE;
break;
@@ -1507,6 +1509,7 @@ function getNoScript()
return this.noscript;
}
+
// ********************************************************************************************* //
// Registration
View
513 extension/content/firebug/console/commandLineInclude.js
@@ -0,0 +1,513 @@
+/* See license.txt for terms of usage */
+
+define([
+ "firebug/chrome/reps",
+ "firebug/lib/domplate",
+ "firebug/lib/locale",
+ "firebug/lib/dom",
+ "firebug/chrome/window",
+ "firebug/lib/css",
+ "firebug/lib/string",
+ "firebug/lib/options",
+ "firebug/chrome/menu",
+ "firebug/lib/system",
+ "firebug/lib/xpcom",
+ "firebug/lib/object",
+ "firebug/editor/editor",
+],
+function(FirebugReps, Domplate, Locale, Dom, Win, Css, Str, Options, Menu, System, Xpcom, Obj) {
+with (Domplate) {
+
+// ********************************************************************************************* //
+// Constants
+
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+const removeConfirmation = "commandline.include.removeConfirmation";
+const prompts = Xpcom.CCSV("@mozilla.org/embedcomp/prompt-service;1", "nsIPromptService");
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+var ScratchpadManager;
+
+try
+{
+ var scope = {};
+ Cu.import("resource:///modules/devtools/scratchpad-manager.jsm", scope);
+ ScratchpadManager = scope.ScratchpadManager;
+}
+catch(ex)
+{
+ // Scratchpad does not exists (when using Seamonkey ...)
+}
+
+Cu.import("resource://firebug/storageService.js");
+
+// ********************************************************************************************* //
+// Implementation
+
+var CommandLineIncludeRep = domplate(FirebugReps.Table,
+{
+ tableClassName: "tableCommandLineInclude dataTable",
+
+ tag:
+ FirebugReps.OBJECTBOX({_repObject: "$object"},
+ FirebugReps.Table.tag
+ ),
+
+ inspectable: false,
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+ // Domplate Handlers
+
+ getValueTag: function(object)
+ {
+ if (object.cons === DomplateTag)
+ return object;
+ else
+ return FirebugReps.Table.getValueTag(object);
+ },
+
+ getUrlTag: function(href, aliasName, context)
+ {
+ var urlTag =
+ SPAN({style:"height:100%"},
+ A({"href": href, "target": "_blank", "class": "url"},
+ Str.cropString(href, 100)
+ ),
+ SPAN({"class": "commands"}
+ // xxxFlorent: temporarily disabled, see:
+ // http://code.google.com/p/fbug/issues/detail?id=5878#c27
+ /*,
+ IMG({
+ "src":"blank.gif",
+ "class":"closeButton ",
+ onclick: this.deleteAlias.bind(this, aliasName),
+ })*/
+ )
+ );
+
+ return urlTag;
+ },
+
+ displayAliases: function(context)
+ {
+ var store = CommandLineInclude.getStore();
+ var keys = store.getKeys();
+ var arrayToDisplay = [];
+
+ for (var i=0; i<keys.length; i++)
+ {
+ var aliasName = keys[i];
+ arrayToDisplay.push({
+ "alias": SPAN({"class":"aliasName", "data-aliasname": aliasName}, aliasName),
+ "URL": this.getUrlTag(store.getItem(aliasName), aliasName, context)
+ });
+ }
+
+ var input = new CommandLineIncludeObject();
+ this.log(arrayToDisplay, ["alias", "URL"], context, input);
+ return Firebug.Console.getDefaultReturnValue(context.window);
+ },
+
+ deleteAlias: function(aliasName, ev)
+ {
+ // NOTE: that piece of code has not been tested since deleting aliases through the table
+ // has been disabled.
+ // Once it is enabled again, make sure FBTests is available for this feature
+ var store = CommandLine.getStore();
+ if (! Options.get(removeConfirmation))
+ {
+ var check = {value: false};
+ var flags = prompts.BUTTON_POS_0 * prompts.BUTTON_TITLE_YES +
+ prompts.BUTTON_POS_1 * prompts.BUTTON_TITLE_NO;
+
+ if (!prompts.confirmEx(context.chrome.window, Locale.$STR("Firebug"),
+ Locale.$STR("commandline.include.confirmDelete"), flags, "", "", "",
+ Locale.$STR("Do_not_show_this_message_again"), check) == 0)
+ {
+ return;
+ }
+
+ // Update 'Remove Cookies' confirmation option according to the value
+ // of the dialog's "do not show again" checkbox.
+ Options.set(removeConfirmation, !check.value);
+ }
+ store.removeItem(aliasName);
+ },
+
+ startEditing: function(target)
+ {
+ var editor = this.getEditor(target.ownerDocument);
+ Firebug.Editor.startEditing(target, target.dataset.aliasname, editor);
+ },
+
+ editAliasName: function(tr)
+ {
+ var target = tr.querySelector(".aliasName");
+ this.startEditing(target);
+ },
+
+ editAliasURL: function(tr)
+ {
+ var target = tr.querySelector(".url");
+ this.startEditing(target);
+ },
+
+ openInScratchpad: function(url)
+ {
+ var spWin = ScratchpadManager.openScratchpad();
+ var scriptContent = null;
+ var editor = null;
+
+ spWin.onload = function()
+ {
+ var spInstance = spWin.Scratchpad;
+ //intro = spInstance.strings.GetStringFromName("scratchpadIntro");
+ spInstance.addObserver(
+ {
+ onReady: function()
+ {
+ editor = spInstance.editor;
+
+ // if the content of the script is loaded, we write the content in the editor
+ // otherwise, we write a text that asks the user to wait
+ if (scriptContent)
+ editor.setText(scriptContent);
+ else
+ editor.setText("// "+Locale.$STR("scratchpad.loading"));
+ }
+ });
+ }
+
+ var xhr = new XMLHttpRequest({mozAnon: true});
+ xhr.open("GET", url, true);
+
+ xhr.onload = function()
+ {
+ if (spWin.closed)
+ return;
+
+ scriptContent = xhr.responseText;
+
+ // if the editor is ready, we put the content on it now
+ // otherwise, we wait for the editor
+ if (editor)
+ editor.setText(scriptContent);
+ }
+
+ xhr.onerror = function()
+ {
+ if (spWin.closed)
+ return;
+
+ spInstance.setText("// "+Locale.$STR("scratchpad.failLoading"));
+ }
+
+ xhr.send(null);
+ },
+
+ supportsObject: function(object, type)
+ {
+ return object instanceof CommandLineIncludeObject;
+ },
+
+ getContextMenuItems: function(object, target, context)
+ {
+ var tr = Dom.getAncestorByTagName(target, "tr");
+ if (!tr)
+ return [];
+
+ var url = tr.querySelector("a.url").href;
+ var aliasName = tr.querySelector(".aliasName").dataset.aliasname;
+ var context = Firebug.currentContext;
+ var items = [
+ {
+ label: "CopyLocation",
+ id: "fbCopyLocation",
+ tooltiptext: "clipboard.tip.Copy_Location",
+ command: Obj.bindFixed(System.copyToClipboard, System, url)
+ },
+ // xxxFlorent: temporarily disabled, see:
+ // http://code.google.com/p/fbug/issues/detail?id=5878#c27
+ /*"-",
+ {
+ label: "commandline.label.EditAliasName",
+ id: "fbEditAliasName",
+ tooltiptext: "commandline.tip.Edit_Alias_Name",
+ command: this.editAliasName.bind(this, tr)
+ },
+ {
+ label: "commandline.label.EditAliasURL",
+ id: "fbEditAliasUrl",
+ tooltiptext: "commandline.tip.Edit_Alias_URL",
+ command: this.editAliasURL.bind(this, tr)
+ },
+ {
+ label: "commandline.label.DeleteAlias",
+ id: "fbDeleteAlias",
+ tooltiptext: "commandline.tip.Delete_Alias",
+ command: this.deleteAlias.bind(this, aliasName, ev)
+ },*/
+ "-",
+ {
+ label: Locale.$STRF("commandline.label.IncludeScript", [aliasName]),
+ id: "fbInclude",
+ tooltiptext: "commandline.tip.Include_Script",
+ command: Obj.bindFixed(CommandLineInclude.include, CommandLineInclude,
+ context, aliasName)
+ },
+ "-",
+ {
+ label: "OpenInTab",
+ id: "fbOpenInTab",
+ tooltiptext: "firebug.tip.Open_In_Tab",
+ command: Obj.bindFixed(Win.openNewTab, Win, url)
+ }
+ ];
+
+ if (ScratchpadManager)
+ {
+ items.push({
+ label: "commandline.label.OpenInScratchpad",
+ id: "fbOpenInScratchpad",
+ tooltiptext: "commandline.tip.Open_In_Scratchpad",
+ command: this.openInScratchpad.bind(this, url)
+ });
+ }
+
+ return items;
+ },
+
+ getEditor: function(doc)
+ {
+ if (!this.editor)
+ this.editor = new IncludeEditor(doc);
+ return this.editor;
+ }
+});
+
+// ********************************************************************************************* //
+
+function CommandLineIncludeObject()
+{
+}
+
+// ********************************************************************************************* //
+
+var CommandLineInclude =
+{
+ onSuccess: function(aliases, newAlias, context, loadingMsgRow, xhr)
+ {
+ var urlComponent = xhr.channel.URI.QueryInterface(Ci.nsIURL);
+ var msg, filename = urlComponent.fileName, url = urlComponent.spec;
+ // clear the message saying "loading..."
+ loadingMsgRow.parentNode.removeChild(loadingMsgRow);
+
+ if (newAlias)
+ {
+ var store = this.getStore();
+ store.setItem(newAlias, url);
+ this.log("aliasCreated", [newAlias], [context, "info"]);
+ }
+
+ this.log("includeSuccess", [filename], [context, "info"]);
+ },
+
+ onError: function(context, url)
+ {
+ loadingMsgRow.parentNode.removeChild(loadingMsgRow);
+ this.log("loadFail", [url], [context, "error"]);
+ },
+
+ getStore: function()
+ {
+ if (!this.store)
+ this.store = StorageService.getStorage("includeAliases.json");
+ return this.store;
+ },
+
+ log: function(localeStr, localeArgs, logArgs)
+ {
+ var msg = Locale.$STRF("commandline.include."+localeStr, localeArgs);
+ logArgs.unshift([msg]);
+ return Firebug.Console.logFormatted.apply(Firebug.Console, logArgs);
+ },
+
+ // include(context, url[, newAlias])
+ // includes a remote script
+ include: function(context, url, newAlias)
+ {
+ var reNotAlias = /[\.\/]/;
+ var urlIsAlias = url !== null && !reNotAlias.test(url);
+ var aliases;
+ var returnValue = Firebug.Console.getDefaultReturnValue(context.window);
+ var acceptedSchemes = ["http", "https"];
+ var msg;
+
+ // checking arguments:
+ if (newAlias !== undefined && typeof newAlias !== "string")
+ throw "wrong alias argument; expected string";
+
+ if (url !== null && typeof url !== "string")
+ throw "wrong url argument; expected string or null";
+
+ if (newAlias !== undefined)
+ newAlias = newAlias.toLowerCase();
+
+ if ((urlIsAlias && url.length > 30) || (newAlias && newAlias.length > 30))
+ {
+ this.log("tooLongAliasName", [newAlias || url], [context, "error"]);
+ return returnValue;
+ }
+
+ if (newAlias !== undefined && reNotAlias.test(newAlias))
+ {
+ this.log("invalidAliasName", [newAlias], [context, "error"]);
+ return returnValue;
+ }
+
+ if (urlIsAlias)
+ {
+ var store = this.getStore();
+ var aliasName = url.toLowerCase();
+ url = store.getItem(aliasName);
+ if (url === undefined)
+ {
+ this.log("aliasNotFound", [aliasName], [context, "error"]);
+ return returnValue;
+ }
+ }
+
+ // if the URL is null, we delete the alias
+ if (newAlias !== undefined && url === null)
+ {
+ var store = this.getStore();
+ if (store.getItem(newAlias) === undefined)
+ {
+ this.log("aliasNotFound", [newAlias], [context, "error"]);
+ return returnValue;
+ }
+
+ store.removeItem(newAlias);
+ this.log("aliasRemoved", [newAlias], [context, "info"]);
+ return returnValue;
+ }
+ var loadingMsg = Locale.$STR("Loading");
+ var loadingMsgRow = Firebug.Console.logFormatted([loadingMsg], context, "loading", true);
+ var onSuccess = this.onSuccess.bind(this, aliases, newAlias, context, loadingMsgRow);
+ var onError = this.onError.bind(this, context, loadingMsgRow);
+ this.evaluateRemoteScript(url, context, onSuccess, onError);
+
+ return returnValue;
+ },
+
+ evaluateRemoteScript: function(url, context, successFunction, errorFunction)
+ {
+ var xhr = new XMLHttpRequest({ mozAnon: true, timeout:30});
+ var acceptedSchemes = ["http", "https"];
+ var absoluteURL = context.browser.currentURI.resolve(url);
+
+ xhr.onload = function()
+ {
+ var contentType = xhr.getResponseHeader("Content-Type").split(";")[0];
+ var codeToEval = xhr.responseText;
+ var headerMatch;
+ Firebug.CommandLine.evaluateInWebPage(codeToEval, context);
+ if (successFunction)
+ successFunction(xhr);
+ }
+
+ if (errorFunction)
+ {
+ xhr.ontimeout = xhr.onerror = function()
+ {
+ errorFunction(url);
+ }
+ }
+
+ xhr.open("GET", absoluteURL, true);
+
+ if (!~acceptedSchemes.indexOf(xhr.channel.URI.scheme))
+ {
+ this.log("invalidRequestProtocol", [], [context, "error"]);
+ return ;
+ }
+
+ xhr.send(null);
+
+ // xxxFlorent: TODO show XHR progress
+ return xhr;
+ }
+};
+
+// ********************************************************************************************* //
+// Command Handler
+
+function onCommand(context, args)
+{
+ if (args.length === 0)
+ return CommandLineIncludeRep.displayAliases(context);
+
+ var self = CommandLineInclude;
+ Array.unshift(args, context);
+ return CommandLineInclude.include.apply(self, args);
+}
+
+// ********************************************************************************************* //
+// Local Helpers
+
+function IncludeEditor(doc)
+{
+ Firebug.InlineEditor.call(this, doc);
+}
+
+IncludeEditor.prototype = domplate(Firebug.InlineEditor.prototype,
+{
+ endEditing: function(target, value, cancel)
+ {
+ if (cancel)
+ return;
+
+ var context = Firebug.currentContext;
+ if (Css.hasClass(target, "aliasName"))
+ this.updateAliasName(target, value, context);
+ else if (Css.hasClass(target, "url"))
+ this.updateURL(target, value, context);
+ },
+
+ updateURL: function(target, value, context)
+ {
+ var tr = Dom.getAncestorByTagName(target, "tr");
+ var aliasName = tr.querySelector(".aliasName").textContent;
+ CommandLineInclude.include(context, value, aliasName, {"onlyUpdate":true});
+ target.textContent = value;
+ },
+
+ updateAliasName: function(target, value, context)
+ {
+ var oldAliasName = target.textContent;
+ var store = CommandLineInclude.getStore();
+ var url = store.getItem(oldAliasName);
+ store.removeItem(oldAliasName);
+ store.setItem(value, url);
+ target.dataset.aliasname = value;
+ target.textContent = value;
+ }
+});
+
+// ********************************************************************************************* //
+// Registration
+
+Firebug.registerCommand("include", {
+ handler: onCommand,
+ description: Locale.$STR("console.cmd.help.include"),
+ helpUrl: "http://getfirebug.com/wiki/index.php/include"
+});
+
+Firebug.registerRep(CommandLineIncludeRep);
+
+return CommandLineIncludeRep;
+
+// ********************************************************************************************* //
+}});
View
12 extension/content/firebug/cookies/cookieModule.js
@@ -709,19 +709,19 @@ Firebug.CookieModule = Obj.extend(Firebug.ActivableModule,
var check = {value: false};
var flags = prompts.BUTTON_POS_0 * prompts.BUTTON_TITLE_YES +
prompts.BUTTON_POS_1 * prompts.BUTTON_TITLE_NO;
-
+
if (!prompts.confirmEx(context.chrome.window, Locale.$STR("Firebug"),
Locale.$STR("cookies.confirm.removeall"), flags, "", "", "",
- Locale.$STR("cookies.msg.Do_not_show_this_message_again"), check) == 0)
+ Locale.$STR("Do_not_show_this_message_again"), check) == 0)
{
return;
}
-
+
// Update 'Remove Cookies' confirmation option according to the value
// of the dialog's "do not show again" checkbox.
Options.set(removeConfirmation, !check.value);
}
-
+
Firebug.CookieModule.removeCookies(context);
},
@@ -735,7 +735,7 @@ Firebug.CookieModule = Obj.extend(Firebug.ActivableModule,
if (!prompts.confirmEx(context.chrome.window, Locale.$STR("Firebug"),
Locale.$STR("cookies.confirm.removeallsession"), flags, "", "", "",
- Locale.$STR("cookies.msg.Do_not_show_this_message_again"), check) == 0)
+ Locale.$STR("Do_not_show_this_message_again"), check) == 0)
{
return;
}
@@ -758,7 +758,7 @@ Firebug.CookieModule = Obj.extend(Firebug.ActivableModule,
if (!prompts.confirmEx(context.chrome.window, Locale.$STR("Firebug"),
Locale.$STRF("cookies.confirm.Remove_All_From_Host", [host]), flags, "", "", "",
- Locale.$STR("cookies.msg.Do_not_show_this_message_again"), check) == 0)
+ Locale.$STR("Do_not_show_this_message_again"), check) == 0)
{
return;
}
View
6 extension/content/firebug/css/cssPanel.js
@@ -1616,7 +1616,11 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
{
var prop = cssRules.props[p];
if (!(prop.disabled || prop.overridden))
- props.push(prop.name + ": " + formatColor(prop.value) + prop.important + ";");
+ {
+ var value = rule.style.getPropertyValue(prop.name);
+ value = formatColor(value);
+ props.push(prop.name + ": " + value + prop.important + ";");
+ }
}
return props;
View
5 extension/locale/en-US/cookies.properties
@@ -62,11 +62,6 @@ cookies.confirm.removeallsession=Do you want to remove all session cookies in th
# LOCALIZATION NOTE (cookies.confirm.Remove_All_From_Host): Used in a confirmation dialog when cookies
# from a specific host are going to be deleted (or permission is set do deny and cookies should be deleted).
cookies.confirm.Remove_All_From_Host=Do you want to remove all cookies from %S?
-# LOCALIZATION NOTE (cookies.msg.Do_not_show_this_message_again):
-# Message within a confirmation dialog that is displayed when deleting cookies.
-# This message is displayed next to a check-box that can be used to disabled this
-# confirmation.
-cookies.msg.Do_not_show_this_message_again=Do not show this message again
# LOCALIZATION NOTE (cookies.Confirm_cookie_removal): A label used for option (mini tab menu)
# that says whether a confirmation dialog is displayed when removing cookies.
cookies.Confirm_cookie_removal=Confirm Cookie Removal
View
76 extension/locale/en-US/firebug.properties
@@ -741,6 +741,80 @@ console.multiHighlightLimitExceeded=There are too many elements in the array to
# in cases when the current page is an XML document. The text between <a> and </a> is a link,
# that causes to switch to HTML rendering of the document.
commandline.disabledForXMLDocs=Firebug command line is disabled for XML pages. You can <a>switch to HTML</a> to enable it.
+
+# LOCALIZATION NOTE (commandline.include.includeSuccess): For the include() function. This message is displayed
+# in the Console panel when a remote script evaluation succeeded
+# %S = the filename
+commandline.include.includeSuccess=%S properly included
+
+# LOCALIZATION NOTE (commandline.include.aliasNotFound): For the include() function. This message is displayed
+# in the Console panel when a requested alias is not found
+# %S = the alias name
+commandline.include.aliasNotFound=alias "%S" not found
+
+# LOCALIZATION NOTE (commandline.include.loadFail): For the include() function. This message is displayed
+# in the Console panel when the remote script download failed
+# %S = the filename
+commandline.include.loadFail=%S failed to load
+
+# LOCALIZATION NOTE (commandline.include.invalidRequestProtocol): For the include() function. This message is displayed
+# in the Console panel when the user tries to download a script with another scheme than HTTP(S)
+# %S = the filename
+commandline.include.invalidRequestProtocol=only HTTP/HTTPS protocols are supported
+
+# LOCALIZATION NOTE (commandline.include.aliasCreated): For the include() function. This message is displayed
+# in the Console panel when a new alias is created successfully
+# %S = the alias name
+commandline.include.aliasCreated=alias "%S" created
+
+# LOCALIZATION NOTE (commandline.include.aliasRemoved): For the include() function. This message is displayed
+# in the Console panel when a new alias is removed successfully
+# %S = the alias name
+commandline.include.aliasRemoved=alias "%S" removed
+
+# LOCALIZATION NOTE (commandline.include.invalidAliasName): For the include() function. This message is displayed
+# in the Console panel if an invalid alias name (which contains "/" or ".") is provided.
+# %S = the invalid alias name
+commandline.include.invalidAliasName=alias names must not contain any "." or "/"; invalid alias name: "%S"
+
+# LOCALIZATION NOTE (commandline.include.tooLongAliasName): For the include() function. This message is displayed
+# in the Console panel if the provided alias name is too long (i.e. more than 30 characters)
+# %S = the invalid alias name
+commandline.include.tooLongAliasName=alias names must not contain more than 30 characters; invalid alias name: "%S"
+
+# LOCALIZATION NOTE (commandline.include.confirmDelete): For the include() function. This message is displayed
+# in a confirmation dialog when the user wants to delete an alias
+# %S = the name of the alias to delete
+commandline.include.confirmDelete=Do you really want to delete this alias : "%S" ?
+
+
+commandline.tip.Delete_Alias=Delete the alias
+commandline.tip.Edit_Alias_Name=Edit the name of the alias
+commandline.tip.Edit_Alias_URL=Edit the URL of the alias
+commandline.tip.Open_In_Scratchpad=Open the content of the script in Scratchpad
+commandline.tip.Include_Script=Download and execute the script
+
+commandline.label.DeleteAlias=Delete Alias
+commandline.label.EditAliasName=Edit Alias Name
+commandline.label.EditAliasURL=Edit Alias URL
+commandline.label.OpenInScratchpad=Open in Scratchpad
+commandline.label.IncludeScript=Include "%S"
+
+
+# LOCALIZATION NOTE (Do_not_show_this_message_again):
+# Message within a confirmation dialog that is displayed when deleting things.
+# This message is displayed next to a check-box that can be used to disabled this
+# confirmation.
+#
+# NOTE to translators: this message was originally taken from cookies.msg.Do_not_show_this_message_again
+Do_not_show_this_message_again=Do not show this message again
+
+# LOCALIZATION NOTE (scratchpad.loading, scratchpad.failLoading)
+# Used when Firebug downloads a remote script and wants to display it in Scratchpad
+# The messages appears as Javascript Comments in Scratchpad
+scratchpad.loading=Loading, please wait...
+scratchpad.failLoading=Error while loading the script
+
# LOCALIZATION NOTE (net.sizeinfo.Response_Body, net.sizeinfo.Post_Body, net.sizeinfo.Total_Sent,
# net.sizeinfo.Total_Received, net.sizeinfo.Including_Headers):
# Labels used for a detailed size info tooltip. The tooltip is displayed, if the mouse hovers over
@@ -1441,6 +1515,8 @@ console.cmd.help.$0=Represents the last element selected via the Inspector.
console.cmd.help.$1=Represents the second last element selected via the Inspector.
console.cmd.help.$n=Returns one of the 5 last elements selected via the Inspector. This method takes one required parameter, which represents the index of the element (starting at 0).
console.cmd.help.help=Displays help for all available commands.
+console.cmd.help.include=Includes a remote script. The first argument is the identifier (the URL to a script or an existing alias for an URL). The optional second argument defines a new alias for the first parameter if the latter is an URL.
+
# LOCALIZATION NOTE (console.cmd.helpUrlNotAvailable): A message used displayed to the user
# if registered command doesn't have help URL associated and the user clicks on the command name.
# List of command names is displayed if you type "help" (without quotes) into the command line.
View
30 extension/skin/classic/console.css
@@ -56,6 +56,7 @@
.logRow-error,
.logRow-assert,
.logRow-warningMessage,
+.logRow-loading,
.logRow-errorMessage {
padding-left: 22px;
background-repeat: no-repeat;
@@ -99,6 +100,10 @@
background-image: url(chrome://firebug/skin/info.svg);
}
+.logRow-loading {
+ background-image: url(chrome://firebug/skin/loading.svg);
+}
+
.logRow-warn,
.logRow-warningMessage {
background-image: url(chrome://firebug/skin/warning.svg);
@@ -787,3 +792,28 @@
color: gray;
padding-left: 5px;
}
+
+
+/************************************************************************************************/
+/* include */
+.tableCommandLineInclude td{
+ height: 17px;
+}
+.tableCommandLineInclude .closeButton{
+ display: none;
+}
+
+.tableCommandLineInclude tr:hover .closeButton{
+ display: block;
+}
+.tableCommandLineInclude .url{ float: left; }
+
+.tableCommandLineInclude .commands{
+ float: right;
+ height:100%;
+}
+.tableCommandLineInclude td:last-child
+{
+ width: 75%;
+ padding-right: 0 !important;
+}
View
43 tests/FBTest/content/FBTestFirebug.js
@@ -414,6 +414,37 @@ this.synthesizeMouse = function(node, offsetX, offsetY, event, win)
synthesizeMouse(node, offsetX, offsetY, event, win);
};
+this.getStringDataFromClipboard = function()
+{
+ // https://developer.mozilla.org/en-US/docs/Using_the_Clipboard
+ var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
+ if (!clip)
+ return false;
+
+ var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
+ if (!trans)
+ return false;
+ if ('init' in trans)
+ trans.init(null);
+ trans.addDataFlavor("text/unicode");
+
+ clip.getData(trans, clip.kGlobalClipboard);
+
+ var str = new Object();
+ var strLength = new Object();
+
+ trans.getTransferData("text/unicode", str, strLength);
+
+ if (str)
+ {
+ str = str.value.QueryInterface(Components.interfaces.nsISupportsString);
+ pastetext = str.data.substring(0, strLength.value / 2);
+ return pastetext;
+ }
+
+ return false;
+};
+
function getFrameOffset(win)
{
var top = 0;
@@ -1164,7 +1195,7 @@ function getCommandLine(useCommandEditor)
*/
this.executeCommand = function(expr, chrome, useCommandEditor)
{
- this.clearAndTypeCommand(expr, useCommandEditor);
+ FBTest.clearAndTypeCommand(expr, useCommandEditor);
if (useCommandEditor)
FBTest.clickToolbarButton(chrome, "fbCmdLineRunButton");
@@ -1226,18 +1257,20 @@ this.typeCommand = function(string, useCommandEditor)
* @param {String} expected Expected value displayed.
* @param {String} tagName Name of the displayed element.
* @param {String} class Class of the displayed element.
+ * @param {Boolean} if set to false, does not clear the console logs
*/
-this.executeCommandAndVerify = function(callback, expression, expected, tagName, classes)
+this.executeCommandAndVerify = function(callback, expression, expected, tagName, classes, clear)
{
- FBTest.clearConsole();
+ if (clear !== false)
+ FBTest.clearConsole();
var config = {tagName: tagName, classes: classes};
FBTest.waitForDisplayedElement("console", config, function(row)
{
FBTest.compare(expected, row.textContent, "Verify: " +
expression + " SHOULD BE " + expected);
-
- FBTest.clearConsole();
+ if (clear !== false)
+ FBTest.clearConsole();
if (callback)
callback();
View
4 tests/content/_common/testcase.css
@@ -114,6 +114,10 @@ code.key {
color: #0000DC;
}
+code.result {
+ color: #000088;
+}
+
input, button {
border: 1px solid #AAAAAA;
border-radius: 5px;
View
44 tests/content/commandLine/5878/issue5878.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Issue 5878: proposal for a command line method: include(url)</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link href="../../_common/testcase.css" type="text/css" rel="stylesheet"/>
+ </head>
+ <body>
+ <header>
+ <h1><a href="http://code.google.com/p/fbug/issues/detail?id=5878">Issue 5878</a>: proposal for a command line method: include(url)</h1>
+ </header>
+ <div>
+ <section id="description">
+ <h3>Steps to reproduce</h3>
+ <ol>
+ <li>Open Firebug</li>
+ <li>Enable and switch to the <em>Console</em> panel</li>
+ <li>Type: <code>include("./myScript.js");</code></li>
+ <li>Type: <code>window.a</code></li>
+ <li>The console should display: <code class="result">1</code></li>
+ <li>Type: <code>include("./myScript.js", "myScript");</code></li>
+ <li>Type: <code>window.a</code></li>
+ <li>The console should display: <code class="result">2</code></li>
+ <li>Type: <code>include()</code></li>
+ <li>The console should display a table containing at least this line:<br/><img src="./result_step10.png" alt="result step 10"/></li>
+ <li>Right-click on "myScript" and select "Import myScript"</li>
+ <li>Type: <code>window.a</code></li>
+ <li>The console should display: <code class="result">3</code></li>
+ <li>Right-click on "myScript" and select "Copy Location"</li>
+ <li>The location of the script should be copied</li>
+ <li>Type: <code>include("./myOtherScript.js", "myScript");</code></li>
+ <li>Type: <code>include();</code></li>
+ <li>The line of step 10 should be replaced by this one:<br/><img src="./result_step18.png" alt="result step 18"/></li>
+ <li>Type: <code>include(null, "myscript");</code></li>
+ <li>Type: <code>include()</code></li>
+ <li>The line of step 18 should have disappeared</li>
+ </ol>
+ </section>
+ <footer>
+ Florent FAYOLLE, florent.fayolle69@gmail.com
+ </footer>
+ </div>
+ </body>
+</html>
View
105 tests/content/commandLine/5878/issue5878.js
@@ -0,0 +1,105 @@
+function runTest()
+{
+ var basePath5878 = basePath + "commandLine/5878/";
+ FBTest.sysout("include.START");
+ FBTest.openNewTab(basePath5878 + "issue5878.html", function(win)
+ {
+ FBTest.openFirebug();
+ FBTest.selectPanel("console");
+
+ FBTest.enableConsolePanel(function(win)
+ {
+ var tasks = new FBTest.TaskList();
+
+ tasks.push(executeIncludeCommand, 'include("./myScript.js");');
+ tasks.push(FBTest.executeCommandAndVerify, 'window.a', "1", "pre", "objectBox-number");
+ tasks.push(executeIncludeCommand, 'include("./myScript.js", "myscript");');
+ tasks.push(FBTest.executeCommandAndVerify, 'window.a', "2", "pre", "objectBox-number");
+ var contextMenuTarget = null;
+ var expectedMyScriptURL = basePath5878 + "myScript.js";
+ tasks.push(checkTableContent, "myscript", function(table, row, aliasName, url)
+ {
+ FBTest.ok(aliasName, "There should be an alias whose name is \"myscript\"");
+ if (aliasName)
+ {
+ contextMenuTarget = row;
+ FBTest.compare(expectedMyScriptURL, url,
+ "The alias should redirect to " + expectedMyScriptURL);
+ }
+ });
+ // test context menu:
+ // (1): test include
+ tasks.push(function(callback)
+ {
+ if (contextMenuTarget)
+ FBTest.executeContextMenuCommand(contextMenuTarget, "fbInclude", callback);
+ });
+ tasks.push(FBTest.executeCommandAndVerify, 'window.a', "3",
+ "pre", "objectBox-number", false);
+ // (2): test copy location
+ tasks.push(function(callback)
+ {
+ FBTest.executeContextMenuCommand(contextMenuTarget, "fbCopyLocation", function()
+ {
+ FBTest.compare(FBTest.getClipboardText(), expectedMyScriptURL,
+ "The copied location should be: "+expectedMyScriptURL);
+ callback();
+ });
+ });
+ tasks.push(executeIncludeCommand, 'include("./myOtherScript.js", "myScript");');
+ tasks.push(checkTableContent, "myscript", function(table, row, aliasName, url)
+ {
+ FBTest.ok(aliasName, "There should be an alias whose name is \"myscript\"");
+ if (aliasName)
+ {
+ var expectedURL = basePath5878 + "myOtherScript.js";
+ FBTest.compare(expectedURL, url,
+ "The alias should redirect to " + basePath5878);
+ }
+ });
+ tasks.push(executeIncludeCommand, 'include(null, "myScript");');
+ tasks.push(checkTableContent, "myscript", function(table, row, aliasName, url)
+ {
+ FBTest.compare(aliasName, undefined,
+ "There should not be any alias whose name is \"myscript\" anymore");
+ });
+ // test for pending scripts
+ tasks.push(executeIncludeCommand, 'include("./pendingScript.php")');
+ tasks.push(FBTest.executeCommandAndVerify, "window.pendingDone", "1", "pre",
+ "objectBox-number");
+ tasks.run(function()
+ {
+ FBTest.testDone("include.DONE");
+ });
+ });
+ });
+}
+
+function checkTableContent(callback, expectedAliasName, checkFunction)
+{
+ var config = {tagName: "table", classes: "tableCommandLineInclude"};
+ FBTest.waitForDisplayedElement("console", config, function(table)
+ {
+ var aliasNameCell = table.querySelector("*[data-aliasname='myscript']");
+ if (!aliasNameCell)
+ checkFunction(table, null, null);
+ else
+ {
+ var row = FW.FBL.getAncestorByTagName(aliasNameCell, "tr");
+ var aliasValueCell = row.querySelector(".url");
+ checkFunction(table, row, aliasNameCell.textContent, aliasValueCell.textContent);
+ }
+ callback();
+ });
+ FBTest.executeCommand("include()");
+}
+
+function executeIncludeCommand(callback, includeCommand)
+{
+ var config = {tagName: "div", classes: "logRow-info"};
+ FBTest.waitForDisplayedElement("console", config, function()
+ {
+ callback();
+ });
+ FBTest.executeCommand(includeCommand);
+}
View
1 tests/content/commandLine/5878/myOtherScript.js
@@ -0,0 +1 @@
+window.b = 1;
View
1 tests/content/commandLine/5878/myScript.js
@@ -0,0 +1 @@
+window.a = (window.a || 0) + 1;
View
5 tests/content/commandLine/5878/pendingScript.php
@@ -0,0 +1,5 @@
+<?php
+ $sleepTime=1;
+ sleep($sleepTime);
+?>
+window.pendingDone = 1;
View
BIN tests/content/commandLine/5878/result_step10.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN tests/content/commandLine/5878/result_step18.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
1 tests/content/firebug.html
@@ -176,6 +176,7 @@
{group: "commandLine", uri: "commandLine/5042/issue5042.js", desc: "Issue 5042: Command Line should not prevent tabbing out when empty", testPage: "commandLine/5042/issue5042.html"},
{group: "commandLine", uri: "commandLine/5130/issue5130.js", desc: "Array indices are sorted alphabetically instead of numerically", testPage: "commandLine/5130/issue5130.html"},
{group: "commandLine", uri: "commandLine/5779/issue5779.js", desc: "Allow to set the root element in $ and $$", testPage: "commandLine/5779/issue5779.html"},
+ {group: "commandLine", uri: "commandLine/5878/issue5878.js", desc: "Issue 5878: proposal for a command line method: include(url)", testPage: "commandLine/5878/issue5878.html"},
{group: "commandLine", uri: "commandLine/5951/issue5951.js", desc: "Title of array-like objects should be clickable", testPage: "commandLine/5951/issue5951.html"},
{group: "html", uri: "html/breakpoints/breakOnElement.js", desc: "Mutation breakpoints test", testPage: "html/breakpoints/breakOnElement.html"},
{group: "html", uri: "html/breakpoints/breakOnElementCB.js", desc: "Mutation breakpoints test (Chromebug active)", testPage: "html/breakpoints/breakOnElement.html"},

0 comments on commit 9fd5d83

Please sign in to comment.
Something went wrong with that request. Please try again.