diff -r 000000000000 -r 6474c204b198 toolkit/devtools/gcli/commands/appcache.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolkit/devtools/gcli/commands/appcache.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,177 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const gcli = require("gcli/index"); + +loader.lazyImporter(this, "AppCacheUtils", "resource:///modules/devtools/AppCacheUtils.jsm"); + +exports.items = [ + { + name: "appcache", + description: gcli.lookup("appCacheDesc") + }, + { + name: "appcache validate", + description: gcli.lookup("appCacheValidateDesc"), + manual: gcli.lookup("appCacheValidateManual"), + returnType: "appcacheerrors", + params: [{ + group: "options", + params: [ + { + type: "string", + name: "uri", + description: gcli.lookup("appCacheValidateUriDesc"), + defaultValue: null, + } + ] + }], + exec: function(args, context) { + let utils; + let deferred = context.defer(); + + if (args.uri) { + utils = new AppCacheUtils(args.uri); + } else { + utils = new AppCacheUtils(context.environment.document); + } + + utils.validateManifest().then(function(errors) { + deferred.resolve([errors, utils.manifestURI || "-"]); + }); + + return deferred.promise; + } + }, + { + item: "converter", + from: "appcacheerrors", + to: "view", + exec: function([errors, manifestURI], context) { + if (errors.length == 0) { + return context.createView({ + html: "" + gcli.lookup("appCacheValidatedSuccessfully") + "" + }); + } + + return context.createView({ + html: + "
" + gcli.lookup("appCacheListKey") + " | " + + "${entry.key} | " + + "
" + gcli.lookup("appCacheListFetchCount") + " | " + + "${entry.fetchCount} | " + + "
" + gcli.lookup("appCacheListLastFetched") + " | " + + "${entry.lastFetched} | " + + "
" + gcli.lookup("appCacheListLastModified") + " | " + + "${entry.lastModified} | " + + "
" + gcli.lookup("appCacheListExpirationTime") + " | " + + "${entry.expirationTime} | " + + "
" + gcli.lookup("appCacheListDataSize") + " | " + + "${entry.dataSize} | " + + "
" + gcli.lookup("appCacheListDeviceID") + " | " + + "${entry.deviceID} " + gcli.lookup("appCacheListViewEntry") + "" + + " | " + + "