/* 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 l10n = require("gcli/l10n"); loader.lazyImporter(this, "AppCacheUtils", "resource://devtools/client/shared/AppCacheUtils.jsm"); exports.items = [ { item: "command", name: "appcache", description: l10n.lookup("appCacheDesc") }, { item: "command", runAt: "server", name: "appcache validate", description: l10n.lookup("appCacheValidateDesc"), manual: l10n.lookup("appCacheValidateManual"), returnType: "appcacheerrors", params: [{ group: "options", params: [ { type: "string", name: "uri", description: l10n.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: "" + l10n.lookup("appCacheValidatedSuccessfully") + "" }); } return context.createView({ html: "
" + l10n.lookup("appCacheListKey") + " | " + "${entry.key} | " + "
" + l10n.lookup("appCacheListFetchCount") + " | " + "${entry.fetchCount} | " + "
" + l10n.lookup("appCacheListLastFetched") + " | " + "${entry.lastFetched} | " + "
" + l10n.lookup("appCacheListLastModified") + " | " + "${entry.lastModified} | " + "
" + l10n.lookup("appCacheListExpirationTime") + " | " + "${entry.expirationTime} | " + "
" + l10n.lookup("appCacheListDataSize") + " | " + "${entry.dataSize} | " + "
" + l10n.lookup("appCacheListDeviceID") + " | " + "${entry.deviceID} " + l10n.lookup("appCacheListViewEntry") + "" + " | " + "