Bug 1310721 - Remove support for the b2g PAC generator; r=mcmanus

This effectively backs out bug 1115495.
This commit is contained in:
Ehsan Akhgari 2016-10-15 12:41:32 -04:00
Родитель c1d2c29601
Коммит ea467855d3
21 изменённых файлов: 20 добавлений и 712 удалений

Просмотреть файл

@ -876,13 +876,6 @@ pref("gfx.screen-mirroring.enabled", true);
// The url of the page used to display network error details.
pref("b2g.neterror.url", "net_error.html");
// Enable PAC generator for B2G.
pref("network.proxy.pac_generator", true);
// List of app origins to apply browsing traffic proxy setting, separated by
// comma. Specify '*' in the list to apply to all apps.
pref("network.proxy.browsing.app_origins", "app://system.gaiamobile.org");
// Enable Web Speech synthesis API
pref("media.webspeech.synth.enabled", true);

Просмотреть файл

@ -35,10 +35,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "uuidgen",
"@mozilla.org/uuid-generator;1",
"nsIUUIDGenerator");
XPCOMUtils.defineLazyServiceGetter(this, "gPACGenerator",
"@mozilla.org/pac-generator;1",
"nsIPACGenerator");
// Once Bug 731746 - Allow chrome JS object to implement nsIDOMEventTarget
// is resolved this helper could be removed.
var SettingsListener = {
@ -481,40 +477,6 @@ setUpdateTrackingId();
});
})();
// =================== Proxy server ======================
(function setupBrowsingProxySettings() {
function setPAC() {
let usePAC;
try {
usePAC = Services.prefs.getBoolPref('network.proxy.pac_generator');
} catch (ex) {}
if (usePAC) {
Services.prefs.setCharPref('network.proxy.autoconfig_url',
gPACGenerator.generate());
Services.prefs.setIntPref('network.proxy.type',
Ci.nsIProtocolProxyService.PROXYCONFIG_PAC);
}
}
SettingsListener.observe('browser.proxy.enabled', false, function(value) {
Services.prefs.setBoolPref('network.proxy.browsing.enabled', value);
setPAC();
});
SettingsListener.observe('browser.proxy.host', '', function(value) {
Services.prefs.setCharPref('network.proxy.browsing.host', value);
setPAC();
});
SettingsListener.observe('browser.proxy.port', 0, function(value) {
Services.prefs.setIntPref('network.proxy.browsing.port', value);
setPAC();
});
setPAC();
})();
// ======================= Dogfooders FOTA ==========================
if (AppConstants.MOZ_B2G_RIL) {
XPCOMUtils.defineLazyModuleGetter(this, "AppsUtils",

Просмотреть файл

@ -624,9 +624,6 @@
@RESPATH@/components/TestInterfaceJSMaplike.js
#endif
@RESPATH@/components/PACGenerator.js
@RESPATH@/components/PACGenerator.manifest
; Modules
@RESPATH@/modules/*

Просмотреть файл

@ -569,9 +569,6 @@
@RESPATH@/components/TestInterfaceJSMaplike.js
#endif
@RESPATH@/components/PACGenerator.js
@RESPATH@/components/PACGenerator.manifest
; [Extensions]
@RESPATH@/components/extensions-toolkit.manifest
@RESPATH@/browser/components/extensions-browser.manifest

Просмотреть файл

@ -31,10 +31,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "gNetworkService",
"@mozilla.org/network/service;1",
"nsINetworkService");
XPCOMUtils.defineLazyServiceGetter(this, "gPACGenerator",
"@mozilla.org/pac-generator;1",
"nsIPACGenerator");
XPCOMUtils.defineLazyServiceGetter(this, "gTetheringService",
"@mozilla.org/tethering/service;1",
"nsITetheringService");
@ -62,8 +58,7 @@ const CONNECTION_TYPE_WIFI = 3;
const CONNECTION_TYPE_OTHER = 4;
const CONNECTION_TYPE_NONE = 5;
const PROXY_TYPE_MANUAL = Ci.nsIProtocolProxyService.PROXYCONFIG_MANUAL;
const PROXY_TYPE_PAC = Ci.nsIProtocolProxyService.PROXYCONFIG_PAC;
const MANUAL_PROXY_CONFIGURATION = 1;
var debug;
function updateDebug() {
@ -1111,6 +1106,8 @@ NetworkManager.prototype = {
}
debug("Going to set proxy settings for " + aNetwork.info.name + " network interface.");
// Sets manual proxy configuration.
Services.prefs.setIntPref("network.proxy.type", MANUAL_PROXY_CONFIGURATION);
// Do not use this proxy server for all protocols.
Services.prefs.setBoolPref("network.proxy.share_proxy_settings", false);
@ -1119,19 +1116,6 @@ NetworkManager.prototype = {
let port = aNetwork.httpProxyPort === 0 ? 8080 : aNetwork.httpProxyPort;
Services.prefs.setIntPref("network.proxy.http_port", port);
Services.prefs.setIntPref("network.proxy.ssl_port", port);
let usePAC;
try {
usePAC = Services.prefs.getBoolPref("network.proxy.pac_generator");
} catch (ex) {}
if (usePAC) {
Services.prefs.setCharPref("network.proxy.autoconfig_url",
gPACGenerator.generate());
Services.prefs.setIntPref("network.proxy.type", PROXY_TYPE_PAC);
} else {
Services.prefs.setIntPref("network.proxy.type", PROXY_TYPE_MANUAL);
}
} catch(ex) {
debug("Exception " + ex + ". Unable to set proxy setting for " +
aNetwork.info.name + " network interface.");
@ -1141,24 +1125,12 @@ NetworkManager.prototype = {
clearNetworkProxy: function() {
debug("Going to clear all network proxy.");
Services.prefs.clearUserPref("network.proxy.type");
Services.prefs.clearUserPref("network.proxy.share_proxy_settings");
Services.prefs.clearUserPref("network.proxy.http");
Services.prefs.clearUserPref("network.proxy.http_port");
Services.prefs.clearUserPref("network.proxy.ssl");
Services.prefs.clearUserPref("network.proxy.ssl_port");
let usePAC;
try {
usePAC = Services.prefs.getBoolPref("network.proxy.pac_generator");
} catch (ex) {}
if (usePAC) {
Services.prefs.setCharPref("network.proxy.autoconfig_url",
gPACGenerator.generate());
Services.prefs.setIntPref("network.proxy.type", PROXY_TYPE_PAC);
} else {
Services.prefs.clearUserPref("network.proxy.type");
}
},
};

Просмотреть файл

@ -6,8 +6,7 @@ MARIONETTE_HEAD_JS = "head.js";
const HTTP_PROXY = "10.0.2.200";
const HTTP_PROXY_PORT = "8080";
const PROXY_TYPE_MANUAL = Ci.nsIProtocolProxyService.PROXYCONFIG_MANUAL;
const PROXY_TYPE_PAC = Ci.nsIProtocolProxyService.PROXYCONFIG_PAC;
const MANUAL_PROXY_CONFIGURATION = 1;
// Test initial State
function verifyInitialState() {
@ -39,7 +38,6 @@ function waitForHttpProxyVerified(aShouldBeSet) {
return new Promise(function(aResolve, aReject) {
try {
waitFor(aResolve, () => {
let usePAC = SpecialPowers.getBoolPref("network.proxy.pac_generator");
let proxyType = SpecialPowers.getIntPref("network.proxy.type");
let httpProxy = SpecialPowers.getCharPref("network.proxy.http");
let sslProxy = SpecialPowers.getCharPref("network.proxy.ssl");
@ -47,16 +45,13 @@ function waitForHttpProxyVerified(aShouldBeSet) {
let sslProxyPort = SpecialPowers.getIntPref("network.proxy.ssl_port");
if ((aShouldBeSet &&
(usePAC ? proxyType == PROXY_TYPE_PAC :
proxyType == PROXY_TYPE_MANUAL) &&
proxyType == MANUAL_PROXY_CONFIGURATION &&
httpProxy == HTTP_PROXY &&
sslProxy == HTTP_PROXY &&
httpProxyPort == HTTP_PROXY_PORT &&
sslProxyPort == HTTP_PROXY_PORT) ||
(!aShouldBeSet &&
(usePAC ? proxyType == PROXY_TYPE_PAC :
proxyType != PROXY_TYPE_MANUAL) &&
!httpProxy && !sslProxy && !httpProxyPort && !sslProxyPort)) {
(!aShouldBeSet && proxyType != MANUAL_PROXY_CONFIGURATION &&
!httpProxy && !sslProxy && !httpProxyPort && !sslProxyPort)) {
return true;
}

Просмотреть файл

@ -414,9 +414,6 @@
@BINPATH@/components/LegacyProviders.manifest
@BINPATH@/components/LegacyPresentationControlService.js
@BINPATH@/components/PACGenerator.js
@BINPATH@/components/PACGenerator.manifest
@BINPATH@/components/TVSimulatorService.js
@BINPATH@/components/TVSimulatorService.manifest

Просмотреть файл

@ -1,165 +0,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 {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
var DEBUG = false;
if (DEBUG) {
debug = function (s) { dump("-*- PACGenerator: " + s + "\n"); };
}
else {
debug = function (s) {};
}
const PACGENERATOR_CONTRACTID = "@mozilla.org/pac-generator;1";
const PACGENERATOR_CID = Components.ID("{788507c4-eb5f-4de8-b19b-e0d531974e8a}");
//
// RFC 2396 section 3.2.2:
//
// host = hostname | IPv4address
// hostname = *( domainlabel "." ) toplabel [ "." ]
// domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
// toplabel = alpha | alpha *( alphanum | "-" ) alphanum
// IPv4address = 1*digit "." 1*digit "." 1*digit "." 1*digit
//
const HOST_REGEX =
new RegExp("^(?:" +
// *( domainlabel "." )
"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)*" +
// toplabel
"[a-z](?:[a-z0-9-]*[a-z0-9])?" +
"|" +
// IPv4 address
"\\d+\\.\\d+\\.\\d+\\.\\d+" +
")$",
"i");
function PACGenerator() {
debug("Starting PAC Generator service.");
}
PACGenerator.prototype = {
classID : PACGENERATOR_CID,
QueryInterface : XPCOMUtils.generateQI([Ci.nsIPACGenerator]),
classInfo : XPCOMUtils.generateCI({classID: PACGENERATOR_CID,
contractID: PACGENERATOR_CONTRACTID,
classDescription: "PACGenerator",
interfaces: [Ci.nsIPACGenerator]}),
/**
* Validate the the host.
*/
isValidHost: function isValidHost(host) {
if (!HOST_REGEX.test(host)) {
debug("Unexpected host: '" + host + "'");
return false;
}
return true;
},
/**
* Returns a PAC string based on proxy settings in the preference.
* Only effective when the network.proxy.pac_generator preference is true.
*/
generate: function generate() {
let enabled, host, port, proxy;
try {
enabled = Services.prefs.getBoolPref("network.proxy.pac_generator");
} catch (ex) {}
if (!enabled) {
debug("PAC Generator disabled.");
return "";
}
let pac = "data:text/plain,function FindProxyForURL(url, host) { ";
// Direct connection for localhost.
pac += "if (shExpMatch(host, 'localhost') || " +
"shExpMatch(host, '127.0.0.1')) {" +
" return 'DIRECT'; } ";
// Rules for browsing proxy.
try {
enabled = Services.prefs.getBoolPref("network.proxy.browsing.enabled");
host = Services.prefs.getCharPref("network.proxy.browsing.host");
port = Services.prefs.getIntPref("network.proxy.browsing.port");
} catch (ex) {}
if (enabled && host && this.isValidHost(host)) {
proxy = host + ":" + ((port && port !== 0) ? port : 8080);
let appOrigins;
try {
appOrigins = Services.prefs.getCharPref("network.proxy.browsing.app_origins");
} catch (ex) {}
pac += "var origins ='" + appOrigins +
"'.split(/[ ,]+/).filter(Boolean); " +
"if ((origins.indexOf('*') > -1 || origins.indexOf(myAppOrigin()) > -1)" +
" && isInIsolatedMozBrowser()) { return 'PROXY " + proxy + "'; } ";
}
// Rules for system proxy.
let share;
try {
share = Services.prefs.getBoolPref("network.proxy.share_proxy_settings");
} catch (ex) {}
if (share) {
// Add rules for all protocols.
try {
host = Services.prefs.getCharPref("network.proxy.http");
port = Services.prefs.getIntPref("network.proxy.http_port");
} catch (ex) {}
if (host && this.isValidHost(host)) {
proxy = host + ":" + ((port && port !== 0) ? port : 8080);
pac += "return 'PROXY " + proxy + "'; "
} else {
pac += "return 'DIRECT'; ";
}
} else {
// Add rules for specific protocols.
const proxyTypes = [
{"scheme": "http:", "pref": "http"},
{"scheme": "https:", "pref": "ssl"},
{"scheme": "ftp:", "pref": "ftp"}
];
for (let i = 0; i < proxyTypes.length; i++) {
try {
host = Services.prefs.getCharPref("network.proxy." +
proxyTypes[i]["pref"]);
port = Services.prefs.getIntPref("network.proxy." +
proxyTypes[i]["pref"] + "_port");
} catch (ex) {}
if (host && this.isValidHost(host)) {
proxy = host + ":" + (port === 0 ? 8080 : port);
pac += "if (url.substring(0, " + (proxyTypes[i]["scheme"]).length +
") == '" + proxyTypes[i]["scheme"] + "') { return 'PROXY " +
proxy + "'; } ";
}
}
pac += "return 'DIRECT'; ";
}
pac += "}";
debug("PAC: " + pac);
return pac;
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PACGenerator]);

Просмотреть файл

@ -1,2 +0,0 @@
component {788507c4-eb5f-4de8-b19b-e0d531974e8a} PACGenerator.js
contract @mozilla.org/pac-generator;1 {788507c4-eb5f-4de8-b19b-e0d531974e8a}

Просмотреть файл

@ -507,64 +507,6 @@ bool PACMyIpAddress(JSContext *cx, unsigned int argc, JS::Value *vp)
return GetRunning()->MyIPAddress(args);
}
// myAppId() javascript implementation
static
bool PACMyAppId(JSContext *cx, unsigned int argc, JS::Value *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (NS_IsMainThread()) {
NS_WARNING("PACMyAppId on Main Thread. How did that happen?");
return false;
}
if (!GetRunning()) {
NS_WARNING("PACMyAppId without a running ProxyAutoConfig object");
return false;
}
return GetRunning()->MyAppId(args);
}
// myAppOrigin() javascript implementation
static
bool PACMyAppOrigin(JSContext *cx, unsigned int argc, JS::Value *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (NS_IsMainThread()) {
NS_WARNING("PACMyAppOrigin on Main Thread. How did that happen?");
return false;
}
if (!GetRunning()) {
NS_WARNING("PACMyAppOrigin without a running ProxyAutoConfig object");
return false;
}
return GetRunning()->MyAppOrigin(args);
}
// IsInIsolatedMozBrowser() javascript implementation
static
bool PACIsInIsolatedMozBrowser(JSContext *cx, unsigned int argc, JS::Value *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (NS_IsMainThread()) {
NS_WARNING("PACIsInIsolatedMozBrowser on Main Thread. How did that happen?");
return false;
}
if (!GetRunning()) {
NS_WARNING("PACIsInIsolatedMozBrowser without a running ProxyAutoConfig"
"object");
return false;
}
return GetRunning()->IsInIsolatedMozBrowser(args);
}
// proxyAlert(msg) javascript implementation
static
bool PACProxyAlert(JSContext *cx, unsigned int argc, JS::Value *vp)
@ -598,9 +540,6 @@ static const JSFunctionSpec PACGlobalFunctions[] = {
// a global "var pacUseMultihomedDNS = true;" will change behavior
// of myIpAddress to actively use DNS
JS_FS("myIpAddress", PACMyIpAddress, 0, 0),
JS_FS("myAppId", PACMyAppId, 0, 0),
JS_FS("myAppOrigin", PACMyAppOrigin, 0, 0),
JS_FS("isInIsolatedMozBrowser", PACIsInIsolatedMozBrowser, 0, 0),
JS_FS("alert", PACProxyAlert, 1, 0),
JS_FS_END
};
@ -819,9 +758,6 @@ ProxyAutoConfig::SetupJS()
nsresult
ProxyAutoConfig::GetProxyForURI(const nsCString &aTestURI,
const nsCString &aTestHost,
uint32_t aAppId,
const nsString &aAppOrigin,
bool aIsInIsolatedMozBrowser,
nsACString &result)
{
if (mJSNeedsSetup)
@ -839,9 +775,6 @@ ProxyAutoConfig::GetProxyForURI(const nsCString &aTestURI,
// while the event loop is spinning on a DNS function. Don't early return.
SetRunning(this);
mRunningHost = aTestHost;
mRunningAppId = aAppId;
mRunningAppOrigin = aAppOrigin;
mRunningIsInIsolatedMozBrowser = aIsInIsolatedMozBrowser;
nsresult rv = NS_ERROR_FAILURE;
nsCString clensedURI = aTestURI;
@ -1077,33 +1010,5 @@ ProxyAutoConfig::MyIPAddress(const JS::CallArgs &aArgs)
return true;
}
bool
ProxyAutoConfig::MyAppId(const JS::CallArgs &aArgs)
{
aArgs.rval().setNumber(mRunningAppId);
return true;
}
bool
ProxyAutoConfig::MyAppOrigin(const JS::CallArgs &aArgs)
{
JSContext *cx = mJSContext->Context();
JSString *origin =
JS_NewStringCopyZ(cx, NS_ConvertUTF16toUTF8(mRunningAppOrigin).get());
if (!origin) {
return false;
}
aArgs.rval().setString(origin);
return true;
}
bool
ProxyAutoConfig::IsInIsolatedMozBrowser(const JS::CallArgs &aArgs)
{
aArgs.rval().setBoolean(mRunningIsInIsolatedMozBrowser);
return true;
}
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -36,9 +36,6 @@ public:
void Shutdown();
void GC();
bool MyIPAddress(const JS::CallArgs &aArgs);
bool MyAppId(const JS::CallArgs &aArgs);
bool MyAppOrigin(const JS::CallArgs &aArgs);
bool IsInIsolatedMozBrowser(const JS::CallArgs &aArgs);
bool ResolveAddress(const nsCString &aHostName,
NetAddr *aNetAddr, unsigned int aTimeout);
@ -72,25 +69,12 @@ public:
* The URI as an ASCII string to test.
* @param aTestHost
* The ASCII hostname to test.
* @param aAppId
* The id of the app requesting connection.
* @param aAppOrigin
* The origin of the app requesting connection.
* @param aIsInIsolatedMozBrowser
* True if the frame is an isolated mozbrowser element. <iframe
* mozbrowser mozapp> and <xul:browser> are not considered to be
* mozbrowser elements. <iframe mozbrowser noisolation> does not count
* as isolated since isolation is disabled. Isolation can only be
* disabled if the containing document is chrome.
*
* @param result
* result string as defined above.
*/
nsresult GetProxyForURI(const nsCString &aTestURI,
const nsCString &aTestHost,
uint32_t aAppId,
const nsString &aAppOrigin,
bool aIsInIsolatedMozBrowser,
nsACString &result);
private:
@ -111,9 +95,6 @@ private:
nsCString mPACURI;
bool mIncludePath;
nsCString mRunningHost;
uint32_t mRunningAppId;
nsString mRunningAppOrigin;
bool mRunningIsInIsolatedMozBrowser;
nsCOMPtr<nsITimer> mTimer;
};

