gecko-dev/netwerk/test/unit/test_standardurl_default_port.js
Andrew McCreight 5dec0e0beb Bug 1432992, part 1 - Remove definitions of Ci, Cr, Cc, and Cu. r=florian
This patch was autogenerated by my decomponents.py

It covers almost every file with the extension js, jsm, html, py,
xhtml, or xul.

It removes blank lines after removed lines, when the removed lines are
preceded by either blank lines or the start of a new block. The "start
of a new block" is defined fairly hackily: either the line starts with
//, ends with */, ends with {, <![CDATA[, """ or '''. The first two
cover comments, the third one covers JS, the fourth covers JS embedded
in XUL, and the final two cover JS embedded in Python. This also
applies if the removed line was the first line of the file.

It covers the pattern matching cases like "var {classes: Cc,
interfaces: Ci, utils: Cu, results: Cr} = Components;". It'll remove
the entire thing if they are all either Ci, Cr, Cc or Cu, or it will
remove the appropriate ones and leave the residue behind. If there's
only one behind, then it will turn it into a normal, non-pattern
matching variable definition. (For instance, "const { classes: Cc,
Constructor: CC, interfaces: Ci, utils: Cu } = Components" becomes
"const CC = Components.Constructor".)

MozReview-Commit-ID: DeSHcClQ7cG

--HG--
extra : rebase_source : d9c41878036c1ef7766ef5e91a7005025bc1d72b
2018-02-06 09:36:57 -08:00

58 lines
2.2 KiB
JavaScript

/* -*- Mode: javascript; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* This test exercises the nsIStandardURL "setDefaultPort" API. */
"use strict";
function run_test() {
function stringToURL(str) {
return Cc["@mozilla.org/network/standard-url-mutator;1"]
.createInstance(Ci.nsIStandardURLMutator)
.init(Ci.nsIStandardURL.URLTYPE_AUTHORITY, 80, str, "UTF-8", null)
.finalize()
.QueryInterface(Ci.nsIStandardURL);
}
// Create a nsStandardURL:
var origUrlStr = "http://foo.com/";
var stdUrl = stringToURL(origUrlStr);
Assert.equal(-1, stdUrl.port);
// Changing default port shouldn't adjust the value returned by "port",
// or the string representation.
let def100Url = stdUrl.mutate()
.QueryInterface(Ci.nsIStandardURLMutator)
.setDefaultPort(100)
.finalize();
Assert.equal(-1, def100Url.port);
Assert.equal(def100Url.spec, origUrlStr);
// Changing port directly should update .port and .spec, though:
let port200Url = stdUrl.mutate()
.setPort("200")
.finalize();
Assert.equal(200, port200Url.port);
Assert.equal(port200Url.spec, "http://foo.com:200/");
// ...but then if we change default port to match the custom port,
// the custom port should reset to -1 and disappear from .spec:
let def200Url = port200Url.mutate()
.QueryInterface(Ci.nsIStandardURLMutator)
.setDefaultPort(200)
.finalize();
Assert.equal(-1, def200Url.port);
Assert.equal(def200Url.spec, origUrlStr);
// And further changes to default port should not make custom port reappear.
let def300Url = def200Url.mutate()
.QueryInterface(Ci.nsIStandardURLMutator)
.setDefaultPort(300)
.finalize();
Assert.equal(-1, def300Url.port);
Assert.equal(def300Url.spec, origUrlStr);
}