Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* 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
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);
}
};
* 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;
});
});
// 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.
*
"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);
/* 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;
function getAddons() {
const { Cu } = require('chrome');
let { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm");
let addons = [];
AddonManager.getAllAddons(function(addonList) {
addonList.forEach(function(addon) {
let o = {};
let states = ['id', 'name', 'appDisabled', 'isActive', 'type',
'userDisabled'];
states.forEach(function(state) { o[state] = addon[state]; });
addons.push(o);
});
});
console.debug(JSON.stringify(addons));
return addons;
}
const { Cu } = require("chrome");
Cu.import("resource://gre/modules/Services.jsm");
exports.get_sytem_font_style = function get_sytem_font_style() {
let rootwin = Services.wm.getMostRecentWindow("navigator:browser");
let { color, fontFamily, fontSize, fontWeight } = rootwin.getComputedStyle(rootwin.document.documentElement);
return `html, body {
color: ${color};
font-family: ${fontFamily}, -apple-system, "Segoe UI", "Roboto", "Ubuntu", "Cantarell", "Oxygen", "Dejavu Sans", "Fira Sans", "Droid Sans", "Helvetica Neue", "Arial", sans-serif;
font-weight: ${fontWeight};
font-size: ${fontSize};
}`;
};
const {Cu} = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "windowMediator",
"@mozilla.org/appshell/window-mediator;1",
"nsIWindowMediator");
module.exports = function getCurrentBrowser() {
const win = windowMediator.getMostRecentWindow("navigator:browser");
const gBrowser = win.getBrowser();
return gBrowser.selectedBrowser;
};
return;
}
var textReader = file.open(oldRedirectsFile, 'r');
var jsonData = JSON.parse(textReader.read());
textReader.close();
var Redirect = require('../redirect').Redirect;
var newData = {redirects:[]};
for (var r of jsonData.redirects) {
var redirect = new Redirect(r);
redirect.updateExampleResult();
newData.redirects.push(redirect.toObject());
}
Cu.import("resource://gre/modules/Services.jsm");
var enabled = true;
try {
enabled = Services.prefs.getBoolPref('extensions.redirector.enabled');
} catch(e) {}
newData.disabled = !enabled;
//Kill old prefs:
var oldPrefs = ['enabled', 'debugEnabled', 'enableShortcutKey', 'version', 'defaultDir'];
for (var p of oldPrefs) {
try {
Services.prefs.deleteBranch('extensions.redirector.' + p);
} catch(e) {
}
}