]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/modules/javascript.jsm
Imported Upstream version 1.1+hg7904
[dactyl.git] / common / modules / javascript.jsm
index dcf206bfacce9b93c66e2e10131ef28c86748369..8555cdf2624ab1112bcd21903775a24dc73ca695 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2008-2014 Kris Maglione <maglione.k at Gmail>
 //
 // This work is licensed for reuse under an MIT license. Details are
 // given in the LICENSE.txt file included with this file.
@@ -55,7 +55,8 @@ var JavaScript = Module("javascript", {
 
     lazyInit: true,
 
-    newContext: function () this.modules.newContext(this.modules.userContext, true, "Dactyl JS Temp Context"),
+    newContext: function () this.modules.newContext(this.modules.userContext, false,
+                                                    "Dactyl JS Temp Context"),
 
     completers: Class.Memoize(() => Object.create(JavaScript.completers)),
 
@@ -72,22 +73,23 @@ var JavaScript = Module("javascript", {
         if (obj == null)
             return;
 
-        let seen = isinstance(obj, ["Sandbox"]) ? Set(JavaScript.magicalNames) : {};
+        let seen = RealSet(isinstance(obj, ["Sandbox"]) ? JavaScript.magicalNames : []);
         let globals = values(toplevel && this.window === obj ? this.globalNames : []);
 
         if (toplevel && isObject(obj) && "wrappedJSObject" in obj)
-            if (!Set.add(seen, "wrappedJSObject"))
+            if (!seen.add("wrappedJSObject"))
                 yield "wrappedJSObject";
 
-        for (let key in iter(globals, properties(obj, !toplevel, true)))
-            if (!Set.add(seen, key))
+        for (let key in iter(globals, properties(obj, !toplevel)))
+            if (!seen.add(key))
                 yield key;
 
         // Properties aren't visible in an XPCNativeWrapper until
         // they're accessed.
-        for (let key in properties(this.getKey(obj, "wrappedJSObject"), !toplevel, true))
+        for (let key in properties(this.getKey(obj, "wrappedJSObject"),
+                                   !toplevel))
             try {
-                if (key in obj && !Set.has(seen, key))
+                if (key in obj && !seen.has(key))
                     yield key;
             }
             catch (e) {}
@@ -336,9 +338,6 @@ var JavaScript = Module("javascript", {
     _complete: function (objects, key, compl, string, last) {
         const self = this;
 
-        if (!getOwnPropertyNames && !services.debugger.isOn && !this.context.message)
-            this.context.message = /*L*/"For better completion data, please enable the JavaScript debugger (:set jsdebugger)";
-
         let base = this.context.fork("js", this._top.offset);
         base.forceAnchored = true;
         base.filter = last == null ? key : string;
@@ -349,7 +348,7 @@ var JavaScript = Module("javascript", {
         else {
             base.quote = [last, text => util.escapeString(text, ""), last];
             if (prefix)
-                base.filters.push(item => item.item.indexOf(prefix) === 0);
+                base.filters.push(item => item.item.startsWith(prefix));
         }
 
         if (!compl) {
@@ -464,7 +463,7 @@ var JavaScript = Module("javascript", {
         }
 
         this.context.getCache("evalled", Object);
-        this.context.getCache("evalContext", this.closure.newContext);
+        this.context.getCache("evalContext", this.bound.newContext);
 
         // Okay, have parse stack. Figure out what we're completing.
 
@@ -635,7 +634,7 @@ var JavaScript = Module("javascript", {
         "ROCSSPrimitiveValue", "RangeError", "ReferenceError", "RegExp",
         "StopIteration", "String", "SyntaxError", "TypeError", "URIError",
         "Uint16Array", "Uint32Array", "Uint8Array", "XML", "XMLHttpProgressEvent",
-        "XMLList", "XMLSerializer", "XPCNativeWrapper", "XPCSafeJSWrapper",
+        "XMLList", "XMLSerializer", "XPCNativeWrapper",
         "XULControllers", "constructor", "decodeURI", "decodeURIComponent",
         "encodeURI", "encodeURIComponent", "escape", "eval", "isFinite", "isNaN",
         "isXMLName", "parseFloat", "parseInt", "undefined", "unescape", "uneval"
@@ -694,7 +693,7 @@ var JavaScript = Module("javascript", {
     completion: function (dactyl, modules, window) {
         const { completion } = modules;
         update(modules.completion, {
-            get javascript() modules.javascript.closure.complete,
+            get javascript() modules.javascript.bound.complete,
             javascriptCompleter: JavaScript // Backwards compatibility
         });
     },
@@ -822,8 +821,10 @@ var JavaScript = Module("javascript", {
 
             leave: function leave(params) {
                 leave.superapply(this, arguments);
-                if (!params.push)
+                if (!params.push) {
                     modes.delay(function () { modes.pop(); });
+                    Cu.nukeSandbox(this.context);
+                }
             },
 
             updatePrompt: function updatePrompt() {