michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: let Ci = Components.interfaces; michael@0: let Cc = Components.classes; michael@0: michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: let unsafeAboutModule = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]), michael@0: newChannel: function (aURI) { michael@0: let chan = Services.io.newChannel("about:blank", null, null); michael@0: chan.owner = Services.scriptSecurityManager.getSystemPrincipal(); michael@0: return chan; michael@0: }, michael@0: getURIFlags: function (aURI) { michael@0: return Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT; michael@0: } michael@0: }; michael@0: michael@0: let factory = { michael@0: createInstance: function(aOuter, aIID) { michael@0: if (aOuter) michael@0: throw Components.results.NS_ERROR_NO_AGGREGATION; michael@0: return unsafeAboutModule.QueryInterface(aIID); michael@0: }, michael@0: lockFactory: function(aLock) { michael@0: throw Components.results.NS_ERROR_NOT_IMPLEMENTED; michael@0: }, michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory]) michael@0: }; michael@0: michael@0: function run_test() { michael@0: let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); michael@0: let classID = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator).generateUUID(); michael@0: registrar.registerFactory(classID, "", "@mozilla.org/network/protocol/about;1?what=unsafe", factory); michael@0: michael@0: let aboutUnsafeURI = Services.io.newURI("about:unsafe", null, null); michael@0: let aboutUnsafeChan = Services.io.newChannelFromURI(aboutUnsafeURI); michael@0: do_check_null(aboutUnsafeChan.owner, "URI_SAFE_FOR_UNTRUSTED_CONTENT channel has no owner"); michael@0: michael@0: registrar.unregisterFactory(classID, factory); michael@0: }