Bug 238898: Allow evaluating the same expression multiple times from the error console, patch by Simon Bünzli <zeniko@gmail.com>, r=me, sr=neil
authorgavin@gavinsharp.com
Fri, 11 May 2007 11:33:42 -0700
changeset 1375 f22604e01f03998d2d2549908ca68cbd64c93141
parent 1374 56ffe04c5db8cd583df113849c4ae8f4885bea02
child 1376 016f4a039d64bf5177149a808025a87ec3aaede6
push idunknown
push userunknown
push dateunknown
reviewersme, neil
bugs238898
milestone1.9a5pre
Bug 238898: Allow evaluating the same expression multiple times from the error console, patch by Simon Bünzli <zeniko@gmail.com>, r=me, sr=neil
toolkit/components/console/content/blank.html
toolkit/components/console/content/console.js
toolkit/components/console/content/console.xul
toolkit/components/console/jar.mn
xpfe/components/console/resources/content/blank.html
xpfe/components/console/resources/content/console.js
xpfe/components/console/resources/content/console.xul
xpfe/components/jar.mn
deleted file mode 100755
--- a/toolkit/components/console/content/blank.html
+++ /dev/null
@@ -1,1 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title></title></head><body></body></html>
\ No newline at end of file
--- a/toolkit/components/console/content/console.js
+++ b/toolkit/components/console/content/console.js
@@ -102,29 +102,27 @@ function onEvalKeyPress(aEvent)
   if (aEvent.keyCode == 13)
     evaluateTypein();
 }
 
 function evaluateTypein()
 {
   var code = gTextBoxEval.value;
   var iframe = document.getElementById("Evaluator");
-  iframe.setAttribute("src", "javascript: " + encodeURIComponent(code));
+  iframe.contentDocument.location = "javascript: " + encodeURIComponent(code);
 }
 
 function displayResult()
 {
   var resultRange = Evaluator.document.createRange();
   resultRange.selectNode(Evaluator.document.documentElement);
   var result = resultRange.toString();
   if (result)
     gConsole.mCService.logStringMessage(result);
     // or could use appendMessage which doesn't persist
-  var iframe = document.getElementById("Evaluator");
-  iframe.setAttribute("src", "chrome://global/content/blank.html");
 }
 
 // XXX DEBUG
 function debug(aText)
 {
   var csClass = Components.classes['@mozilla.org/consoleservice;1'];
   var cs = csClass.getService(Components.interfaces.nsIConsoleService);
   cs.logStringMessage(aText);
--- a/toolkit/components/console/content/console.xul
+++ b/toolkit/components/console/content/console.xul
@@ -124,11 +124,11 @@
     <toolbar class="chromeclass-toolbar" id="ToolbarEval">
       <textbox id="TextboxEval" class="toolbar" value="" onkeypress="onEvalKeyPress(event)" flex="1"/>
       <toolbarbutton id="ButtonEval" label="&evaluate.label;" oncommand="evaluateTypein()"/>
     </toolbar>
   </toolbox>
   
   <vbox id="ConsoleBox" class="console-box" flex="1" context="ConsoleContext" persist="sortOrder"/>
 
-  <iframe name="Evaluator" id="Evaluator" collapsed="true" src="chrome://global/content/blank.html"/>
+  <iframe name="Evaluator" id="Evaluator" collapsed="true"/>
 
 </window>
--- a/toolkit/components/console/jar.mn
+++ b/toolkit/components/console/jar.mn
@@ -1,6 +1,5 @@
 toolkit.jar:
 *+ content/global/console.js                            (content/console.js)
 *+ content/global/console.xul                           (content/console.xul)
 +  content/global/console.css                           (content/console.css)
 +  content/global/consoleBindings.xml                   (content/consoleBindings.xml)
-   content/global/blank.html                            (content/blank.html)
deleted file mode 100644
--- a/xpfe/components/console/resources/content/blank.html
+++ /dev/null
@@ -1,1 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title></title></head><body></body></html>
\ No newline at end of file
--- a/xpfe/components/console/resources/content/console.js
+++ b/xpfe/components/console/resources/content/console.js
@@ -130,29 +130,27 @@ function onEvalKeyPress(aEvent)
   if (aEvent.keyCode == 13)
     evaluateTypein();
 }
 
 function evaluateTypein()
 {
   var code = document.getElementById("TextboxEval").value;
   var iframe = document.getElementById("Evaluator");
-  iframe.setAttribute("src", "javascript: " + code);
+  iframe.contentDocument.location = "javascript: " + encodeURIComponent(code);
 }
 
 function displayResult()
 {
   var resultRange = Evaluator.document.createRange();
   resultRange.selectNode(Evaluator.document.documentElement);
   var result = resultRange.toString();
   if (result)
     gConsole.mCService.logStringMessage(result);
     // or could use appendMessage which doesn't persist
-  var iframe = document.getElementById("Evaluator");
-  iframe.setAttribute("src", "chrome://global/content/blank.html");
 }
 
 /* :::::::: Command Controller for the Window ::::::::::::::: */
 
 var ConsoleController = 
 {
   isCommandEnabled: function (aCommand)
   {
--- a/xpfe/components/console/resources/content/console.xul
+++ b/xpfe/components/console/resources/content/console.xul
@@ -166,13 +166,13 @@
   <toolbar class="chromeclass-toolbar" id="ToolbarEval" grippytooltiptext="&entryToolbar.tooltip;">
     <textbox id="TextboxEval" class="toolbar" value="" onkeypress="onEvalKeyPress(event)" flex="1"/>
     <toolbarbutton id="ButtonEval" label="&evaluate.label;" oncommand="evaluateTypein()"/>
   </toolbar>
 </toolbox>
   
 <vbox id="ConsoleBox" class="console-box" flex="1" context="ConsoleContext" persist="sortOrder"/>
 
-<iframe name="Evaluator" id="Evaluator" collapsed="true" src="chrome://global/content/blank.html"/>
+<iframe name="Evaluator" id="Evaluator" collapsed="true"/>
 
 </window>
 
 
--- a/xpfe/components/jar.mn
+++ b/xpfe/components/jar.mn
@@ -20,17 +20,16 @@ en-US.jar:
     locale/en-US/global/console.properties                      (console/resources/locale/en-US/console.properties)
     locale/en-US/global/finddialog.dtd                          (find/resources/locale/en-US/finddialog.dtd)
     locale/en-US/global/finddialog.properties                   (find/resources/locale/en-US/finddialog.properties)
 *   locale/en-US/cookie/contents.rdf                            (cookie/locale/en-US/contents.rdf)
     locale/en-US/cookie/cookieAcceptDialog.properties           (/toolkit/locales/en-US/chrome/cookie/cookieAcceptDialog.properties)
     locale/en-US/cookie/cookieAcceptDialog.dtd                  (/toolkit/locales/en-US/chrome/cookie/cookieAcceptDialog.dtd)
 
 toolkit.jar:
-    content/global/blank.html                                   (console/resources/content/blank.html)
     content/global/console.js                                   (console/resources/content/console.js)
     content/global/console.xul                                  (console/resources/content/console.xul)
     content/global/console.css                                  (console/resources/content/console.css)
     content/global/consoleBindings.xml                          (console/resources/content/consoleBindings.xml)
     content/global/finddialog.js                                (find/resources/finddialog.js)
     content/global/finddialog.xul                               (find/resources/finddialog.xul)
     content/global/filepicker.js				(filepicker/res/content/filepicker.js)
     content/global/filepicker.xul				(filepicker/res/content/filepicker.xul)