Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

FBTest for issue 5867

  • Loading branch information...
commit 6478c16dac2aff69f8a436009fb46f4b12f0534d 1 parent d07d337
Jan Odvarko authored August 27, 2012
25  tests/content/commandLine/api/dir.html
... ...
@@ -0,0 +1,25 @@
  1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2
+<html>
  3
+<head>
  4
+  <title>Test Case for command line</title>
  5
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  6
+</head>
  7
+<body>
  8
+
  9
+<h1>Command Line API: dir</h1>
  10
+
  11
+<p>This test-case is intended for <b>dir</b> method.
  12
+<br/>
  13
+<i>Jan Odvarko, odvarko@gmail.com</i>
  14
+</p>
  15
+
  16
+<ol>
  17
+<li>Open Firebug and enable the Console panel.</li>
  18
+<li>Execute the following expression in the command line:<br/>
  19
+<code style="color:green">dir({'a': {'b': {'c': 1}}});</code></li>
  20
+<li>the console panel should display a log (one row) with variable a and value Object { b={...} }.</li>
  21
+<li>Expand the object a, expand the object b, collapse b and collapse a. All should work as expected.</li>
  22
+</ol>
  23
+
  24
+</body>
  25
+</html>
97  tests/content/commandLine/api/dir.js
... ...
@@ -0,0 +1,97 @@
  1
+function runTest()
  2
+{
  3
+    FBTest.sysout("console.dir.START");
  4
+
  5
+    FBTest.openNewTab(basePath + "console/api/dir.html", function(win)
  6
+    {
  7
+        FBTest.openFirebug();
  8
+        FBTest.enableConsolePanel(function(win)
  9
+        {
  10
+            var tasks = new FBTest.TaskList();
  11
+            tasks.push(test1, win);
  12
+            tasks.push(test2, win);
  13
+            tasks.run(function() {
  14
+                FBTest.testDone("console.dir.DONE");
  15
+            });
  16
+        });
  17
+    });
  18
+}
  19
+
  20
+function test1(callback, win)
  21
+{
  22
+    var config = {tagName: "div", classes: "logRow logRow-dir"};
  23
+    FBTest.waitForDisplayedElement("console", config, function(row)
  24
+    {
  25
+        var name = row.getElementsByClassName("memberLabelCell")[0];
  26
+        var value = row.getElementsByClassName("memberValueCell")[0];
  27
+
  28
+        FBTest.compare("a", name.textContent, "The variable name must be: 'a'");
  29
+        FBTest.compare("\"b\"", value.textContent, "The variable value must be: 'b'");
  30
+
  31
+        callback();
  32
+    });
  33
+
  34
+    // Execute test 1 implemented on the page.
  35
+    FBTest.executeCommand("dir({'a': 'b'});");
  36
+}
  37
+
  38
+function test2(callback, win)
  39
+{
  40
+    var config = {tagName: "div", classes: "logRow logRow-dir"};
  41
+    FBTest.waitForDisplayedElement("console", config, function(row)
  42
+    {
  43
+        var domTable = row.getElementsByClassName("domTable")[0];
  44
+
  45
+        FBTest.compare(2, domTable.rows.length, "There should be 1 row (excluding header)");
  46
+
  47
+        // Expand object 'a'.
  48
+        var labelA = domTable.getElementsByClassName("memberLabel")[0];
  49
+        expandMembers(labelA, function(rowA)
  50
+        {
  51
+            FBTest.compare(3, domTable.rows.length, "There should be 2 rows (excluding header)");
  52
+
  53
+            // Expand object 'b'.
  54
+            var labelB = domTable.getElementsByClassName("memberLabel")[1];
  55
+            expandMembers(labelB, function(rowB)
  56
+            {
  57
+                FBTest.compare(4, domTable.rows.length, "There should be 3 rows (excluding header)");
  58
+
  59
+                // Close object 'b';
  60
+                collapseMembers(labelB, function()
  61
+                {
  62
+                    FBTest.compare(3, domTable.rows.length, "There should be 2 rows (excluding header)");
  63
+
  64
+                    // Close object 'a';
  65
+                    collapseMembers(labelA, function()
  66
+                    {
  67
+                        FBTest.compare(2, domTable.rows.length, "There should be 1 rows (excluding header)");
  68
+
  69
+                        callback();
  70
+                    });
  71
+                });
  72
+            });
  73
+        });
  74
+    });
  75
+
  76
+    // Execute test 1 implemented on the page.
  77
+    FBTest.executeCommand("dir({'a': {'b': {'c': 1}}})");
  78
+}
  79
+
  80
+// xxxHonza: how to avoid following timeouts?
  81
+function expandMembers(node, callback)
  82
+{
  83
+    setTimeout(function()
  84
+    {
  85
+        callback();
  86
+    }, 200);
  87
+    FBTest.click(node);
  88
+}
  89
+
  90
+function collapseMembers(node, callback)
  91
+{
  92
+    setTimeout(function()
  93
+    {
  94
+        callback();
  95
+    }, 200);
  96
+    FBTest.click(node);
  97
+}
1  tests/content/firebug.html
@@ -155,6 +155,7 @@
155 155
     {group: "commandLine/api",    uri: "commandLine/api/monitorEvents.js",        desc: "Verify command line monitorEvents API.", testPage: "commandLine/api/monitorEvents.html" },
156 156
     {group: "commandLine/api",    uri: "commandLine/api/profile.js",              desc: "Verify command line profile & profileEnd API.", testPage: "commandLine/api/profile.html" },
157 157
     {group: "commandLine/api",    uri: "commandLine/api/help.js",                 desc: "Verify command line help API", testPage: "commandLine/api/help.html"},
  158
+    {group: "commandLine/api",    uri: "commandLine/api/dir.js",                  desc: "Verify command line dir API.", testPage: "commandLine/api/dir.html" },
158 159
     {group: "commandLine",        uri: "commandLine/dom.js",                      desc: "Verify command line DOM access.", testPage: "commandLine/dom.html" },
159 160
     {group: "commandLine",        uri: "commandLine/objects.js",                  desc: "Page objects used on the command line", testPage: "commandLine/objects.html"},
160 161
     {group: "commandLine",        uri: "commandLine/2934/issue2934.js",           desc: "1.6a7 console and auto-complete (needs 'window.' prefix)", testPage: "commandLine/2934/issue2934.html" },

0 notes on commit 6478c16

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