From 58d880b09e03ca443bc7de19648801ff38a95943 Mon Sep 17 00:00:00 2001 From: Florent FAYOLLE Date: Sat, 4 May 2013 16:42:12 +0200 Subject: [PATCH] issue6268: add FBTests --- tests/FBTest/content/FBTestFirebug.js | 13 +++++ tests/content/console/6268/issue6268.html | 71 +++++++++++++++++++++++ tests/content/console/6268/issue6268.js | 65 +++++++++++++++++++++ tests/content/firebug.html | 1 + 4 files changed, 150 insertions(+) create mode 100644 tests/content/console/6268/issue6268.html create mode 100644 tests/content/console/6268/issue6268.js diff --git a/tests/FBTest/content/FBTestFirebug.js b/tests/FBTest/content/FBTestFirebug.js index 05a852c1b1..7be1446bcf 100644 --- a/tests/FBTest/content/FBTestFirebug.js +++ b/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); diff --git a/tests/content/console/6268/issue6268.html b/tests/content/console/6268/issue6268.html new file mode 100644 index 0000000000..22cbfd3199 --- /dev/null +++ b/tests/content/console/6268/issue6268.html @@ -0,0 +1,71 @@ + + + + + + + Issue 6268: Expose a clean "console" object to the Command Line + + + + + +
+

Issue 6268: Expose a clean "console" object to the Command Line

+
+
+
+ + +
+
+ +

Steps to reproduce

+
    +
  1. Open Firebug
  2. +
  3. Enable and switch to the Console Panel
  4. +
  5. Execute: console === window.console (should return false)
  6. +
  7. Execute: console.expando = "commandLine"
  8. +
  9. Click on the Set console expandos button
  10. +
  11. Execute: console.expando (should return "commandLine"
  12. +
  13. Execute: console.webpageExpando (should return "webpage"
  14. +
  15. Execute: console.log("commandLine") (should display "commandLine"
  16. +
  17. Execute: window.console.log("console")
  18. +
  19. Click on "Hacked console.log"
  20. +
  21. Execute: console.log = function(){window.hackedFromCL = true;} +
  22. Click again on "Hacked console.log"
  23. +
  24. Execute: hackedFromCL (should return true)
  25. +
  26. Execute: numberOfCalls (should be 2)
  27. +
  28. Execute: console.debug() === "_firebugIgnore" (should be true)
  29. +
  30. Execute: window.console.debug() === undefined (should be true)
  31. +
+
+ +
+ + diff --git a/tests/content/console/6268/issue6268.js b/tests/content/console/6268/issue6268.js new file mode 100644 index 0000000000..9f68de783c --- /dev/null +++ b/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(); +} diff --git a/tests/content/firebug.html b/tests/content/firebug.html index d5d36dcde9..7aeb4187c3 100644 --- a/tests/content/firebug.html +++ b/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" },