mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 21:00:42 +02:00
The base .eslintrc is essentially a merge of the root Toolkit .eslintrc and the devtools .eslintrc, with some minor changes to match our prevalent style. For the most enforces the coding styles that we've been using most consistently. There are a couple of significant differences, though: * The rule for opening brace alignment can only be applied globally, and doesn't make exceptions for top-level functions. I chose to turn it on, and change the brace style of existing top-level functions that violated it, since the rule seemed worth using, and that's the direction most Toolkit JS code has been headed anyway. * The rule for switch/case statements requires an added indentation level for case statements. Most of our switch statements did not use an extra level of indentation, and I initially wrote the rule to enforce that style, until I came across case statements that used blocks, and required the extra indentation level for sanity. --HG-- rename : devtools/.eslintrc => toolkit/components/extensions/.eslintrc extra : commitid : 4aDZOi5MNPc extra : rebase_source : f34ba43aeb8046a0c971cb76b76410497bd12b42 extra : source : 2a7eb4ef7b375e5fd52d843ca206a071367a6475
57 lines
2 KiB
JavaScript
57 lines
2 KiB
JavaScript
/* 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 EXPORTED_SYMBOLS = ["WebRequestCommon"];
|
|
|
|
/* exported WebRequestCommon */
|
|
|
|
const Ci = Components.interfaces;
|
|
const Cc = Components.classes;
|
|
const Cu = Components.utils;
|
|
const Cr = Components.results;
|
|
|
|
var WebRequestCommon = {
|
|
typeForPolicyType(type) {
|
|
switch (type) {
|
|
case Ci.nsIContentPolicy.TYPE_DOCUMENT: return "main_frame";
|
|
case Ci.nsIContentPolicy.TYPE_SUBDOCUMENT: return "sub_frame";
|
|
case Ci.nsIContentPolicy.TYPE_STYLESHEET: return "stylesheet";
|
|
case Ci.nsIContentPolicy.TYPE_SCRIPT: return "script";
|
|
case Ci.nsIContentPolicy.TYPE_IMAGE: return "image";
|
|
case Ci.nsIContentPolicy.TYPE_OBJECT: return "object";
|
|
case Ci.nsIContentPolicy.TYPE_OBJECT_SUBREQUEST: return "object_subrequest";
|
|
case Ci.nsIContentPolicy.TYPE_XMLHTTPREQUEST: return "xmlhttprequest";
|
|
case Ci.nsIContentPolicy.TYPE_XBL: return "xbl";
|
|
case Ci.nsIContentPolicy.TYPE_XSLT: return "xslt";
|
|
case Ci.nsIContentPolicy.TYPE_PING: return "ping";
|
|
case Ci.nsIContentPolicy.TYPE_BEACON: return "beacon";
|
|
case Ci.nsIContentPolicy.TYPE_DTD: return "xml_dtd";
|
|
case Ci.nsIContentPolicy.TYPE_FONT: return "font";
|
|
case Ci.nsIContentPolicy.TYPE_MEDIA: return "media";
|
|
case Ci.nsIContentPolicy.TYPE_WEBSOCKET: return "websocket";
|
|
case Ci.nsIContentPolicy.TYPE_CSP_REPORT: return "csp_report";
|
|
case Ci.nsIContentPolicy.TYPE_IMAGESET: return "imageset";
|
|
case Ci.nsIContentPolicy.TYPE_WEB_MANIFEST: return "web_manifest";
|
|
default: return "other";
|
|
}
|
|
},
|
|
|
|
typeMatches(policyType, filterTypes) {
|
|
if (filterTypes === null) {
|
|
return true;
|
|
}
|
|
|
|
return filterTypes.indexOf(this.typeForPolicyType(policyType)) != -1;
|
|
},
|
|
|
|
urlMatches(uri, urlFilter) {
|
|
if (urlFilter === null) {
|
|
return true;
|
|
}
|
|
|
|
return urlFilter.matches(uri);
|
|
},
|
|
};
|