Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

issue6268: add FBTests

  • Loading branch information...
commit 58d880b09e03ca443bc7de19648801ff38a95943 1 parent 9fac439
@fflorent fflorent authored
View
13 tests/FBTest/content/FBTestFirebug.js
@@ -2658,6 +2658,19 @@ this.TaskList.prototype =
this.tasks.push(FW.FBL.bind.apply(this, args));
},
+ /**
+ * Wrap a function that does not take a callback parameter and push it to the list.
+ */
+ wrapAndPush: function(func)
+ {
+ var args = Array.prototype.slice.call(arguments, 1);
+ this.push(function(callback)
+ {
+ func.apply(null, args);
+ callback();
+ });
+ },
+
run: function(callback, delay)
{
FBTest.runTestSuite(this.tasks, callback, delay);
View
71 tests/content/console/6268/issue6268.html
@@ -0,0 +1,71 @@
+
+<!DOCTYPE html>
+<html>
+ <!--
+ STEPS TO CREATE A TEST CASE:
+ 5. Add the exact steps to reproduce the test case under "Steps to reproduce"
+ 6. Describe what is expected to see under "Expected result"
+ 7. Add your contact information
+ 8. Remove all template comments
+ -->
+ <head>
+ <!--
+ Add the issue number and title here.
+ -->
+ <title>Issue 6268: Expose a clean "console" object to the Command Line</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link href="../../_common/testcase.css" type="text/css" rel="stylesheet"/>
+ <script>
+ // hack console.debug from the webpage:
@simonlindholm Owner

console.log, I guess.

@fflorent Owner
fflorent added a note

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ var numberOfCalls = 0;
+ console.log = function(invokerName)
+ {
+ numberOfCalls++;
+ }
+ function setExpandos()
+ {
+ // console expandos:
+ console.expando = "webpage";
+ console.webpageExpando = "webpage";
+ }
+ </script>
+ </head>
+ <body>
+ <header>
+ <h1><a href="http://code.google.com/p/fbug/issues/detail?id=6268">Issue 6268</a>: Expose a clean "console" object to the Command Line</h1>
+ </header>
+ <div>
+ <section id="content">
+ <button onclick="setExpandos()" id="setExpandos">Set console expandos</button>
+ <button onclick="console.log()" id="hackedConsoleLog">Hacked console.log</button>
+ </section>
+ <section id="description">
+ <!--
+ The steps to reproduce the test case should be described here in detail.
+ -->
+ <h3>Steps to reproduce</h3>
+ <ol>
+ <li>Open Firebug</li>
+ <li>Enable and switch to the Console Panel</li>
+ <li>Execute: <code>console === window.console</code> (should return <code>false</code>)</li>
+ <li>Execute: <code>console.expando = "commandLine"</code></li>
+ <li>Click on the <i>Set console expandos</i> button</li>
+ <li>Execute: <code>console.expando</code> (should return <code>"commandLine"</code></li>
+ <li>Execute: <code>console.webpageExpando</code> (should return <code>"webpage"</code></li>
+ <li>Execute: <code>console.log("commandLine")</code> (should display <code>"commandLine"</code></li>
+ <li>Execute: <code>window.console.log("console")</code></li>
+ <li>Click on "Hacked console.log"</li>
+ <li>Execute: <code>console.log = function(){window.hackedFromCL = true;}</code>
+ <li>Click again on "Hacked console.log"</li>
+ <li>Execute: <code>hackedFromCL</code> (should return true)</li>
+ <li>Execute: <code>numberOfCalls</code> (should be 2)</li>
+ <li>Execute: <code>console.debug() === "_firebugIgnore"</code> (should be <code>true</code>)</li>
+ <li>Execute: <code>window.console.debug() === undefined</code> (should be <code>true</code>)</li>
+ </ol>
+ </section>
+ <footer>
+ Florent FAYOLLE, florent.fayolle69@gmail.com
+ </footer>
+ </div>
+ </body>
+</html>
View
65 tests/content/console/6268/issue6268.js
@@ -0,0 +1,65 @@
+function runTest()
+{
+ FBTest.sysout("issue6268.START");
+
+ FBTest.openNewTab(basePath + "console/6268/issue6268.html", function(win)
+ {
+ FBTest.openFirebug();
+
+ FBTest.enableConsolePanel(function(win)
+ {
+ var $id = document.getElementById.bind(win.document);
+ FBTest.selectPanel("console");
+ var tasks = new FBTest.TaskList();
+
+ // 3.
+ tasks.push(FBTest.executeCommandAndVerify, "console === window.console", "false",
+ "span", "objectBox-number");
+ // 4.
+ tasks.wrapAndPush(FBTest.executeCommand, "console.expando = 'commandLine'");
+ // 5.
+ tasks.wrapAndPush(FBTest.click, $id("setExpandos"), win);
+ // 6.
+ tasks.push(FBTest.executeCommandAndVerify, "console.expando", '"commandLine"',
+ "span", "objectBox-string");
+ // 7.
+ tasks.push(FBTest.executeCommandAndVerify, "console.webpageExpando", '"webpage"',
+ "span", "objectBox-string");
+ // 8.
+ tasks.push(FBTest.executeCommandAndVerify, "console.log('commandLine');",
+ "commandLine", "div", "logRow-log");
+ // 9.
+ tasks.wrapAndPush(FBTest.executeCommand, "window.console.log('console');");
+ // 10.
+ tasks.wrapAndPush(FBTest.click, $id("hackedConsoleLog"), win);
+ // 11.
+ tasks.wrapAndPush(FBTest.executeCommand,
+ "console.log = function(){window.hackedFromCL = true;}");
+ // 12.
+ tasks.wrapAndPush(FBTest.click, $id("hackedConsoleLog"), win);
+ // 13.
+ tasks.push(FBTest.executeCommandAndVerify, "hackedFromCL", "true", "span",
+ "objectBox-number");
+ // 14.
+ tasks.push(FBTest.executeCommandAndVerify, "window.numberOfCalls", 2, "span",
+ "objectBox-number");
+ // 15.
+ tasks.push(FBTest.executeCommandAndVerify, "console.debug() === '_firebugIgnore'",
+ "true", "span", "objectBox-number");
+ // 16.
+ tasks.push(FBTest.executeCommandAndVerify,
+ "window.console.debug() === undefined", "true", "span", "objectBox-number");
+
+ tasks.run(function()
+ {
+ FBTest.testDone("issue6268.DONE");
+ });
+ });
+ });
+}
+
+function click(callback, win, id)
+{
+ FBTest.click(win.document.getElementById(id));
+ callback();
+}
View
1  tests/content/firebug.html
@@ -122,6 +122,7 @@
{group: "console", uri: "console/6104/issue6104.js", desc: "Firebug should display DOMTokenList content", testPage: "console/6104/issue6104.html"},
{group: "console", uri: "console/5786/issue5786.js", desc: "Show array-like objects differently than actual arrays", testPage: "console/5786/issue5786.html"},
{group: "console", uri: "console/6116/issue6116.js", desc: "undefined values are ignored in string formatting of console.log", testPage: "console/6116/issue6116.html"},
+ {group: "console", uri: "console/6268/issue6268.js", desc: "Expose a clean \"console\" object to the Command Line", testPage: "console/6268/issue6268.html"},
{group: "console", uri: "console/6356/issue6356.js", desc: "Value attribute doesn't show up in console: follow-ups", testPage: "console/6356/issue6356.html"},
{group: "console/spy", uri: "console/spy/2285/issue2285.js", desc: "support for content-type: multipart/x-mixed-replace", testPage: "console/spy/2285/issue2285.html" },
{group: "console/spy", uri: "console/spy/2462/issue2462.js", desc: "The firebug console still shows the xhr in progress if you abort it (via request.abort()) ", testPage: "console/spy/2462/issue2462.html" },

3 comments on commit 58d880b

@simonlindholm

Test also that window.console.warn("") === undefined.

@fflorent
Owner

I test at step 16 that window.console.debug() === undefined.
What case this test would cover that the above step does not?

@simonlindholm

Oh, I missed it. Then it's fine. :)

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