4 <title>Crashtests for style system with content policy
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css">
9 <iframe id=
"iframe"></iframe>
12 "file_bug1381233.html",
15 const Cc
= SpecialPowers
.Cc
;
16 const Ci
= SpecialPowers
.Ci
;
18 var policyID
= SpecialPowers
.wrap(SpecialPowers
.Components
).ID("{b80e19d0-878f-d41b-2654-194714a4115c}");
19 var policyName
= "@mozilla.org/testpolicy;1";
21 // nsISupports implementation
22 QueryInterface: function(iid
) {
24 iid
= SpecialPowers
.wrap(iid
);
25 if (iid
.equals(Ci
.nsISupports
) ||
26 iid
.equals(Ci
.nsIFactory
) ||
27 iid
.equals(Ci
.nsIContentPolicy
))
30 throw SpecialPowers
.Cr
.NS_ERROR_NO_INTERFACE
;
33 // nsIFactory implementation
34 createInstance: function(outer
, iid
) {
35 return this.QueryInterface(iid
);
38 // nsIContentPolicy implementation
39 shouldLoad: function(contentLocation
, loadInfo
, mimeTypeGuess
) {
40 info(`shouldLoad is invoked for ${SpecialPowers.wrap(contentLocation).spec}`);
41 return Ci
.nsIContentPolicy
.ACCEPT
;
43 shouldProcess: function(contentLocation
, loadInfo
, mimeTypeGuess
) {
44 return Ci
.nsIContentPolicy
.ACCEPT
;
47 policy
= SpecialPowers
.wrapCallbackObject(policy
);
49 // Register content policy
50 var componentManager
= SpecialPowers
.wrap(SpecialPowers
.Components
).manager
51 .QueryInterface(Ci
.nsIComponentRegistrar
);
52 componentManager
.registerFactory(policyID
, "Test content policy", policyName
, policy
);
53 var categoryManager
= Cc
["@mozilla.org/categorymanager;1"].getService(Ci
.nsICategoryManager
);
54 categoryManager
.addCategoryEntry("content-policy", policyName
, policyName
, false, true);
57 SimpleTest
.waitForExplicitFinish();
59 async
function runTests() {
60 let iframe
= document
.getElementById("iframe");
61 for (let test
of TESTS
) {
63 await
new Promise(resolve
=> {
64 iframe
.onload
= resolve
;
66 ok(true, `${test} doesn't crash`);
68 categoryManager
.deleteCategoryEntry("content-policy", policyName
, false);
69 componentManager
.unregisterFactory(policyID
, policy
);