Bug 1892041 - Part 1: Update test262 features. r=spidermonkey-reviewers,dminor
[gecko.git] / dom / base / test / test_bug498897.html
blob5793fb36873a72a6643eceecab8d09e98a02ff4c
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=498897
5 -->
6 <head>
7 <title>Test for Bug 498897</title>
8 <script src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=498897">Mozilla Bug 498897</a>
13 <p id="display"><iframe id="testframe"></iframe></p>
14 <div id="content" style="display: none">
16 </div>
17 <pre id="test">
18 <script type="application/javascript">
20 /** Test for Bug 498897 **/
22 var checkedLoad = false;
24 const Cc = SpecialPowers.Cc;
25 const Ci = SpecialPowers.Ci;
27 // Content policy / factory implementation for the test
28 var policyID = SpecialPowers.wrap(SpecialPowers.Components).ID("{65944d64-2390-422e-bea3-80d0af7f69ef}");
29 var policyName = "@mozilla.org/498897_testpolicy;1";
30 var policy = {
31 // nsISupports implementation
32 QueryInterface(iid) {
33 if (iid.equals(Ci.nsISupports) ||
34 iid.equals(Ci.nsIFactory) ||
35 iid.equals(Ci.nsIContentPolicy))
36 return this;
38 throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
41 // nsIFactory implementation
42 createInstance(iid) {
43 return this.QueryInterface(iid);
46 // nsIContentPolicy implementation
47 shouldLoad(contentLocation, loadInfo) {
48 var url = window.location.href.substr(0, window.location.href.indexOf('test_bug498897'));
49 let loadingPrincipal = loadInfo.loadingPrincipal;
50 if (loadingPrincipal) {
51 requestOrigin = loadingPrincipal.spec;
53 if (contentLocation.spec == url + "file_bug498897.css" &&
54 requestOrigin == url + "file_bug498897.html") {
55 checkedLoad = true;
58 return Ci.nsIContentPolicy.ACCEPT;
61 shouldProcess(contentLocation, loadInfo) {
62 return Ci.nsIContentPolicy.ACCEPT;
65 policy = SpecialPowers.wrapCallbackObject(policy);
67 var componentManager = SpecialPowers.wrap(SpecialPowers.Components).manager
68 .QueryInterface(Ci.nsIComponentRegistrar);
69 componentManager.registerFactory(policyID, "Test content policy for bug 498897",
70 policyName, policy);
72 var categoryManager =
73 Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
74 categoryManager.addCategoryEntry("content-policy", policyName, policyName,
75 false, true);
77 function testFinished()
79 ok(checkedLoad, "Content policy didn't get called!");
81 categoryManager.deleteCategoryEntry("content-policy", policyName, false);
83 setTimeout(function() {
84 componentManager.unregisterFactory(policyID, policy);
86 SimpleTest.finish();
87 }, 0);
90 SimpleTest.waitForExplicitFinish();
92 document.getElementById("testframe").src = "file_bug498897.html";
94 </script>
95 </pre>
96 </body>
97 </html>