How to use chrome - 10 common examples

To help you get started, we’ve selected a few chrome 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-services / screenshots / addon / lib / headless.js View on Github external
*   inlineCss (=true to force inline CSS instead of loading external CSS)
 *   useReadability (=true to include the Readability extraction)
 *   allowUnknownAttributes (=true to not scrub data-*, etc, attributes)
 *   delayAfterLoad (=milliseconds to pause before capture)
 *   thumbnailWidth (=pixels of the fullscreenThumbnail width, 0 to not take a thumbnail)
 *
 * Usage without X:
 * To use this without X, start the server as normal. Then, in the bin/
 * directory, run `sh ephemeral-x.sh ./run-addon`.
 */

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

const HTTPD_MOD_URL = module.uri.replace("/headless.js", "/httpd.jsm");
const { nsHttpServer } = Cu.import(HTTPD_MOD_URL);

const { randomString } = require("./randomstring");
const { autoShot, RANDOM_STRING_LENGTH, urlDomainForId } = require("./shooter");
const { prefs } = require("sdk/simple-prefs");
const { setTimeout, clearTimeout } = require("sdk/timers");
const querystringParse = require("sdk/querystring").parse;

const DEFAULT_TIMEOUT = 30000; // 30 seconds

var ip = prefs.httpServerIp;
var port = prefs.httpServerPort;
var backend = prefs.backend;    // set global backend, handleRequest needs it

exports.init = function init() {
  /* Initializes the backend server, which listens for requests made to / and
   * passes them to the handleRequest function below
github firebug / firebug.next / lib / console / remote / commands-actor.js View on Github external
const { Cc, Ci, Cu } = require("chrome");
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});

const protocol = devtools["require"]("devtools/server/protocol");

const { method, RetVal, ActorClass, Actor } = protocol;
const { WebConsoleCommands } = devtools["require"]("devtools/toolkit/webconsole/utils");
const { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});

// xxxHonza: do not hard-code the URL
// xxxHonza: The path should be: 'resource://firebug/lib/core/actor.js'
// See also: https://bugzilla.mozilla.org/show_bug.cgi?id=1081930
const baseUrl = "resource://firebug-at-software-dot-joehewitt-dot-com/";

const { expectState, getTrace } = Cu.import(baseUrl + "lib/core/actor.js");
const Trace = getTrace(DebuggerServer.parentMessageManager);

const actorTypeName = "firebugCommands";

/**
 * Commands we want to register.
 */
let commands = {
  dir: function(owner, ...args) {
    owner.window.console.dir(...args);
  },
  dirxml: function(owner, ...args) {
    owner.window.console.dirxml(...args);
  }
};
github mozilla / activity-stream / addon / ActivityStreams.js View on Github external
send(action, worker, skipMasterStore) {
    // if the function is async, the worker might not be there yet, or might have already disappeared
    try {
      if (!skipMasterStore) {
        this._store.dispatch(action);
      }
      worker.port.emit(ADDON_TO_CONTENT, action);
      this._perfMeter.log(worker.tab, action.type);
    } catch (err) {
      this._pagemod.removeWorker(worker);
      Cu.reportError(err);
    }
  },
github mozilla / memchaser / extension / lib / garbage-collector.js View on Github external
observe: function CollectorObserver_observe(aSubject, aTopic, aData) {
    let data = { };
    let type = aTopic;

    try {
      data = JSON.parse(aData);
    } catch (e) {
      Cu.reportError("Failure parsing JSON data: " + aData);
    }

    // Use milliseconds instead of microseconds for the timestamp
    if ('timestamp' in data)
      data['timestamp'] = Math.round(data['timestamp'] / 1000);

    emit(reporter, type, data);
  }
}
github facebook / react-devtools / shells / firefox / main / trackSelection.js View on Github external
* All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *
 */
'use strict';

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

// The path to this file was moved in Firefox 44 and later.
// See https://bugzil.la/912121 and https://bugzil.la/1203159 for more details.
let gDevTools;
try {
  ({ gDevTools } = Cu.import('resource://devtools/client/framework/' +
                             'gDevTools.jsm', {}));
} catch (e) {
  ({ gDevTools } = Cu.import('resource:///modules/devtools/gDevTools.jsm', {}));
}

/**
 * Whenever the devtools inspector panel selection changes, pass that node to
 * __REACT_DEVTOOLS_GLOBAL_HOOK__.$0
 */
