content/base/test/test_bug498897.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

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.)

     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 type="application/javascript" 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: function(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;
    39   },
    41   // nsIFactory implementation
    42   createInstance: function(outer, iid) {
    43     return this.QueryInterface(iid);
    44   },
    46   // nsIContentPolicy implementation
    47   shouldLoad: function(contentType, contentLocation, requestOrigin, context,
    48                        mimeTypeGuess, extra) {
    49     var url = window.location.href.substr(0, window.location.href.indexOf('test_bug498897'));
    50     if (contentLocation.spec == url + "file_bug498897.css" &&
    51         requestOrigin.spec == url + "file_bug498897.html") {
    52       checkedLoad = true;
    53     }
    55     return Ci.nsIContentPolicy.ACCEPT;
    56   },
    58   shouldProcess: function(contentType, contentLocation, requestOrigin, context,
    59                           mimeTypeGuess, extra) {
    60     return Ci.nsIContentPolicy.ACCEPT;
    61   }
    62 }
    63 policy = SpecialPowers.wrapCallbackObject(policy);
    65 var componentManager = SpecialPowers.wrap(SpecialPowers.Components).manager
    66                                  .QueryInterface(Ci.nsIComponentRegistrar);
    67 componentManager.registerFactory(policyID, "Test content policy for bug 498897",
    68                                  policyName, policy);
    70 var categoryManager =
    71   Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
    72 categoryManager.addCategoryEntry("content-policy", policyName, policyName,
    73                                  false, true);
    75 function testFinished()
    76 {
    77   ok(checkedLoad, "Content policy didn't get called!");
    79   categoryManager.deleteCategoryEntry("content-policy", policyName, false);
    81   setTimeout(function() {
    82     componentManager.unregisterFactory(policyID, policy);
    84     SimpleTest.finish();
    85   }, 0);
    86 }
    88 SimpleTest.waitForExplicitFinish();
    90 document.getElementById("testframe").src = "file_bug498897.html";
    92 </script>
    93 </pre>
    94 </body>
    95 </html>

mercurial