Skip to content

Commit

Permalink
issue6268: add FBTests
Browse files Browse the repository at this point in the history
  • Loading branch information
fflorent committed May 4, 2013
1 parent 9fac439 commit 58d880b
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/FBTest/content/FBTestFirebug.js
Expand Up @@ -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);
Expand Down
71 changes: 71 additions & 0 deletions 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:

This comment has been minimized.

Copy link
@simonlindholm

simonlindholm May 4, 2013

Member

console.log, I guess.

This comment has been minimized.

Copy link
@fflorent

fflorent May 4, 2013

Author Member

Yes

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>
65 changes: 65 additions & 0 deletions 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();
}
1 change: 1 addition & 0 deletions tests/content/firebug.html
Expand Up @@ -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" },
Expand Down

3 comments on commit 58d880b

@simonlindholm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@fflorent
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@simonlindholm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.