michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: const gcli = require("gcli/index"); michael@0: michael@0: loader.lazyImporter(this, "AppCacheUtils", "resource:///modules/devtools/AppCacheUtils.jsm"); michael@0: michael@0: exports.items = [ michael@0: { michael@0: name: "appcache", michael@0: description: gcli.lookup("appCacheDesc") michael@0: }, michael@0: { michael@0: name: "appcache validate", michael@0: description: gcli.lookup("appCacheValidateDesc"), michael@0: manual: gcli.lookup("appCacheValidateManual"), michael@0: returnType: "appcacheerrors", michael@0: params: [{ michael@0: group: "options", michael@0: params: [ michael@0: { michael@0: type: "string", michael@0: name: "uri", michael@0: description: gcli.lookup("appCacheValidateUriDesc"), michael@0: defaultValue: null, michael@0: } michael@0: ] michael@0: }], michael@0: exec: function(args, context) { michael@0: let utils; michael@0: let deferred = context.defer(); michael@0: michael@0: if (args.uri) { michael@0: utils = new AppCacheUtils(args.uri); michael@0: } else { michael@0: utils = new AppCacheUtils(context.environment.document); michael@0: } michael@0: michael@0: utils.validateManifest().then(function(errors) { michael@0: deferred.resolve([errors, utils.manifestURI || "-"]); michael@0: }); michael@0: michael@0: return deferred.promise; michael@0: } michael@0: }, michael@0: { michael@0: item: "converter", michael@0: from: "appcacheerrors", michael@0: to: "view", michael@0: exec: function([errors, manifestURI], context) { michael@0: if (errors.length == 0) { michael@0: return context.createView({ michael@0: html: "" + gcli.lookup("appCacheValidatedSuccessfully") + "" michael@0: }); michael@0: } michael@0: michael@0: return context.createView({ michael@0: html: michael@0: "
" + michael@0: "

Manifest URI: ${manifestURI}

" + michael@0: "
    " + michael@0: "
  1. ${error.msg}
  2. " + michael@0: "
" + michael@0: "
", michael@0: data: { michael@0: errors: errors, michael@0: manifestURI: manifestURI michael@0: } michael@0: }); michael@0: } michael@0: }, michael@0: { michael@0: name: "appcache clear", michael@0: description: gcli.lookup("appCacheClearDesc"), michael@0: manual: gcli.lookup("appCacheClearManual"), michael@0: exec: function(args, context) { michael@0: let utils = new AppCacheUtils(args.uri); michael@0: utils.clearAll(); michael@0: michael@0: return gcli.lookup("appCacheClearCleared"); michael@0: } michael@0: }, michael@0: { michael@0: name: "appcache list", michael@0: description: gcli.lookup("appCacheListDesc"), michael@0: manual: gcli.lookup("appCacheListManual"), michael@0: returnType: "appcacheentries", michael@0: params: [{ michael@0: group: "options", michael@0: params: [ michael@0: { michael@0: type: "string", michael@0: name: "search", michael@0: description: gcli.lookup("appCacheListSearchDesc"), michael@0: defaultValue: null, michael@0: }, michael@0: ] michael@0: }], michael@0: exec: function(args, context) { michael@0: let utils = new AppCacheUtils(); michael@0: return utils.listEntries(args.search); michael@0: } michael@0: }, michael@0: { michael@0: item: "converter", michael@0: from: "appcacheentries", michael@0: to: "view", michael@0: exec: function(entries, context) { michael@0: return context.createView({ michael@0: html: "" + michael@0: "", michael@0: data: { michael@0: entries: entries, michael@0: onclick: context.update, michael@0: ondblclick: context.updateExec michael@0: } michael@0: }); michael@0: } michael@0: }, michael@0: { michael@0: name: "appcache viewentry", michael@0: description: gcli.lookup("appCacheViewEntryDesc"), michael@0: manual: gcli.lookup("appCacheViewEntryManual"), michael@0: params: [ michael@0: { michael@0: type: "string", michael@0: name: "key", michael@0: description: gcli.lookup("appCacheViewEntryKey"), michael@0: defaultValue: null, michael@0: } michael@0: ], michael@0: exec: function(args, context) { michael@0: let utils = new AppCacheUtils(); michael@0: return utils.viewEntry(args.key); michael@0: } michael@0: } michael@0: ];