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 959 (Enable auto-completion of built-in members)

  • Loading branch information...
commit 40a5c9d5703ddcf0b4d7bf38e2d1449fff143288 1 parent 191f202
Simon Lindholm authored
2  tests/content/console/completion/3394/issue3394.js
@@ -9,7 +9,7 @@ function runTest()
9 9
             var panel = FW.Firebug.chrome.selectPanel("console");
10 10
 
11 11
             FBTest.clearAndTypeCommand("loc");
12  
-            FBTest.synthesizeKey("VK_TAB", null, win); // 9 == tab
  12
+            FBTest.synthesizeKey("VK_TAB", null, win);
13 13
 
14 14
             var doc = FW.Firebug.chrome.window.document;
15 15
             var cmdLine = doc.getElementById("fbCommandLine");
6  tests/content/console/completion/4233/issue4233.html
@@ -3,6 +3,10 @@
3 3
 <head>
4 4
   <title>Test Case for Issue #4233</title>
5 5
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  6
+<script>
  7
+var htmlCollection = document.getElementsByTagName("html");
  8
+var anArray = [1,2,3,4];
  9
+</script>
6 10
 </head>
7 11
 <body>
8 12
 
@@ -80,6 +84,8 @@
80 84
     <li><code style="color:green">function([i</code></li>
81 85
     <li><code style="color:green">[{set a([i</code></li>
82 86
     <li><code style="color:green">id(eval('window')).i</code></li>
  87
+    <li><code style="color:green">anArray.0</code></li>
  88
+    <li><code style="color:green">htmlCollection.0</code></li>
83 89
     <li><code style="color:green">(window).i</code></li>
84 90
     <li><code style="color:green">q='';q.s</code></li>
85 91
 </ul>
5  tests/content/console/completion/4233/issue4233.js
@@ -19,7 +19,7 @@ function runTest()
19 19
                 cmdLine.value = expr.slice(0, -1);
20 20
                 FBTest.synthesizeKey(expr.slice(-1), null, win);
21 21
 
22  
-                var hasCompletion = (completionBox.value.length > cmdLine.value.length);
  22
+                var hasCompletion = (completionBox.value.length > expr.length);
23 23
                 FBTest.compare(shouldComplete, hasCompletion,
24 24
                     "Completions should " + (shouldComplete ? "" : "not ") +
25 25
                     "appear for: " + expr);
@@ -89,6 +89,9 @@ function runTest()
89 89
                 ["String.prototype.ch", true],
90 90
                 ["new Date().g", true],
91 91
 
  92
+                ["anArray.0", false],
  93
+                ["htmlCollection.0", false],
  94
+
92 95
                 // currently not handled
93 96
                 ["(window).i", false],
94 97
                 ["q='';q.s", false]
65  tests/content/console/completion/959/issue959.html
... ...
@@ -0,0 +1,65 @@
  1
+<!DOCTYPE html>
  2
+<html>
  3
+    <head>
  4
+        <meta charset="UTF-8"/>
  5
+        <title>Issue 959: Enable auto-completion of built-in members</title>
  6
+        <link href="../../../_common/testcase.css" type="text/css" rel="stylesheet"/>
  7
+        <script>
  8
+
  9
+obj1 = Object.create(null, {
  10
+    aa1: { enumerable: false, configurable: false, set: function() { for (;;) { /* break everything */ } }},
  11
+    aa2: { value: 1 }
  12
+});
  13
+obj2 = Object.create({}, {
  14
+    aa1: { enumerable: false, configurable: false, set: function() { for (;;) { /* break everything */ } }},
  15
+    aa2: { value: 1 }
  16
+});
  17
+        </script>
  18
+    </head>
  19
+    <body>
  20
+        <header>
  21
+        <h1><a href="http://code.google.com/p/fbug/issues/detail?id=959">Issue 959</a>: Enable auto-completion of built-in members</h1>
  22
+        </header>
  23
+        <div>
  24
+            <section id="description">
  25
+                <h3>Steps to reproduce</h3>
  26
+                <ol>
  27
+                    <li>Verify the following completions:
  28
+                        <ul>
  29
+                            <li><code>Object.prototype.</code> -&gt; <code>toString</code> (with popup)</li>
  30
+                            <li><code>Object.</code> -&gt; <code>prototype</code> (with popup)</li>
  31
+                            <li><code>Object.getOwn</code> -&gt; <code>propertyNames</code> (with popup)</li>
  32
+                            <li><code>do</code> -&gt; <code>cument</code> (without popup)</li>
  33
+                            <li><code>document._</code> -&gt; <code>_proto__</code> (without popup)</li>
  34
+                            <li><code>obj1.</code> -&gt; <code>aa1</code> (with popup)</li>
  35
+                            <li><code>obj2.</code> -&gt; <code>aa1</code> (with popup)</li>
  36
+                        </ul>
  37
+                    </li>
  38
+                    <li>Verify that the following completions are avoided unless they are the only
  39
+                    option (e.g. by creating a similar property in the console)</li>
  40
+                        <ul>
  41
+                            <li><code>String.prototype.toLocaleUpperCase</code></li>
  42
+                            <li><code>''.toLocaleUpperCase</code></li>
  43
+                            <li><code>tostring</code></li>
  44
+                            <li><code>alert.arguments</code></li>
  45
+                            <li><code>document.body.__lookupGetter__</code></li>
  46
+                            <li><code>document.body.vLink</code></li>
  47
+                        </ul>
  48
+                    </li>
  49
+                </ol>
  50
+                <h3>Expected Results</h3>
  51
+                <ul>
  52
+                    <li>All properties should be completeable.</li>
  53
+                    <li>A subset of annoying properties should never appear in completion popups
  54
+                    (except on Ctrl+Space), nor be findable with up/down as long as there are
  55
+                    properties not from that subset.</li>
  56
+                    <li><code>Object.prototype.</code> should show every Object-general property,
  57
+                    but e.g. <code>document.</code> should not.</li>
  58
+                </ul>
  59
+            </section>
  60
+            <footer>
  61
+                Simon Lindholm, simon.lindholm10@gmail.com
  62
+            </footer>
  63
+        </div>
  64
+    </body>
  65
+</html>
72  tests/content/console/completion/959/issue959.js
... ...
@@ -0,0 +1,72 @@
  1
+function runTest()
  2
+{
  3
+    FBTest.sysout("issue959.START");
  4
+    FBTest.setPref("commandLineShowCompleterPopup", true);
  5
+    FBTest.openNewTab(basePath + "console/completion/959/issue959.html", function(win)
  6
+    {
  7
+        FBTest.openFirebug();
  8
+        FBTest.enableConsolePanel(function(win)
  9
+        {
  10
+            var panel = FW.Firebug.chrome.selectPanel("console");
  11
+
  12
+            var doc = FW.Firebug.chrome.window.document;
  13
+            var cmdLine = doc.getElementById("fbCommandLine");
  14
+            var completionBox = doc.getElementById("fbCommandLineCompletion");
  15
+            var popup = doc.getElementById("fbCommandLineCompletionList");
  16
+            cmdLine.value = "";
  17
+
  18
+            function testWithPopup(callback, expr, wanted, wantedPopup)
  19
+            {
  20
+                // To save on time, only send the last character as a key press.
  21
+                cmdLine.focus();
  22
+                cmdLine.value = expr.slice(0, -1);
  23
+                FBTest.synthesizeKey(expr.slice(-1), null, win);
  24
+
  25
+                FBTest.compare(expr + wanted, completionBox.value,
  26
+                    "Completing \"" + expr + "|" + wanted + "\"");
  27
+                FBTest.compare(wantedPopup, (popup.state !== "closed"),
  28
+                    "Completion box should " + (wantedPopup ? "" : "not ") + " open.");
  29
+
  30
+                callback();
  31
+            }
  32
+
  33
+            function testHidden(callback, expr)
  34
+            {
  35
+                // Add one shown property - if the popup shows there must have been
  36
+                // another one before.
  37
+                // (N.B., in the case expr = "''.toLocaleU" the eval doesn't
  38
+                // work, but this is okay because the correct property is set
  39
+                // on String.prototype just before.)
  40
+                win.wrappedJSObject.eval(expr + "2 = 0");
  41
+
  42
+                cmdLine.focus();
  43
+                cmdLine.value = expr.slice(0, -1);
  44
+                FBTest.synthesizeKey(expr.slice(-1), null, win);
  45
+                FBTest.compare("closed", popup.state, "Completion box should not open.");
  46
+
  47
+                callback();
  48
+            }
  49
+
  50
+            var tasks = new FBTest.TaskList();
  51
+            tasks.push(testWithPopup, "Object.prototype.", "toString", true);
  52
+            tasks.push(testWithPopup, "Object.", "prototype", true);
  53
+            tasks.push(testWithPopup, "Object.getOwn", "PropertyNames", true);
  54
+            tasks.push(testWithPopup, "do", "cument", false);
  55
+            tasks.push(testWithPopup, "document._", "_proto__", false);
  56
+            tasks.push(testWithPopup, "obj1.", "aa1", true);
  57
+            tasks.push(testWithPopup, "obj2.", "aa1", true);
  58
+
  59
+            tasks.push(testHidden, "String.prototype.toLocaleU");
  60
+            tasks.push(testHidden, "''.toLocaleU");
  61
+            tasks.push(testHidden, "tos");
  62
+            tasks.push(testHidden, "document.body.__lo");
  63
+            tasks.push(testHidden, "alert.arg");
  64
+            tasks.push(testHidden, "document.body.vLin");
  65
+
  66
+            tasks.run(function()
  67
+            {
  68
+                FBTest.testDone("issue959.DONE");
  69
+            }, 0);
  70
+        });
  71
+    });
  72
+}
1  tests/content/firebug.html
@@ -141,6 +141,7 @@
141 141
     {group: "console/api",        uri: "console/api/trace.js",                    desc: "Test for console.trace API.", testPage: "console/api/trace.html" },
142 142
     {group: "console/api",        uri: "console/api/warn.js",                     desc: "Test for console.warn API.", testPage: "console/api/warn.html" },
143 143
     {group: "console/completion", uri: "console/completion/index/index.js",       desc: "Completions involving []-access.", testPage: "console/completion/index/index.html"},
  144
+    {group: "console/completion", uri: "console/completion/959/issue959.js",      desc: "Issue 959: Enable auto-completion of built-in members", testPage: "console/completion/959/issue959.html" },
144 145
     {group: "console/completion", uri: "console/completion/3394/issue3394.js",    desc: "Issue 3394: TAB Key does not finish an autocomplete keyword in Gnome (Ubuntu)", testPage: "console/completion/3394/issue3394.html" },
145 146
     {group: "console/completion", uri: "console/completion/3421/issue3421.js",    desc: "Issue 3421: Autocompletion expression parsing is wrong", testPage: "console/completion/3421/issue3421.html" },
146 147
     {group: "console/completion", uri: "console/completion/3466/issue3466.js",    desc: "Issue 3466: Can not use dir() command in console's command line", testPage: "console/completion/3466/issue3466.html" },

0 notes on commit 40a5c9d

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