Skip to content

Commit

Permalink
devtools: allow toggling debug flags via url params
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Aug 25, 2016
1 parent c6962d1 commit 5e88664
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions resources/unpacked/devtools/front_end/dirac/dirac.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,28 @@ Object.assign(window.dirac, (function() {
"beautify-function-names"];

function hasFeature(feature) {
var flag = featureFlags[feature];
const flag = featureFlags[feature];
if (flag !== undefined) {
return flag;
}
var featureIndex = knownFeatureFlags.indexOf(feature);
const featureIndex = knownFeatureFlags.indexOf(feature);
if (featureIndex === -1) {
return true;
}
var activeFlags = Runtime.queryParam("dirac_flags") || "";
var result = activeFlags[featureIndex] !== '0';
const activeFlags = Runtime.queryParam("dirac_flags") || "";
const result = activeFlags[featureIndex] !== '0';
featureFlags[feature] = result;
return result;
}

function hasDebugFlag(flagName) {
if (Runtime.queryParam("debug_all") == "1") {
return true;
}
const paramName = "debug_" + flagName.toLowerCase();
return Runtime.queryParam(paramName) == "1";
}

// taken from https://github.com/joliss/js-string-escape/blob/master/index.js
function stringEscape(string) {
return ('' + string).replace(/["'\\\n\r\u2028\u2029]/g, function(character) {
Expand Down Expand Up @@ -242,14 +250,14 @@ Object.assign(window.dirac, (function() {

// don't forget to update externs.js too
return {
_DEBUG_EVAL: false,
_DEBUG_COMPLETIONS: false,
_DEBUG_KEYSIM: false,
_DEBUG_FEEDBACK: false,
_DEBUG_WATCHING: false,
_DEBUG_CACHES: false,
_DEBUG_BACKEND_API: false,
_DEBUG_BACKEND_CSS: false,
_DEBUG_EVAL: hasDebugFlag("eval"),
_DEBUG_COMPLETIONS: hasDebugFlag("completions"),
_DEBUG_KEYSIM: hasDebugFlag("keysim"),
_DEBUG_FEEDBACK: hasDebugFlag("feedback"),
_DEBUG_WATCHING: hasDebugFlag("watching"),
_DEBUG_CACHES: hasDebugFlag("caches"),
_DEBUG_BACKEND_API: hasDebugFlag("backend_api"),
_DEBUG_BACKEND_CSS: hasDebugFlag("backend_css"),

// -- feature toggles -----------------------------------------------------------------------------------------------
hasREPL: hasFeature("enable-repl"),
Expand Down

0 comments on commit 5e88664

Please sign in to comment.