How to use the url.fromFilename function in url

To help you get started, we’ve selected a few url examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / fx-share-addon / tests / test_utils.js View on Github external
exports.getTestUrl = function(testPage) {
  let lastSlash = this.module.uri.lastIndexOf("/");
  let resourceUrl = this.module.uri.substr(0, lastSlash+1) + testPage;
  // return the file:// as F1 disables itself for resource:// urls.
  return URL.fromFilename(URL.toFilename(resourceUrl));
}
github mozilla / chromeless / modules / internal / main.js View on Github external
exports.main = function main(options, testCallbacks) {
    // access appinfo.json contents for startup parameters
    const ai = appinfo.contents;

    var call = options.staticArgs;
    const contentWindow = require("chromeless-sandbox-window");

    var file = path.basename(call.browser);

    var systemMode = appinfo.contents.enableSystemPrivileges ? true : false;

    if(systemMode) {
        var rootPath = path.join(call.appBasePath, path.dirname(call.browser));
        var startPage = require('url').fromFilename(call.appBasePath);
        var protocol = require("custom-protocol").register("chromeless");
        protocol.setHost("main", startPage , "system");
        var startPage = "chromeless://main/" + call.browser;
    } else {
       // convert browser url into a resource:// url
       // i.e. 'browser_code/index.html' is mapped to 'resource://app/index.html'
       var file = path.basename(call.browser);
       var rootPath = path.join(call.appBasePath, path.dirname(call.browser));
       var startPage = "resource://app/" + file;

       ios = Cc["@mozilla.org/network/io-service;1"]
                         .getService(Ci.nsIIOService),
       resProtocol = ios.getProtocolHandler("resource")
                         .QueryInterface(Ci.nsIResProtocolHandler),

       environment = Cc["@mozilla.org/process/environment;1"]
github mozilla / chromeless / tests / test-url.js View on Github external
exports.testFromFilename = function(test) {
  var fileUrl = url.fromFilename(url.toFilename(__url__));
  test.assertEqual(url.parse(fileUrl).scheme, 'file',
                   'url.toFilename() should return a file: url');
  test.assertEqual(url.fromFilename(url.toFilename(fileUrl)),
                   fileUrl);
};
github mozilla / addon-builder-helper / tests / test-json-channel.js View on Github external
exports.testBasic = function(test) {
  var manager = require("json-channel").createManager("boop");
  var file = require("file");
  var url = require("url");
  var mydir = file.dirname(url.toFilename(__url__));
  var indexUrl = url.fromFilename(file.join(mydir, "test-json-channel.html"));

  var tracker = tabBrowser.whenContentLoaded(
    function(window) {
      if (window.location == indexUrl) {
        var foo = window.document.getElementById("foo");
        var channel = manager.addChannel(window);
        channel.whenMessaged(
          function(data) {
            test.assertEqual(data, "HAI2u!",
                             "chrome channel.whenMessaged() works.");
            channel.send("O YEA!");
            timer.setTimeout(
              function() {
                test.assertEqual(foo.textContent,
                                 'got "O YEA!"',
                                 "content channel.whenMessaged works.");
github mozilla / chromeless / tests / test-url.js View on Github external
exports.testFromFilename = function(test) {
  var fileUrl = url.fromFilename(url.toFilename(__url__));
  test.assertEqual(url.parse(fileUrl).scheme, 'file',
                   'url.toFilename() should return a file: url');
  test.assertEqual(url.fromFilename(url.toFilename(fileUrl)),
                   fileUrl);
};