netwerk/test/unit/test_about_protocol.js

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 let Ci = Components.interfaces;
     6 let Cc = Components.classes;
     8 Components.utils.import("resource://gre/modules/Services.jsm");
     9 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
    11 let unsafeAboutModule = {
    12   QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
    13   newChannel: function (aURI) {
    14     let chan = Services.io.newChannel("about:blank", null, null);
    15     chan.owner = Services.scriptSecurityManager.getSystemPrincipal();
    16     return chan;
    17   },
    18   getURIFlags: function (aURI) {
    19     return Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
    20   }
    21 };
    23 let factory = {
    24   createInstance: function(aOuter, aIID) {
    25     if (aOuter)
    26       throw Components.results.NS_ERROR_NO_AGGREGATION;
    27     return unsafeAboutModule.QueryInterface(aIID);
    28   },
    29   lockFactory: function(aLock) {
    30     throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
    31   },
    32   QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory])
    33 };
    35 function run_test() {
    36   let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
    37   let classID = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator).generateUUID();
    38   registrar.registerFactory(classID, "", "@mozilla.org/network/protocol/about;1?what=unsafe", factory);
    40   let aboutUnsafeURI = Services.io.newURI("about:unsafe", null, null);
    41   let aboutUnsafeChan = Services.io.newChannelFromURI(aboutUnsafeURI);
    42   do_check_null(aboutUnsafeChan.owner, "URI_SAFE_FOR_UNTRUSTED_CONTENT channel has no owner");
    44   registrar.unregisterFactory(classID, factory);
    45 }

mercurial