Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / netwerk / test / unit / test_about_protocol.js
blob972b1e3a4364be3b5c062eabf97ec6ea6a969a10
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 "use strict";
7 var unsafeAboutModule = {
8 QueryInterface: ChromeUtils.generateQI(["nsIAboutModule"]),
9 newChannel(aURI, aLoadInfo) {
10 var uri = Services.io.newURI("about:blank");
11 let chan = Services.io.newChannelFromURIWithLoadInfo(uri, aLoadInfo);
12 chan.owner = Services.scriptSecurityManager.getSystemPrincipal();
13 return chan;
15 getURIFlags() {
16 return Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
20 var factory = {
21 createInstance(aIID) {
22 return unsafeAboutModule.QueryInterface(aIID);
24 QueryInterface: ChromeUtils.generateQI(["nsIFactory"]),
27 function run_test() {
28 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
29 let classID = Services.uuid.generateUUID();
30 registrar.registerFactory(
31 classID,
32 "",
33 "@mozilla.org/network/protocol/about;1?what=unsafe",
34 factory
37 let aboutUnsafeChan = NetUtil.newChannel({
38 uri: "about:unsafe",
39 loadUsingSystemPrincipal: true,
40 });
42 Assert.equal(
43 null,
44 aboutUnsafeChan.owner,
45 "URI_SAFE_FOR_UNTRUSTED_CONTENT channel has no owner"
48 registrar.unregisterFactory(classID, factory);