Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / netwerk / test / unit / test_uri_mutator.js
blobfb9228fc5b69ca21ff69842bd29851446ee808b6
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 "use strict";
8 function standardMutator() {
9 return Cc["@mozilla.org/network/standard-url-mutator;1"].createInstance(
10 Ci.nsIURIMutator
14 add_task(async function test_simple_setter_chaining() {
15 let uri = standardMutator()
16 .setSpec("http://example.com/")
17 .setQuery("hello")
18 .setRef("bla")
19 .setScheme("ftp")
20 .finalize();
21 equal(uri.spec, "ftp://example.com/?hello#bla");
22 });
24 add_task(async function test_qi_behaviour() {
25 let uri = standardMutator()
26 .setSpec("http://example.com/")
27 .QueryInterface(Ci.nsIURI);
28 equal(uri.spec, "http://example.com/");
30 Assert.throws(
31 () => {
32 uri = standardMutator().QueryInterface(Ci.nsIURI);
34 /NS_NOINTERFACE/,
35 "mutator doesn't QI if it holds no URI"
38 let mutator = standardMutator().setSpec("http://example.com/path");
39 uri = mutator.QueryInterface(Ci.nsIURI);
40 equal(uri.spec, "http://example.com/path");
41 Assert.throws(
42 () => {
43 uri = mutator.QueryInterface(Ci.nsIURI);
45 /NS_NOINTERFACE/,
46 "Second QueryInterface should fail"
48 });