summaryrefslogtreecommitdiffstats
path: root/netwerk
diff options
context:
space:
mode:
Diffstat (limited to 'netwerk')
-rw-r--r--netwerk/base/LoadInfo.cpp6
-rw-r--r--netwerk/base/LoadInfo.h1
-rw-r--r--netwerk/base/NetUtil.jsm35
-rw-r--r--netwerk/base/nsICryptoHash.idl3
-rw-r--r--netwerk/base/nsSocketTransport2.cpp16
-rw-r--r--netwerk/base/nsSocketTransportService2.cpp11
-rw-r--r--netwerk/dns/nsIDNService.cpp54
-rw-r--r--netwerk/protocol/http/nsHttpChannel.cpp24
-rw-r--r--netwerk/protocol/http/nsHttpChannelAuthProvider.cpp30
-rw-r--r--netwerk/protocol/http/nsHttpHandler.cpp83
-rw-r--r--netwerk/protocol/http/nsHttpHandler.h4
-rw-r--r--netwerk/test/TestUDPSocket.cpp13
-rw-r--r--netwerk/test/mochitests/mochitest.ini1
-rw-r--r--netwerk/test/mochitests/test_1396395.html52
-rw-r--r--netwerk/wifi/moz.build1
-rw-r--r--netwerk/wifi/nsWifiMonitor.h2
-rw-r--r--netwerk/wifi/nsWifiScannerWin.cpp11
-rw-r--r--netwerk/wifi/win_wifiScanner.h13
-rw-r--r--netwerk/wifi/win_xp_wifiScanner.cpp399
-rw-r--r--netwerk/wifi/win_xp_wifiScanner.h25
20 files changed, 277 insertions, 507 deletions
diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp
index 216cf559c..42fdea4a1 100644
--- a/netwerk/base/LoadInfo.cpp
+++ b/netwerk/base/LoadInfo.cpp
@@ -859,6 +859,12 @@ LoadInfo::SetIsPreflight()
mIsPreflight = true;
}
+void
+LoadInfo::SetUpgradeInsecureRequests()
+{
+ mUpgradeInsecureRequests = true;
+}
+
NS_IMETHODIMP
LoadInfo::GetIsPreflight(bool* aIsPreflight)
{
diff --git a/netwerk/base/LoadInfo.h b/netwerk/base/LoadInfo.h
index 261f85349..3e1b92ff4 100644
--- a/netwerk/base/LoadInfo.h
+++ b/netwerk/base/LoadInfo.h
@@ -78,6 +78,7 @@ public:
already_AddRefed<nsILoadInfo> CloneForNewRequest() const;
void SetIsPreflight();
+ void SetUpgradeInsecureRequests();
private:
// private constructor that is only allowed to be called from within
diff --git a/netwerk/base/NetUtil.jsm b/netwerk/base/NetUtil.jsm
index e970c8ad8..93025e97e 100644
--- a/netwerk/base/NetUtil.jsm
+++ b/netwerk/base/NetUtil.jsm
@@ -363,6 +363,41 @@ this.NetUtil = {
},
/**
+ * @deprecated Use newChannel({ ...options... }) instead.
+ */
+ newChannel2: function NetUtil_newChannel2(aWhatToLoad,
+ aOriginCharset,
+ aBaseURI,
+ aLoadingNode,
+ aLoadingPrincipal,
+ aTriggeringPrincipal,
+ aSecurityFlags,
+ aContentPolicyType)
+ {
+ if (!aWhatToLoad) {
+ let exception = new Components.Exception(
+ "Must have a non-null string spec, nsIURI, or nsIFile object",
+ Cr.NS_ERROR_INVALID_ARG,
+ Components.stack.caller
+ );
+ throw exception;
+ }
+
+ let uri = aWhatToLoad;
+ if (!(aWhatToLoad instanceof Ci.nsIURI)) {
+ // We either have a string or an nsIFile that we'll need a URI for.
+ uri = this.newURI(aWhatToLoad, aOriginCharset, aBaseURI);
+ }
+
+ return this.ioService.newChannelFromURI2(uri,
+ aLoadingNode,
+ aLoadingPrincipal,
+ aTriggeringPrincipal,
+ aSecurityFlags,
+ aContentPolicyType);
+ },
+
+ /**
* Reads aCount bytes from aInputStream into a string.
*
* @param aInputStream
diff --git a/netwerk/base/nsICryptoHash.idl b/netwerk/base/nsICryptoHash.idl
index cd865a3a9..ddd3103af 100644
--- a/netwerk/base/nsICryptoHash.idl
+++ b/netwerk/base/nsICryptoHash.idl
@@ -10,7 +10,7 @@ interface nsIInputStream;
* This interface provides crytographic hashing algorithms.
*/
-[scriptable, uuid(1e5b7c43-4688-45ce-92e1-77ed931e3bbe)]
+[scriptable, uuid(0a248513-dfa7-4474-8777-8c452d60dd04)]
interface nsICryptoHash : nsISupports
{
/**
@@ -25,6 +25,7 @@ interface nsICryptoHash : nsISupports
const short SHA256 = 4; /* String value: "sha256" */
const short SHA384 = 5; /* String value: "sha384" */
const short SHA512 = 6; /* String value: "sha512" */
+ const short SHA224 = 7; /* String value: "sha224" */
/**
* Initialize the hashing object. This method may be
diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp
index 1bfd1fc91..184757d33 100644
--- a/netwerk/base/nsSocketTransport2.cpp
+++ b/netwerk/base/nsSocketTransport2.cpp
@@ -40,7 +40,6 @@
#include "xpcpublic.h"
#if defined(XP_WIN)
-#include "mozilla/WindowsVersion.h"
#include "ShutdownLayer.h"
#endif
@@ -1724,21 +1723,6 @@ nsSocketTransport::OnSocketConnected()
NS_ASSERTION(mFDref == 1, "wrong socket ref count");
SetSocketName(mFD);
mFDconnected = true;
-
-#ifdef XP_WIN
- if (!IsWin2003OrLater()) { // windows xp
- PRSocketOptionData opt;
- opt.option = PR_SockOpt_RecvBufferSize;
- if (PR_GetSocketOption(mFD, &opt) == PR_SUCCESS) {
- SOCKET_LOG(("%p checking rwin on xp originally=%u\n",
- this, opt.value.recv_buffer_size));
- if (opt.value.recv_buffer_size < 65535) {
- opt.value.recv_buffer_size = 65535;
- PR_SetSocketOption(mFD, &opt);
- }
- }
- }
-#endif
}
// Ensure keepalive is configured correctly if previously enabled.
diff --git a/netwerk/base/nsSocketTransportService2.cpp b/netwerk/base/nsSocketTransportService2.cpp
index d2f20651e..068bf0eca 100644
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -28,10 +28,6 @@
#include "nsIWidget.h"
#include "mozilla/dom/FlyWebService.h"
-#if defined(XP_WIN)
-#include "mozilla/WindowsVersion.h"
-#endif
-
namespace mozilla {
namespace net {
@@ -1204,12 +1200,7 @@ nsSocketTransportService::UpdateSendBufferPref(nsIPrefBranch *pref)
}
#if defined(XP_WIN)
- // If the pref is not set but this is windows set it depending on windows version
- if (!IsWin2003OrLater()) { // windows xp
- mSendBufferSize = 131072;
- } else { // vista or later
- mSendBufferSize = 131072 * 4;
- }
+ mSendBufferSize = 131072 * 4;
#endif
}
diff --git a/netwerk/dns/nsIDNService.cpp b/netwerk/dns/nsIDNService.cpp
index d4f31027e..49beecbb3 100644
--- a/netwerk/dns/nsIDNService.cpp
+++ b/netwerk/dns/nsIDNService.cpp
@@ -26,6 +26,7 @@
const bool kIDNA2008_TransitionalProcessing = false;
#include "ICUUtils.h"
+#include "unicode/uscript.h"
#endif
using namespace mozilla::unicode;
@@ -797,6 +798,7 @@ bool nsIDNService::isLabelSafe(const nsAString &label)
Script lastScript = Script::INVALID;
uint32_t previousChar = 0;
+ uint32_t baseChar = 0; // last non-diacritic seen (base char for marks)
uint32_t savedNumberingSystem = 0;
// Simplified/Traditional Chinese check temporarily disabled -- bug 857481
#if 0
@@ -834,8 +836,8 @@ bool nsIDNService::isLabelSafe(const nsAString &label)
}
// Check for mixed numbering systems
- if (GetGeneralCategory(ch) ==
- HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER) {
+ auto genCat = GetGeneralCategory(ch);
+ if (genCat == HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER) {
uint32_t zeroCharacter = ch - GetNumericValue(ch);
if (savedNumberingSystem == 0) {
// If we encounter a decimal number, save the zero character from that
@@ -846,11 +848,49 @@ bool nsIDNService::isLabelSafe(const nsAString &label)
}
}
- // Check for consecutive non-spacing marks
- if (previousChar != 0 &&
- previousChar == ch &&
- GetGeneralCategory(ch) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) {
- return false;
+ if (genCat == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) {
+ // Check for consecutive non-spacing marks
+ if (previousChar != 0 && previousChar == ch) {
+ return false;
+ }
+ // Check for marks whose expected script doesn't match the base script.
+ if (lastScript != Script::INVALID) {
+ const size_t kMaxScripts = 32; // more than ample for current values
+ // of ScriptExtensions property
+ UScriptCode scripts[kMaxScripts];
+ UErrorCode errorCode = U_ZERO_ERROR;
+ int nScripts = uscript_getScriptExtensions(ch, scripts, kMaxScripts,
+ &errorCode);
+ MOZ_ASSERT(U_SUCCESS(errorCode), "uscript_getScriptExtensions failed");
+ if (U_FAILURE(errorCode)) {
+ return false;
+ }
+ // nScripts will always be >= 1, because even for undefined characters
+ // uscript_getScriptExtensions will return Script::INVALID.
+ // If the mark just has script=COMMON or INHERITED, we can't check any
+ // more carefully, but if it has specific scriptExtension codes, then
+ // assume those are the only valid scripts to use it with.
+ if (nScripts > 1 ||
+ (Script(scripts[0]) != Script::COMMON &&
+ Script(scripts[0]) != Script::INHERITED)) {
+ while (--nScripts >= 0) {
+ if (Script(scripts[nScripts]) == lastScript) {
+ break;
+ }
+ }
+ if (nScripts == -1) {
+ return false;
+ }
+ }
+ }
+ // Check for diacritics on dotless-i or dotless-j, which would be
+ // indistinguishable from normal accented letter.
+ if ((baseChar == 0x0237 || baseChar == 0x0131) &&
+ ((ch >= 0x0300 && ch <= 0x0314) || ch == 0x031a)) {
+ return false;
+ }
+ } else {
+ baseChar = ch;
}
// Simplified/Traditional Chinese check temporarily disabled -- bug 857481
diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp
index 0e570e8cb..1c9093495 100644
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -8335,9 +8335,31 @@ nsHttpChannel::ResumeInternal()
LOG(("nsHttpChannel::ResumeInternal [this=%p]\n", this));
if (--mSuspendCount == 0 && mCallOnResume) {
- nsresult rv = AsyncCall(mCallOnResume);
+ // Resume the interrupted procedure first, then resume
+ // the pump to continue process the input stream.
+ RefPtr<nsRunnableMethod<nsHttpChannel>> callOnResume=
+ NewRunnableMethod(this, mCallOnResume);
+ // Should not resume pump that created after resumption.
+ RefPtr<nsInputStreamPump> transactionPump = mTransactionPump;
+ RefPtr<nsInputStreamPump> cachePump = mCachePump;
+
+ nsresult rv =
+ NS_DispatchToCurrentThread(NS_NewRunnableFunction(
+ [callOnResume, transactionPump, cachePump]() {
+ callOnResume->Run();
+
+ if (transactionPump) {
+ transactionPump->Resume();
+ }
+
+ if (cachePump) {
+ cachePump->Resume();
+ }
+ })
+ );
mCallOnResume = nullptr;
NS_ENSURE_SUCCESS(rv, rv);
+ return rv;
}
nsresult rvTransaction = NS_OK;
diff --git a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
index 9a2275287..d04f47ddc 100644
--- a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
+++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
@@ -53,6 +53,9 @@ namespace net {
#define HTTP_AUTH_NEGOTIATE_INSECURE 6
#define HTTP_AUTH_NEGOTIATE_SECURE 7
+#define MAX_DISPLAYED_USER_LENGTH 64
+#define MAX_DISPLAYED_HOST_LENGTH 64
+
static void
GetOriginAttributesSuffix(nsIChannel* aChan, nsACString &aSuffix)
{
@@ -1512,6 +1515,33 @@ nsHttpChannelAuthProvider::ConfirmAuth(const nsString &bundleKey,
return true;
NS_ConvertUTF8toUTF16 ucsHost(host), ucsUser(user);
+
+ size_t userLength = ucsUser.Length();
+ if (userLength > MAX_DISPLAYED_USER_LENGTH) {
+ size_t desiredLength = MAX_DISPLAYED_USER_LENGTH;
+ // Don't cut off right before a low surrogate. Just include it.
+ if (NS_IS_LOW_SURROGATE(ucsUser[desiredLength])) {
+ desiredLength++;
+ }
+ ucsUser.Replace(desiredLength, userLength - desiredLength,
+ nsContentUtils::GetLocalizedEllipsis());
+ }
+
+ size_t hostLen = ucsHost.Length();
+ if (hostLen > MAX_DISPLAYED_HOST_LENGTH) {
+ size_t cutPoint = hostLen - MAX_DISPLAYED_HOST_LENGTH;
+ // Likewise, don't cut off right before a low surrogate here.
+ // Keep the low surrogate
+ if (NS_IS_LOW_SURROGATE(ucsHost[cutPoint])) {
+ cutPoint--;
+ }
+ // It's possible cutPoint was 1 and is now 0. Only insert the ellipsis
+ // if we're actually removing anything.
+ if (cutPoint > 0) {
+ ucsHost.Replace(0, cutPoint, nsContentUtils::GetLocalizedEllipsis());
+ }
+ }
+
const char16_t *strs[2] = { ucsHost.get(), ucsUser.get() };
nsXPIDLString msg;
diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp
index 1ddffabff..67e29a029 100644
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -199,8 +199,9 @@ nsHttpHandler::nsHttpHandler()
, mSessionStartTime(0)
, mLegacyAppName("Mozilla")
, mLegacyAppVersion("5.0")
- , mProduct("Gecko")
+ , mProduct("Goanna")
, mCompatFirefoxEnabled(false)
+ , mCompatFirefoxVersion("52.9")
, mUserAgentIsDirty(true)
, mPromptTempRedirect(true)
, mEnablePersistentHttpsCaching(false)
@@ -316,9 +317,13 @@ nsHttpHandler::Init()
nsHttpChannelAuthProvider::InitializePrefs();
- mMisc.AssignLiteral("rv:" MOZILLA_UAVERSION);
+ // rv: should have the Firefox/Gecko compatversion for web compatibility
+ mMisc.AssignLiteral("rv:");
+ mMisc += mCompatFirefoxVersion;
- mCompatFirefox.AssignLiteral("Firefox/" MOZILLA_UAVERSION);
+ mCompatGecko.AssignLiteral("Gecko/20100101");
+ mCompatFirefox.AssignLiteral("Firefox/");
+ mCompatFirefox += mCompatFirefoxVersion;
nsCOMPtr<nsIXULAppInfo> appInfo =
do_GetService("@mozilla.org/xre/app-info;1");
@@ -330,12 +335,30 @@ nsHttpHandler::Init()
if (mAppName.Length() == 0) {
appInfo->GetName(mAppName);
}
- appInfo->GetVersion(mAppVersion);
mAppName.StripChars(R"( ()<>@,;:\"/[]?={})");
+ }
+
+ nsCString dynamicBuildID;
+ if (appInfo) {
+ appInfo->GetPlatformBuildID(dynamicBuildID);
+ if (dynamicBuildID.Length() > 8 )
+ dynamicBuildID.Left(dynamicBuildID, 8);
+ }
+
+ if (mAppVersionIsBuildID) {
+ // Override BuildID
+ mAppVersion.AssignLiteral(MOZ_UA_BUILDID);
+ } else if (appInfo) {
+ appInfo->GetVersion(mAppVersion);
} else {
- mAppVersion.AssignLiteral(MOZ_APP_UA_VERSION);
+ // Fall back to platform if appInfo is unavailable
+ mAppVersion.AssignLiteral(MOZILLA_UAVERSION);
}
+ // If there's no override set, set it to the dynamic BuildID
+ if (mAppVersion.IsEmpty())
+ mAppVersion.Assign(dynamicBuildID);
+
mSessionStartTime = NowInSeconds();
mHandlerActive = true;
@@ -351,11 +374,11 @@ nsHttpHandler::Init()
mRequestContextService =
do_GetService("@mozilla.org/network/request-context-service;1");
-#if defined(ANDROID) || defined(MOZ_MULET)
+ // Goanna slice version
mProductSub.AssignLiteral(MOZILLA_UAVERSION);
-#else
- mProductSub.AssignLiteral("20100101");
-#endif
+
+ if (mProductSub.IsEmpty())
+ mProductSub.Assign(dynamicBuildID);
#if DEBUG
// dump user agent prefs
@@ -369,6 +392,7 @@ nsHttpHandler::Init()
LOG(("> app-name = %s\n", mAppName.get()));
LOG(("> app-version = %s\n", mAppVersion.get()));
LOG(("> compat-firefox = %s\n", mCompatFirefox.get()));
+ LOG(("> compat-gecko = %s\n", mCompatGecko.get()));
LOG(("> user-agent = %s\n", UserAgent().get()));
#endif
@@ -678,9 +702,10 @@ nsHttpHandler::BuildUserAgent()
mAppName.Length() +
mAppVersion.Length() +
mCompatFirefox.Length() +
+ mCompatGecko.Length() +
mCompatDevice.Length() +
mDeviceModelId.Length() +
- 13);
+ 14);
// Application portion
mUserAgent.Assign(mLegacyAppName);
@@ -710,6 +735,12 @@ nsHttpHandler::BuildUserAgent()
}
mUserAgent += mMisc;
mUserAgent += ')';
+
+ if(mCompatGeckoEnabled) {
+ // Provide frozen Gecko/20100101 slice
+ mUserAgent += ' ';
+ mUserAgent += mCompatGecko;
+ }
// Product portion
mUserAgent += ' ';
@@ -719,7 +750,7 @@ nsHttpHandler::BuildUserAgent()
bool isFirefox = mAppName.EqualsLiteral("Firefox");
if (isFirefox || mCompatFirefoxEnabled) {
- // "Firefox/x.y" (compatibility) app token
+ // Provide "Firefox/x.y" (compatibility) app token
mUserAgent += ' ';
mUserAgent += mCompatFirefox;
}
@@ -966,16 +997,44 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
bool cVar = false;
+ if (PREF_CHANGED(UA_PREF("appVersionIsBuildID"))) {
+ rv = prefs->GetBoolPref(UA_PREF("appVersionIsBuildID"), &cVar);
+ mAppVersionIsBuildID = (NS_SUCCEEDED(rv) && cVar);
+ mUserAgentIsDirty = true;
+ }
+
+ if (PREF_CHANGED(UA_PREF("compatMode.gecko"))) {
+ rv = prefs->GetBoolPref(UA_PREF("compatMode.gecko"), &cVar);
+ mCompatGeckoEnabled = (NS_SUCCEEDED(rv) && cVar);
+ mUserAgentIsDirty = true;
+ }
+
if (PREF_CHANGED(UA_PREF("compatMode.firefox"))) {
rv = prefs->GetBoolPref(UA_PREF("compatMode.firefox"), &cVar);
mCompatFirefoxEnabled = (NS_SUCCEEDED(rv) && cVar);
mUserAgentIsDirty = true;
}
+ // general.useragent.compatMode.version
+ // This is the version number used in rv: for Gecko compatibility
+ // and in the Firefox/nn.nn slice when compatMode.firefox is enabled.
+ if (PREF_CHANGED(UA_PREF("compatMode.version"))) {
+ prefs->GetCharPref(UA_PREF("compatMode.version"),
+ getter_Copies(mCompatFirefoxVersion));
+
+ // rebuild mMisc and compatMode slice
+ mMisc.AssignLiteral("rv:");
+ mMisc += mCompatFirefoxVersion;
+ mCompatFirefox.AssignLiteral("Firefox/");
+ mCompatFirefox += mCompatFirefoxVersion;
+
+ mUserAgentIsDirty = true;
+ }
+
// general.useragent.override
if (PREF_CHANGED(UA_PREF("override"))) {
prefs->GetCharPref(UA_PREF("override"),
- getter_Copies(mUserAgentOverride));
+ getter_Copies(mUserAgentOverride));
mUserAgentIsDirty = true;
}
diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h
index 13cc72e8e..d51662db9 100644
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -485,7 +485,11 @@ private:
nsXPIDLCString mProductSub;
nsXPIDLCString mAppName;
nsXPIDLCString mAppVersion;
+ bool mAppVersionIsBuildID;
+ nsCString mCompatGecko;
+ bool mCompatGeckoEnabled;
nsCString mCompatFirefox;
+ nsCString mCompatFirefoxVersion;
bool mCompatFirefoxEnabled;
nsXPIDLCString mCompatDevice;
nsCString mDeviceModelId;
diff --git a/netwerk/test/TestUDPSocket.cpp b/netwerk/test/TestUDPSocket.cpp
index 9236d2ea3..0ec43a650 100644
--- a/netwerk/test/TestUDPSocket.cpp
+++ b/netwerk/test/TestUDPSocket.cpp
@@ -13,9 +13,6 @@
#include "nsIScriptSecurityManager.h"
#include "nsITimer.h"
#include "mozilla/net/DNS.h"
-#ifdef XP_WIN
-#include "mozilla/WindowsVersion.h"
-#endif
#include "prerror.h"
#define REQUEST 0x68656c6f
@@ -334,16 +331,6 @@ main(int32_t argc, char *argv[])
}
RefPtr<MulticastTimerCallback> timerCb = new MulticastTimerCallback();
- // The following multicast tests using multiple sockets require a firewall
- // exception on Windows XP (the earliest version of Windows we now support)
- // before they pass. For now, we'll skip them here. Later versions of Windows
- // (Win2003 and onward) don't seem to have this issue.
-#ifdef XP_WIN
- if (!mozilla::IsWin2003OrLater()) { // i.e. if it is WinXP
- goto close;
- }
-#endif
-
// Join multicast group
printf("Joining multicast group\n");
phase = TEST_MULTICAST;
diff --git a/netwerk/test/mochitests/mochitest.ini b/netwerk/test/mochitests/mochitest.ini
index 98d406c80..f8a919031 100644
--- a/netwerk/test/mochitests/mochitest.ini
+++ b/netwerk/test/mochitests/mochitest.ini
@@ -24,3 +24,4 @@ support-files =
[test_user_agent_updates_reset.html]
[test_viewsource_unlinkable.html]
[test_xhr_method_case.html]
+[test_1396395.html]
diff --git a/netwerk/test/mochitests/test_1396395.html b/netwerk/test/mochitests/test_1396395.html
new file mode 100644
index 000000000..193ef219c
--- /dev/null
+++ b/netwerk/test/mochitests/test_1396395.html
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML>
+<!-- vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: -->
+<html>
+ <!-- Any copyright is dedicated to the Public Domain.
+ - http://creativecommons.org/publicdomain/zero/1.0/ -->
+<head>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+</head>
+<body>
+ <iframe id="f" src="http://example.com"></iframe>
+ <script type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+
+var script = SpecialPowers.loadChromeScript(() => {
+ const Ci = Components.interfaces;
+ const Cc = Components.classes;
+ const Cu = Components.utils;
+ Cu.import('resource://gre/modules/Services.jsm');
+
+ Services.obs.addObserver(function onExamResp(subject, topic, data) {
+ let channel = subject.QueryInterface(Ci.nsIHttpChannel);
+ if (!channel.URI.spec.startsWith("http://example.org")) {
+ return;
+ }
+ Services.obs.removeObserver(onExamResp, 'http-on-examine-response');
+ channel.suspend();
+ Promise.resolve().then(() => {
+ channel.resume();
+ });
+ }, 'http-on-examine-response');
+
+ sendAsyncMessage('start-test');
+});
+
+script.addMessageListener('start-test', () => {
+ const iframe = document.getElementById('f');
+
+ iframe.contentWindow.onunload = function () {
+ xhr = new XMLHttpRequest();
+ xhr.open('GET', window.location, false);
+ xhr.send(null);
+ ok(true, 'complete without crash');
+ script.destroy();
+ SimpleTest.finish();
+ }
+
+ iframe.src = 'http://example.org';
+});
+ </script>
+</body>
+</html>
+
diff --git a/netwerk/wifi/moz.build b/netwerk/wifi/moz.build
index b6ddd2139..e3edb0842 100644
--- a/netwerk/wifi/moz.build
+++ b/netwerk/wifi/moz.build
@@ -45,7 +45,6 @@ elif CONFIG['OS_ARCH'] == 'WINNT':
'nsWifiScannerWin.cpp',
'win_wifiScanner.cpp',
'win_wlanLibrary.cpp',
- 'win_xp_wifiScanner.cpp'
]
elif CONFIG['OS_ARCH'] == 'SunOS':
CXXFLAGS += CONFIG['GLIB_CFLAGS']
diff --git a/netwerk/wifi/nsWifiMonitor.h b/netwerk/wifi/nsWifiMonitor.h
index 3783d38bd..665798efc 100644
--- a/netwerk/wifi/nsWifiMonitor.h
+++ b/netwerk/wifi/nsWifiMonitor.h
@@ -76,7 +76,7 @@ class nsWifiMonitor final : nsIRunnable, nsIWifiMonitor, nsIObserver
mozilla::ReentrantMonitor mReentrantMonitor;
#ifdef XP_WIN
- nsAutoPtr<WindowsWifiScannerInterface> mWinWifiScanner;
+ nsAutoPtr<WinWifiScanner> mWinWifiScanner;
#endif
};
#else
diff --git a/netwerk/wifi/nsWifiScannerWin.cpp b/netwerk/wifi/nsWifiScannerWin.cpp
index ef18706e4..6089c45c6 100644
--- a/netwerk/wifi/nsWifiScannerWin.cpp
+++ b/netwerk/wifi/nsWifiScannerWin.cpp
@@ -12,8 +12,6 @@
#include "nsServiceManagerUtils.h"
#include "nsWifiAccessPoint.h"
#include "win_wifiScanner.h"
-#include "win_xp_wifiScanner.h"
-#include "mozilla/WindowsVersion.h"
using namespace mozilla;
@@ -31,14 +29,7 @@ nsresult
nsWifiMonitor::DoScan()
{
if (!mWinWifiScanner) {
- if (IsWin2003OrLater()) {
- mWinWifiScanner = new WinWifiScanner();
- LOG(("Using Windows 2003+ wifi scanner."));
- } else {
- mWinWifiScanner = new WinXPWifiScanner();
- LOG(("Using Windows XP wifi scanner."));
- }
-
+ mWinWifiScanner = new WinWifiScanner();
if (!mWinWifiScanner) {
// TODO: Probably return OOM error
return NS_ERROR_FAILURE;
diff --git a/netwerk/wifi/win_wifiScanner.h b/netwerk/wifi/win_wifiScanner.h
index b43c23899..79b1bf132 100644
--- a/netwerk/wifi/win_wifiScanner.h
+++ b/netwerk/wifi/win_wifiScanner.h
@@ -11,19 +11,10 @@
class nsWifiAccessPoint;
-// This class allows the wifi monitor to use WinWifiScanner and WinXPWifiScanner interchangeably.
-class WindowsWifiScannerInterface {
-public:
- virtual ~WindowsWifiScannerInterface() {}
-
- virtual nsresult GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint> &accessPoints) = 0;
-};
-
-
-class WinWifiScanner : public WindowsWifiScannerInterface {
+class WinWifiScanner final {
public:
WinWifiScanner();
- virtual ~WinWifiScanner();
+ ~WinWifiScanner();
/**
* GetAccessPointsFromWLAN
diff --git a/netwerk/wifi/win_xp_wifiScanner.cpp b/netwerk/wifi/win_xp_wifiScanner.cpp
deleted file mode 100644
index 4dcd34034..000000000
--- a/netwerk/wifi/win_xp_wifiScanner.cpp
+++ /dev/null
@@ -1,399 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Windows Vista uses the Native Wifi (WLAN) API for accessing WiFi cards. See
-// http://msdn.microsoft.com/en-us/library/ms705945(VS.85).aspx. Windows XP
-// Service Pack 3 (and Windows XP Service Pack 2, if upgraded with a hot fix)
-// also support a limited version of the WLAN API. See
-// http://msdn.microsoft.com/en-us/library/bb204766.aspx. The WLAN API uses
-// wlanapi.h, which is not part of the SDK used by Gears, so is replicated
-// locally using data from the MSDN.
-//\
-// Windows XP from Service Pack 2 onwards supports the Wireless Zero
-// Configuration (WZC) programming interface. See
-// http://msdn.microsoft.com/en-us/library/ms706587(VS.85).aspx.
-//
-// The MSDN recommends that one use the WLAN API where available, and WZC
-// otherwise.
-//
-// However, it seems that WZC fails for some wireless cards. Also, WLAN seems
-// not to work on XP SP3. So we use WLAN on Vista, and use NDIS directly
-// otherwise.
-
-// MOZILLA NOTE:
-// This code is ported from chromium:
-// https://chromium.googlesource.com/chromium/src/+/master/content/browser/geolocation/wifi_data_provider_win.cc
-// Based on changeset 42c5878
-
-#include "win_xp_wifiScanner.h"
-#include "nsWifiAccessPoint.h"
-#include <windows.h>
-#include <winioctl.h>
-#include <wlanapi.h>
-#include <string>
-#include <vector>
-
-// Taken from ndis.h for WinCE.
-#define NDIS_STATUS_INVALID_LENGTH ((NDIS_STATUS)0xC0010014L)
-#define NDIS_STATUS_BUFFER_TOO_SHORT ((NDIS_STATUS)0xC0010016L)
-
-namespace {
-// The limits on the size of the buffer used for the OID query.
-const int kInitialBufferSize = 2 << 12; // Good for about 50 APs.
-const int kMaximumBufferSize = 2 << 20; // 2MB
-
-// Length for generic string buffers passed to Win32 APIs.
-const int kStringLength = 512;
-
-// WlanOpenHandle
-typedef DWORD (WINAPI* WlanOpenHandleFunction)(DWORD dwClientVersion,
- PVOID pReserved,
- PDWORD pdwNegotiatedVersion,
- PHANDLE phClientHandle);
-
-// WlanEnumInterfaces
-typedef DWORD (WINAPI* WlanEnumInterfacesFunction)(
- HANDLE hClientHandle,
- PVOID pReserved,
- PWLAN_INTERFACE_INFO_LIST* ppInterfaceList);
-
-// WlanGetNetworkBssList
-typedef DWORD (WINAPI* WlanGetNetworkBssListFunction)(
- HANDLE hClientHandle,
- const GUID* pInterfaceGuid,
- const PDOT11_SSID pDot11Ssid,
- DOT11_BSS_TYPE dot11BssType,
- BOOL bSecurityEnabled,
- PVOID pReserved,
- PWLAN_BSS_LIST* ppWlanBssList
-);
-
-// WlanFreeMemory
-typedef VOID (WINAPI* WlanFreeMemoryFunction)(PVOID pMemory);
-
-// WlanCloseHandle
-typedef DWORD (WINAPI* WlanCloseHandleFunction)(HANDLE hClientHandle,
- PVOID pReserved);
-
-// Extracts data for an access point and converts to Gears format.
-bool UndefineDosDevice(const std::string& device_name);
-bool DefineDosDeviceIfNotExists(const std::string& device_name);
-HANDLE GetFileHandle(const std::string& device_name);
-// Makes the OID query and returns a Win32 error code.
-int PerformQuery(HANDLE adapter_handle, std::vector<char>& buffer, DWORD* bytes_out);
-bool ResizeBuffer(size_t requested_size, std::vector<char>& buffer);
-// Gets the system directory and appends a trailing slash if not already
-// present.
-bool GetSystemDirectory(std::string* path);
-
-bool ConvertToAccessPointData(const NDIS_WLAN_BSSID& data, nsWifiAccessPoint* access_point_data);
-int GetDataFromBssIdList(const NDIS_802_11_BSSID_LIST& bss_id_list,
- int list_size,
- nsCOMArray<nsWifiAccessPoint>& outData);
-} // namespace
-
-class WindowsNdisApi
-{
-public:
- virtual ~WindowsNdisApi();
- static WindowsNdisApi* Create();
- virtual bool GetAccessPointData(nsCOMArray<nsWifiAccessPoint>& outData);
-
-private:
- static bool GetInterfacesNDIS(std::vector<std::string>& interface_service_names_out);
- // Swaps in content of the vector passed
- explicit WindowsNdisApi(std::vector<std::string>* interface_service_names);
- bool GetInterfaceDataNDIS(HANDLE adapter_handle, nsCOMArray<nsWifiAccessPoint>& outData);
- // NDIS variables.
- std::vector<std::string> interface_service_names_;
- std::vector<char> _buffer;
-};
-
-// WindowsNdisApi
-WindowsNdisApi::WindowsNdisApi(
- std::vector<std::string>* interface_service_names)
- : _buffer(kInitialBufferSize) {
- interface_service_names_.swap(*interface_service_names);
-}
-
-WindowsNdisApi::~WindowsNdisApi() {
-}
-
-WindowsNdisApi* WindowsNdisApi::Create() {
- std::vector<std::string> interface_service_names;
- if (GetInterfacesNDIS(interface_service_names)) {
- return new WindowsNdisApi(&interface_service_names);
- }
- return NULL;
-}
-
-bool WindowsNdisApi::GetAccessPointData(nsCOMArray<nsWifiAccessPoint>& outData) {
- int interfaces_failed = 0;
- int interfaces_succeeded = 0;
-
- for (int i = 0; i < static_cast<int>(interface_service_names_.size()); ++i) {
- // First, check that we have a DOS device for this adapter.
- if (!DefineDosDeviceIfNotExists(interface_service_names_[i])) {
- continue;
- }
-
- // Get the handle to the device. This will fail if the named device is not
- // valid.
- HANDLE adapter_handle = GetFileHandle(interface_service_names_[i]);
- if (adapter_handle == INVALID_HANDLE_VALUE) {
- continue;
- }
-
- // Get the data.
- if (GetInterfaceDataNDIS(adapter_handle, outData)) {
- ++interfaces_succeeded;
- } else {
- ++interfaces_failed;
- }
-
- // Clean up.
- CloseHandle(adapter_handle);
- UndefineDosDevice(interface_service_names_[i]);
- }
-
- // Return true if at least one interface succeeded, or at the very least none
- // failed.
- return interfaces_succeeded > 0 || interfaces_failed == 0;
-}
-
-bool WindowsNdisApi::GetInterfacesNDIS(std::vector<std::string>& interface_service_names_out) {
- HKEY network_cards_key = NULL;
- if (RegOpenKeyEx(
- HKEY_LOCAL_MACHINE,
- "Software\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards",
- 0,
- KEY_READ,
- &network_cards_key) != ERROR_SUCCESS) {
- return false;
- }
- if (!network_cards_key) {
- return false;
- }
-
- for (int i = 0; ; ++i) {
- TCHAR name[kStringLength];
- DWORD name_size = kStringLength;
- FILETIME time;
- if (RegEnumKeyEx(network_cards_key,
- i,
- name,
- &name_size,
- NULL,
- NULL,
- NULL,
- &time) != ERROR_SUCCESS) {
- break;
- }
- HKEY hardware_key = NULL;
- if (RegOpenKeyEx(network_cards_key, name, 0, KEY_READ, &hardware_key) !=
- ERROR_SUCCESS) {
- break;
- }
- if (!hardware_key) {
- return false;
- }
-
- TCHAR service_name[kStringLength];
- DWORD service_name_size = kStringLength;
- DWORD type = 0;
- if (RegQueryValueEx(hardware_key,
- "ServiceName",
- NULL,
- &type,
- reinterpret_cast<LPBYTE>(service_name),
- &service_name_size) == ERROR_SUCCESS) {
- interface_service_names_out.push_back(service_name);
- }
- RegCloseKey(hardware_key);
- }
-
- RegCloseKey(network_cards_key);
- return true;
-}
-
-bool WindowsNdisApi::GetInterfaceDataNDIS(HANDLE adapter_handle,
- nsCOMArray<nsWifiAccessPoint>& outData) {
- DWORD bytes_out;
- int result;
-
- while (true) {
- bytes_out = 0;
- result = PerformQuery(adapter_handle, _buffer, &bytes_out);
- if (result == ERROR_GEN_FAILURE || // Returned by some Intel cards.
- result == ERROR_INSUFFICIENT_BUFFER ||
- result == ERROR_MORE_DATA ||
- result == NDIS_STATUS_INVALID_LENGTH ||
- result == NDIS_STATUS_BUFFER_TOO_SHORT) {
- // The buffer we supplied is too small, so increase it. bytes_out should
- // provide the required buffer size, but this is not always the case.
- size_t newSize;
- if (bytes_out > static_cast<DWORD>(_buffer.size())) {
- newSize = bytes_out;
- } else {
- newSize = _buffer.size() * 2;
- }
- if (!ResizeBuffer(newSize, _buffer)) {
- return false;
- }
- } else {
- // The buffer is not too small.
- break;
- }
- }
-
- if (result == ERROR_SUCCESS) {
- NDIS_802_11_BSSID_LIST* bssid_list =
- reinterpret_cast<NDIS_802_11_BSSID_LIST*>(&_buffer[0]);
- GetDataFromBssIdList(*bssid_list, _buffer.size(), outData);
- }
-
- return true;
-}
-
-namespace {
-#define uint8 unsigned char
-
-bool ConvertToAccessPointData(const NDIS_WLAN_BSSID& data, nsWifiAccessPoint* access_point_data)
-{
- access_point_data->setMac(data.MacAddress);
- access_point_data->setSignal(data.Rssi);
- // Note that _NDIS_802_11_SSID::Ssid::Ssid is not null-terminated.
- const unsigned char* ssid = data.Ssid.Ssid;
- size_t len = data.Ssid.SsidLength;
- access_point_data->setSSID(reinterpret_cast<const char*>(ssid), len);
- return true;
-}
-
-int GetDataFromBssIdList(const NDIS_802_11_BSSID_LIST& bss_id_list,
- int list_size,
- nsCOMArray<nsWifiAccessPoint>& outData)
-{
- // Walk through the BSS IDs.
- int found = 0;
- const uint8* iterator = reinterpret_cast<const uint8*>(&bss_id_list.Bssid[0]);
- const uint8* end_of_buffer =
- reinterpret_cast<const uint8*>(&bss_id_list) + list_size;
- for (int i = 0; i < static_cast<int>(bss_id_list.NumberOfItems); ++i) {
- const NDIS_WLAN_BSSID *bss_id =
- reinterpret_cast<const NDIS_WLAN_BSSID*>(iterator);
- // Check that the length of this BSS ID is reasonable.
- if (bss_id->Length < sizeof(NDIS_WLAN_BSSID) ||
- iterator + bss_id->Length > end_of_buffer) {
- break;
- }
- nsWifiAccessPoint* ap = new nsWifiAccessPoint();
- if (ConvertToAccessPointData(*bss_id, ap)) {
- outData.AppendObject(ap);
- ++found;
- }
- // Move to the next BSS ID.
- iterator += bss_id->Length;
- }
- return found;
-}
-
-
-bool UndefineDosDevice(const std::string& device_name) {
- // We remove only the mapping we use, that is \Device\<device_name>.
- std::string target_path = "\\Device\\" + device_name;
- return DefineDosDevice(
- DDD_RAW_TARGET_PATH | DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE,
- device_name.c_str(),
- target_path.c_str()) == TRUE;
-}
-
-bool DefineDosDeviceIfNotExists(const std::string& device_name) {
- // We create a DOS device name for the device at \Device\<device_name>.
- std::string target_path = "\\Device\\" + device_name;
-
- TCHAR target[kStringLength];
- if (QueryDosDevice(device_name.c_str(), target, kStringLength) > 0 &&
- target_path.compare(target) == 0) {
- // Device already exists.
- return true;
- }
-
- if (GetLastError() != ERROR_FILE_NOT_FOUND) {
- return false;
- }
-
- if (!DefineDosDevice(DDD_RAW_TARGET_PATH,
- device_name.c_str(),
- target_path.c_str())) {
- return false;
- }
-
- // Check that the device is really there.
- return QueryDosDevice(device_name.c_str(), target, kStringLength) > 0 &&
- target_path.compare(target) == 0;
-}
-
-HANDLE GetFileHandle(const std::string& device_name) {
- // We access a device with DOS path \Device\<device_name> at
- // \\.\<device_name>.
- std::string formatted_device_name = "\\\\.\\" + device_name;
-
- return CreateFile(formatted_device_name.c_str(),
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE, // share mode
- 0, // security attributes
- OPEN_EXISTING,
- 0, // flags and attributes
- INVALID_HANDLE_VALUE);
-}
-
-int PerformQuery(HANDLE adapter_handle,
- std::vector<char>& buffer,
- DWORD* bytes_out) {
- DWORD oid = OID_802_11_BSSID_LIST;
- if (!DeviceIoControl(adapter_handle,
- IOCTL_NDIS_QUERY_GLOBAL_STATS,
- &oid,
- sizeof(oid),
- &buffer[0],
- buffer.size(),
- bytes_out,
- NULL)) {
- return GetLastError();
- }
- return ERROR_SUCCESS;
-}
-
-bool ResizeBuffer(size_t requested_size, std::vector<char>& buffer) {
- if (requested_size > kMaximumBufferSize) {
- buffer.resize(kInitialBufferSize);
- return false;
- }
-
- buffer.resize(requested_size);
- return true;
-}
-
-} // namespace
-
-
-nsresult
-WinXPWifiScanner::GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint> &accessPoints)
-{
- if (!mImplementation) {
- mImplementation = WindowsNdisApi::Create();
- if (!mImplementation) {
- return NS_ERROR_FAILURE;
- }
- }
-
- accessPoints.Clear();
- bool isOk = mImplementation->GetAccessPointData(accessPoints);
- if (!isOk) {
- mImplementation = 0;
- return NS_ERROR_FAILURE;
- }
-
- return NS_OK;
-}
diff --git a/netwerk/wifi/win_xp_wifiScanner.h b/netwerk/wifi/win_xp_wifiScanner.h
deleted file mode 100644
index 33ae4cae4..000000000
--- a/netwerk/wifi/win_xp_wifiScanner.h
+++ /dev/null
@@ -1,25 +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/. */
-
-#ifndef WINXPWIFISCANNER_H_
-#define WINXPWIFISCANNER_H_
-
-#include "nsAutoPtr.h"
-#include "nsCOMArray.h"
-#include "win_wifiScanner.h"
-
-class nsWifiAccessPoint;
-class WindowsNdisApi;
-
-// This class is wrapper into the Chromium WindowNdisApi class for scanning wifis
-// on Windows XP. When Firefox drops XP support, this code can go.
-class WinXPWifiScanner : public WindowsWifiScannerInterface {
-public:
- nsresult GetAccessPointsFromWLAN(nsCOMArray<nsWifiAccessPoint> &accessPoints);
- virtual ~WinXPWifiScanner() {}
-private:
- nsAutoPtr<WindowsNdisApi> mImplementation;
-};
-
-#endif \ No newline at end of file