Skip to content

Instantly share code, notes, and snippets.

@jiacai2050
Forked from lduros/content-policy.js
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiacai2050/f75f9d1a3d577f9a60e6 to your computer and use it in GitHub Desktop.
Save jiacai2050/f75f9d1a3d577f9a60e6 to your computer and use it in GitHub Desktop.
const { Cc, Ci } = require("chrome");
const xpcom = require("xpcom");
const { Class } = require("api-utils/heritage");
exports.preventCrossRequest = Class({
extends: xpcom.Unknown,
interfaces: ["nsIContentPolicy"],
shouldLoad: function (contType, contLoc, reqOrig, ctx, typeGuess, extra) {
return Ci.nsIContentPolicy.REJECT;
},
shouldProcess: function (contType, contLoc, reqOrig, ctx, mimeType, extra) {
return Ci.nsIContentPolicy.ACCEPT;
}
});
let factory = xpcom.Factory({
Component: exports.preventCrossRequest,
description: "Implements content policy to prevent cross requests",
contract: "@lduros.net/PreventCrossRequest-policy"
});
var catman = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
catman.addCategoryEntry("content-policy", "prevent-cross-request.preventCrossRequest", factory.contract, false, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment