зеркало из https://github.com/mozilla/gecko-dev.git
Merge inbound to mozilla-central. a=merge
This commit is contained in:
Коммит
64199f841e
|
@ -355,27 +355,6 @@ add_task(async function() {
|
|||
gBrowser.removeTab(gBrowser.getTabForBrowser(browser));
|
||||
});
|
||||
|
||||
/**
|
||||
* In this test, we check that the author defined error message is shown.
|
||||
*/
|
||||
add_task(async function() {
|
||||
incrementTest();
|
||||
let uri = getDocHeader() + "<form target='t' action='data:text/html,'><input x-moz-errormessage='foo' required id='i'><input id='s' type='submit'></form>" + getDocFooter();
|
||||
let browser = await openNewTab(uri);
|
||||
|
||||
let popupShownPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popupshown");
|
||||
await clickChildElement(browser);
|
||||
await popupShownPromise;
|
||||
|
||||
checkPopupShow();
|
||||
await checkChildFocus(browser, gInvalidFormPopup.firstElementChild.textContent);
|
||||
|
||||
is(gInvalidFormPopup.firstElementChild.textContent, "foo",
|
||||
"The panel should show the author defined error message");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
/**
|
||||
* In this test, we check that the message is correctly updated when it changes.
|
||||
*/
|
||||
|
|
|
@ -431,6 +431,17 @@ toolbarpaletteitem[place=toolbar] > toolbarspring {
|
|||
border-inline-end: 1px solid var(--panel-separator-color);
|
||||
}
|
||||
|
||||
.customization-uidensity-menuitem > .menu-iconic-left > .menu-iconic-icon:-moz-locale-dir(rtl),
|
||||
.customization-lwtheme-menu-theme > .toolbarbutton-icon:-moz-locale-dir(rtl) {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
|
||||
#customization-uidensity-button > .box-inherit > .box-inherit > .button-icon:-moz-locale-dir(rtl),
|
||||
#customization-lwtheme-button > .box-inherit > .box-inherit > .button-icon:-moz-locale-dir(rtl) {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
|
||||
|
||||
#customization-panelWrapper > .panel-arrowcontent {
|
||||
color: var(--arrowpanel-color);
|
||||
background: var(--arrowpanel-background);
|
||||
|
|
|
@ -46,20 +46,7 @@ void nsIConstraintValidation::GetValidationMessage(
|
|||
aValidationMessage.Truncate();
|
||||
|
||||
if (IsCandidateForConstraintValidation() && !IsValid()) {
|
||||
nsCOMPtr<Element> element = do_QueryInterface(this);
|
||||
NS_ASSERTION(element,
|
||||
"This class should be inherited by HTML elements only!");
|
||||
|
||||
nsAutoString authorMessage;
|
||||
element->GetAttr(kNameSpaceID_None, nsGkAtoms::x_moz_errormessage,
|
||||
authorMessage);
|
||||
|
||||
if (!authorMessage.IsEmpty()) {
|
||||
aValidationMessage.Assign(authorMessage);
|
||||
if (aValidationMessage.Length() > sContentSpecifiedMaxLengthMessage) {
|
||||
aValidationMessage.Truncate(sContentSpecifiedMaxLengthMessage);
|
||||
}
|
||||
} else if (GetValidityState(VALIDITY_STATE_CUSTOM_ERROR)) {
|
||||
if (GetValidityState(VALIDITY_STATE_CUSTOM_ERROR)) {
|
||||
aValidationMessage.Assign(mCustomValidity);
|
||||
if (aValidationMessage.Length() > sContentSpecifiedMaxLengthMessage) {
|
||||
aValidationMessage.Truncate(sContentSpecifiedMaxLengthMessage);
|
||||
|
|
|
@ -24,7 +24,7 @@ var content = document.getElementById('content');
|
|||
for (var eName of subjectForConstraintValidation) {
|
||||
var e = document.createElement(eName);
|
||||
content.appendChild(e);
|
||||
e.setAttribute("x-moz-errormessage", "foo");
|
||||
e.setCustomValidity("foo");
|
||||
if ("required" in e) {
|
||||
e.required = true;
|
||||
} else {
|
||||
|
|
|
@ -39,13 +39,8 @@ for (var i=0; i<75; ++i) {
|
|||
input.setCustomValidity(msg);
|
||||
checkMessage(input, msg, false);
|
||||
|
||||
// The input is still invalid but x-moz-errormessage will be used as the message.
|
||||
input.setAttribute("x-moz-errormessage", msg);
|
||||
checkMessage(input, msg, false);
|
||||
|
||||
// Cleaning.
|
||||
input.setCustomValidity("");
|
||||
input.removeAttribute("x-moz-errormessage");
|
||||
|
||||
// Testing with pattern and titl.
|
||||
input.pattern = "[0-9]*";
|
||||
|
|
|
@ -1812,6 +1812,13 @@ VARCACHE_PREF(
|
|||
RelaxedAtomicBool, false
|
||||
)
|
||||
|
||||
// Password protection
|
||||
VARCACHE_PREF(
|
||||
"browser.safebrowsing.passwords.enabled",
|
||||
browser_safebrowsing_passwords_enabled,
|
||||
bool, false
|
||||
)
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// ChannelClassifier prefs
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -5599,9 +5599,6 @@ pref("browser.safebrowsing.downloads.remote.block_dangerous_host", true);
|
|||
pref("browser.safebrowsing.downloads.remote.block_potentially_unwanted", true);
|
||||
pref("browser.safebrowsing.downloads.remote.block_uncommon", true);
|
||||
|
||||
// Password protection
|
||||
pref("browser.safebrowsing.passwords.enabled", false);
|
||||
|
||||
// Google Safe Browsing provider (legacy)
|
||||
pref("browser.safebrowsing.provider.google.pver", "2.2");
|
||||
pref("browser.safebrowsing.provider.google.lists", "goog-badbinurl-shavar,goog-downloadwhite-digest256,goog-phish-shavar,googpub-phish-shavar,goog-malware-shavar,goog-unwanted-shavar");
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "mozilla/net/UrlClassifierFeatureFactory.h"
|
||||
|
||||
// List of Features
|
||||
#include "UrlClassifierFeatureLoginReputation.h"
|
||||
#include "UrlClassifierFeatureTrackingProtection.h"
|
||||
#include "UrlClassifierFeatureTrackingAnnotation.h"
|
||||
|
||||
|
@ -31,6 +32,7 @@ namespace net {
|
|||
return;
|
||||
}
|
||||
|
||||
UrlClassifierFeatureLoginReputation::MaybeShutdown();
|
||||
UrlClassifierFeatureTrackingAnnotation::Shutdown();
|
||||
UrlClassifierFeatureTrackingProtection::Shutdown();
|
||||
}
|
||||
|
@ -61,5 +63,11 @@ namespace net {
|
|||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsIUrlClassifierFeature*
|
||||
UrlClassifierFeatureFactory::GetFeatureLoginReputation() {
|
||||
return UrlClassifierFeatureLoginReputation::MaybeGetOrCreate();
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -25,6 +25,8 @@ class UrlClassifierFeatureFactory final {
|
|||
static void GetFeaturesFromChannel(
|
||||
nsIChannel* aChannel,
|
||||
nsTArray<nsCOMPtr<nsIUrlClassifierFeature>>& aFeatures);
|
||||
|
||||
static nsIUrlClassifierFeature* GetFeatureLoginReputation();
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 "UrlClassifierFeatureLoginReputation.h"
|
||||
|
||||
#include "mozilla/StaticPrefs.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
namespace {
|
||||
|
||||
#define PREF_PASSWORD_ALLOW_TABLE "urlclassifier.passwordAllowTable"
|
||||
|
||||
StaticRefPtr<UrlClassifierFeatureLoginReputation> gFeatureLoginReputation;
|
||||
|
||||
} // namespace
|
||||
|
||||
UrlClassifierFeatureLoginReputation::UrlClassifierFeatureLoginReputation()
|
||||
: UrlClassifierFeatureBase(NS_LITERAL_CSTRING("login-reputation"),
|
||||
EmptyCString(), // blacklist tables
|
||||
NS_LITERAL_CSTRING(PREF_PASSWORD_ALLOW_TABLE),
|
||||
EmptyCString(), // blacklist pref
|
||||
EmptyCString(), // whitelist pref
|
||||
EmptyCString(), // blacklist pref table name
|
||||
EmptyCString(), // whitelist pref table name
|
||||
EmptyCString()) // skip host pref
|
||||
{}
|
||||
|
||||
/* static */ void UrlClassifierFeatureLoginReputation::MaybeShutdown() {
|
||||
UC_LOG(("UrlClassifierFeatureLoginReputation: MaybeShutdown"));
|
||||
|
||||
if (gFeatureLoginReputation) {
|
||||
gFeatureLoginReputation->ShutdownPreferences();
|
||||
gFeatureLoginReputation = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ nsIUrlClassifierFeature*
|
||||
UrlClassifierFeatureLoginReputation::MaybeGetOrCreate() {
|
||||
if (!StaticPrefs::browser_safebrowsing_passwords_enabled()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!gFeatureLoginReputation) {
|
||||
gFeatureLoginReputation = new UrlClassifierFeatureLoginReputation();
|
||||
gFeatureLoginReputation->InitializePreferences();
|
||||
}
|
||||
|
||||
return gFeatureLoginReputation;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureLoginReputation::ProcessChannel(nsIChannel* aChannel,
|
||||
const nsACString& aList,
|
||||
bool* aShouldContinue) {
|
||||
MOZ_CRASH(
|
||||
"UrlClassifierFeatureLoginReputation::ProcessChannel should never be "
|
||||
"called");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureLoginReputation::GetTables(
|
||||
nsIUrlClassifierFeature::listType aListType, nsTArray<nsCString>& aTables) {
|
||||
MOZ_ASSERT(aListType == nsIUrlClassifierFeature::whitelist,
|
||||
"UrlClassifierFeatureLoginReputation is meant to be used just to "
|
||||
"whitelist URLs");
|
||||
return UrlClassifierFeatureBase::GetTables(aListType, aTables);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureLoginReputation::HasTable(
|
||||
const nsACString& aTable, nsIUrlClassifierFeature::listType aListType,
|
||||
bool* aResult) {
|
||||
MOZ_ASSERT(aListType == nsIUrlClassifierFeature::whitelist,
|
||||
"UrlClassifierFeatureLoginReputation is meant to be used just to "
|
||||
"whitelist URLs");
|
||||
return UrlClassifierFeatureBase::HasTable(aTable, aListType, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UrlClassifierFeatureLoginReputation::HasHostInPreferences(
|
||||
const nsACString& aHost, nsIUrlClassifierFeature::listType aListType,
|
||||
nsACString& aPrefTableName, bool* aResult) {
|
||||
MOZ_ASSERT(aListType == nsIUrlClassifierFeature::whitelist,
|
||||
"UrlClassifierFeatureLoginReputation is meant to be used just to "
|
||||
"whitelist URLs");
|
||||
return UrlClassifierFeatureBase::HasHostInPreferences(
|
||||
aHost, aListType, aPrefTableName, aResult);
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 mozilla_net_UrlClassifierFeatureLoginReputation_h
|
||||
#define mozilla_net_UrlClassifierFeatureLoginReputation_h
|
||||
|
||||
#include "UrlClassifierFeatureBase.h"
|
||||
|
||||
class nsIChannel;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
class UrlClassifierFeatureLoginReputation final
|
||||
: public UrlClassifierFeatureBase {
|
||||
public:
|
||||
static void MaybeShutdown();
|
||||
|
||||
static nsIUrlClassifierFeature* MaybeGetOrCreate();
|
||||
|
||||
NS_IMETHOD
|
||||
GetTables(nsIUrlClassifierFeature::listType aListType,
|
||||
nsTArray<nsCString>& aResult) override;
|
||||
|
||||
NS_IMETHOD
|
||||
HasTable(const nsACString& aTable,
|
||||
nsIUrlClassifierFeature::listType aListType, bool* aResult) override;
|
||||
|
||||
NS_IMETHOD
|
||||
HasHostInPreferences(const nsACString& aHost,
|
||||
nsIUrlClassifierFeature::listType aListType,
|
||||
nsACString& aPrefTableName, bool* aResult) override;
|
||||
|
||||
NS_IMETHOD ProcessChannel(nsIChannel* aChannel, const nsACString& aList,
|
||||
bool* aShouldContinue) override;
|
||||
|
||||
private:
|
||||
UrlClassifierFeatureLoginReputation();
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_UrlClassifierFeatureLoginReputation_h
|
|
@ -23,6 +23,7 @@ UNIFIED_SOURCES += [
|
|||
'UrlClassifierCommon.cpp',
|
||||
'UrlClassifierFeatureBase.cpp',
|
||||
'UrlClassifierFeatureFactory.cpp',
|
||||
'UrlClassifierFeatureLoginReputation.cpp',
|
||||
'UrlClassifierFeatureResult.cpp',
|
||||
'UrlClassifierFeatureTrackingAnnotation.cpp',
|
||||
'UrlClassifierFeatureTrackingProtection.cpp',
|
||||
|
|
|
@ -885,6 +885,13 @@ class MachCommandConditions(object):
|
|||
return cls.substs.get('MOZ_BUILD_APP') == 'browser'
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def is_thunderbird(cls):
|
||||
"""Must have a Thunderbird build."""
|
||||
if hasattr(cls, 'substs'):
|
||||
return cls.substs.get('MOZ_BUILD_APP') == 'comm/mail'
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def is_android(cls):
|
||||
"""Must have an Android build."""
|
||||
|
|
|
@ -58,6 +58,10 @@ function androidStartup() {
|
|||
|
||||
// ///// Desktop ///////
|
||||
|
||||
// Special case for Thunderbird windows.
|
||||
const IS_THUNDERBIRD = Services.appinfo.ID == "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
|
||||
const WINDOW_TYPE = IS_THUNDERBIRD ? "mail:3pane" : "navigator:browser";
|
||||
|
||||
var WindowListener = {
|
||||
// browser-test.js is only loaded into the first window. Setup that
|
||||
// needs to happen in all navigator:browser windows should go here.
|
||||
|
@ -78,7 +82,7 @@ var WindowListener = {
|
|||
let win = xulWin.docShell.domWindow;
|
||||
|
||||
win.addEventListener("load", function() {
|
||||
if (win.document.documentElement.getAttribute("windowtype") == "navigator:browser") {
|
||||
if (win.document.documentElement.getAttribute("windowtype") == WINDOW_TYPE) {
|
||||
WindowListener.setupWindow(win);
|
||||
}
|
||||
}, {once: true});
|
||||
|
@ -89,12 +93,14 @@ function loadMochitest(e) {
|
|||
let flavor = e.detail[0];
|
||||
let url = e.detail[1];
|
||||
|
||||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
let win = Services.wm.getMostRecentWindow(WINDOW_TYPE);
|
||||
win.removeEventListener("mochitest-load", loadMochitest);
|
||||
|
||||
// for mochitest-plain, navigating to the url is all we need
|
||||
win.loadURI(url, null, null, null, null, null, null, null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal());
|
||||
if (!IS_THUNDERBIRD) {
|
||||
win.loadURI(url, null, null, null, null, null, null, null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal());
|
||||
}
|
||||
if (flavor == "mochitest") {
|
||||
return;
|
||||
}
|
||||
|
@ -118,7 +124,7 @@ this.mochikit = class extends ExtensionAPI {
|
|||
if (AppConstants.platform == "android") {
|
||||
androidStartup();
|
||||
} else {
|
||||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
let win = Services.wm.getMostRecentWindow(WINDOW_TYPE);
|
||||
// wait for event fired from start_desktop.js containing the
|
||||
// suite and url to load
|
||||
win.addEventListener("mochitest-load", loadMochitest);
|
||||
|
@ -127,7 +133,7 @@ this.mochikit = class extends ExtensionAPI {
|
|||
|
||||
onShutdown() {
|
||||
if (AppConstants.platform != "android") {
|
||||
for (let win of Services.wm.getEnumerator("navigator:browser")) {
|
||||
for (let win of Services.wm.getEnumerator(WINDOW_TYPE)) {
|
||||
WindowListener.tearDownWindow(win);
|
||||
}
|
||||
|
||||
|
|
|
@ -232,7 +232,11 @@
|
|||
function createTester(links) {
|
||||
var windowMediator = Cc['@mozilla.org/appshell/window-mediator;1'].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
var winType = gConfig.testRoot == "browser" ? "navigator:browser" : null;
|
||||
var winType = null;
|
||||
if (gConfig.testRoot == "browser") {
|
||||
const IS_THUNDERBIRD = Services.appinfo.ID == "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
|
||||
winType = IS_THUNDERBIRD ? "mail:3pane" : "navigator:browser";
|
||||
}
|
||||
if (!winType) {
|
||||
throw new Error("Unrecognized gConfig.testRoot: " + gConfig.testRoot);
|
||||
}
|
||||
|
|
|
@ -503,6 +503,8 @@ Tester.prototype = {
|
|||
"Application",
|
||||
"__SS_tabsToRestore", "__SSi",
|
||||
"webConsoleCommandController",
|
||||
// Thunderbird
|
||||
"MailMigrator", "SearchIntegration",
|
||||
];
|
||||
|
||||
this.PerTestCoverageUtils.beforeTestSync();
|
||||
|
@ -522,7 +524,7 @@ Tester.prototype = {
|
|||
},
|
||||
|
||||
async promiseMainWindowReady() {
|
||||
if (!gBrowserInit.idleTasksFinished) {
|
||||
if (window.gBrowserInit && !gBrowserInit.idleTasksFinished) {
|
||||
await this.TestUtils.topicObserved("browser-idle-startup-tasks-finished",
|
||||
subject => subject === window);
|
||||
}
|
||||
|
@ -584,6 +586,9 @@ Tester.prototype = {
|
|||
case "navigator:browser":
|
||||
type = "browser window";
|
||||
break;
|
||||
case "mail:3pane":
|
||||
type = "mail window";
|
||||
break;
|
||||
case null:
|
||||
type = "unknown window with document URI: " + win.document.documentURI +
|
||||
" and title: " + win.document.title;
|
||||
|
@ -629,7 +634,7 @@ Tester.prototype = {
|
|||
this.structuredLogger.info("TEST-START | Shutdown");
|
||||
|
||||
if (this.tests.length) {
|
||||
let e10sMode = gMultiProcessBrowser ? "e10s" : "non-e10s";
|
||||
let e10sMode = window.gMultiProcessBrowser ? "e10s" : "non-e10s";
|
||||
this.structuredLogger.info("Browser Chrome Test Summary");
|
||||
this.structuredLogger.info("Passed: " + passCount);
|
||||
this.structuredLogger.info("Failed: " + failCount);
|
||||
|
@ -907,9 +912,11 @@ Tester.prototype = {
|
|||
// to touch the sidebar. They will thus not be blamed for leaking
|
||||
// a document.
|
||||
let sidebar = document.getElementById("sidebar");
|
||||
sidebar.setAttribute("src", "data:text/html;charset=utf-8,");
|
||||
sidebar.docShell.createAboutBlankContentViewer(null);
|
||||
sidebar.setAttribute("src", "about:blank");
|
||||
if (sidebar) {
|
||||
sidebar.setAttribute("src", "data:text/html;charset=utf-8,");
|
||||
sidebar.docShell.createAboutBlankContentViewer(null);
|
||||
sidebar.setAttribute("src", "about:blank");
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy BackgroundPageThumbs resources.
|
||||
|
@ -917,7 +924,9 @@ Tester.prototype = {
|
|||
ChromeUtils.import("resource://gre/modules/BackgroundPageThumbs.jsm", {});
|
||||
BackgroundPageThumbs._destroy();
|
||||
|
||||
gBrowser.removePreloadedBrowser();
|
||||
if (window.gBrowser) {
|
||||
gBrowser.removePreloadedBrowser();
|
||||
}
|
||||
}
|
||||
|
||||
// Schedule GC and CC runs before finishing in order to detect
|
||||
|
|
|
@ -68,7 +68,7 @@ test path(s):
|
|||
Please check spelling and make sure the named tests exist.
|
||||
'''.lstrip()
|
||||
|
||||
SUPPORTED_APPS = ['firefox', 'android']
|
||||
SUPPORTED_APPS = ['firefox', 'android', 'thunderbird']
|
||||
|
||||
parser = None
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ ALL_FLAVORS = {
|
|||
'browser-chrome': {
|
||||
'suite': 'browser',
|
||||
'aliases': ('browser', 'browser-chrome', 'mochitest-browser-chrome', 'bc'),
|
||||
'enabled_apps': ('firefox',),
|
||||
'enabled_apps': ('firefox', 'thunderbird'),
|
||||
'extra_args': {
|
||||
'flavor': 'browser',
|
||||
}
|
||||
|
|
|
@ -11,6 +11,9 @@ const url = __webDriverArguments[0].testUrl;
|
|||
let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Ci.nsIWindowMediator);
|
||||
let win = wm.getMostRecentWindow("navigator:browser");
|
||||
if (!win) {
|
||||
win = wm.getMostRecentWindow("mail:3pane");
|
||||
}
|
||||
|
||||
// mochikit's bootstrap.js has set up a listener for this event. It's
|
||||
// used so bootstrap.js knows which flavor and url to load.
|
||||
|
|
|
@ -7,19 +7,19 @@
|
|||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/ErrorNames.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/net/UrlClassifierFeatureFactory.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticPrefs.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "nsIUrlClassifierFeature.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
#define PREF_PP_ENABLED "browser.safebrowsing.passwords.enabled"
|
||||
#define PREF_PASSWORD_ALLOW_TABLE "urlclassifier.passwordAllowTable"
|
||||
|
||||
static bool sPasswordProtectionEnabled = false;
|
||||
|
||||
// MOZ_LOG=LoginReputation:5
|
||||
LazyLogModule gLoginReputationLogModule("LoginReputation");
|
||||
|
@ -30,11 +30,6 @@ LazyLogModule gLoginReputationLogModule("LoginReputation");
|
|||
|
||||
static Atomic<bool> gShuttingDown(false);
|
||||
|
||||
static const char* kObservedPrefs[] = {
|
||||
PREF_PASSWORD_ALLOW_TABLE,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// ReputationQueryParam
|
||||
//
|
||||
|
@ -67,39 +62,29 @@ ReputationQueryParam::GetFormURI(nsIURI** aURI) {
|
|||
// This class is a wrapper that encapsulate asynchronous callback API provided
|
||||
// by DBService into a MozPromise callback.
|
||||
//
|
||||
class LoginWhitelist final : public nsIURIClassifierCallback {
|
||||
class LoginWhitelist final : public nsIUrlClassifierFeatureCallback {
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIURICLASSIFIERCALLBACK
|
||||
NS_DECL_NSIURLCLASSIFIERFEATURECALLBACK
|
||||
|
||||
RefPtr<ReputationPromise> QueryLoginWhitelist(
|
||||
nsILoginReputationQuery* aParam);
|
||||
|
||||
LoginWhitelist() = default;
|
||||
|
||||
nsresult Init();
|
||||
nsresult Uninit();
|
||||
|
||||
void UpdateWhitelistTables();
|
||||
nsresult Shutdown();
|
||||
|
||||
private:
|
||||
~LoginWhitelist() = default;
|
||||
|
||||
nsCString mTables;
|
||||
|
||||
// Queries that are waiting for callback from ::AsyncClassifyLocalWithTables.
|
||||
// Queries that are waiting for callback from
|
||||
// ::AsyncClassifyLocalWithFeatures.
|
||||
nsTArray<UniquePtr<MozPromiseHolder<ReputationPromise>>> mQueryPromises;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(LoginWhitelist, nsIURIClassifierCallback)
|
||||
NS_IMPL_ISUPPORTS(LoginWhitelist, nsIUrlClassifierFeatureCallback)
|
||||
|
||||
nsresult LoginWhitelist::Init() {
|
||||
UpdateWhitelistTables();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult LoginWhitelist::Uninit() {
|
||||
nsresult LoginWhitelist::Shutdown() {
|
||||
// Reject all query promise before releasing.
|
||||
for (uint8_t i = 0; i < mQueryPromises.Length(); i++) {
|
||||
mQueryPromises[i]->Reject(NS_ERROR_ABORT, __func__);
|
||||
|
@ -136,8 +121,18 @@ RefPtr<ReputationPromise> LoginWhitelist::QueryLoginWhitelist(
|
|||
// AsyncClassifyLocalWithTables API won't trigger a gethash request on
|
||||
// a full-length match, so this API call should only include local operation.
|
||||
// We don't support prefs overwrite for this classification.
|
||||
rv = uriClassifier->AsyncClassifyLocalWithTables(
|
||||
uri, mTables, nsTArray<nsCString>(), nsTArray<nsCString>(), this);
|
||||
|
||||
nsCOMPtr<nsIUrlClassifierFeature> feature =
|
||||
mozilla::net::UrlClassifierFeatureFactory::GetFeatureLoginReputation();
|
||||
if (NS_WARN_IF(!feature)) {
|
||||
return p;
|
||||
}
|
||||
|
||||
nsTArray<RefPtr<nsIUrlClassifierFeature>> features;
|
||||
features.AppendElement(feature);
|
||||
|
||||
rv = uriClassifier->AsyncClassifyLocalWithFeatures(
|
||||
uri, features, nsIUrlClassifierFeature::whitelist, this);
|
||||
if (NS_FAILED(rv)) {
|
||||
return p;
|
||||
}
|
||||
|
@ -147,27 +142,22 @@ RefPtr<ReputationPromise> LoginWhitelist::QueryLoginWhitelist(
|
|||
return p;
|
||||
}
|
||||
|
||||
nsresult LoginWhitelist::OnClassifyComplete(nsresult aErrorCode,
|
||||
const nsACString& aLists,
|
||||
const nsACString& aProvider,
|
||||
const nsACString& aFullHash) {
|
||||
nsresult LoginWhitelist::OnClassifyComplete(
|
||||
const nsTArray<RefPtr<nsIUrlClassifierFeatureResult>>& aResults) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (gShuttingDown) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
LR_LOG(("OnClassifyComplete : list = %s", aLists.BeginReading()));
|
||||
LR_LOG(("OnClassifyComplete : %s",
|
||||
aResults.IsEmpty() ? "blacklisted" : "whitelisted"));
|
||||
|
||||
UniquePtr<MozPromiseHolder<ReputationPromise>> holder =
|
||||
std::move(mQueryPromises.ElementAt(0));
|
||||
mQueryPromises.RemoveElementAt(0);
|
||||
|
||||
if (NS_FAILED(aErrorCode)) {
|
||||
// This should not happen
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected error received in OnClassifyComplete");
|
||||
holder->Reject(aErrorCode, __func__);
|
||||
} else if (aLists.IsEmpty()) {
|
||||
if (aResults.IsEmpty()) {
|
||||
// Reject if we can not find url in white list.
|
||||
holder->Reject(NS_OK, __func__);
|
||||
} else {
|
||||
|
@ -177,10 +167,6 @@ nsresult LoginWhitelist::OnClassifyComplete(nsresult aErrorCode,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void LoginWhitelist::UpdateWhitelistTables() {
|
||||
Preferences::GetCString(PREF_PASSWORD_ALLOW_TABLE, mTables);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// LoginReputationService
|
||||
//
|
||||
|
@ -215,9 +201,6 @@ NS_IMETHODIMP
|
|||
LoginReputationService::Init() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
Preferences::AddBoolVarCache(&sPasswordProtectionEnabled, PREF_PP_ENABLED,
|
||||
true);
|
||||
|
||||
switch (XRE_GetProcessType()) {
|
||||
case GeckoProcessType_Default:
|
||||
LR_LOG(("Init login reputation service in parent"));
|
||||
|
@ -240,7 +223,7 @@ LoginReputationService::Init() {
|
|||
|
||||
mLoginWhitelist = new LoginWhitelist();
|
||||
|
||||
if (sPasswordProtectionEnabled) {
|
||||
if (StaticPrefs::browser_safebrowsing_passwords_enabled()) {
|
||||
Enable();
|
||||
}
|
||||
|
||||
|
@ -249,15 +232,10 @@ LoginReputationService::Init() {
|
|||
|
||||
nsresult LoginReputationService::Enable() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT(sPasswordProtectionEnabled);
|
||||
MOZ_ASSERT(StaticPrefs::browser_safebrowsing_passwords_enabled());
|
||||
|
||||
LR_LOG(("Enable login reputation service"));
|
||||
|
||||
nsresult rv = mLoginWhitelist->Init();
|
||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
|
||||
Preferences::AddStrongObservers(this, kObservedPrefs);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -266,16 +244,11 @@ nsresult LoginReputationService::Disable() {
|
|||
|
||||
LR_LOG(("Disable login reputation service"));
|
||||
|
||||
nsresult rv = mLoginWhitelist->Uninit();
|
||||
nsresult rv = mLoginWhitelist->Shutdown();
|
||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
|
||||
mQueryRequests.Clear();
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefs) {
|
||||
Preferences::RemoveObservers(this, kObservedPrefs);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -308,7 +281,7 @@ LoginReputationService::QueryReputationAsync(
|
|||
|
||||
LR_LOG(("QueryReputationAsync() [this=%p]", this));
|
||||
|
||||
if (!sPasswordProtectionEnabled) {
|
||||
if (!StaticPrefs::browser_safebrowsing_passwords_enabled()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -351,7 +324,7 @@ LoginReputationService::QueryReputation(
|
|||
|
||||
LR_LOG(("QueryReputation() [this=%p]", this));
|
||||
|
||||
if (gShuttingDown || !sPasswordProtectionEnabled) {
|
||||
if (gShuttingDown || !StaticPrefs::browser_safebrowsing_passwords_enabled()) {
|
||||
LR_LOG(("QueryReputation() abort [this=%p]", this));
|
||||
aCallback->OnComplete(NS_ERROR_ABORT,
|
||||
nsILoginReputationVerdictType::UNSPECIFIED);
|
||||
|
@ -479,10 +452,8 @@ LoginReputationService::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
nsDependentString data(aData);
|
||||
|
||||
if (data.EqualsLiteral(PREF_PP_ENABLED)) {
|
||||
nsresult rv = sPasswordProtectionEnabled ? Enable() : Disable();
|
||||
nsresult rv = StaticPrefs::browser_safebrowsing_passwords_enabled() ? Enable() : Disable();
|
||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
} else if (data.EqualsLiteral(PREF_PASSWORD_ALLOW_TABLE)) {
|
||||
mLoginWhitelist->UpdateWhitelistTables();
|
||||
}
|
||||
} else if (!strcmp(aTopic, "quit-application")) {
|
||||
// Prepare to shutdown, won't allow any query request after 'gShuttingDown'
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
#ifndef LoginReputation_h__
|
||||
#define LoginReputation_h__
|
||||
|
||||
#include "nsILoginReputation.h"
|
||||
#include "nsIURIClassifier.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "nsILoginReputation.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsIURIClassifier.h"
|
||||
|
||||
class LoginWhitelist;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "nsIOutputStream.h"
|
||||
#include "nsICryptoHash.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsString.h"
|
||||
#include "nsToolkitCompsCID.h"
|
||||
#include "../../../netwerk/base/nsBufferedStreams.h"
|
||||
|
|
|
@ -40,7 +40,7 @@ label.findbar-find-fast:-moz-lwtheme {
|
|||
border-style: @roundButtonBorderStyle@;
|
||||
border-color: @roundButtonBorderColor@;
|
||||
color: @roundButtonColor@;
|
||||
background-image: @roundButtonBackground@;
|
||||
background-image: @roundButtonBackgroundImage@;
|
||||
}
|
||||
|
||||
.findbar-button {
|
||||
|
@ -60,7 +60,7 @@ label.findbar-find-fast:-moz-lwtheme {
|
|||
.findbar-find-previous:not(:-moz-lwtheme):not([disabled]):hover:active,
|
||||
.findbar-button:not([disabled]):hover:active,
|
||||
.findbar-button:not([disabled])[checked="true"] {
|
||||
background-image: @roundButtonPressedBackground@;
|
||||
background-image: @roundButtonPressedBackgroundImage@;
|
||||
box-shadow: @roundButtonPressedShadow@;
|
||||
}
|
||||
|
||||
|
|
|
@ -228,13 +228,13 @@ notification > hbox > button {
|
|||
border: @roundButtonBorderWidth@ @roundButtonBorderStyle@ @roundButtonBorderColor@;
|
||||
text-shadow: @loweredShadow@;
|
||||
color: @roundButtonColor@;
|
||||
background: @roundButtonBackground@;
|
||||
background: @roundButtonBackgroundImage@;
|
||||
box-shadow: @roundButtonShadow@;
|
||||
}
|
||||
|
||||
notification > hbox > button:active:hover {
|
||||
color: @roundButtonColor@;
|
||||
background: @roundButtonPressedBackground@;
|
||||
background: @roundButtonPressedBackgroundImage@;
|
||||
box-shadow: @roundButtonPressedShadow@;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
%define roundButtonBorderStyle solid
|
||||
%define roundButtonBorderColor rgba(0,0,0,.35)
|
||||
%define roundButtonColor black
|
||||
%define roundButtonBackground linear-gradient(#f6f6f6, #e9e9e9)
|
||||
%define roundButtonBackgroundImage linear-gradient(#f6f6f6, #e9e9e9)
|
||||
%define roundButtonShadow 0 1px rgba(255,255,255,.5), inset 0 1px 1px rgba(255,255,255,.5)
|
||||
%define roundButtonPressedBackground linear-gradient(#dadada, #dadada)
|
||||
%define roundButtonPressedBackgroundImage linear-gradient(#dadada, #dadada)
|
||||
%define roundButtonPressedShadow 0 1px rgba(255,255,255,.4), inset 0 1px 3px rgba(0,0,0,.2)
|
||||
|
||||
%define scopeBarBackground linear-gradient(#E8E8E8, #D0D0D0) repeat-x
|
||||
|
|
|
@ -671,7 +671,6 @@ STATIC_ATOMS = [
|
|||
Atom("mozTableRemoveColumn", "mozTableRemoveColumn"),
|
||||
Atom("moz_opaque", "moz-opaque"),
|
||||
Atom("moz_action_hint", "mozactionhint"),
|
||||
Atom("x_moz_errormessage", "x-moz-errormessage"),
|
||||
Atom("multicol", "multicol"),
|
||||
Atom("multiple", "multiple"),
|
||||
Atom("muted", "muted"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче