зеркало из https://github.com/mozilla/gecko-dev.git
Bug 758696 - Add a dialog to the debugger to deny or allow incoming server connections (Part 1: Firefox); r=rcampbell
This commit is contained in:
Родитель
9d7f00830b
Коммит
ffabfb5218
|
@ -201,7 +201,8 @@ DebuggerPane.prototype = {
|
||||||
*/
|
*/
|
||||||
_initServer: function DP__initServer() {
|
_initServer: function DP__initServer() {
|
||||||
if (!DebuggerServer.initialized) {
|
if (!DebuggerServer.initialized) {
|
||||||
DebuggerServer.init();
|
// Always allow connections from nsIPipe transports.
|
||||||
|
DebuggerServer.init(function () { return true; });
|
||||||
DebuggerServer.addBrowserActors();
|
DebuggerServer.addBrowserActors();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -405,13 +406,39 @@ ChromeDebuggerProcess.prototype = {
|
||||||
*/
|
*/
|
||||||
_initServer: function RDP__initServer() {
|
_initServer: function RDP__initServer() {
|
||||||
if (!DebuggerServer.initialized) {
|
if (!DebuggerServer.initialized) {
|
||||||
DebuggerServer.init();
|
DebuggerServer.init(this._allowConnection);
|
||||||
DebuggerServer.addBrowserActors();
|
DebuggerServer.addBrowserActors();
|
||||||
}
|
}
|
||||||
DebuggerServer.closeListener();
|
DebuggerServer.closeListener();
|
||||||
DebuggerServer.openListener(DebuggerPreferences.remotePort, false);
|
DebuggerServer.openListener(DebuggerPreferences.remotePort, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prompt the user to accept or decline the incoming connection.
|
||||||
|
*
|
||||||
|
* @return true if the connection should be permitted, false otherwise
|
||||||
|
*/
|
||||||
|
_allowConnection: function RDP__allowConnection() {
|
||||||
|
let title = L10N.getStr("remoteIncomingPromptTitle");
|
||||||
|
let msg = L10N.getStr("remoteIncomingPromptMessage");
|
||||||
|
let disableButton = L10N.getStr("remoteIncomingPromptDisable");
|
||||||
|
let prompt = Services.prompt;
|
||||||
|
let flags = prompt.BUTTON_POS_0 * prompt.BUTTON_TITLE_OK +
|
||||||
|
prompt.BUTTON_POS_1 * prompt.BUTTON_TITLE_CANCEL +
|
||||||
|
prompt.BUTTON_POS_2 * prompt.BUTTON_TITLE_IS_STRING +
|
||||||
|
prompt.BUTTON_POS_1_DEFAULT;
|
||||||
|
let result = prompt.confirmEx(null, title, msg, flags, null, null,
|
||||||
|
disableButton, null, { value: false });
|
||||||
|
if (result == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (result == 2) {
|
||||||
|
DebuggerServer.closeListener();
|
||||||
|
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a profile for the remote debugger process.
|
* Initializes a profile for the remote debugger process.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -105,7 +105,9 @@ let DebuggerController = {
|
||||||
if (!Prefs.remoteAutoConnect) {
|
if (!Prefs.remoteAutoConnect) {
|
||||||
let prompt = new RemoteDebuggerPrompt();
|
let prompt = new RemoteDebuggerPrompt();
|
||||||
let result = prompt.show(!!this._remoteConnectionTimeout);
|
let result = prompt.show(!!this._remoteConnectionTimeout);
|
||||||
if (!result) {
|
// If the connection was not established before the user canceled the
|
||||||
|
// prompt, close the remote debugger.
|
||||||
|
if (!result && !DebuggerController.activeThread) {
|
||||||
this.dispatchEvent("Debugger:Close");
|
this.dispatchEvent("Debugger:Close");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ function test() {
|
||||||
},
|
},
|
||||||
function beforeTabAdded() {
|
function beforeTabAdded() {
|
||||||
if (!DebuggerServer.initialized) {
|
if (!DebuggerServer.initialized) {
|
||||||
DebuggerServer.init();
|
DebuggerServer.init(function() { return true; });
|
||||||
DebuggerServer.addBrowserActors();
|
DebuggerServer.addBrowserActors();
|
||||||
}
|
}
|
||||||
DebuggerServer.closeListener();
|
DebuggerServer.closeListener();
|
||||||
|
|
|
@ -19,9 +19,15 @@ const EXAMPLE_URL = "http://example.com/browser/browser/devtools/debugger/test/"
|
||||||
const TAB1_URL = EXAMPLE_URL + "browser_dbg_tab1.html";
|
const TAB1_URL = EXAMPLE_URL + "browser_dbg_tab1.html";
|
||||||
const TAB2_URL = EXAMPLE_URL + "browser_dbg_tab2.html";
|
const TAB2_URL = EXAMPLE_URL + "browser_dbg_tab2.html";
|
||||||
const STACK_URL = EXAMPLE_URL + "browser_dbg_stack.html";
|
const STACK_URL = EXAMPLE_URL + "browser_dbg_stack.html";
|
||||||
|
// Enable remote debugging for the relevant tests.
|
||||||
|
let gEnableRemote = Services.prefs.getBoolPref("devtools.debugger.remote-enabled");
|
||||||
|
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
|
||||||
|
registerCleanupFunction(function() {
|
||||||
|
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", gEnableRemote);
|
||||||
|
});
|
||||||
|
|
||||||
if (!DebuggerServer.initialized) {
|
if (!DebuggerServer.initialized) {
|
||||||
DebuggerServer.init();
|
DebuggerServer.init(function () { return true; });
|
||||||
DebuggerServer.addBrowserActors();
|
DebuggerServer.addBrowserActors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,19 @@ loadingText=Loading\u2026
|
||||||
# %1$S=URL, %2$S=status code
|
# %1$S=URL, %2$S=status code
|
||||||
loadingError=Error loading %1$S: %2$S
|
loadingError=Error loading %1$S: %2$S
|
||||||
|
|
||||||
|
# LOCALIZATION NOTE (remoteIncomingPromptTitle): The title displayed on the
|
||||||
|
# dialog that prompts the user to allow the incoming connection.
|
||||||
|
remoteIncomingPromptTitle=Incoming Connection
|
||||||
|
|
||||||
|
# LOCALIZATION NOTE (remoteIncomingPromptMessage): The message displayed on the
|
||||||
|
# dialog that prompts the user to allow the incoming connection.
|
||||||
|
remoteIncomingPromptMessage=An incoming request to permit remote debugging connection was detected. A remote client can take complete control over your browser! Allow connection?
|
||||||
|
|
||||||
|
# LOCALIZATION NOTE (remoteIncomingPromptDisable): The label displayed on the
|
||||||
|
# third button in the incoming connection dialog that lets the user disable the
|
||||||
|
# remote debugger server.
|
||||||
|
remoteIncomingPromptDisable=Disable
|
||||||
|
|
||||||
# LOCALIZATION NOTE (emptyVariablesText): The text that is displayed in the
|
# LOCALIZATION NOTE (emptyVariablesText): The text that is displayed in the
|
||||||
# variables pane when there are no variables to display.
|
# variables pane when there are no variables to display.
|
||||||
emptyVariablesText=No variables to display.
|
emptyVariablesText=No variables to display.
|
||||||
|
|
|
@ -59,25 +59,34 @@ var DebuggerServer = {
|
||||||
_listener: null,
|
_listener: null,
|
||||||
_transportInitialized: false,
|
_transportInitialized: false,
|
||||||
xpcInspector: null,
|
xpcInspector: null,
|
||||||
|
_allowConnection: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the debugger server.
|
* Initialize the debugger server.
|
||||||
|
*
|
||||||
|
* @param function aAllowConnectionCallback
|
||||||
|
* The embedder-provider callback, that decides whether an incoming
|
||||||
|
* remote protocol conection should be allowed or refused.
|
||||||
*/
|
*/
|
||||||
init: function DH_init() {
|
init: function DH_init(aAllowConnectionCallback) {
|
||||||
if (this.initialized) {
|
if (this.initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
|
this.xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
|
||||||
this.initTransport();
|
this.initTransport(aAllowConnectionCallback);
|
||||||
this.addActors("chrome://global/content/devtools/dbg-script-actors.js");
|
this.addActors("chrome://global/content/devtools/dbg-script-actors.js");
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the debugger server's transport variables. This can be
|
* Initialize the debugger server's transport variables. This can be
|
||||||
* in place of init() for cases where the jsdebugger isn't needed.
|
* in place of init() for cases where the jsdebugger isn't needed.
|
||||||
|
*
|
||||||
|
* @param function aAllowConnectionCallback
|
||||||
|
* The embedder-provider callback, that decides whether an incoming
|
||||||
|
* remote protocol conection should be allowed or refused.
|
||||||
*/
|
*/
|
||||||
initTransport: function DH_initTransport() {
|
initTransport: function DH_initTransport(aAllowConnectionCallback) {
|
||||||
if (this._transportInitialized) {
|
if (this._transportInitialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -85,6 +94,7 @@ var DebuggerServer = {
|
||||||
this._connections = {};
|
this._connections = {};
|
||||||
this._nextConnID = 0;
|
this._nextConnID = 0;
|
||||||
this._transportInitialized = true;
|
this._transportInitialized = true;
|
||||||
|
this._allowConnection = aAllowConnectionCallback;
|
||||||
},
|
},
|
||||||
|
|
||||||
get initialized() { return !!this.xpcInspector; },
|
get initialized() { return !!this.xpcInspector; },
|
||||||
|
@ -117,6 +127,9 @@ var DebuggerServer = {
|
||||||
* If true, server will listen on the loopback device.
|
* If true, server will listen on the loopback device.
|
||||||
*/
|
*/
|
||||||
openListener: function DH_openListener(aPort, aLocalOnly) {
|
openListener: function DH_openListener(aPort, aLocalOnly) {
|
||||||
|
if (!Services.prefs.getBoolPref("devtools.debugger.remote-enabled")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
this._checkInit();
|
this._checkInit();
|
||||||
|
|
||||||
if (this._listener) {
|
if (this._listener) {
|
||||||
|
@ -209,6 +222,9 @@ var DebuggerServer = {
|
||||||
* after connectPipe() or after an incoming socket connection.
|
* after connectPipe() or after an incoming socket connection.
|
||||||
*/
|
*/
|
||||||
_onConnection: function DH_onConnection(aTransport) {
|
_onConnection: function DH_onConnection(aTransport) {
|
||||||
|
if (!this._allowConnection()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let connID = "conn" + this._nextConnID++ + '.';
|
let connID = "conn" + this._nextConnID++ + '.';
|
||||||
let conn = new DebuggerServerConnection(connID, aTransport);
|
let conn = new DebuggerServerConnection(connID, aTransport);
|
||||||
this._connections[connID] = conn;
|
this._connections[connID] = conn;
|
||||||
|
|
|
@ -12,6 +12,8 @@ Cu.import("resource://gre/modules/Services.jsm");
|
||||||
// Always log packets when running tests. runxpcshelltests.py will throw
|
// Always log packets when running tests. runxpcshelltests.py will throw
|
||||||
// the output away anyway, unless you give it the --verbose flag.
|
// the output away anyway, unless you give it the --verbose flag.
|
||||||
Services.prefs.setBoolPref("devtools.debugger.log", true);
|
Services.prefs.setBoolPref("devtools.debugger.log", true);
|
||||||
|
// Enable remote debugging for the relevant tests.
|
||||||
|
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
|
||||||
|
|
||||||
Cu.import("resource:///modules/devtools/dbg-server.jsm");
|
Cu.import("resource:///modules/devtools/dbg-server.jsm");
|
||||||
Cu.import("resource:///modules/devtools/dbg-client.jsm");
|
Cu.import("resource:///modules/devtools/dbg-client.jsm");
|
||||||
|
@ -123,7 +125,8 @@ function attachTestGlobalClientAndResume(aClient, aName, aCallback) {
|
||||||
function initTestDebuggerServer()
|
function initTestDebuggerServer()
|
||||||
{
|
{
|
||||||
DebuggerServer.addActors("resource://test/testactors.js");
|
DebuggerServer.addActors("resource://test/testactors.js");
|
||||||
DebuggerServer.init();
|
// Allow incoming connections.
|
||||||
|
DebuggerServer.init(function () { return true; });
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishClient(aClient)
|
function finishClient(aClient)
|
||||||
|
|
|
@ -8,7 +8,8 @@ function run_test()
|
||||||
{
|
{
|
||||||
DebuggerServer.addActors("resource://test/testactors.js");
|
DebuggerServer.addActors("resource://test/testactors.js");
|
||||||
|
|
||||||
DebuggerServer.init();
|
// Allow incoming connections.
|
||||||
|
DebuggerServer.init(function () { return true; });
|
||||||
gDebuggee = testGlobal("test-1");
|
gDebuggee = testGlobal("test-1");
|
||||||
DebuggerServer.addTestGlobal(gDebuggee);
|
DebuggerServer.addTestGlobal(gDebuggee);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,8 @@ function run_test()
|
||||||
{
|
{
|
||||||
DebuggerServer.addActors("resource://test/testactors.js");
|
DebuggerServer.addActors("resource://test/testactors.js");
|
||||||
|
|
||||||
DebuggerServer.init();
|
// Allow incoming connections.
|
||||||
|
DebuggerServer.init(function () { return true; });
|
||||||
gDebuggee = testGlobal("test-1");
|
gDebuggee = testGlobal("test-1");
|
||||||
DebuggerServer.addTestGlobal(gDebuggee);
|
DebuggerServer.addTestGlobal(gDebuggee);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,8 @@ function run_test()
|
||||||
{
|
{
|
||||||
DebuggerServer.addActors("resource://test/testactors.js");
|
DebuggerServer.addActors("resource://test/testactors.js");
|
||||||
|
|
||||||
DebuggerServer.init();
|
// Allow incoming connections.
|
||||||
|
DebuggerServer.init(function () { return true; });
|
||||||
gDebuggee = testGlobal("test-1");
|
gDebuggee = testGlobal("test-1");
|
||||||
DebuggerServer.addTestGlobal(gDebuggee);
|
DebuggerServer.addTestGlobal(gDebuggee);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@ function run_test()
|
||||||
check_except(DebuggerServer.closeListener);
|
check_except(DebuggerServer.closeListener);
|
||||||
check_except(DebuggerServer.connectPipe);
|
check_except(DebuggerServer.connectPipe);
|
||||||
|
|
||||||
DebuggerServer.init();
|
// Allow incoming connections.
|
||||||
|
DebuggerServer.init(function () { return true; });
|
||||||
|
|
||||||
// These should still fail because we haven't added a createRootActor
|
// These should still fail because we haven't added a createRootActor
|
||||||
// implementation yet.
|
// implementation yet.
|
||||||
|
|
|
@ -6,7 +6,8 @@ Cu.import("resource:///modules/devtools/dbg-client.jsm");
|
||||||
|
|
||||||
function run_test()
|
function run_test()
|
||||||
{
|
{
|
||||||
DebuggerServer.init();
|
// Allow incoming connections.
|
||||||
|
DebuggerServer.init(function () { return true; });
|
||||||
DebuggerServer.addActors("resource://test/testactors.js");
|
DebuggerServer.addActors("resource://test/testactors.js");
|
||||||
|
|
||||||
add_test(test_socket_conn);
|
add_test(test_socket_conn);
|
||||||
|
|
|
@ -8,7 +8,8 @@ function run_test()
|
||||||
{
|
{
|
||||||
DebuggerServer.addActors("resource://test/testactors.js");
|
DebuggerServer.addActors("resource://test/testactors.js");
|
||||||
|
|
||||||
DebuggerServer.init();
|
// Allow incoming connections.
|
||||||
|
DebuggerServer.init(function () { return true; });
|
||||||
gDebuggee = testGlobal("test-1");
|
gDebuggee = testGlobal("test-1");
|
||||||
DebuggerServer.addTestGlobal(gDebuggee);
|
DebuggerServer.addTestGlobal(gDebuggee);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче