Bug 815523. patches stolen from 782542 Parts 1,2,3: Necko IPC security pref, and disable for xpcshell tests, r=ted,jdm

This commit is contained in:
Josh Matthews 2012-12-07 17:12:02 -05:00
parent cd4872fcf7
commit fccec36a4b
4 changed files with 35 additions and 17 deletions

View File

@ -773,6 +773,9 @@ pref("security.fileuri.strict_origin_policy", true);
// the results
pref("network.allow-experiments", true);
// Turn off interprocess security checks. Needed to run xpcshell tests.
pref("network.disable.ipc.security", false);
// Default action for unlisted external protocol handlers
pref("network.protocol-handler.external-default", true); // OK to load
pref("network.protocol-handler.warn-external-default", true); // warn before load

View File

@ -14,17 +14,22 @@
#include "mozilla/net/FTPChannelChild.h"
#include "mozilla/net/WebSocketChannelChild.h"
#include "mozilla/dom/network/TCPSocketChild.h"
#include "mozilla/Preferences.h"
using mozilla::dom::TCPSocketChild;
namespace mozilla {
namespace net {
static bool gDisableIPCSecurity = false;
static const char kPrefDisableIPCSecurity[] = "network.disable.ipc.security";
PNeckoChild *gNeckoChild = nullptr;
// C++ file contents
NeckoChild::NeckoChild()
{
Preferences::AddBoolVarCache(&gDisableIPCSecurity, kPrefDisableIPCSecurity);
}
NeckoChild::~NeckoChild()

View File

@ -14,6 +14,7 @@
#include "mozilla/net/WebSocketChannelParent.h"
#include "mozilla/dom/TabParent.h"
#include "mozilla/dom/network/TCPSocketParent.h"
#include "mozilla/Preferences.h"
#include "nsHTMLDNSPrefetch.h"
@ -24,9 +25,13 @@ using mozilla::dom::TCPSocketParent;
namespace mozilla {
namespace net {
static bool gDisableIPCSecurity = false;
static const char kPrefDisableIPCSecurity[] = "network.disable.ipc.security";
// C++ file contents
NeckoParent::NeckoParent()
{
Preferences::AddBoolVarCache(&gDisableIPCSecurity, kPrefDisableIPCSecurity);
}
NeckoParent::~NeckoParent()

View File

@ -36,16 +36,27 @@ let (ios = Components.classes["@mozilla.org/network/io-service;1"]
ios.offline = false;
}
// Disable IPv6 lookups for 'localhost' on windows.
// Determine if we're running on parent or child
let runningInParent = true;
try {
if ("@mozilla.org/windows-registry-key;1" in Components.classes) {
let processType = Components.classes["@mozilla.org/xre/runtime;1"].
getService(Components.interfaces.nsIXULRuntime).processType;
if (processType == Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
let (prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch)) {
prefs.setCharPref("network.dns.ipv4OnlyDomains", "localhost");
}
runningInParent = Components.classes["@mozilla.org/xre/runtime;1"].
getService(Components.interfaces.nsIXULRuntime).processType
== Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
}
catch (e) { }
try {
if (runningInParent) {
let prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
// disable necko IPC security checks for xpcshell, as they lack the
// docshells needed to pass them
prefs.setBoolPref("network.disable.ipc.security", true);
// Disable IPv6 lookups for 'localhost' on windows.
if ("@mozilla.org/windows-registry-key;1" in Components.classes) {
prefs.setCharPref("network.dns.ipv4OnlyDomains", "localhost");
}
}
}
@ -57,9 +68,7 @@ catch (e) { }
// Note that if we're in a child process, we don't want to init the
// crashreporter component.
try { // nsIXULRuntime is not available in some configurations.
let processType = Components.classes["@mozilla.org/xre/runtime;1"].
getService(Components.interfaces.nsIXULRuntime).processType;
if (processType == Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT &&
if (runningInParent &&
"@mozilla.org/toolkit/crash-reporter;1" in Components.classes) {
// Remember to update </toolkit/crashreporter/test/unit/test_crashreporter.js>
// too if you change this initial setting.
@ -800,11 +809,7 @@ function do_get_profile() {
function do_load_child_test_harness()
{
// Make sure this isn't called from child process
var runtime = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime);
if (runtime.processType !=
Components.interfaces.nsIXULRuntime.PROCESS_TYPE_DEFAULT)
{
if (!runningInParent) {
do_throw("run_test_in_child cannot be called from child!");
}