Example #1
0
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

"use strict";

const {Cu} = require("chrome")

Cu.import('resource://gre/modules/ctypes.jsm');
const {MacTypes} = require("./MacTypes");
const {Framework} = require("./Framework");
const {CoreFoundation} = require("./CoreFoundation");

function SecurityFramework() {};
SecurityFramework.prototype = new Framework('Security');

var Security = exports.Security = new SecurityFramework();



var sec = SecurityFramework.prototype;


sec.OpaqueSecKeychainRef = new ctypes.StructType('OpaqueSecKeychainRef');
Example #2
0
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=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/. */
"use strict";

const {Cu} = require("chrome");

let {TiltVisualizer} = require("devtools/tilt/tilt-visualizer");
let TiltGL = require("devtools/tilt/tilt-gl");
let TiltUtils = require("devtools/tilt/tilt-utils");
let EventEmitter = require("devtools/toolkit/event-emitter");
let Telemetry = require("devtools/shared/telemetry");

Cu.import("resource://gre/modules/Services.jsm");

// Tilt notifications dispatched through the nsIObserverService.
const TILT_NOTIFICATIONS = {
  // Called early in the startup of a new tilt instance
  STARTUP: "tilt-startup",

  // Fires when Tilt starts the initialization.
  INITIALIZING: "tilt-initializing",

  // Fires immediately after initialization is complete.
  // (when the canvas overlay is visible and the 3D mesh is completely created)
  INITIALIZED: "tilt-initialized",

  // Fires immediately before the destruction is started.
  DESTROYING: "tilt-destroying",
Example #3
0
/* See license.txt for terms of usage */

"use strict";

const { Cu } = require("chrome");
const { Trace, TraceError } = require("../core/trace.js").get(module.id);
const { EventTarget } = require("sdk/event/target");
const { Class } = require("sdk/core/heritage");
const { prefs } = require("sdk/simple-prefs");
const { Locale } = require("../core/locale.js");
const { on } = require("sdk/dom/events.js");
const { Dom } = require("../core/dom.js");

const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
const { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});

const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

var Menu = {};

Menu.createMenu = function(popup, item) {
  let menu = popup.ownerDocument.createElement("menu");
  popup.appendChild(menu);

  Menu.setItemIntoElement(menu, item);

  this.createMenuPopup(menu, item);

  return menu;
};
Example #4
0
/* globals Task, ClientID */

const {PlacesProvider} = require("lib/PlacesProvider");
const {SearchProvider} = require("lib/SearchProvider");
const {ActivityStreams} = require("lib/ActivityStreams");
const simplePrefs = require("sdk/simple-prefs");
const {Cu} = require("chrome");

Cu.import("resource://gre/modules/ClientID.jsm");
Cu.import("resource://gre/modules/Task.jsm");

let app = null;

