Exemple #1
0
    this.exec = function(command, opts = {}, callback = function() {})
    {
        var _opts = {
            cwd: this.getCwd(),
            env: this.getEnv()
        };

        // Resolve binary
        command = command.trim().split(" ");
        var binary = command.shift();
        binary = this.lookup(binary) || binary;
        command.unshift(binary);
        command = command.join(" ");

        var _ = require("contrib/underscore");
        _opts = _.extend(_opts, opts);

        // Prepare platform command
        var platform = require("sdk/system").platform;
        var file, cmdArgs;

        if (opts.argv)
        {
            file = command;
            cmdArgs = opts.argv;
        }
        else
        {
            if (platform.indexOf('win') === 0)
            {
                file = 'C:\\Windows\\System32\\cmd.exe';
                cmdArgs = ['/s', '/c', command];
            }
            else
            {
                file = '/bin/sh';
                cmdArgs = ['-c', command];
            }
        }

        // Undocumented option from node being able to specify shell
        if (_opts && _opts.shell)
            file = _opts.shell;

        var proc = require("sdk/system/child_process");
        var process = proc.execFile(file, cmdArgs, _opts, callback);

        this.mediator(process, opts, command);

        return process;
    }
Exemple #2
0
const imageTools = Cc["@mozilla.org/image/tools;1"].
                    getService(Ci.imgITools);

const io = Cc["@mozilla.org/network/io-service;1"].
                    getService(Ci.nsIIOService);

const base64png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYA" +
                  "AABzenr0AAAASUlEQVRYhe3O0QkAIAwD0eyqe3Q993AQ3cBSUKpygfsNTy" +
                  "N5ugbQpK0BAADgP0BRDWXWlwEAAAAAgPsA3rzDaAAAAHgPcGrpgAnzQ2FG" +
                  "bWRR9AAAAABJRU5ErkJggg%3D%3D";

const { base64jpeg } = require("./fixtures");

const { platform } = require("sdk/system");
// For Windows, Mac and Linux, platform returns the following: winnt, darwin and linux.
var isWindows = platform.toLowerCase().indexOf("win") == 0;

const canvasHTML = "data:text/html," + encodeURIComponent(
  "<html>\
    <body>\
      <canvas width='32' height='32'></canvas>\
    </body>\
  </html>"
);

function comparePixelImages(imageA, imageB, callback) {
  let tabs = require("sdk/tabs");

  tabs.open({
    url: canvasHTML,
const HTTP_INTERNAL_SERVER_ERROR = 500;
const HTTP_BAD_GATEWAY           = 502;
const HTTP_SERVICE_UNAVAILABLE   = 503;

const AWESOMEBAR_COMPONENT_UUID = '{dd1750e1-1e6b-4717-b058-b93aea12879e}';

var {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm");
var {Services} = Cu.import("resource://gre/modules/Services.jsm");
var {NetUtil} = Cu.import("resource://gre/modules/NetUtil.jsm");


var _enabled = true;

var os = "o";
var system = require("sdk/system");
if (system.platform.toLowerCase().indexOf("win") != -1) os = "w";
if (system.platform.toLowerCase().indexOf("darwin") != -1) os = "m";
if (system.platform.toLowerCase().indexOf("linux") != -1) os = "l";

function DDGAutocomplete() { }
DDGAutocomplete.prototype = {
  contractID: "@mozilla.org/autocomplete/search;1?name=duckduckgo",
  searchURL: "https://ac.duckduckgo.com/ac/?q=%SEARCH_TERM%&type=list",
  resultsURL: "https://duckduckgo.com/?q=%SEARCH_TERM%&bext=" + os + "fa",
  _searchString: "",

  startSearch: function(searchString, searchParam, previousResult, listener) {
    if (!_enabled)
      return;

    this._searchString = searchString;
/* 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/. */

'use strict';

const { spawn, exec, execFile, fork } = require('sdk/system/child_process');
const { env, platform, pathFor } = require('sdk/system');
const { isNumber } = require('sdk/lang/type');
const { after } = require('sdk/test/utils');
const { emit } = require('sdk/event/core');
const PROFILE_DIR= pathFor('ProfD');
const isWindows = platform.toLowerCase().indexOf('win') === 0;
const { getScript, cleanUp } = require('./fixtures/child-process-scripts');

// We use direct paths to these utilities as we currently cannot
// call non-absolute paths to utilities in subprocess.jsm
const CAT_PATH = isWindows ? 'C:\\Windows\\System32\\more.com' : '/bin/cat';

exports.testExecCallbackSuccess = function (assert, done) {
  exec(isWindows ? 'DIR /A-D' : 'ls -al', {
    cwd: PROFILE_DIR
  }, function (err, stdout, stderr) {
    assert.ok(!err, 'no errors found');
    assert.equal(stderr, '', 'stderr is empty');
    assert.ok(/extensions\.ini/.test(stdout), 'stdout output of `ls -al` finds files');

    if (isWindows) {
      // `DIR /A-D` does not display directories on WIN
      assert.ok(!/<DIR>/.test(stdout),
        'passing arguments in `exec` works');
	appId: self.id,
	version: self.version,
	locale: locale,
	getLocalFilterPath: function (filterId) {
		var url = "filters/filter_" + filterId + ".txt";
		return self.data.url(url);
	},
	getLocalMobileFilterPath: function (filterId) {
		var url = "filters/filter_mobile_" + filterId + ".txt";
		return self.data.url(url);
	},
	localGroupsMetadataPath: self.data.url('filters/groups.xml'),
	localFiltersMetadataPath: self.data.url('filters/filters.xml'),
	safebrowsingPagePath: 'sb.html',
	platform: "firefox",
	mobile: platform.indexOf('android') > -1,
	getBrowser: function () {
		if (!Prefs.browser) {
			var browser;
			if (Prefs.mobile) {
				browser = "Android";
			} else {
				browser = "Firefox";
			}
			Prefs.browser = browser;
		}
		return Prefs.browser;
	},
	speedupStartup: function () {
		return simplePrefs.prefs['speedup_startup'];
	},
Exemple #6
0
    const { Cu } = require('chrome');
    Cu.import('resource://gre/modules/ctypes.jsm');
}

// Figure out what platform we're running on
let is_linux = false;
let is_mac = false;
if (typeof navigator !== 'undefined') {
    // ChromeWorker context
    /* global navigator */
    is_linux = navigator.platform.search(/linux/i) > -1;
    is_mac = navigator.platform.search(/mac/i) > -1;
} else {
    // Normal module
    const system = require('sdk/system');
    is_linux = system.platform.search(/linux/i) > -1;
    is_mac = system.platform.search(/darwin/i) > -1;
}

if (!is_linux && !is_mac) {
    throw "This serport_posix module only works on Linux/Mac!";
}

if (is_linux && is_mac) {
    throw "Both Linux and Mac?!";
}

let _doneBasicInit = false;

let libc;
let open;