NumberType.prototype.parse = function(arg) { if (arg.text.replace(/\s/g, '').length === 0) { return new Conversion(undefined, arg, Status.INCOMPLETE, ''); } var value = parseInt(arg.text, 10); if (isNaN(value)) { return new Conversion(undefined, arg, Status.ERROR, l10n.lookupFormat('typesNumberNan', [ arg.text ])); } var max = this.getMax(); if (max != null && value > max) { return new Conversion(undefined, arg, Status.ERROR, l10n.lookupFormat('typesNumberMax', [ value, max ])); } var min = this.getMin(); if (min != null && value < min) { return new Conversion(undefined, arg, Status.ERROR, l10n.lookupFormat('typesNumberMin', [ value, min ])); } return new Conversion(value, arg); };
exec: function* (args, context) { let document = context.environment.document; let library = args.library; let name = (library.type === "selection") ? library.selection.name : library.url; let src = (library.type === "selection") ? library.selection.src : library.url; if (context.environment.window.location.protocol == "https:") { src = src.replace(/^http:/, "https:"); } try { // Check if URI is valid Services.io.newURI(src, null, null); } catch (e) { return l10n.lookupFormat("injectFailed", [name]); } let newSource = document.createElement("script"); newSource.setAttribute("src", src); let loadPromise = listenOnce(newSource, "load"); document.head.appendChild(newSource); yield loadPromise; return l10n.lookupFormat("injectLoaded", [name]); }
return OS.File.exists(clobber).then(function(exists) { if (exists) { let str = Cc["@mozilla.org/supports-string;1"] .createInstance(Ci.nsISupportsString); str.data = args.srcdir; Services.prefs.setComplexValue("devtools.loader.srcdir", Ci.nsISupportsString, str); devtools.reload(); return l10n.lookupFormat("toolsSrcdirReloaded2", [ args.srcdir ]); } return l10n.lookupFormat("toolsSrcdirNotFound2", [ args.srcdir ]); });
NodeType.prototype.parse = function(arg) { if (arg.text === '') { return new Conversion(undefined, arg, Status.INCOMPLETE); } var nodes; try { nodes = doc.querySelectorAll(arg.text); } catch (ex) { return new Conversion(undefined, arg, Status.ERROR, l10n.lookup('nodeParseSyntax')); } if (nodes.length === 0) { return new Conversion(undefined, arg, Status.INCOMPLETE, l10n.lookup('nodeParseNone')); } if (nodes.length === 1) { var node = nodes.item(0); node.__gcliQuery = arg.text; host.flashNodes(node, true); return new Conversion(node, arg, Status.VALID, ''); } host.flashNodes(nodes, false); return new Conversion(undefined, arg, Status.ERROR, l10n.lookupFormat('nodeParseMultiple', [ nodes.length ])); };
CommandType.prototype.parse = function(arg) { // Especially at startup, predictions live over the time that things change // so we provide a completion function rather than completion values var predictFunc = function() { return this._findPredictions(arg); }.bind(this); var predictions = this._findPredictions(arg); if (predictions.length === 0) { var msg = l10n.lookupFormat('typesSelectionNomatch', [ arg.text ]); return new Conversion(undefined, arg, Status.ERROR, msg, predictFunc); } var command = predictions[0].value; if (predictions.length === 1) { // Is it an exact match of an executable command, // or just the only possibility? if (command.name === arg.text && typeof command.exec === 'function') { return new Conversion(command, arg, Status.VALID, ''); } return new Conversion(undefined, arg, Status.INCOMPLETE, '', predictFunc); } // It's valid if the text matches, even if there are several options if (predictions[0].name === arg.text) { return new Conversion(command, arg, Status.VALID, '', predictFunc); } return new Conversion(undefined, arg, Status.INCOMPLETE, '', predictFunc); };
exec: function Restart(args, context) { let canceled = Cc["@mozilla.org/supports-PRBool;1"] .createInstance(Ci.nsISupportsPRBool); Services.obs.notifyObservers(canceled, "quit-application-requested", "restart"); if (canceled.data) { return l10n.lookup("restartBrowserRequestCancelled"); } // disable loading content from cache. if (args.nocache) { Services.appinfo.invalidateCachesOnRestart(); } const appStartup = Cc["@mozilla.org/toolkit/app-startup;1"] .getService(Ci.nsIAppStartup); if (args.safemode) { // restart in safemode appStartup.restartInSafeMode(Ci.nsIAppStartup.eAttemptQuit); } else { // restart normally appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); } return l10n.lookupFormat("restartBrowserRestarting", [ BRAND_SHORT_NAME ]); }
exec: function(cookies, context) { if (cookies.length == 0) { let host = new URL(context.environment.target.url).host; host = sanitizeHost(host); let msg = l10n.lookupFormat("cookieListOutNoneHost", [ host ]); return context.createView({ html: "<span>" + msg + "</span>" }); } for (let cookie of cookies) { cookie.expires = translateExpires(cookie.expires); let noAttrs = !cookie.secure && !cookie.httpOnly && !cookie.sameDomain; cookie.attrs = (cookie.secure ? "secure" : " ") + (cookie.httpOnly ? "httpOnly" : " ") + (cookie.sameDomain ? "sameDomain" : " ") + (noAttrs ? l10n.lookup("cookieListOutNone") : " "); } return context.createView({ html: "<ul class='gcli-cookielist-list'>" + " <li foreach='cookie in ${cookies}'>" + " <div>${cookie.name}=${cookie.value}</div>" + " <table class='gcli-cookielist-detail'>" + " <tr>" + " <td>" + l10n.lookup("cookieListOutHost") + "</td>" + " <td>${cookie.host}</td>" + " </tr>" + " <tr>" + " <td>" + l10n.lookup("cookieListOutPath") + "</td>" + " <td>${cookie.path}</td>" + " </tr>" + " <tr>" + " <td>" + l10n.lookup("cookieListOutExpires") + "</td>" + " <td>${cookie.expires}</td>" + " </tr>" + " <tr>" + " <td>" + l10n.lookup("cookieListOutAttributes") + "</td>" + " <td>${cookie.attrs}</td>" + " </tr>" + " <tr><td colspan='2'>" + " <span class='gcli-out-shortcut' onclick='${onclick}'" + " data-command='cookie set ${cookie.name} '" + " >" + l10n.lookup("cookieListOutEdit") + "</span>" + " <span class='gcli-out-shortcut'" + " onclick='${onclick}' ondblclick='${ondblclick}'" + " data-command='cookie remove ${cookie.name}'" + " >" + l10n.lookup("cookieListOutRemove") + "</span>" + " </td></tr>" + " </table>" + " </li>" + "</ul>", data: { options: { allowEval: true }, cookies: cookies, onclick: context.update, ondblclick: context.updateExec } }); }
exec: function(result, context) { let propertyName = result.property; let document = context.document; let root = document.createElement("div"); if (result.error) { // The css property specified doesn't exist. root.appendChild(document.createTextNode( l10n.lookupFormat("mdnCssPropertyNotFound", [ propertyName ]) + " (" + result.error + ")")); } else { let title = document.createElement("h2"); title.textContent = propertyName; root.appendChild(title); let link = document.createElement("p"); link.classList.add("gcli-mdn-url"); link.textContent = l10n.lookup("mdnCssVisitPage"); root.appendChild(link); link.addEventListener("click", () => { let gBrowser = context.environment.chromeWindow.gBrowser; gBrowser.selectedTab = gBrowser.addTab(result.url); }); let summary = document.createElement("p"); summary.textContent = result.data.summary; root.appendChild(summary); } return root; }
/** * Create a block of data suitable to be passed to the help_list.html template */ function getListTemplateData(args, context) { var matchingCommands = canon.getCommands().filter(function(command) { if (command.hidden) { return false; } if (args.search && command.name.indexOf(args.search) !== 0) { // Filtered out because they don't match the search return false; } if (!args.search && command.name.indexOf(' ') != -1) { // We don't show sub commands with plain 'help' return false; } return true; }); matchingCommands.sort(function(c1, c2) { return c1.name.localeCompare(c2.name); }); var heading; if (matchingCommands.length === 0) { heading = l10n.lookupFormat('helpListNone', [ args.search ]); } else if (args.search == null) { heading = l10n.lookup('helpListAll'); } else { heading = l10n.lookupFormat('helpListPrefix', [ args.search ]); } return { l10n: l10n.propertyLookup, includeIntro: args.search == null, matchingCommands: matchingCommands, heading: heading, onclick: function(ev) { util.updateCommand(ev.currentTarget, context); }, ondblclick: function(ev) { util.executeCommand(ev.currentTarget, context); }, }; }
exec: function(args, context) { if (isMultiProcess(context)) { return l10n.lookupFormat("notAvailableInE10S", [this.name]); } let chromeWindow = context.environment.chromeDocument.defaultView; let Tilt = TiltManager.getTiltForBrowser(chromeWindow); Tilt.toggle(); }
exec: function(args, context) { if (isMultiProcess(context)) { return l10n.lookupFormat("notAvailableInE10S", [this.name]); } let chromeWindow = context.environment.chromeDocument.defaultView; let Tilt = TiltManager.getTiltForBrowser(chromeWindow); if (Tilt.currentInstance) { Tilt.currentInstance.controller.arcball.translate([args.x, args.y]); } }
exec: function(args, context) { let numDebuggers = debuggers.length; if (numDebuggers == 0) { return l10n.lookup("calllogStopNoLogging"); } for (let dbg of debuggers) { dbg.onEnterFrame = undefined; } debuggers = []; return l10n.lookupFormat("calllogStopReply", [ numDebuggers ]); }
xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { reply.href = xhr.response.data.link; reply.destinations.push(l10n.lookupFormat("screenshotImgurUploaded", [ reply.href ])); } else { reply.destinations.push(l10n.lookup("screenshotImgurError")); } resolve(); } };
exec: function(args, context) { var listener = debuggerServer.createListener(); if (!listener) { throw new Error(l10n.lookup("listenDisabledOutput")); } listener.portOrPath = args.port; listener.open(); if (debuggerServer.initialized) { return l10n.lookupFormat("listenInitOutput", [ "" + args.port ]); } return l10n.lookup("listenNoInitOutput"); },
function showFolder(path) { let NSLocalFile = CC("@mozilla.org/file/local;1", "nsIFile", "initWithPath"); try { let file = new NSLocalFile(path); if (file.exists()) { file.reveal(); return l10n.lookupFormat("folderOpenDirResult", [path]); } return l10n.lookup("folderInvalidPath"); } catch (e) { return l10n.lookup("folderInvalidPath"); } }
exec: function(args, context) { let numDebuggers = chromeDebuggers.length; if (numDebuggers == 0) { return l10n.lookup("calllogChromeStopNoLogging"); } for (let dbg of chromeDebuggers) { dbg.onEnterFrame = undefined; dbg.enabled = false; } for (let sandbox of sandboxes) { Cu.nukeSandbox(sandbox); } chromeDebuggers = []; sandboxes = []; return l10n.lookupFormat("calllogChromeStopReply", [ numDebuggers ]); }
/** * Model an instanceof SelectionType as a select input box. * <p>There are 3 slightly overlapping concepts to be aware of: * <ul> * <li>value: This is the (probably non-string) value, known as a value by the * assignment * <li>optValue: This is the text value as known by the DOM option element, as * in <option value=???%gt... * <li>optText: This is the contents of the DOM option element. * </ul> */ function SelectionField(type, options) { this.document = options.document; this.type = type; this.items = []; this.element = dom.createElement(this.document, 'select'); this.element.style.width = '180px'; this._addOption({ name: l10n.lookupFormat('fieldSelectionSelect', [ options.name ]) }); var lookup = this.type.getLookup(); lookup.forEach(this._addOption, this); this.onInputChange = this.onInputChange.bind(this); this.element.addEventListener('change', this.onInputChange, false); this.fieldChanged = createEvent('SelectionField.fieldChanged'); }
/** * Model an instanceof SelectionType as a select input box. * <p>There are 3 slightly overlapping concepts to be aware of: * <ul> * <li>value: This is the (probably non-string) value, known as a value by the * assignment * <li>optValue: This is the text value as known by the DOM option element, as * in <option value=???%gt... * <li>optText: This is the contents of the DOM option element. * </ul> */ function SelectionField(type, options) { Field.call(this, type, options); this.items = []; this.element = dom.createElement(this.document, 'select'); this.element.classList.add('gcli-field'); this._addOption({ name: l10n.lookupFormat('fieldSelectionSelect', [ options.name ]) }); var lookup = this.type.getLookup(); lookup.forEach(this._addOption, this); this.onInputChange = this.onInputChange.bind(this); this.element.addEventListener('change', this.onInputChange, false); this.fieldChanged = createEvent('SelectionField.fieldChanged'); }
exec: function (args, context) { // Remove all existing highlighters unless told otherwise if (!args.keep) { unhighlightAll(); } let env = context.environment; highlighterEnv = new HighlighterEnvironment(); highlighterEnv.initFromWindow(env.window); // Unhighlight on navigate highlighterEnv.once("will-navigate", unhighlightAll); let i = 0; for (let node of args.selector) { if (!args.showall && i >= MAX_HIGHLIGHTED_ELEMENTS) { break; } let highlighter = new BoxModelHighlighter(highlighterEnv); if (args.fill) { highlighter.regionFill[args.region] = args.fill; } highlighter.show(node, { region: args.region, hideInfoBar: !args.showinfobar, hideGuides: args.hideguides, showOnly: args.region }); exports.highlighters.push(highlighter); i++; } let highlightText = L10N.getStr("highlightOutputConfirm2"); let output = PluralForm.get(args.selector.length, highlightText) .replace("%1$S", args.selector.length); if (args.selector.length > i) { output = l10n.lookupFormat("highlightOutputMaxReached", ["" + args.selector.length, "" + i]); } return output; }
/** * We may have a filename specified in args, or we might have to generate * one. */ function getFilename(defaultName) { // Create a name for the file if not present if (defaultName != FILENAME_DEFAULT_VALUE) { return defaultName; } const date = new Date(); let dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); dateString = dateString.split("-").map(function(part) { if (part.length == 1) { part = "0" + part; } return part; }).join("-"); const timeString = date.toTimeString().replace(/:/g, ".").split(" ")[0]; return l10n.lookupFormat("screenshotGeneratedFilename", [ dateString, timeString ]) + ".png"; }
SelectionType.prototype.parse = function(arg) { var predictions = this._findPredictions(arg); if (predictions.length === 0) { var msg = l10n.lookupFormat('typesSelectionNomatch', [ arg.text ]); return new Conversion(undefined, arg, Status.ERROR, msg, predictions); } // This is something of a hack it basically allows us to tell the // setting type to forget its last setting hack. if (this.noMatch) { this.noMatch(); } if (predictions[0].name === arg.text) { var value = predictions[0].value; return new Conversion(value, arg, Status.VALID, '', predictions); } return new Conversion(undefined, arg, Status.INCOMPLETE, '', predictions); };
exec: function (args, context) { let listener = debuggerServer.createListener(); if (!listener) { throw new Error(l10n.lookup("listenDisabledOutput")); } let webSocket = false; if (args.protocol === "websocket") { webSocket = true; } else if (args.protocol === "mozilla-rdp") { webSocket = false; } listener.portOrPath = args.port; listener.webSocket = webSocket; listener.open(); if (debuggerServer.initialized) { return l10n.lookupFormat("listenInitOutput", [ "" + args.port ]); } return l10n.lookup("listenNoInitOutput"); },
NodeType.prototype.parse = function(arg) { if (arg.text === '') { return new Conversion(null, arg, Status.INCOMPLETE, l10n.lookup('nodeParseNone')); } var nodes; try { nodes = doc.querySelectorAll(arg.text); } catch (ex) { return new Conversion(null, arg, Status.ERROR, l10n.lookup('nodeParseSyntax')); } if (nodes.length === 0) { return new Conversion(null, arg, Status.INCOMPLETE, l10n.lookup('nodeParseNone')); } if (nodes.length === 1) { var node = nodes.item(0); node.__gcliQuery = arg.text; host.flashNode(node, 'green'); return new Conversion(node, arg, Status.VALID, ''); } Array.prototype.forEach.call(nodes, function(n) { host.flashNode(n, 'red'); }); return new Conversion(null, arg, Status.ERROR, l10n.lookupFormat('nodeParseMultiple', [ nodes.length ])); };
const { Cc, Ci, Cu } = require("chrome"); const Services = require("Services"); const { OS } = require("resource://gre/modules/osfile.jsm"); const { devtools } = require("resource://devtools/shared/Loader.jsm"); const gcli = require("gcli/index"); const l10n = require("gcli/l10n"); const BRAND_SHORT_NAME = Cc["@mozilla.org/intl/stringbundle;1"] .getService(Ci.nsIStringBundleService) .createBundle("chrome://branding/locale/brand.properties") .GetStringFromName("brandShortName"); exports.items = [ { name: "tools", description: l10n.lookupFormat("toolsDesc2", [ BRAND_SHORT_NAME ]), manual: l10n.lookupFormat("toolsManual2", [ BRAND_SHORT_NAME ]), get hidden() { return gcli.hiddenByChromePref(); } }, { item: "command", runAt: "client", name: "tools srcdir", description: l10n.lookup("toolsSrcdirDesc"), manual: l10n.lookupFormat("toolsSrcdirManual2", [ BRAND_SHORT_NAME ]), get hidden() { return gcli.hiddenByChromePref(); }, params: [
}, aError => { deferred.resolve(l10n.lookupFormat("breakaddFailed", [aError])); });
exec: function (args, context) { let doc = context.environment.document; let { referrerPolicy } = doc; let pageURI = doc.documentURIObject; let sameDomainReferrer = ""; let otherDomainReferrer = ""; let downgradeReferrer = ""; let otherDowngradeReferrer = ""; let origin = pageURI.prePath; switch (referrerPolicy) { case Ci.nsIHttpChannel.REFERRER_POLICY_NO_REFERRER: // sends no referrer sameDomainReferrer = otherDomainReferrer = downgradeReferrer = otherDowngradeReferrer = "(no referrer)"; break; case Ci.nsIHttpChannel.REFERRER_POLICY_ORIGIN: // only sends the origin of the referring URL sameDomainReferrer = otherDomainReferrer = downgradeReferrer = otherDowngradeReferrer = origin; break; case Ci.nsIHttpChannel.REFERRER_POLICY_ORIGIN_WHEN_XORIGIN: // same as default, but reduced to ORIGIN when cross-origin. sameDomainReferrer = pageURI.spec; otherDomainReferrer = downgradeReferrer = otherDowngradeReferrer = origin; break; case Ci.nsIHttpChannel.REFERRER_POLICY_UNSAFE_URL: // always sends the referrer, even on downgrade. sameDomainReferrer = otherDomainReferrer = downgradeReferrer = otherDowngradeReferrer = pageURI.spec; break; case Ci.nsIHttpChannel.REFERRER_POLICY_NO_REFERRER_WHEN_DOWNGRADE: // default state, doesn't send referrer from https->http sameDomainReferrer = otherDomainReferrer = pageURI.spec; downgradeReferrer = otherDowngradeReferrer = "(no referrer)"; break; default: // this is a new referrer policy which we do not know about sameDomainReferrer = otherDomainReferrer = downgradeReferrer = otherDowngradeReferrer = "(unknown Referrer Policy)"; break; } let sameDomainUri = origin + "/*"; let referrerUrls = [ // add the referrer uri 'referrer' we would send when visiting 'uri' { uri: pageURI.scheme + "://example.com/", referrer: otherDomainReferrer, description: l10n.lookup("securityReferrerPolicyOtherDomain")}, { uri: sameDomainUri, referrer: sameDomainReferrer, description: l10n.lookup("securityReferrerPolicySameDomain")} ]; if (pageURI.schemeIs("https")) { // add the referrer we would send on downgrading http->https if (sameDomainReferrer != downgradeReferrer) { referrerUrls.push({ uri: "http://" + pageURI.hostPort + "/*", referrer: downgradeReferrer, description: l10n.lookup("securityReferrerPolicySameDomainDowngrade") }); } if (otherDomainReferrer != otherDowngradeReferrer) { referrerUrls.push({ uri: "http://example.com/", referrer: otherDowngradeReferrer, description: l10n.lookup("securityReferrerPolicyOtherDomainDowngrade") }); } } return { header: l10n.lookupFormat("securityReferrerPolicyReportHeader", [pageURI.spec]), policyName: REFERRER_POLICY_NAMES[referrerPolicy], urls: referrerUrls }; }
description: l10n.lookup("screenshotDesc"), manual: l10n.lookup("screenshotManual"), returnType: "imageSummary", buttonId: "command-button-screenshot", buttonClass: "command-button command-button-invertable", tooltipText: l10n.lookup("screenshotTooltip"), params: [ filenameParam, standardParams, { group: l10n.lookup("screenshotAdvancedOptions"), params: [ { name: "chrome", type: "boolean", description: l10n.lookupFormat("screenshotChromeDesc2", [BRAND_SHORT_NAME]), manual: l10n.lookupFormat("screenshotChromeManual2", [BRAND_SHORT_NAME]) }, ] }, ], exec: function(args, context) { if (args.chrome && args.selector) { // Node screenshot with chrome option does not work as intended // Refer https://bugzilla.mozilla.org/show_bug.cgi?id=659268#c7 // throwing for now. throw new Error(l10n.lookup("screenshotSelectorChromeConflict")); } let capture; if (!args.chrome) {
* * @param boolean nocache * Disables loading content from cache upon restart. * * Examples : * >> restart * - restarts browser immediately * >> restart --nocache * - restarts immediately and starts Firefox without using cache */ exports.items = [ { item: "command", runAt: "client", name: "restart", description: l10n.lookupFormat("restartBrowserDesc", [ BRAND_SHORT_NAME ]), params: [{ group: l10n.lookup("restartBrowserGroupOptions"), params: [ { name: "nocache", type: "boolean", description: l10n.lookup("restartBrowserNocacheDesc") }, { name: "safemode", type: "boolean", description: l10n.lookup("restartBrowserSafemodeDesc") } ] }],
"use strict"; const l10n = require("gcli/l10n"); loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true); exports.items = [ { item: "command", runAt: "client", name: "splitconsole", hidden: true, buttonId: "command-button-splitconsole", buttonClass: "command-button", tooltipText: l10n.lookupFormat("splitconsoleTooltip2", ["Esc"]), isRemoteSafe: true, state: { isChecked: function (target) { let toolbox = gDevTools.getToolbox(target); return !!(toolbox && toolbox.splitConsole); }, onChange: function (target, changeHandler) { // Register handlers for when a change event should be fired // (which resets the checked state of the button). let toolbox = gDevTools.getToolbox(target); let callback = changeHandler.bind(null, "changed", { target: target }); if (!toolbox) { return; }
serverLoader.invisibleToDebugger = true; serverLoader.main("devtools/server/main"); let debuggerServer = serverLoader.DebuggerServer; debuggerServer.init(); debuggerServer.addBrowserActors(); debuggerServer.allowChromeProcess = !l10n.hiddenByChromePref(); return debuggerServer; }); exports.items = [ { item: "command", runAt: "client", name: "listen", description: l10n.lookup("listenDesc"), manual: l10n.lookupFormat("listenManual2", [ BRAND_SHORT_NAME ]), params: [ { name: "port", type: "number", get defaultValue() { return Services.prefs.getIntPref("devtools.debugger.chrome-debugging-port"); }, description: l10n.lookup("listenPortDesc"), } ], exec: function(args, context) { var listener = debuggerServer.createListener(); if (!listener) { throw new Error(l10n.lookup("listenDisabledOutput")); }