Permalink
Browse files

FEATURE: added repl.reloadChrome and repl.debugPrefs(true/false) util…

…ity functions
  • Loading branch information...
1 parent a7fba5b commit 0e7439af2893c85e17dd38a13215200b5b92055b @rpl committed Dec 7, 2009
Showing with 28 additions and 0 deletions.
  1. +28 −0 chrome/content/repl.js
View
28 chrome/content/repl.js
@@ -471,6 +471,34 @@ doc.doc =
'Looks up documentation for a given object, either in the doc string \
(if present) or on XULPlanet.com.';
+// COMMON CHROME ENVIRONMENT UTILITY FUNCTIONS
+// ----------------------------------------------------------------------
+
+function reloadChrome() {
+ try {
+ Components.classes["@mozilla.org/chrome/chrome-registry;1"].
+ getService(Components.interfaces.nsIXULChromeRegistry).reloadChrome();
+ } catch(e) { this.print('Exception while reloading chrome: '+e); }
+}
+
+reloadChrome.doc = "Reload all chrome packages";
+
+function debugPrefs(enabled) {
+ try {
+ var dbgPrefs = ["nglayout.debug.disable_xul_cache",
+ "javascript.options.showInConsole",
+ "browser.dom.window.dump.enabled"];
+
+ var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch);
+
+ for each (let pname in dbgPrefs) {
+ prefs.setBoolPref(pname, enabled);
+ }
+ } catch(e) { this.print('Exception while setting debugging preferences: '+e); }
+}
+
+debugPrefs.doc = "Enable/Disable common debugging preferences";
// INTERACTOR HANDLING
// ----------------------------------------------------------------------

1 comment on commit 0e7439a

@bard

479: Use Cc and Ci instead of Components.classes and Components.interfaces

483, 500: (nit) Stick to no blank line between function and doc string

486: Have the function name tell what the function does. "toggleDebugPrefs" seems a better candidate.

492: Use srvPref

496: Do I sense a tab? :)

Please sign in to comment.