toolkit/devtools/gcli/commands/appcache.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 const gcli = require("gcli/index");
michael@0 8
michael@0 9 loader.lazyImporter(this, "AppCacheUtils", "resource:///modules/devtools/AppCacheUtils.jsm");
michael@0 10
michael@0 11 exports.items = [
michael@0 12 {
michael@0 13 name: "appcache",
michael@0 14 description: gcli.lookup("appCacheDesc")
michael@0 15 },
michael@0 16 {
michael@0 17 name: "appcache validate",
michael@0 18 description: gcli.lookup("appCacheValidateDesc"),
michael@0 19 manual: gcli.lookup("appCacheValidateManual"),
michael@0 20 returnType: "appcacheerrors",
michael@0 21 params: [{
michael@0 22 group: "options",
michael@0 23 params: [
michael@0 24 {
michael@0 25 type: "string",
michael@0 26 name: "uri",
michael@0 27 description: gcli.lookup("appCacheValidateUriDesc"),
michael@0 28 defaultValue: null,
michael@0 29 }
michael@0 30 ]
michael@0 31 }],
michael@0 32 exec: function(args, context) {
michael@0 33 let utils;
michael@0 34 let deferred = context.defer();
michael@0 35
michael@0 36 if (args.uri) {
michael@0 37 utils = new AppCacheUtils(args.uri);
michael@0 38 } else {
michael@0 39 utils = new AppCacheUtils(context.environment.document);
michael@0 40 }
michael@0 41
michael@0 42 utils.validateManifest().then(function(errors) {
michael@0 43 deferred.resolve([errors, utils.manifestURI || "-"]);
michael@0 44 });
michael@0 45
michael@0 46 return deferred.promise;
michael@0 47 }
michael@0 48 },
michael@0 49 {
michael@0 50 item: "converter",
michael@0 51 from: "appcacheerrors",
michael@0 52 to: "view",
michael@0 53 exec: function([errors, manifestURI], context) {
michael@0 54 if (errors.length == 0) {
michael@0 55 return context.createView({
michael@0 56 html: "<span>" + gcli.lookup("appCacheValidatedSuccessfully") + "</span>"
michael@0 57 });
michael@0 58 }
michael@0 59
michael@0 60 return context.createView({
michael@0 61 html:
michael@0 62 "<div>" +
michael@0 63 " <h4>Manifest URI: ${manifestURI}</h4>" +
michael@0 64 " <ol>" +
michael@0 65 " <li foreach='error in ${errors}'>${error.msg}</li>" +
michael@0 66 " </ol>" +
michael@0 67 "</div>",
michael@0 68 data: {
michael@0 69 errors: errors,
michael@0 70 manifestURI: manifestURI
michael@0 71 }
michael@0 72 });
michael@0 73 }
michael@0 74 },
michael@0 75 {
michael@0 76 name: "appcache clear",
michael@0 77 description: gcli.lookup("appCacheClearDesc"),
michael@0 78 manual: gcli.lookup("appCacheClearManual"),
michael@0 79 exec: function(args, context) {
michael@0 80 let utils = new AppCacheUtils(args.uri);
michael@0 81 utils.clearAll();
michael@0 82
michael@0 83 return gcli.lookup("appCacheClearCleared");
michael@0 84 }
michael@0 85 },
michael@0 86 {
michael@0 87 name: "appcache list",
michael@0 88 description: gcli.lookup("appCacheListDesc"),
michael@0 89 manual: gcli.lookup("appCacheListManual"),
michael@0 90 returnType: "appcacheentries",
michael@0 91 params: [{
michael@0 92 group: "options",
michael@0 93 params: [
michael@0 94 {
michael@0 95 type: "string",
michael@0 96 name: "search",
michael@0 97 description: gcli.lookup("appCacheListSearchDesc"),
michael@0 98 defaultValue: null,
michael@0 99 },
michael@0 100 ]
michael@0 101 }],
michael@0 102 exec: function(args, context) {
michael@0 103 let utils = new AppCacheUtils();
michael@0 104 return utils.listEntries(args.search);
michael@0 105 }
michael@0 106 },
michael@0 107 {
michael@0 108 item: "converter",
michael@0 109 from: "appcacheentries",
michael@0 110 to: "view",
michael@0 111 exec: function(entries, context) {
michael@0 112 return context.createView({
michael@0 113 html: "" +
michael@0 114 "<ul class='gcli-appcache-list'>" +
michael@0 115 " <li foreach='entry in ${entries}'>" +
michael@0 116 " <table class='gcli-appcache-detail'>" +
michael@0 117 " <tr>" +
michael@0 118 " <td>" + gcli.lookup("appCacheListKey") + "</td>" +
michael@0 119 " <td>${entry.key}</td>" +
michael@0 120 " </tr>" +
michael@0 121 " <tr>" +
michael@0 122 " <td>" + gcli.lookup("appCacheListFetchCount") + "</td>" +
michael@0 123 " <td>${entry.fetchCount}</td>" +
michael@0 124 " </tr>" +
michael@0 125 " <tr>" +
michael@0 126 " <td>" + gcli.lookup("appCacheListLastFetched") + "</td>" +
michael@0 127 " <td>${entry.lastFetched}</td>" +
michael@0 128 " </tr>" +
michael@0 129 " <tr>" +
michael@0 130 " <td>" + gcli.lookup("appCacheListLastModified") + "</td>" +
michael@0 131 " <td>${entry.lastModified}</td>" +
michael@0 132 " </tr>" +
michael@0 133 " <tr>" +
michael@0 134 " <td>" + gcli.lookup("appCacheListExpirationTime") + "</td>" +
michael@0 135 " <td>${entry.expirationTime}</td>" +
michael@0 136 " </tr>" +
michael@0 137 " <tr>" +
michael@0 138 " <td>" + gcli.lookup("appCacheListDataSize") + "</td>" +
michael@0 139 " <td>${entry.dataSize}</td>" +
michael@0 140 " </tr>" +
michael@0 141 " <tr>" +
michael@0 142 " <td>" + gcli.lookup("appCacheListDeviceID") + "</td>" +
michael@0 143 " <td>${entry.deviceID} <span class='gcli-out-shortcut' " +
michael@0 144 "onclick='${onclick}' ondblclick='${ondblclick}' " +
michael@0 145 "data-command='appcache viewentry ${entry.key}'" +
michael@0 146 ">" + gcli.lookup("appCacheListViewEntry") + "</span>" +
michael@0 147 " </td>" +
michael@0 148 " </tr>" +
michael@0 149 " </table>" +
michael@0 150 " </li>" +
michael@0 151 "</ul>",
michael@0 152 data: {
michael@0 153 entries: entries,
michael@0 154 onclick: context.update,
michael@0 155 ondblclick: context.updateExec
michael@0 156 }
michael@0 157 });
michael@0 158 }
michael@0 159 },
michael@0 160 {
michael@0 161 name: "appcache viewentry",
michael@0 162 description: gcli.lookup("appCacheViewEntryDesc"),
michael@0 163 manual: gcli.lookup("appCacheViewEntryManual"),
michael@0 164 params: [
michael@0 165 {
michael@0 166 type: "string",
michael@0 167 name: "key",
michael@0 168 description: gcli.lookup("appCacheViewEntryKey"),
michael@0 169 defaultValue: null,
michael@0 170 }
michael@0 171 ],
michael@0 172 exec: function(args, context) {
michael@0 173 let utils = new AppCacheUtils();
michael@0 174 return utils.viewEntry(args.key);
michael@0 175 }
michael@0 176 }
michael@0 177 ];

mercurial