gecko-dev/chrome/test/unit/test_resolve_uris.js
Jim Blandy 7e20285e70 Bug 914753: Make Emacs file variable header lines correct, or at least consistent. DONTBUILD r=ehsan
The -*- file variable lines -*- establish per-file settings that Emacs will
pick up. This patch makes the following changes to those lines (and touches
nothing else):

 - Never set the buffer's mode.

   Years ago, Emacs did not have a good JavaScript mode, so it made sense
   to use Java or C++ mode in .js files. However, Emacs has had js-mode for
   years now; it's perfectly serviceable, and is available and enabled by
   default in all major Emacs packagings.

   Selecting a mode in the -*- file variable line -*- is almost always the
   wrong thing to do anyway. It overrides Emacs's default choice, which is
   (now) reasonable; and even worse, it overrides settings the user might
   have made in their '.emacs' file for that file extension. It's only
   useful when there's something specific about that particular file that
   makes a particular mode appropriate.

 - Correctly propagate settings that establish the correct indentation
   level for this file: c-basic-offset and js2-basic-offset should be
   js-indent-level. Whatever value they're given should be preserved;
   different parts of our tree use different indentation styles.

 - We don't use tabs in Mozilla JS code. Always set indent-tabs-mode: nil.
   Remove tab-width: settings, at least in files that don't contain tab
   characters.

 - Remove js2-mode settings that belong in the user's .emacs file, like
   js2-skip-preprocessor-directives.
2014-06-24 22:12:07 -07:00

94 lines
2.7 KiB
JavaScript

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* 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/. */
// head_crtestutils.js doesn't get included in the child by default
if (typeof registerManifests === "undefined") {
load("../unit/head_crtestutils.js");
}
let manifestFile = do_get_file("../unit/data/test_resolve_uris.manifest");
let manifests = [ manifestFile ];
registerManifests(manifests);
let ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
function do_run_test()
{
let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIChromeRegistry);
// If we don't have libxul or e10s then we don't have process separation, so
// we don't need to worry about checking for new chrome.
var appInfo = Cc["@mozilla.org/xre/app-info;1"];
if (!appInfo ||
(appInfo.getService(Ci.nsIXULRuntime).processType ==
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT)) {
cr.checkForNewChrome();
}
// See if our various things were able to register
let registrationTypes = [
"content",
"locale",
"skin",
"override",
"resource",
];
for (let j = 0; j < registrationTypes.length; j++) {
let type = registrationTypes[j];
dump("Testing type '" + type + "'\n");
let expectedURI = "resource://foo/foo-" + type + "/";
let sourceURI = "chrome://foo/" + type + "/";
switch (type) {
case "content":
expectedURI += "foo.xul";
break;
case "locale":
expectedURI += "foo.dtd";
break;
case "skin":
expectedURI += "foo.css";
break;
case "override":
sourceURI = "chrome://good-package/content/override-me.xul";
expectedURI += "override-me.xul";
break;
case "resource":
expectedURI = ios.newFileURI(manifestFile.parent).spec;
sourceURI = "resource://foo/";
break;
};
try {
sourceURI = ios.newURI(sourceURI, null, null);
let uri;
if (type == "resource") {
// resources go about a slightly different way than everything else
let rph = ios.getProtocolHandler("resource").
QueryInterface(Ci.nsIResProtocolHandler);
uri = rph.resolveURI(sourceURI);
}
else {
uri = cr.convertChromeURL(sourceURI).spec;
}
do_check_eq(expectedURI, uri);
}
catch (e) {
dump(e + "\n");
do_throw("Should have registered a handler for type '" +
type + "'\n");
}
}
}
if (typeof run_test === "undefined") {
run_test = function() {
do_run_test();
};
}