Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=498897 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 498897</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=498897">Mozilla Bug 498897</a> |
michael@0 | 13 | <p id="display"><iframe id="testframe"></iframe></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | |
michael@0 | 16 | </div> |
michael@0 | 17 | <pre id="test"> |
michael@0 | 18 | <script type="application/javascript"> |
michael@0 | 19 | |
michael@0 | 20 | /** Test for Bug 498897 **/ |
michael@0 | 21 | |
michael@0 | 22 | var checkedLoad = false; |
michael@0 | 23 | |
michael@0 | 24 | const Cc = SpecialPowers.Cc; |
michael@0 | 25 | const Ci = SpecialPowers.Ci; |
michael@0 | 26 | |
michael@0 | 27 | // Content policy / factory implementation for the test |
michael@0 | 28 | var policyID = SpecialPowers.wrap(SpecialPowers.Components).ID("{65944d64-2390-422e-bea3-80d0af7f69ef}"); |
michael@0 | 29 | var policyName = "@mozilla.org/498897_testpolicy;1"; |
michael@0 | 30 | var policy = { |
michael@0 | 31 | // nsISupports implementation |
michael@0 | 32 | QueryInterface: function(iid) { |
michael@0 | 33 | if (iid.equals(Ci.nsISupports) || |
michael@0 | 34 | iid.equals(Ci.nsIFactory) || |
michael@0 | 35 | iid.equals(Ci.nsIContentPolicy)) |
michael@0 | 36 | return this; |
michael@0 | 37 | |
michael@0 | 38 | throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE; |
michael@0 | 39 | }, |
michael@0 | 40 | |
michael@0 | 41 | // nsIFactory implementation |
michael@0 | 42 | createInstance: function(outer, iid) { |
michael@0 | 43 | return this.QueryInterface(iid); |
michael@0 | 44 | }, |
michael@0 | 45 | |
michael@0 | 46 | // nsIContentPolicy implementation |
michael@0 | 47 | shouldLoad: function(contentType, contentLocation, requestOrigin, context, |
michael@0 | 48 | mimeTypeGuess, extra) { |
michael@0 | 49 | var url = window.location.href.substr(0, window.location.href.indexOf('test_bug498897')); |
michael@0 | 50 | if (contentLocation.spec == url + "file_bug498897.css" && |
michael@0 | 51 | requestOrigin.spec == url + "file_bug498897.html") { |
michael@0 | 52 | checkedLoad = true; |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | return Ci.nsIContentPolicy.ACCEPT; |
michael@0 | 56 | }, |
michael@0 | 57 | |
michael@0 | 58 | shouldProcess: function(contentType, contentLocation, requestOrigin, context, |
michael@0 | 59 | mimeTypeGuess, extra) { |
michael@0 | 60 | return Ci.nsIContentPolicy.ACCEPT; |
michael@0 | 61 | } |
michael@0 | 62 | } |
michael@0 | 63 | policy = SpecialPowers.wrapCallbackObject(policy); |
michael@0 | 64 | |
michael@0 | 65 | var componentManager = SpecialPowers.wrap(SpecialPowers.Components).manager |
michael@0 | 66 | .QueryInterface(Ci.nsIComponentRegistrar); |
michael@0 | 67 | componentManager.registerFactory(policyID, "Test content policy for bug 498897", |
michael@0 | 68 | policyName, policy); |
michael@0 | 69 | |
michael@0 | 70 | var categoryManager = |
michael@0 | 71 | Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager); |
michael@0 | 72 | categoryManager.addCategoryEntry("content-policy", policyName, policyName, |
michael@0 | 73 | false, true); |
michael@0 | 74 | |
michael@0 | 75 | function testFinished() |
michael@0 | 76 | { |
michael@0 | 77 | ok(checkedLoad, "Content policy didn't get called!"); |
michael@0 | 78 | |
michael@0 | 79 | categoryManager.deleteCategoryEntry("content-policy", policyName, false); |
michael@0 | 80 | |
michael@0 | 81 | setTimeout(function() { |
michael@0 | 82 | componentManager.unregisterFactory(policyID, policy); |
michael@0 | 83 | |
michael@0 | 84 | SimpleTest.finish(); |
michael@0 | 85 | }, 0); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 89 | |
michael@0 | 90 | document.getElementById("testframe").src = "file_bug498897.html"; |
michael@0 | 91 | |
michael@0 | 92 | </script> |
michael@0 | 93 | </pre> |
michael@0 | 94 | </body> |
michael@0 | 95 | </html> |