Object.assign(exports, {
  main(options) {

    // options.loadReason can be install/enable/startup/upgrade/downgrade
    PlacesProvider.links.init();
    SearchProvider.search.init();
    options.telemetry = false;

    Task.spawn(function*() {
      options.clientID = yield ClientID.getClientID();
      options.pingEndpoint = simplePrefs.prefs["telemetry.ping.endpoint"];
      app = new ActivityStreams(options);
    }.bind(this));
  },

  onUnload(reason) {
    if (app) {
      app.unload(reason);
/* 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 { Cc, Ci, Cu } = require("chrome");
const {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {});

let protocol = require("devtools/server/protocol");
let events = require("sdk/event/core");

let { Arg, method, RetVal, ActorClass, FrontClass, Front, Actor, types, preEvent } = protocol;
let { Services } = Cu.import("resource://gre/modules/Services.jsm");

const gAccRetrieval = Cc["@mozilla.org/accessibleRetrieval;1"].
  getService(Ci.nsIAccessibleRetrieval);

function debug() {
  dump("accessibility-tree.js: " + Array.prototype.join.call(arguments, " ") + "\n");
}

types.addActorType("accessible");

types.addDictType("disconnectedAccessible", {
  // The actual node to return
  accessible: "accessible",

  // lineage all the way to the root
  path: "array:accessible"
});
 this.defineLazyGetter(object, name, function () {
   let temp = {};
   Cu.import(resource, temp);
   return temp[symbol || name];
 });
DevToolsUtils.defineLazyGetter(this, "OS", () => {
  return Cu.import("resource://gre/modules/osfile.jsm", {}).OS;
});
Example #8
0
/*
 * This Source Code is subject to the terms of the Mozilla Public License
 * version 2.0 (the 'License'). You can obtain a copy of the License at
 * http://mozilla.org/MPL/2.0/.
 */

const settings = {};

let setInstalledFlagPageMod;
let messageBridgePageMod;
let button;
let app;

const {Cc, Ci, Cu} = require('chrome');

const AddonManager = Cu.import('resource://gre/modules/AddonManager.jsm').AddonManager;

const Prefs = Cu.import('resource://gre/modules/Preferences.jsm').Preferences;
const cookieManager2 = Cc['@mozilla.org/cookiemanager;1']
                       .getService(Ci.nsICookieManager2);

const self = require('sdk/self');
const store = require('sdk/simple-storage').storage;
const {Panel} = require('sdk/panel');
const {PageMod} = require('sdk/page-mod');
const tabs = require('sdk/tabs');
const {ToggleButton} = require('sdk/ui/button/toggle');
const request = require('sdk/request').Request;
const simplePrefs = require('sdk/simple-prefs');
const URL = require('sdk/url').URL;
const history = require('sdk/places/history');
Example #9
0
/* 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";

module.metadata = {
  "stability": "experimental",
  "engines": {
    "Firefox": "> 28"
  }
};

const { Cu } = require("chrome");
const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
const { subscribe, send, Reactor, foldp, lift, merges } = require("../../event/utils");
const { InputPort } = require("../../input/system");
const { OutputPort } = require("../../output/system");
const { Interactive } = require("../../input/browser");
const { CustomizationInput } = require("../../input/customizable-ui");
const { pairs, map, isEmpty, object,
        each, keys, values } = require("../../util/sequence");
const { curry, flip } = require("../../lang/functional");
const { patch, diff } = require("diffpatcher/index");
const prefs = require("../../preferences/service");
const { getByOuterId } = require("../../window/utils");
const { ignoreWindow } = require('../../private-browsing/utils');

const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const PREF_ROOT = "extensions.sdk-toolbar-collapsed.";

Example #10
0
/* 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 { Cc, Ci, Cu, Cm, components } = require("chrome");
const xulApp = require("sdk/system/xul-app");
const self = require("sdk/self");
const { Loader, main, unload } = require("toolkit/loader");
const loaderOptions = require("@loader/options");

const { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm", {});

exports.testSelf = function(assert) {
  // Likewise, we can't assert anything about the full URL, because that
  // depends on self.id . We can only assert that it ends in the right
  // thing.
  var url = self.data.url("test-content-symbiont.js");
  assert.equal(typeof(url), "string", "self.data.url('x') returns string");
  assert.equal(/\/test-content-symbiont\.js$/.test(url), true);

  // Make sure 'undefined' is not in url when no string is provided.
  url = self.data.url();
  assert.equal(typeof(url), "string", "self.data.url() returns string");
  assert.equal(/\/undefined$/.test(url), false);

  // When tests are run on just the api-utils package, self.name is
  // api-utils. When they're run as 'cfx testall', self.name is testpkgs.
  assert.equal(self.name, "addon-sdk", "self.name is addon-sdk");

  // loadReason may change here, as we change the way tests addons are installed
Example #11
0
"use strict";

var main = require("../../main.js");
const self = require("sdk/self");

const { Ci, Cu, Cc } = require("chrome");
const { Http } = require("../../core/http.js");
const { Dom } = require("../../core/dom.js");
const { System } = require("../../core/system.js");
const { Trace, TraceError } = require("../../core/trace.js");//.get(module.id);
const { ConsoleMessage } = require("../console-message.js");
const { LoggerFront } = require("./logger-front.js");
const { defer } = require("sdk/core/promise");

const { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
const { console } = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
const { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});

// Calling devtools.require() does not work. For some reasons, the path
// provided will be checked according to the addons-sdk path logic.
const { Messages, Widgets } = devtools["require"]("devtools/webconsole/console-output");

// xxxHonza: Firefox 36+
const { ActorRegistryFront } = System.devtoolsRequire("devtools/server/actors/actor-registry");

const Events = require("sdk/system/events.js");
const base64 = require("sdk/base64");
const tabUtils = require("sdk/tabs/utils");
Example #12
0
 * 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';

let {
  Loader, main, unload, parseStack, generateMap, resolve, join
} = require('toolkit/loader');
let { readURI } = require('sdk/net/url');

let root = module.uri.substr(0, module.uri.lastIndexOf('/'))


// The following adds Debugger constructor to the global namespace.
const { Cu } = require('chrome');
const { addDebuggerToGlobal } = Cu.import('resource://gre/modules/jsdebugger.jsm', {});
addDebuggerToGlobal(this);

exports['test resolve'] = function (assert) {
  let cuddlefish_id = 'sdk/loader/cuddlefish';
  assert.equal(resolve('../index.js', './dir/c.js'), './index.js');
  assert.equal(resolve('./index.js', './dir/c.js'), './dir/index.js');
  assert.equal(resolve('./dir/c.js', './index.js'), './dir/c.js');
  assert.equal(resolve('../utils/file.js', './dir/b.js'), './utils/file.js');

  assert.equal(resolve('../utils/./file.js', './dir/b.js'), './utils/file.js');
  assert.equal(resolve('../utils/file.js', './'), './../utils/file.js');
  assert.equal(resolve('./utils/file.js', './'), './utils/file.js');
  assert.equal(resolve('./utils/file.js', './index.js'), './utils/file.js');

  assert.equal(resolve('../utils/./file.js', cuddlefish_id), 'sdk/utils/file.js');
Example #13
0
const ADB = require("adb/adb");
const Timer = require("timer");
const Promise = require("sdk/core/promise");
const { Cu, Ci } = require("chrome");
const { OS } = Cu.import("resource://gre/modules/osfile.jsm", {});

const File = require("sdk/io/file");
const TEMP_DIR = require("sdk/system").pathFor('TmpD');

Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");

let isPhonePluggedIn = null;

let observer = {
  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                         Ci.nsISupportsWeakReference]),
  observe: function observe(subject, topic, data) {
    console.log("simulator.observe: " + topic);
    switch (topic) {
      case "adb-ready":
        break;
      case "adb-device-connected":
        isPhonePluggedIn = true;
        break;
      case "adb-device-disconnected":
        isPhonePluggedIn = false;
        break;
    }
  }
};
Example #14
0
exports = (function(exports) {
  let ADB = null;
  const Timer = require("timer");
  const Promise = require("sdk/core/promise");
  const { Cu, Ci } = require("chrome");
  const { OS } = Cu.import("resource://gre/modules/osfile.jsm", {});

  const File = require("sdk/io/file");
  const TEMP_DIR = require("sdk/system").pathFor('TmpD');

  Cu.import("resource://gre/modules/XPCOMUtils.jsm");
  Cu.import("resource://gre/modules/Services.jsm");

  let isPhonePluggedIn = null;
  let isPortInUse = false;

  let observer = {
    QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                           Ci.nsISupportsWeakReference]),
    observe: function observe(subject, topic, data) {
      console.log("simulator.observe: " + topic);
      switch (topic) {
        case "adb-ready":
          ADB.trackDevices();
          break;
        case "adb-device-connected":
          isPhonePluggedIn = true;
          break;
        case "adb-device-disconnected":
          isPhonePluggedIn = false;
          break;
        case "adb-port-in-use":
          isPortInUse = true;
          break;
      }
    }
  };

  // Before all
  exports["test a before"] = function(assert, done) {
    require("adb/adb-running-checker").check().then(function(isAdbRunning) {
        ADB = require("adb/adb");
        if (!ADB.ready) {
          ADB.start();
        }
        Services.obs.addObserver(observer, "adb-device-connected", true);
        Services.obs.addObserver(observer, "adb-device-disconnected", true);
        Services.obs.addObserver(observer, "adb-ready", true);
        Services.obs.addObserver(observer, "adb-port-in-use", true);
        assert.pass("Started");
        done();
      });
  };

  function dumpBanner(msg) {
    let starCount = msg.length + 8;
    let starLine = '';
    for (let i = 0; i < starCount; i++) {
      starLine += '*';
    }
    let msgLine = '*   ' + msg + '   *';

    console.log();
    console.log(starLine);
    console.log(starLine);
    console.log(msgLine);
    console.log(starLine);
    console.log(starLine);
    console.log();
  }

  function waitUntil(trigger, andThen) {
    Timer.setTimeout(function() {
      if (!trigger()) {
        waitUntil(trigger, andThen);
      } else {
        andThen();
      }
    }, 50);
  }

  exports["test ab list devices"] = function(assert, done) {
    // Give adb 2 seconds to startup
    Timer.setTimeout(function listDevices() {
      if (isPortInUse) {
        isPhonePluggedIn = false;
        assert.fail("Error: Port 5037 is in use.\nHave you opened the " +
                    "Simulator in a different Firefox profile?\nMake " +
                    "sure you quit that process before running the tests.");
        done();
        return;
      }
      ADB.listDevices().then(
        function success(e) {
          if (ADB.didRunInitially && e[0]) {
            let [, status] = e[0];
            if (status === "offline") {
              isPhonePluggedIn = false;
              assert.fail("Device is offline");
              done();
              return;
            }
          } else {
            // adb-fallback returns a string if the device is plugged in
            isPhonePluggedIn = !!e[0];
          }

          if (isPhonePluggedIn) {
            assert.pass("Devices: " + JSON.stringify(e));
            console.log("Device is plugged in");
            done();
          } else {
            assert.pass("Devices: " + JSON.stringify(e));
            console.log("Device is not plugged in");
            done();
          }
        },
        function fail(e) {
          assert.fail("Failed to list devices: " + JSON.stringify(e));
          done();
        });
    }, 2000);
  };

  exports["test b adb.shell, no phone"] = function (assert, done) {
    if (isPhonePluggedIn || !ADB.didRunInitially) {
      assert.pass("Skipping test");
      done();
      return;
    }

    let command = "ls";
    ADB.shell(command).then(
        function success(output) {
          assert.fail("Should reject promise when phone unplugged");
          done();
        },
        function fail(e) {
          assert.ok(e, ADB.DEVICE_NOT_CONNECTED, "Error wasn't DEVICE_NOT_CONNECTED");
          done();
        });
  };

  exports["test c adb push, no phone"] = function (assert, done) {
    if (isPhonePluggedIn || !ADB.didRunInitially) {
      assert.pass("Skipping test");
      done();
      return;
    }

    let str = "astring" + Math.random();
    let pathToFile = require("sdk/test/tmp-file").createFromString(str);

    ADB.push(pathToFile,
                 "/sdcard/test.txt").then(
      function success(e) {
        assert.fail("Should reject promise when phone unplugged");
        done();
      },
      function fail(e) {
        assert.ok(e, ADB.DEVICE_NOT_CONNECTED, "Error wasn't DEVICE_NOT_CONNECTED");
        done();
      });
  };

  exports["test d adb shell, with phone"] = function (assert, done) {
    if (!isPhonePluggedIn || !ADB.didRunInitially) {
      assert.pass("Skipping test");
      done();
      return;
    }

    let command = "ls";
    console.log("Running adb shell");
    ADB.shell(command).then(
      function success(output) {
        assert.ok(output.split('\n').length > 7, "Recieved `ls` output");
        done();
      },
      function fail(e) {
        assert.fail("Shell failed: " + JSON.stringify(e));
        done();
      });
  };

  exports["test e adb push, with phone"] = function (assert, done) {
    if (!isPhonePluggedIn || !ADB.didRunInitially) {
      assert.pass("Skipping test");
      done();
      return;
    }

    let str = "astring" + Math.random();
    let pathToFile = require("sdk/test/tmp-file").createFromString(str);

    ADB.push(pathToFile,
                 "/sdcard/test.txt").then(
      function success(e) {
        ADB.shell("cat /sdcard/test.txt").then(
          function success(e) {
            assert.equal(e, str, "Contents of file on host: " + e + " should be same on device: " + str);
            done();
          },
          function fail(e) {
            console.log("Error: " + e);
            assert.fail("Error catting");
            done();
          });
      },
      function fail(e) {
        assert.fail("Error pushing: " + e);
        done();
      });
  };

  // Uncomment to test proper disconnecting and connecting of devices
  // Requires manual intervention
  /*
  exports["test f device tracking, with phone"] = function(assert, done) {
    if (!isPhonePluggedIn) {
      assert.pass("Skipping test");
      done();
      return;
    }

    dumpBanner("UNPLUG YOUR DEVICE");

    waitUntil(function() !isPhonePluggedIn, function andThen() {
      assert.pass("Tracker caught disconnection successfully");
      dumpBanner("PLUG IN YOUR DEVICE");
      waitUntil(function() isPhonePluggedIn, function andThen() {
        assert.pass("Tracker caught connection successfully");
        done();
      });
    });
  };
  */

  exports["test shutdown and start"] = function (assert, done) {
    ADB.close();
    ADB.start();
    assert.pass("No crash.");
    done();
  };

  exports["test zz after"] = function(assert, done) {
    if (ADB.didRunInitially) {
      try {
        ADB.close();
      } catch (e) {
        if (!isPortInUse) {
          throw e;
        }
      }
    }
    assert.pass("Done!");
    done();
  };

  return exports;
})(exports);
Example #15
0
const { Ci, Cu, Cc, Cr } = require('chrome');
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/devtools/Console.jsm');

var observers = {
    'http-on-modify-request': {
        observe: function (aSubject, aTopic, aData) {
            var httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
            var requestUrl = httpChannel.URI.spec
            if ( requestUrl.indexOf('%E2%80%8B') != -1
             ||  requestUrl.indexOf('%E2%80%8C') != -1
             ||  requestUrl.indexOf('%E2%80%8D') != -1
             ||  requestUrl.indexOf('%EF%BB%BF') != -1
             ||  requestUrl.indexOf('​') != -1
             ||  requestUrl.indexOf('​') != -1
             ||  requestUrl.indexOf('‌') != -1
             ||  requestUrl.indexOf('‍') != -1
             ||  requestUrl.indexOf('а') != -1) {
                   httpChannel.redirectTo(Services.io.newURI('data:text,url_blocked_because_of_zero_width_space_characters_presence', null, null));
            }
        },
        reg: function () {
            Services.obs.addObserver(observers['http-on-modify-request'], 'http-on-modify-request', false);
        },
        unreg: function () {
            Services.obs.removeObserver(observers['http-on-modify-request'], 'http-on-modify-request');
        }
    }
};

for (var o in observers) {
Example #16
0
/* 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 {Cc, Cu, Ci} = require("chrome");
const promise = require("sdk/core/promise");
const IOService = Cc["@mozilla.org/network/io-service;1"]
  .getService(Ci.nsIIOService);
const {Spectrum} = require("devtools/shared/widgets/Spectrum");
const EventEmitter = require("devtools/shared/event-emitter");
const {colorUtils} = require("devtools/css-color");
const Heritage = require("sdk/core/heritage");

Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/devtools/ViewHelpers.jsm");

const GRADIENT_RE = /\b(repeating-)?(linear|radial)-gradient\(((rgb|hsl)a?\(.+?\)|[^\)])+\)/gi;
const BORDERCOLOR_RE = /^border-[-a-z]*color$/ig;
const BORDER_RE = /^border(-(top|bottom|left|right))?$/ig;
const BACKGROUND_IMAGE_RE = /url\([\'\"]?(.*?)[\'\"]?\)/;
const XHTML_NS = "http://www.w3.org/1999/xhtml";
const SPECTRUM_FRAME = "chrome://browser/content/devtools/spectrum-frame.xhtml";
const ESCAPE_KEYCODE = Ci.nsIDOMKeyEvent.DOM_VK_ESCAPE;
const ENTER_KEYCODE = Ci.nsIDOMKeyEvent.DOM_VK_RETURN;
const SHOW_TIMEOUT = 50;

/**
 * Tooltip widget.
 *
Example #17
0
/* See license.txt for terms of usage */

"use strict";

const { Cc, Ci, Cu } = require("chrome");
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});

const events = require("sdk/event/core");
let protocol = devtools["require"]("devtools/server/protocol");
let { method, Arg, RetVal, ActorClass, FrontClass, Front, Actor } = protocol;

// dump("\n\n\n\n\t\tjit-actor.js is being loaded\n\n\n\n\n");

/**
 * This new type is the type of arguments returned by onIonCompilation
 * argument.  The only difference is that the Debugger.Scripts have to be
 * filtered ahead such that not all properties are accessed.
 *
 * The try catch is needed because this file is imported twice, once by the
 * sdk, where it is used to define the JitFront, and a second time by the
 * actor registery, which load this file on the remote to define the
 * JitActor. Sadly, when the remote is on the same runtime, then we have an
 * issue about the Type which already exists.
 */
try {
  protocol.types.addDictType("compilationgraph", {
    scripts: "json",
    json: "string" // "longstring" does not seems to work well.
  });
} catch (e) {
}
Example #18
0
    exec: function (args, context) {
      let globalObj;
      let contentWindow = context.environment.window;

      if (args.sourceType == "jsm") {
        try {
          globalObj = Cu.import(args.source, {});
        } catch (e) {
          return l10n.lookup("callLogChromeInvalidJSM");
        }
      } else if (args.sourceType == "content-variable") {
        if (args.source in contentWindow) {
          globalObj = Cu.getGlobalForObject(contentWindow[args.source]);
        } else {
          throw new Error(l10n.lookup("callLogChromeVarNotFoundContent"));
        }
      } else if (args.sourceType == "chrome-variable") {
        let chromeWin = context.environment.chromeDocument.defaultView;
        if (args.source in chromeWin) {
          globalObj = Cu.getGlobalForObject(chromeWin[args.source]);
        } else {
          return l10n.lookup("callLogChromeVarNotFoundChrome");
        }
      } else {
        let chromeWin = context.environment.chromeDocument.defaultView;
        let sandbox = new Cu.Sandbox(chromeWin, {
          sandboxPrototype: chromeWin,
          wantXrays: false,
          sandboxName: "gcli-cmd-calllog-chrome"
        });
        let returnVal;
        try {
          returnVal = Cu.evalInSandbox(args.source, sandbox, "ECMAv5");
          sandboxes.push(sandbox);
        } catch (e) {
          // We need to save the message before cleaning up else e contains a dead
          // object.
          let msg = l10n.lookup("callLogChromeEvalException") + ": " + e;
          Cu.nukeSandbox(sandbox);
          return msg;
        }

        if (typeof returnVal == "undefined") {
          return l10n.lookup("callLogChromeEvalNeedsObject");
        }

        globalObj = Cu.getGlobalForObject(returnVal);
      }

      let dbg = new Debugger(globalObj);
      chromeDebuggers.push(dbg);

      dbg.onEnterFrame = function (frame) {
        // BUG 773652 -  Make the output from the GCLI calllog command nicer
        contentWindow.console.log(l10n.lookup("callLogChromeMethodCall") +
                                  ": " + this.callDescription(frame));
      }.bind(this);

      let gBrowser = context.environment.chromeDocument.defaultView.gBrowser;
      let target = TargetFactory.forTab(gBrowser.selectedTab);
      gDevTools.showToolbox(target, "webconsole");

      return l10n.lookup("calllogChromeStartReply");
    },
DevToolsUtils.defineLazyGetter(this, "NetUtil", () => {
  return Cu.import("resource://gre/modules/NetUtil.jsm", {}).NetUtil;
});
Example #20
0
/* 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 { Cu } = require('chrome');
const { PageMod } = require('sdk/page-mod');
const tabs = require('sdk/tabs');
const promise = require('sdk/core/promise')
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
const { data } = require('sdk/self');
const { set } = require('sdk/preferences/service');

const { DebuggerServer } = Cu.import('resource://gre/modules/devtools/dbg-server.jsm', {});
const { DebuggerClient } = Cu.import('resource://gre/modules/devtools/dbg-client.jsm', {});

let gClient;
let ok;
let testName = 'testDebugger';
let iframeURL = 'data:text/html;charset=utf-8,' + testName;
let TAB_URL = 'data:text/html;charset=utf-8,' + encodeURIComponent('<iframe src="' + iframeURL + '" />');
TAB_URL = data.url('index.html');
let mod;

exports.testDebugger = function(assert, done) {
  ok = assert.ok.bind(assert);
  assert.pass('starting test');
  set('devtools.debugger.log', true);

  if (!DebuggerServer.initialized) {
    DebuggerServer.init(() => true);
DevToolsUtils.defineLazyGetter(this, "TextDecoder", () => {
  return Cu.import("resource://gre/modules/osfile.jsm", {}).TextDecoder;
});
Example #22
0
/* 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/. */

/* globals StopIteration */

"use strict";

const {Cc, Ci, Cu} = require("chrome");

const ToolDefinitions = require("devtools/client/definitions").Tools;
const {CssLogic} = require("devtools/shared/inspector/css-logic");
const {ELEMENT_STYLE} = require("devtools/server/actors/styles");
const promise = require("promise");
const Services = require("Services");
const {setTimeout, clearTimeout} = Cu.import("resource://gre/modules/Timer.jsm", {});
const {OutputParser} = require("devtools/client/shared/output-parser");
const {PrefObserver, PREF_ORIG_SOURCES} = require("devtools/client/styleeditor/utils");
const {createChild} = require("devtools/client/inspector/shared/utils");
const {gDevTools} = require("devtools/client/framework/devtools");

loader.lazyRequireGetter(this, "overlays",
  "devtools/client/inspector/shared/style-inspector-overlays");
loader.lazyRequireGetter(this, "StyleInspectorMenu",
  "devtools/client/inspector/shared/style-inspector-menu");

Cu.import("resource://gre/modules/XPCOMUtils.jsm");

XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
                                  "resource://gre/modules/PluralForm.jsm");