function trackSelection() {
  var wc;
  gDevTools.on('webconsole-init', function(_, toolbox, panelFrame) {
    toolbox.once('webconsole-ready', (eid, panel) => {
      wc = panel;
    });
  });
github firebug / firebug.next / lib / console / remote / monitor-actor.js View on Github external
// Debugger
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
const { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});

// Remote Debugging Protocol API
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
const protocol = devtools["require"]("devtools/server/protocol");
const { method, RetVal, ActorClass, Actor } = protocol;

// xxxHonza: do not hard-code the URL
// xxxHonza: The path should be: 'resource://firebug/lib/core/actor.js'
// See also: https://bugzilla.mozilla.org/show_bug.cgi?id=1081930
const baseUrl = "resource://firebug-at-software-dot-joehewitt-dot-com/";

// Backend helpers
const { expectState, getTrace } = Cu.import(baseUrl + "lib/core/actor.js");
const { getTopFrameElementForRequest } = Cu.import(baseUrl + "lib/console/remote/utils.js");

// TODO support FirePHP
const acceptableHeaders = ["x-chromelogger-data"];

const actorTypeName = "firebugMonitor";
const Trace = getTrace();

/**
 * @actor This object represents an HTTP network event observer.
 * It's registered as a global actor that runs in the parent process
 * in case of multiprocess browser. This is necessary since HTTP
 * events can't be observed inside a child process.
 * Events are consequently forwarded to {@LoggerActor} actor that is
 * running inside the child process.
 *
github firebug / firebug.next / lib / debug / actor-inspector / inspector-actor.js View on Github external

"use strict";

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

// Remote Debugging Protocol API
const { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
const protocol = devtools["require"]("devtools/server/protocol");
const { method, RetVal, ActorClass, Actor } = protocol;

// xxxHonza: do not hard-code the URL
const baseUrl = "resource://firebug-at-software-dot-joehewitt-dot-com/";

// Backend helpers
const { expectState, getTrace } = Cu.import(baseUrl + "lib/core/actor.js");

const Trace = getTrace();

/**
 * @actor TODO docs
 */
var InspectorActor = ActorClass(
/** @lends InspectorActor */
{
  typeName: "actorInspector",

  // Initialization

  initialize: function(conn, parent) {
    Trace.sysout("InspectorActor.initialize; parent: " +
      parent.actorID + ", conn: " + conn.prefix, this);
github mozilla / activity-stream / addon / PreviewProvider.js View on Github external
}).catch(err => {
      // TODO: add more exception handling code, e.g. sending exception report
      Cu.reportError(err);
    });
  },
github MozillaReality / webvr-addon / index.js View on Github external
/* global require, exports */

const { Cc, Ci, Cu, Cm } = require('chrome');
const { PageMod } = require('sdk/page-mod');
const self = require('sdk/self');
const prefs = require('sdk/preferences/service');

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

const pkg = require('./package.json');

const PREFS = {
  // Enables WebVR. Not needed for Nightly, but we need to keep for other versions.
  'dom.vr.enabled': true,

  // Enables the OpenVR API (e.g., Steam VR).
  'dom.vr.openvr.enabled': true,

  // Enables mirroring. It's confusing otherwise, if you're not looking at your headset.
  'gfx.vr.mirror-textures': true
};

function setDefaultPrefs () {
  var needsReset = false;
github firebug / har-export-trigger / lib / trigger-toolbox-overlay.js View on Github external
onReady: function(options) {
    ToolboxOverlay.prototype.onReady.apply(this, arguments);

    Trace.sysout("TriggerToolboxOverlay.onReady;", options);

    // Platform support is needed here.
    // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1184889
    if (typeof getHarOverlay != "function") {
      Cu.reportError("Platform support needed, see Bug: " +
        "https://bugzilla.mozilla.org/show_bug.cgi?id=1184889");
      return;
    }

    // Call make remote to make sure the target.client exists.
    let target = this.toolbox.target;
    target.makeRemote().then(() => {
      // The 'devtools.netmonitor.har.enableAutoExportToFile' option doesn't
      // have to be set if users don't want to auto export to file after
      // every page load.
      // But, if users want to use HAR content API to trigger HAR export
      // when needed, HAR automation needs to be activated. Let's do it now
      // if 'extensions.netmonitor.har.enableAutomation' preference is true.
      if (prefs.enableAutomation && !this.automation) {
        Trace.sysout("TriggerToolboxOverlay.onReady; Init automation");

chrome

Open chrome in shell

ISC
Latest version published 9 years ago

Package Health Score

42 / 100
Full package analysis

Popular chrome functions