Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

issue 5878: FBTest + localized loading message

  • Loading branch information...
commit e4019279880badb29c820a9f74e629a8be5f5b5a 1 parent 7b82c8c
@fflorent authored
View
31 extension/content/firebug/console/commandLineInclude.js
@@ -42,7 +42,7 @@ Cu.import("resource://firebug/storageService.js");
// ********************************************************************************************* //
// Implementation
-var CommandLineIncludeRep = FirebugReps.CommandLineInclude = domplate(FirebugReps.Table,
+var CommandLineIncludeRep = domplate(FirebugReps.Table,
{
tag: FirebugReps.OBJECTBOX( {"oncontextmenu":"$onContextMenu"}, FirebugReps.Table.tag ),
tableClassName: "tableCommandLineInclude dataTable",
@@ -83,7 +83,7 @@ var CommandLineIncludeRep = FirebugReps.CommandLineInclude = domplate(FirebugRep
{
var aliasName = keys[i];
arrayToDisplay.push({
- "alias": SPAN({"class":"aliasName"}, aliasName),
+ "alias": SPAN({"class":"aliasName", "data-aliasname":aliasName}, aliasName),

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
"URL": this.getUrlTag(store.getItem(aliasName), aliasName, context)
});
}
@@ -107,9 +107,8 @@ var CommandLineIncludeRep = FirebugReps.CommandLineInclude = domplate(FirebugRep
startEditing: function(target)
{
- // xxxFlorent: clumsy ?
var editor = this.getEditor(target.ownerDocument);
- Firebug.Editor.startEditing(target, target.textContent, editor);
+ Firebug.Editor.startEditing(target, target.dataset.aliasname, editor);
},
editAliasName: function(tr)
@@ -192,7 +191,7 @@ var CommandLineIncludeRep = FirebugReps.CommandLineInclude = domplate(FirebugRep
{
var url = tr.querySelector("a.url").href;
// xxxFlorent: not so pretty ...
- var aliasName = tr.querySelector(".aliasName").textContent;
+ var aliasName = tr.querySelector(".aliasName").dataset.aliasname;
var context = Firebug.currentContext;
var items = [
@@ -265,11 +264,7 @@ var CommandLineIncludeRep = FirebugReps.CommandLineInclude = domplate(FirebugRep
if (target === null)
return;
- // xxxFlorent: we should implement a common function that do that work
- // for example: openMenu(items[, popup]);
- // this would also be called in console/commandEditor.js:159 and in editor/editor.js:968
-
- // good popup ?
+ // xxxFlorent: FIXME use fbContextMenu...
var popup = document.getElementById("fbIncludePopup");
Dom.eraseNode(popup);
@@ -331,15 +326,6 @@ var CommandLineInclude =
this.setAliases(aliases);
},
- animateLoadingMessage: function(row, message, iteration)
- {
- if (!row || row.parentNode === null)
- return;
- var dots = "...".substr(3-iteration%4);
- row.querySelector(".objectBox-text").textContent = message + dots;
- setTimeout(CommandLineInclude.animateLoadingMessage, 500, row, message, iteration+1);
- },
-
log: function(localeStr, localeArgs, logArgs)
{
var msg = Locale.$STRF("commandline.include."+localeStr, localeArgs);
@@ -347,7 +333,7 @@ var CommandLineInclude =
return Firebug.Console.logFormatted.apply(Firebug.Console, logArgs);
},
- // include(context, url[, newAliasi])
+ // include(context, url[, newAlias])
// includes a remote script
include: function(context, url, newAlias)
{
@@ -406,8 +392,8 @@ var CommandLineInclude =
this.log("aliasRemoved", [newAlias], [context, "info"]);
return returnValue;
}
- var loadingMsgRow = this.log("loading", [], [context, "info", true]);
- this.animateLoadingMessage(loadingMsgRow, loadingMsgRow.textContent, 0);
+ 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);
@@ -502,6 +488,7 @@ IncludeEditor.prototype = domplate(Firebug.InlineEditor.prototype,
var url = store.getItem(oldAliasName);
store.removeItem(oldAliasName);
store.setItem(value, url);
+ target.dataset.aliasname = value;
target.textContent = value;
}
});
View
1  extension/defaults/preferences/firebug.js
@@ -59,7 +59,6 @@ pref("extensions.firebug.console.enableSites", false);
pref("extensions.firebug.tabularLogMaxHeight", 200);
pref("extensions.firebug.consoleFilterTypes", "all");
pref("extensions.firebug.preferJSDSourceLinks", false);
-pref("extensions.firebug.consoleAliases", "{}");
// HTML
pref("extensions.firebug.showCommentNodes", false);
View
6 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);
@@ -802,6 +807,7 @@
display: block;
}
.tableCommandLineInclude .url{ float: left; }
+
.tableCommandLineInclude .commands{
float: right;
height:100%;
View
33 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");
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
39 tests/content/commandLine/5878/issue5878.html
@@ -0,0 +1,39 @@
+<!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>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_step13.png" alt="result step 13"/></li>
+ <li>Type: <code>include(null, "myscript");</code></li>
+ <li>Type: <code>include()</code></li>
+ <li>The line of step 13 should have disappeared</li>
+ </ol>
+ </section>
+ <footer>
+ Florent FAYOLLE, florent.fayolle69@gmail.com
+ </footer>
+ </div>
+ </body>
+</html>
View
81 tests/content/commandLine/5878/issue5878.js
@@ -0,0 +1,81 @@
+function runTest()
+{
+ var basePath5878 = basePath + "console/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");
+ 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 + "myScript.js";
+ FBTest.compare(expectedURL, url,
+ "The alias should redirect to " + basePath5878);
+ }
+ });
+ 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);
+ // FBTest.executeContextMenuCommand(row, "fbOpenInScratchpad");
+ }
+ });
+ 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");
+ });
+ 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
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_step13.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
@@ -177,6 +177,7 @@
{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/5951/issue5951.js", desc: "Title of array-like objects should be clickable", testPage: "commandLine/5951/issue5951.html"},
+ {group: "commandLine", uri: "commandLine/5878/issue5878.js", desc: "Issue 5878: proposal for a command line method: include(url)", testPage: "console/5878/issue5878.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"},
{group: "html", uri: "html/breakpoints/breakOnNext.js", desc: "Mutation breakpoints test", testPage: "html/breakpoints/breakOnNext.html"},
Please sign in to comment.
Something went wrong with that request. Please try again.