Просмотреть файл

@ -73,7 +73,6 @@ XPIDL_SOURCES += [
'nsINetworkProperties.idl',
'nsINSSErrorsService.idl',
'nsINullChannel.idl',
'nsIPACGenerator.idl',
'nsIPackagedAppService.idl',
'nsIPackagedAppUtils.idl',
'nsIPackagedAppVerifier.idl',
@ -296,11 +295,6 @@ elif CONFIG['OS_ARCH'] == 'Linux':
'nsNetworkInfoService.cpp',
]
EXTRA_COMPONENTS += [
'PACGenerator.js',
'PACGenerator.manifest'
]
EXTRA_JS_MODULES += [
'NetUtil.jsm',
]

Просмотреть файл

@ -1,15 +0,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/. */
#include "nsISupports.idl"
[scriptable, uuid(4b3eeeea-1108-4aa0-8f26-e3ebdeb0454c)]
interface nsIPACGenerator : nsISupports
{
/**
* Returns a PAC string based on proxy settings in the preference.
* Only effective when the network.proxy.pac_generator preference is true.
*/
DOMString generate();
};

Просмотреть файл

@ -5,8 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsPACMan.h"
#include "mozIApplication.h"
#include "nsIAppsService.h"
#include "nsThreadUtils.h"
#include "nsIAuthPrompt.h"
#include "nsIPromptFactory.h"
@ -234,12 +232,9 @@ private:
//-----------------------------------------------------------------------------
PendingPACQuery::PendingPACQuery(nsPACMan *pacMan, nsIURI *uri,
uint32_t appId, bool isInIsolatedMozBrowser,
nsPACManCallback *callback,
bool mainThreadResponse)
: mPACMan(pacMan)
, mAppId(appId)
, mIsInIsolatedMozBrowser(isInIsolatedMozBrowser)
, mCallback(callback)
, mOnMainThreadOnly(mainThreadResponse)
{
@ -247,18 +242,6 @@ PendingPACQuery::PendingPACQuery(nsPACMan *pacMan, nsIURI *uri,
uri->GetAsciiHost(mHost);
uri->GetScheme(mScheme);
uri->GetPort(&mPort);
nsCOMPtr<nsIAppsService> appsService =
do_GetService(APPS_SERVICE_CONTRACTID);
if (!appsService) {
return;
}
nsCOMPtr<mozIApplication> mozApp;
nsresult rv = appsService->GetAppByLocalId(appId, getter_AddRefs(mozApp));
if (NS_FAILED(rv) || !mozApp) {
return;
}
mozApp->GetOrigin(mAppOrigin);
}
void
@ -351,8 +334,7 @@ nsPACMan::Shutdown()
}
nsresult
nsPACMan::AsyncGetProxyForURI(nsIURI *uri, uint32_t appId,
bool isInIsolatedMozBrowser,
nsPACMan::AsyncGetProxyForURI(nsIURI *uri,
nsPACManCallback *callback,
bool mainThreadResponse)
{
@ -369,8 +351,7 @@ nsPACMan::AsyncGetProxyForURI(nsIURI *uri, uint32_t appId,
}
RefPtr<PendingPACQuery> query =
new PendingPACQuery(this, uri, appId, isInIsolatedMozBrowser, callback,
mainThreadResponse);
new PendingPACQuery(this, uri, callback, mainThreadResponse);
if (IsPACURI(uri)) {
// deal with this directly instead of queueing it
@ -629,8 +610,6 @@ nsPACMan::ProcessPending()
// the systemproxysettings didn't complete the resolution. try via PAC
if (!completed) {
nsresult status = mPAC.GetProxyForURI(query->mSpec, query->mHost,
query->mAppId, query->mAppOrigin,
query->mIsInIsolatedMozBrowser,
pacString);
LOG(("Use proxy from PAC: %s\n", pacString.get()));
query->Complete(status, pacString);

Просмотреть файл

@ -59,8 +59,8 @@ class PendingPACQuery final : public Runnable,
public LinkedListElement<PendingPACQuery>
{
public:
PendingPACQuery(nsPACMan *pacMan, nsIURI *uri, uint32_t appId,
bool isInIsolatedMozBrowser, nsPACManCallback *callback,
PendingPACQuery(nsPACMan *pacMan, nsIURI *uri,
nsPACManCallback *callback,
bool mainThreadResponse);
// can be called from either thread
@ -77,11 +77,6 @@ public:
private:
nsPACMan *mPACMan; // weak reference
public:
uint32_t mAppId;
bool mIsInIsolatedMozBrowser;
nsString mAppOrigin;
private:
RefPtr<nsPACManCallback> mCallback;
bool mOnMainThreadOnly;
@ -116,17 +111,12 @@ public:
*
* @param uri
* The URI to query.
* @param appId
* The appId of the app making the connection.
* @param isInBrowser
* True if the iframe has mozbrowser but has no mozapp attribute.
* @param callback
* The callback to run once the PAC result is available.
* @param mustCallbackOnMainThread
* If set to false the callback can be made from the PAC thread
*/
nsresult AsyncGetProxyForURI(nsIURI *uri, uint32_t appId,
bool isInBrowser,
nsresult AsyncGetProxyForURI(nsIURI *uri,
nsPACManCallback *callback,
bool mustCallbackOnMainThread);

Просмотреть файл

@ -103,7 +103,6 @@ public:
NS_DECL_THREADSAFE_ISUPPORTS
nsAsyncResolveRequest(nsProtocolProxyService *pps, nsIChannel *channel,
uint32_t aAppId, bool aIsInIsolatedMozBrowser,
uint32_t aResolveFlags,
nsIProtocolProxyCallback *callback)
: mStatus(NS_OK)
@ -112,8 +111,6 @@ public:
, mPPS(pps)
, mXPComPPS(pps)
, mChannel(channel)
, mAppId(aAppId)
, mIsInIsolatedMozBrowser(aIsInIsolatedMozBrowser)
, mCallback(callback)
{
NS_ASSERTION(mCallback, "null callback");
@ -261,11 +258,9 @@ private:
if (NS_SUCCEEDED(rv)) {
// now that the load is triggered, we can resubmit the query
RefPtr<nsAsyncResolveRequest> newRequest =
new nsAsyncResolveRequest(mPPS, mChannel, mAppId,
mIsInIsolatedMozBrowser, mResolveFlags,
new nsAsyncResolveRequest(mPPS, mChannel, mResolveFlags,
mCallback);
rv = mPPS->mPACMan->AsyncGetProxyForURI(proxyURI, mAppId,
mIsInIsolatedMozBrowser,
rv = mPPS->mPACMan->AsyncGetProxyForURI(proxyURI,
newRequest,
true);
}
@ -304,8 +299,6 @@ private:
nsProtocolProxyService *mPPS;
nsCOMPtr<nsIProtocolProxyService> mXPComPPS;
nsCOMPtr<nsIChannel> mChannel;
uint32_t mAppId;
bool mIsInIsolatedMozBrowser;
nsCOMPtr<nsIProtocolProxyCallback> mCallback;
nsCOMPtr<nsIProxyInfo> mProxyInfo;
};
@ -1207,7 +1200,7 @@ nsProtocolProxyService::DeprecatedBlockingResolve(nsIChannel *aChannel,
// but if neither of them are in use, we can just do the work
// right here and directly invoke the callback
rv = Resolve_Internal(aChannel, NECKO_NO_APP_ID, false, info, aFlags,
rv = Resolve_Internal(aChannel, info, aFlags,
&usePACThread, getter_AddRefs(pi));
if (NS_FAILED(rv))
return rv;
@ -1222,8 +1215,7 @@ nsProtocolProxyService::DeprecatedBlockingResolve(nsIChannel *aChannel,
// code, but block this thread on that completion.
RefPtr<nsAsyncBridgeRequest> ctx = new nsAsyncBridgeRequest();
ctx->Lock();
if (NS_SUCCEEDED(mPACMan->AsyncGetProxyForURI(uri, NECKO_NO_APP_ID, false,
ctx, false))) {
if (NS_SUCCEEDED(mPACMan->AsyncGetProxyForURI(uri, ctx, false))) {
// this can really block the main thread, so cap it at 3 seconds
ctx->Wait();
}
@ -1275,14 +1267,9 @@ nsProtocolProxyService::AsyncResolveInternal(nsIChannel *channel, uint32_t flags
nsresult rv = GetProxyURI(channel, getter_AddRefs(uri));
if (NS_FAILED(rv)) return rv;
uint32_t appId = NECKO_NO_APP_ID;
bool isInIsolatedMozBrowser = false;
NS_GetAppInfo(channel, &appId, &isInIsolatedMozBrowser);
*result = nullptr;
RefPtr<nsAsyncResolveRequest> ctx =
new nsAsyncResolveRequest(this, channel, appId, isInIsolatedMozBrowser,
flags, callback);
new nsAsyncResolveRequest(this, channel, flags, callback);
nsProtocolInfo info;
rv = GetProtocolInfo(uri, &info);
@ -1296,7 +1283,7 @@ nsProtocolProxyService::AsyncResolveInternal(nsIChannel *channel, uint32_t flags
// but if neither of them are in use, we can just do the work
// right here and directly invoke the callback
rv = Resolve_Internal(channel, appId, isInIsolatedMozBrowser, info, flags,
rv = Resolve_Internal(channel, info, flags,
&usePACThread, getter_AddRefs(pi));
if (NS_FAILED(rv))
return rv;
@ -1318,8 +1305,7 @@ nsProtocolProxyService::AsyncResolveInternal(nsIChannel *channel, uint32_t flags
// else kick off a PAC thread query
rv = mPACMan->AsyncGetProxyForURI(uri, appId, isInIsolatedMozBrowser, ctx,
true);
rv = mPACMan->AsyncGetProxyForURI(uri, ctx, true);
if (NS_SUCCEEDED(rv))
ctx.forget(result);
return rv;
@ -1770,8 +1756,6 @@ nsProtocolProxyService::NewProxyInfo_Internal(const char *aType,
nsresult
nsProtocolProxyService::Resolve_Internal(nsIChannel *channel,
uint32_t appId,
bool isInBrowser,
const nsProtocolInfo &info,
uint32_t flags,
bool *usePACThread,

Просмотреть файл

@ -215,10 +215,6 @@ protected:
*
* @param channel
* The channel to test.
* @param appId
* The id of the app making the query.
* @param isInBrowser
* True if the iframe has mozbrowser but has no mozapp attribute.
* @param info
* Information about the URI's protocol.
* @param flags
@ -230,8 +226,6 @@ protected:
* The resulting proxy info or null.
*/
nsresult Resolve_Internal(nsIChannel *channel,
uint32_t appId,
bool isInBrowser,
const nsProtocolInfo &info,
uint32_t flags,
bool *usePAC,

Просмотреть файл

@ -11,7 +11,6 @@ MOCHITEST_MANIFESTS += ['mochitests/mochitest.ini']
XPCSHELL_TESTS_MANIFESTS += [
'unit/xpcshell.ini',
'unit/xpcshell_b2g.ini',
'unit_ipc/xpcshell.ini',
]

Просмотреть файл

@ -1,236 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
var ios = Cc["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var pps = Cc["@mozilla.org/network/protocol-proxy-service;1"].getService();
var prefs = Cc["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var pgen = Cc["@mozilla.org/pac-generator;1"]
.getService(Components.interfaces.nsIPACGenerator);
const TARGET_HOST ="www.mozilla.org";
const HTTP_HOST = "httpHost";
const HTTP_PORT = 1111;
const HTTPS_HOST = "httpsHost";
const HTTPS_PORT = 2222;
const FTP_HOST= "ftpHost";
const FTP_PORT = 3333;
const MY_APP_ID = 10;
const MY_APP_ORIGIN = "apps://browser.gaiamobile.com";
const APP_ORIGINS_LIST = "apps://test1.com, apps://browser.gaiamobile.com";
const BROWSING_HOST = "browsingHost";
const BROWSING_PORT = 4444;
const PROXY_TYPE_PAC = Ci.nsIProtocolProxyService.PROXYCONFIG_PAC;
const proxyTypes = {
"http": {"pref": "http", "host": HTTP_HOST, "port": HTTP_PORT},
"https": {"pref": "ssl", "host": HTTPS_HOST, "port": HTTPS_PORT},
"ftp": {"pref": "ftp", "host": FTP_HOST, "port": FTP_PORT}
};
function default_proxy_settings() {
prefs.setBoolPref("network.proxy.pac_generator", true);
prefs.setIntPref("network.proxy.type", 0);
prefs.setCharPref("network.proxy.autoconfig_url", "");
for (let i in proxyTypes) {
let p = proxyTypes[i];
prefs.setCharPref("network.proxy." + p["pref"], p["host"]);
prefs.setIntPref("network.proxy." + p["pref"] + "_port", p["port"]);
}
}
function TestResolveCallback(type, host, callback) {
this.type = type;
this.host = host;
this.callback = callback;
}
TestResolveCallback.prototype = {
QueryInterface:
function TestResolveCallback_QueryInterface(iid) {
if (iid.equals(Components.interfaces.nsIProtocolProxyCallback) ||
iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
},
onProxyAvailable:
function TestResolveCallback_onProxyAvailable(req, channel, pi, status) {
if (this.type) {
// Check for localhost.
if (this.host == "localhost" || this.host == "127.0.0.1") {
do_check_eq(pi, null);
this.callback();
return;
}
// Check for browsing proxy.
let browsingEnabled;
try {
browsingEnabled = prefs.getBoolPref("network.proxy.browsing.enabled");
} catch (ex) {}
if (browsingEnabled) {
let proxyHost, proxyPort;
try {
proxyHost = prefs.getCharPref("network.proxy.browsing.host");
proxyPort = prefs.getIntPref("network.proxy.browsing.port");
} catch (ex) {}
if (proxyHost) {
do_check_eq(pi.host, proxyHost);
do_check_eq(pi.port, proxyPort);
this.callback();
return;
}
}
// Check for system proxy.
let share;
try {
share = prefs.getBoolPref("network.proxy.share_proxy_settings");
} catch (ex) {}
let p = share ? proxyTypes["http"] : proxyTypes[this.type];
if (p) {
let proxyHost, proxyPort;
try {
proxyHost = prefs.getCharPref("network.proxy." + p["pref"]);
proxyPort = prefs.getIntPref("network.proxy." + p["pref"] + "_port");
} catch (ex) {}
if (proxyHost) {
// Connection through proxy.
do_check_neq(pi, null);
do_check_eq(pi.host, proxyHost);
do_check_eq(pi.port, proxyPort);
} else {
// Direct connection.
do_check_eq(pi, null);
}
}
}
this.callback();
}
};
function test_resolve_type(type, host, callback) {
// We have to setup a profile, otherwise indexed db used by webapps
// will throw random exception when trying to get profile folder.
do_get_profile();
// We also need a valid nsIXulAppInfo service as Webapps.jsm is querying it.
Cu.import("resource://testing-common/AppInfo.jsm");
updateAppInfo();
// Mock getAppByLocalId() to return testing app origin.
Cu.import("resource://gre/modules/AppsUtils.jsm");
AppsUtils.getAppByLocalId = function(aAppId) {
let app = { origin: MY_APP_ORIGIN};
return app;
};
let channel = NetUtil.newChannel({
uri: type + "://" + host + "/",
loadUsingSystemPrincipal: true
});
channel.loadInfo.originAttributes = { appId: MY_APP_ID,
inIsolatedMozBrowser: true
};
let req = pps.asyncResolve(channel, 0, new TestResolveCallback(type, host, callback));
}
function test_resolve(host, callback) {
test_resolve_type("http", host, function() {
test_resolve_type("https", host, function() {
test_resolve_type("ftp", host, run_next_test);
});
});
}
add_test(function test_localhost() {
default_proxy_settings();
prefs.setBoolPref("network.proxy.share_proxy_settings", true);
Services.prefs.setCharPref("network.proxy.autoconfig_url", pgen.generate());
Services.prefs.setIntPref("network.proxy.type", PROXY_TYPE_PAC);
test_resolve("localhost", run_next_test);
});
add_test(function test_share_on_proxy() {
default_proxy_settings();
prefs.setBoolPref("network.proxy.share_proxy_settings", true);
Services.prefs.setCharPref("network.proxy.autoconfig_url", pgen.generate());
Services.prefs.setIntPref("network.proxy.type", PROXY_TYPE_PAC);
test_resolve(TARGET_HOST, run_next_test);
});
add_test(function test_share_on_direct() {
default_proxy_settings();
prefs.setBoolPref("network.proxy.share_proxy_settings", true);
prefs.setCharPref("network.proxy.http", "");
prefs.setCharPref("network.proxy.ssl", "");
prefs.setCharPref("network.proxy.ftp", "");
Services.prefs.setCharPref("network.proxy.autoconfig_url", pgen.generate());
Services.prefs.setIntPref("network.proxy.type", PROXY_TYPE_PAC);
test_resolve(TARGET_HOST, run_next_test);
});
add_test(function test_share_off_proxy() {
default_proxy_settings();
prefs.setBoolPref("network.proxy.share_proxy_settings", false);
Services.prefs.setCharPref("network.proxy.autoconfig_url", pgen.generate());
Services.prefs.setIntPref("network.proxy.type", PROXY_TYPE_PAC);
test_resolve(TARGET_HOST, run_next_test);
});
add_test(function test_share_off_direct() {
default_proxy_settings();
prefs.setBoolPref("network.proxy.share_proxy_settings", false);
prefs.setCharPref("network.proxy.http", "");
prefs.setCharPref("network.proxy.ssl", "");
prefs.setCharPref("network.proxy.ftp", "");
Services.prefs.setCharPref("network.proxy.autoconfig_url", pgen.generate());
Services.prefs.setIntPref("network.proxy.type", PROXY_TYPE_PAC);
test_resolve(TARGET_HOST, run_next_test);
});
add_test(function test_browsing_proxy() {
default_proxy_settings();
prefs.setBoolPref("network.proxy.browsing.enabled", true);
prefs.setCharPref("network.proxy.browsing.host", BROWSING_HOST);
prefs.setIntPref("network.proxy.browsing.port", BROWSING_PORT);
prefs.setCharPref("network.proxy.browsing.app_origins", APP_ORIGINS_LIST);
Services.prefs.setCharPref("network.proxy.autoconfig_url", pgen.generate());
Services.prefs.setIntPref("network.proxy.type", PROXY_TYPE_PAC);
test_resolve(TARGET_HOST, run_next_test);
});
function run_test(){
do_register_cleanup(() => {
prefs.clearUserPref("network.proxy.pac_generator");
prefs.clearUserPref("network.proxy.type");
prefs.clearUserPref("network.proxy.autoconfig_url");
prefs.clearUserPref("network.proxy.share_proxy_settings");
prefs.clearUserPref("network.proxy.http");
prefs.clearUserPref("network.proxy.http_port");
prefs.clearUserPref("network.proxy.ssl");
prefs.clearUserPref("network.proxy.ssl_port");
prefs.clearUserPref("network.proxy.ftp");
prefs.clearUserPref("network.proxy.ftp_port");
prefs.clearUserPref("network.proxy.browsing.enabled");
prefs.clearUserPref("network.proxy.browsing.host");
prefs.clearUserPref("network.proxy.browsing.port");
prefs.clearUserPref("network.proxy.browsing.app_origins");
});
run_next_test();
}

Просмотреть файл

@ -1,9 +0,0 @@
[DEFAULT]
head = head_channels.js head_cache.js head_cache2.js
tail =
skip-if = buildapp != 'b2g'
# For bug 1148503. This is to accommodate non-mozilla-central that didn't
# include required files for this test.
[test_pac_generator.js]
requesttimeoutfactor = 4

Просмотреть файл

@ -327,10 +327,6 @@ user_pref("extensions.e10sBlocksEnabling", false);
// Avoid performing Reader Mode intros during tests.
user_pref("browser.reader.detectedFirstArticle", true);
// Don't let PAC generator to set PAC, as mochitest framework has its own PAC
// rules during testing.
user_pref("network.proxy.pac_generator", false);
// Make tests run consistently on DevEdition (which has a lightweight theme
// selected by default).
user_pref("lightweightThemes.selectedThemeID", "");