Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / test / test_crash_with_content_policy.html
blob119ee0b53a8c52c4bcb0b732dc8a075e72901f05
1 <!DOCTYPE HTML>
2 <html>
3 <head>
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">
7 </head>
8 <body>
9 <iframe id="iframe"></iframe>
10 <script>
11 const TESTS = [
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";
20 var policy = {
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))
28 return this;
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) {
62 iframe.src = test;
63 await new Promise(resolve => {
64 iframe.onload = resolve;
65 });
66 ok(true, `${test} doesn't crash`);
68 categoryManager.deleteCategoryEntry("content-policy", policyName, false);
69 componentManager.unregisterFactory(policyID, policy);
70 SimpleTest.finish();
72 runTests();
73 </script>
74 </body>
75 </html>