Example #23
0
/* 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 { Cu, Ci } = require("chrome");
const { Class } = require("sdk/core/heritage");
const { resolve } = require("promise");
const Services = require("Services");

Cu.import("resource://gre/modules/Task.jsm");

loader.lazyRequireGetter(this, "HarCollector", "devtools/client/netmonitor/har/har-collector", true);
loader.lazyRequireGetter(this, "HarExporter", "devtools/client/netmonitor/har/har-exporter", true);
loader.lazyRequireGetter(this, "HarUtils", "devtools/client/netmonitor/har/har-utils", true);

const prefDomain = "devtools.netmonitor.har.";

// Helper tracer. Should be generic sharable by other modules (bug 1171927)
const trace = {
  log: function (...args) {
  }
};

/**
 * This object is responsible for automated HAR export. It listens
 * for Network activity, collects all HTTP data and triggers HAR
 * export when the page is loaded.
 *
 * The user needs to enable the following preference to make the
 * auto-export work: devtools.netmonitor.har.enableAutoExportToFile
Example #24
0
/* 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/. */

const {Cu} = require("chrome");
const {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm");
const {AddonManager} = Cu.import("resource://gre/modules/AddonManager.jsm");
const {Services} = Cu.import("resource://gre/modules/Services.jsm");
const {getJSON} = require("devtools/shared/getjson");
const EventEmitter = require("devtools/toolkit/event-emitter");

const ADDONS_URL = "devtools.webide.addonsURL";

let SIMULATOR_LINK = Services.prefs.getCharPref("devtools.webide.simulatorAddonsURL");
let ADB_LINK = Services.prefs.getCharPref("devtools.webide.adbAddonURL");
let ADAPTERS_LINK = Services.prefs.getCharPref("devtools.webide.adaptersAddonURL");
let SIMULATOR_ADDON_ID = Services.prefs.getCharPref("devtools.webide.simulatorAddonID");
let ADB_ADDON_ID = Services.prefs.getCharPref("devtools.webide.adbAddonID");
let ADAPTERS_ADDON_ID = Services.prefs.getCharPref("devtools.webide.adaptersAddonID");

let platform = Services.appShell.hiddenDOMWindow.navigator.platform;
let OS = "";
if (platform.indexOf("Win") != -1) {
  OS = "win32";
} else if (platform.indexOf("Mac") != -1) {
  OS = "mac64";
} else if (platform.indexOf("Linux") != -1) {
  if (platform.indexOf("x86_64") != -1) {
    OS = "linux64";
  } else {
    OS = "linux32";
Example #25
0
/* global Services */

const {Cu} = require('chrome');
Cu.import('resource://gre/modules/Services.jsm');

const { getActiveView } = require('sdk/view/core');

module.exports = sendMetricsData;

function sendMetricsData(o, panel) {
  const coords = getActiveView(panel).getBoundingClientRect();

  // NOTE: this packet follows a predefined data format and cannot be changed
  //       without notifying the data team. See docs/metrics.md for more.
  const data = {
    object: o.object,
    method: o.method,
    domain: o.domain,
    'played_count': o.playedCount,
    video_x: coords.top,
    video_y: coords.left,
    video_width: coords.width,
    video_height: coords.height
  };

  const subject = {
    wrappedJSObject: {
      observersModuleSubjectWrapper: true,
      object: '@min-vid'
    }
  };
Example #26
0
/* 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";

let {Cu, Cc, Ci} = require("chrome");

Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");

let {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {});

let DevToolsUtils = require("devtools/toolkit/DevToolsUtils");
let { ActorPool } = require("devtools/server/actors/common");
let { DebuggerServer } = require("devtools/server/main");
let Services = require("Services");

// Comma separated list of permissions that a sideloaded app can't ask for
const UNSAFE_PERMISSIONS = Services.prefs.getCharPref("devtools.apps.forbidden-permissions");

let FramesMock = null;

exports.setFramesMock = function (mock) {
  FramesMock = mock;
};

DevToolsUtils.defineLazyGetter(this, "Frames", () => {
  // Offer a way for unit test to provide a mock
Example #27
0
/* 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 { Cu } = require('chrome');
const { PageMod } = require('sdk/page-mod');
const tabs = require('sdk/tabs');
const { closeTab } = require('sdk/tabs/utils');
const promise = require('sdk/core/promise')
const { getMostRecentBrowserWindow } = require('sdk/window/utils');
const { data } = require('sdk/self');
const { set } = require('sdk/preferences/service');

const { require: devtoolsRequire } = Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
const { DebuggerServer } = devtoolsRequire("devtools/server/main");
const { DebuggerClient } = devtoolsRequire("devtools/shared/client/main");

var gClient;
var ok;
var testName = 'testDebugger';
var iframeURL = 'data:text/html;charset=utf-8,' + testName;
var TAB_URL = 'data:text/html;charset=utf-8,' + encodeURIComponent('<iframe src="' + iframeURL + '" />');
TAB_URL = data.url('index.html');
var mod;

exports.testDebugger = function(assert, done) {
  ok = assert.ok.bind(assert);
  assert.pass('starting test');
  set('devtools.debugger.log', true);
Example #28
0
/* 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/. */

// Wrapper around the fastboot utility.

'use strict';

// Whether or not this script is being loaded as a CommonJS module
// (from an add-on built using the Add-on SDK).  If it isn't a CommonJS Module,
// then it's a JavaScript Module.

const { Cc, Ci, Cu, Cr } = require("chrome");
const { Subprocess } = Cu.import("resource://gre/modules/Subprocess.jsm", {});
const { setInterval, clearInterval } = Cu.import("resource://gre/modules/Timer.jsm", {});
const { PromiseUtils } = Cu.import("resource://gre/modules/PromiseUtils.jsm", {});

Cu.import("resource://gre/modules/Services.jsm");

const { XPCOMABI } = Services.appinfo;

Cu.import("resource://gre/modules/osfile.jsm");

let { Devices } =
  require("./devtools-import")("resource://devtools/shared/apps/Devices.jsm");

let fastbootTimer = null;
let fastbootDevices = [];

const Fastboot = {
  get fastbootDevices() {
Example #29
0
 * @license GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.html>
 */

// This file is using libnotify, which is the client-side
// implementation of the org.freedesktop.Notifications D-Bus
// interface.
//
// Relevant specification descriptions can be found here:
// https://people.gnome.org/~mccann/docs/notification-spec/
//
// In the code, checking for "1.2" or other server versions
// refers to the version implemented server-side.

const {Cu} = require("chrome");

Cu.import("resource://gre/modules/ctypes.jsm", this);
const _ = require("sdk/l10n").get;
const utils = require("./utils.js");
const sps = require("sdk/simple-prefs").prefs;

let libc = null;
let actionsCallbackFunArray = [];
let closedCallbackFunArray = [];
let notificationMap = new Map();

let serverCapabilities = [];
let serverName;

/* eslint-disable no-unused-vars */
let serverVendor;
let serverVersion;
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=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/. */

"use strict";

const {Cc, Ci, Cu} = require("chrome");
const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
const Services = require("Services");

loader.lazyRequireGetter(this, "NetworkHelper",
                               "devtools/shared/webconsole/network-helper");
loader.lazyRequireGetter(this, "JsonViewUtils",
                               "devtools/client/jsonview/utils");

const childProcessMessageManager =
  Cc["@mozilla.org/childprocessmessagemanager;1"]
    .getService(Ci.nsISyncMessageSender);

// Amount of space that will be allocated for the stream's backing-store.
// Must be power of 2. Used to copy the data stream in onStopRequest.
const SEGMENT_SIZE = Math.pow(2, 17);

// Localization
loader.lazyGetter(this, "jsonViewStrings", () => {
  return Services.strings.createBundle(
    "chrome://devtools/locale/jsonview.properties");
});