Merge mozilla-inbound to mozilla-central. a=merge

This commit is contained in:
Cosmin Sabou 2018-12-17 02:01:29 +02:00
Родитель e985f5ee15 5b2de0d7eb
Коммит b9bad8ace2
41 изменённых файлов: 729 добавлений и 609 удалений

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

@ -137,13 +137,8 @@ public:
virtual void MacroExpands(const Token &Tok, const MacroDefinition &Md,
SourceRange Range, const MacroArgs *Ma) override;
#if CLANG_VERSION_MAJOR >= 5
virtual void MacroUndefined(const Token &Tok, const MacroDefinition &Md,
const MacroDirective *Undef) override;
#else
virtual void MacroUndefined(const Token &Tok,
const MacroDefinition &Md) override;
#endif
virtual void Defined(const Token &Tok, const MacroDefinition &Md,
SourceRange Range) override;
virtual void Ifdef(SourceLocation Loc, const Token &Tok,
@ -282,18 +277,8 @@ private:
std::string Backing;
llvm::raw_string_ostream Stream(Backing);
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
#if CLANG_VERSION_MAJOR > 5
printTemplateArgumentList(
Stream, TemplateArgs.asArray(), PrintingPolicy(CI.getLangOpts()));
#elif CLANG_VERSION_MAJOR > 3 || \
(CLANG_VERSION_MAJOR == 3 && CLANG_VERSION_MINOR >= 9)
TemplateSpecializationType::PrintTemplateArgumentList(
Stream, TemplateArgs.asArray(), PrintingPolicy(CI.getLangOpts()));
#else
TemplateSpecializationType::PrintTemplateArgumentList(
stream, templateArgs.data(), templateArgs.size(),
PrintingPolicy(CI.getLangOpts()));
#endif
Result += Stream.str();
}
} else if (const auto *Nd = dyn_cast<NamespaceDecl>(DC)) {
@ -1491,14 +1476,9 @@ void PreprocessorHook::MacroExpands(const Token &Tok, const MacroDefinition &Md,
Indexer->macroUsed(Tok, Md.getMacroInfo());
}
#if CLANG_VERSION_MAJOR >= 5
void PreprocessorHook::MacroUndefined(const Token &Tok,
const MacroDefinition &Md,
const MacroDirective *Undef)
#else
void PreprocessorHook::MacroUndefined(const Token &Tok,
const MacroDefinition &Md)
#endif
{
Indexer->macroUsed(Tok, Md.getMacroInfo());
}

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

@ -47,6 +47,7 @@
#include "mozilla/dom/HTMLAnchorElement.h"
#include "mozilla/dom/PerformanceNavigation.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/dom/PopupBlocker.h"
#include "mozilla/dom/ProfileTimelineMarkerBinding.h"
#include "mozilla/dom/ScreenOrientation.h"
#include "mozilla/dom/ScriptSettings.h"
@ -3966,12 +3967,12 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI, uint32_t aLoadFlags,
return NS_ERROR_FAILURE;
}
PopupControlState popupState;
PopupBlocker::PopupControlState popupState;
if (aLoadFlags & LOAD_FLAGS_ALLOW_POPUPS) {
popupState = openAllowed;
popupState = PopupBlocker::openAllowed;
aLoadFlags &= ~LOAD_FLAGS_ALLOW_POPUPS;
} else {
popupState = openOverridden;
popupState = PopupBlocker::openOverridden;
}
nsAutoPopupStatePusher statePusher(popupState);
@ -12520,7 +12521,7 @@ class OnLinkClickEvent : public Runnable {
nsCOMPtr<nsIInputStream> mPostDataStream;
nsCOMPtr<nsIInputStream> mHeadersDataStream;
nsCOMPtr<nsIContent> mContent;
PopupControlState mPopupState;
PopupBlocker::PopupControlState mPopupState;
bool mNoOpenerImplied;
bool mIsUserTriggered;
bool mIsTrusted;
@ -12543,7 +12544,7 @@ OnLinkClickEvent::OnLinkClickEvent(nsDocShell* aHandler, nsIContent* aContent,
mPostDataStream(aPostDataStream),
mHeadersDataStream(aHeadersDataStream),
mContent(aContent),
mPopupState(mHandler->mScriptGlobal->GetPopupControlState()),
mPopupState(PopupBlocker::GetPopupControlState()),
mNoOpenerImplied(aNoOpenerImplied),
mIsUserTriggered(aIsUserTriggered),
mIsTrusted(aIsTrusted),

389
dom/base/PopupBlocker.cpp Normal file
Просмотреть файл

@ -0,0 +1,389 @@
/* -*- 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 "mozilla/dom/PopupBlocker.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/Preferences.h"
#include "mozilla/TextEvents.h"
#include "nsXULPopupManager.h"
namespace mozilla {
namespace dom {
namespace {
static char* sPopupAllowedEvents;
static PopupBlocker::PopupControlState sPopupControlState = PopupBlocker::openAbused;
static uint32_t sPopupStatePusherCount = 0;
// This token is by default set to false. When a popup/filePicker is shown, it
// is set to true.
static bool sUnusedPopupToken = false;
void PopupAllowedEventsChanged() {
if (sPopupAllowedEvents) {
free(sPopupAllowedEvents);
}
nsAutoCString str;
Preferences::GetCString("dom.popup_allowed_events", str);
// We'll want to do this even if str is empty to avoid looking up
// this pref all the time if it's not set.
sPopupAllowedEvents = ToNewCString(str);
}
// return true if eventName is contained within events, delimited by
// spaces
bool PopupAllowedForEvent(const char* eventName) {
if (!sPopupAllowedEvents) {
PopupAllowedEventsChanged();
if (!sPopupAllowedEvents) {
return false;
}
}
nsDependentCString events(sPopupAllowedEvents);
nsCString::const_iterator start, end;
nsCString::const_iterator startiter(events.BeginReading(start));
events.EndReading(end);
while (startiter != end) {
nsCString::const_iterator enditer(end);
if (!FindInReadable(nsDependentCString(eventName), startiter, enditer))
return false;
// the match is surrounded by spaces, or at a string boundary
if ((startiter == start || *--startiter == ' ') &&
(enditer == end || *enditer == ' ')) {
return true;
}
// Move on and see if there are other matches. (The delimitation
// requirement makes it pointless to begin the next search before
// the end of the invalid match just found.)
startiter = enditer;
}
return false;
}
// static
void OnPrefChange(const char* aPrefName, void*) {
nsDependentCString prefName(aPrefName);
if (prefName.EqualsLiteral("dom.popup_allowed_events")) {
PopupAllowedEventsChanged();
}
}
} // namespace
/* static */
PopupBlocker::PopupControlState PopupBlocker::PushPopupControlState(
PopupBlocker::PopupControlState aState, bool aForce) {
MOZ_ASSERT(NS_IsMainThread());
PopupBlocker::PopupControlState old = sPopupControlState;
if (aState < old || aForce) {
sPopupControlState = aState;
}
return old;
}
/* static */ void PopupBlocker::PopPopupControlState(
PopupBlocker::PopupControlState aState) {
MOZ_ASSERT(NS_IsMainThread());
sPopupControlState = aState;
}
/* static */ PopupBlocker::PopupControlState
PopupBlocker::GetPopupControlState() {
return sPopupControlState;
}
/* static */ bool PopupBlocker::CanShowPopupByPermission(
nsIPrincipal* aPrincipal) {
MOZ_ASSERT(aPrincipal);
uint32_t permit;
nsCOMPtr<nsIPermissionManager> permissionManager =
services::GetPermissionManager();
if (permissionManager &&
NS_SUCCEEDED(permissionManager->TestPermissionFromPrincipal(
aPrincipal, "popup", &permit))) {
if (permit == nsIPermissionManager::ALLOW_ACTION) {
return true;
}
if (permit == nsIPermissionManager::DENY_ACTION) {
return false;
}
}
return !StaticPrefs::dom_disable_open_during_load();
}
/* static */ bool PopupBlocker::TryUsePopupOpeningToken() {
MOZ_ASSERT(sPopupStatePusherCount);
if (!sUnusedPopupToken) {
sUnusedPopupToken = true;
return true;
}
return false;
}
/* static */ void PopupBlocker::PopupStatePusherCreated() {
++sPopupStatePusherCount;
}
/* static */ void PopupBlocker::PopupStatePusherDestroyed() {
MOZ_ASSERT(sPopupStatePusherCount);
if (!--sPopupStatePusherCount) {
sUnusedPopupToken = false;
}
}
// static
PopupBlocker::PopupControlState PopupBlocker::GetEventPopupControlState(
WidgetEvent* aEvent, Event* aDOMEvent) {
// generally if an event handler is running, new windows are disallowed.
// check for exceptions:
PopupBlocker::PopupControlState abuse = PopupBlocker::openAbused;
if (aDOMEvent && aDOMEvent->GetWantsPopupControlCheck()) {
nsAutoString type;
aDOMEvent->GetType(type);
if (PopupAllowedForEvent(NS_ConvertUTF16toUTF8(type).get())) {
return PopupBlocker::openAllowed;
}
}
switch (aEvent->mClass) {
case eBasicEventClass:
// For these following events only allow popups if they're
// triggered while handling user input. See
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
abuse = PopupBlocker::openBlocked;
switch (aEvent->mMessage) {
case eFormSelect:
if (PopupAllowedForEvent("select")) {
abuse = PopupBlocker::openControlled;
}
break;
case eFormChange:
if (PopupAllowedForEvent("change")) {
abuse = PopupBlocker::openControlled;
}
break;
default:
break;
}
}
break;
case eEditorInputEventClass:
// For this following event only allow popups if it's triggered
// while handling user input. See
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
abuse = PopupBlocker::openBlocked;
switch (aEvent->mMessage) {
case eEditorInput:
if (PopupAllowedForEvent("input")) {
abuse = PopupBlocker::openControlled;
}
break;
default:
break;
}
}
break;
case eInputEventClass:
// For this following event only allow popups if it's triggered
// while handling user input. See
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
abuse = PopupBlocker::openBlocked;
switch (aEvent->mMessage) {
case eFormChange:
if (PopupAllowedForEvent("change")) {
abuse = PopupBlocker::openControlled;
}
break;
case eXULCommand:
abuse = PopupBlocker::openControlled;
break;
default:
break;
}
}
break;
case eKeyboardEventClass:
if (aEvent->IsTrusted()) {
abuse = PopupBlocker::openBlocked;
uint32_t key = aEvent->AsKeyboardEvent()->mKeyCode;
switch (aEvent->mMessage) {
case eKeyPress:
// return key on focused button. see note at eMouseClick.
if (key == NS_VK_RETURN) {
abuse = PopupBlocker::openAllowed;
} else if (PopupAllowedForEvent("keypress")) {
abuse = PopupBlocker::openControlled;
}
break;
case eKeyUp:
// space key on focused button. see note at eMouseClick.
if (key == NS_VK_SPACE) {
abuse = PopupBlocker::openAllowed;
} else if (PopupAllowedForEvent("keyup")) {
abuse = PopupBlocker::openControlled;
}
break;
case eKeyDown:
if (PopupAllowedForEvent("keydown")) {
abuse = PopupBlocker::openControlled;
}
break;
default:
break;
}
}
break;
case eTouchEventClass:
if (aEvent->IsTrusted()) {
abuse = PopupBlocker::openBlocked;
switch (aEvent->mMessage) {
case eTouchStart:
if (PopupAllowedForEvent("touchstart")) {
abuse = PopupBlocker::openControlled;
}
break;
case eTouchEnd:
if (PopupAllowedForEvent("touchend")) {
abuse = PopupBlocker::openControlled;
}
break;
default:
break;
}
}
break;
case eMouseEventClass:
if (aEvent->IsTrusted() &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
abuse = PopupBlocker::openBlocked;
switch (aEvent->mMessage) {
case eMouseUp:
if (PopupAllowedForEvent("mouseup")) {
abuse = PopupBlocker::openControlled;
}
break;
case eMouseDown:
if (PopupAllowedForEvent("mousedown")) {
abuse = PopupBlocker::openControlled;
}
break;
case eMouseClick:
/* Click events get special treatment because of their
historical status as a more legitimate event handler. If
click popups are enabled in the prefs, clear the popup
status completely. */
if (PopupAllowedForEvent("click")) {
abuse = PopupBlocker::openAllowed;
}
break;
case eMouseDoubleClick:
if (PopupAllowedForEvent("dblclick")) {
abuse = PopupBlocker::openControlled;
}
break;
default:
break;
}
}
break;
case ePointerEventClass:
if (aEvent->IsTrusted() &&
aEvent->AsPointerEvent()->button == WidgetMouseEvent::eLeftButton) {
switch (aEvent->mMessage) {
case ePointerUp:
if (PopupAllowedForEvent("pointerup")) {
abuse = PopupBlocker::openControlled;
}
break;
case ePointerDown:
if (PopupAllowedForEvent("pointerdown")) {
abuse = PopupBlocker::openControlled;
}
break;
default:
break;
}
}
break;
case eFormEventClass:
// For these following events only allow popups if they're
// triggered while handling user input. See
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
abuse = PopupBlocker::openBlocked;
switch (aEvent->mMessage) {
case eFormSubmit:
if (PopupAllowedForEvent("submit")) {
abuse = PopupBlocker::openControlled;
}
break;
case eFormReset:
if (PopupAllowedForEvent("reset")) {
abuse = PopupBlocker::openControlled;
}
break;
default:
break;
}
}
break;
default:
break;
}
return abuse;
}
/* static */ void PopupBlocker::Initialize() {
DebugOnly<nsresult> rv =
Preferences::RegisterCallback(OnPrefChange, "dom.popup_allowed_events");
MOZ_ASSERT(NS_SUCCEEDED(rv),
"Failed to observe \"dom.popup_allowed_events\"");
}
/* static */ void PopupBlocker::Shutdown() {
if (sPopupAllowedEvents) {
free(sPopupAllowedEvents);
}
Preferences::UnregisterCallback(OnPrefChange, "dom.popup_allowed_events");
}
} // namespace dom
} // namespace mozilla
nsAutoPopupStatePusherInternal::nsAutoPopupStatePusherInternal(
mozilla::dom::PopupBlocker::PopupControlState aState, bool aForce)
: mOldState(
mozilla::dom::PopupBlocker::PushPopupControlState(aState, aForce)) {
mozilla::dom::PopupBlocker::PopupStatePusherCreated();
}
nsAutoPopupStatePusherInternal::~nsAutoPopupStatePusherInternal() {
mozilla::dom::PopupBlocker::PopPopupControlState(mOldState);
mozilla::dom::PopupBlocker::PopupStatePusherDestroyed();
}

111
dom/base/PopupBlocker.h Normal file
Просмотреть файл

@ -0,0 +1,111 @@
/* -*- 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_dom_PopupBlocker_h
#define mozilla_dom_PopupBlocker_h
#include "mozilla/BasicEvents.h"
class nsIDocument;
class nsIPrincipal;
namespace mozilla {
namespace dom {
class PopupBlocker final {
public:
// Popup control state enum. The values in this enum must go from most
// permissive to least permissive so that it's safe to push state in
// all situations. Pushing popup state onto the stack never makes the
// current popup state less permissive.
enum PopupControlState {
openAllowed = 0, // open that window without worries
openControlled, // it's a popup, but allow it
openBlocked, // it's a popup, but not from an allowed event
openAbused, // it's a popup. disallow it, but allow domain override.
openOverridden // disallow window open
};
static PopupControlState PushPopupControlState(PopupControlState aState,
bool aForce);
static void PopPopupControlState(PopupControlState aState);
static PopupControlState GetPopupControlState();
static void PopupStatePusherCreated();
static void PopupStatePusherDestroyed();
// This method checks if the principal is allowed by open popups by user
// permissions. In this case, the caller should not block popups.
static bool CanShowPopupByPermission(nsIPrincipal* aPrincipal);
// This method returns true if the caller is allowed to show a popup, and it
// consumes the popup token for the current event. There is just 1 popup
// allowed per event.
static bool TryUsePopupOpeningToken();
static PopupBlocker::PopupControlState GetEventPopupControlState(
WidgetEvent* aEvent, Event* aDOMEvent = nullptr);
static void Initialize();
static void Shutdown();
};
} // namespace dom
} // namespace mozilla
#ifdef MOZILLA_INTERNAL_API
#define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherInternal
#else
#define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherExternal
#endif
// Helper class that helps with pushing and popping popup control
// state. Note that this class looks different from within code that's
// part of the layout library than it does in code outside the layout
// library. We give the two object layouts different names so the symbols
// don't conflict, but code should always use the name
// |nsAutoPopupStatePusher|.
class NS_AUTO_POPUP_STATE_PUSHER {
public:
#ifdef MOZILLA_INTERNAL_API
explicit NS_AUTO_POPUP_STATE_PUSHER(
mozilla::dom::PopupBlocker::PopupControlState aState,
bool aForce = false);
~NS_AUTO_POPUP_STATE_PUSHER();
#else
NS_AUTO_POPUP_STATE_PUSHER(
nsPIDOMWindowOuter* aWindow,
mozilla::dom::PopupBlocker::PopupControlState aState)
: mWindow(aWindow), mOldState(openAbused) {
if (aWindow) {
mOldState = PopupBlocker::PushPopupControlState(aState, false);
}
}
~NS_AUTO_POPUP_STATE_PUSHER() {
if (mWindow) {
PopupBlocker::PopPopupControlState(mOldState);
}
}
#endif
protected:
#ifndef MOZILLA_INTERNAL_API
nsCOMPtr<nsPIDOMWindowOuter> mWindow;
#endif
mozilla::dom::PopupBlocker::PopupControlState mOldState;
private:
// Hide so that this class can only be stack-allocated
static void* operator new(size_t /*size*/) CPP_THROW_NEW { return nullptr; }
static void operator delete(void* /*memory*/) {}
};
#define nsAutoPopupStatePusher NS_AUTO_POPUP_STATE_PUSHER
#endif // mozilla_PopupBlocker_h

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

@ -7,6 +7,7 @@
#include "Timeout.h"
#include "mozilla/dom/TimeoutManager.h"
#include "nsGlobalWindowInner.h"
namespace mozilla {
namespace dom {
@ -14,7 +15,7 @@ namespace dom {
Timeout::Timeout()
: mTimeoutId(0),
mFiringId(TimeoutManager::InvalidFiringId),
mPopupState(openAllowed),
mPopupState(PopupBlocker::openAllowed),
mReason(Reason::eTimeoutOrInterval),
mNestingLevel(0),
mCleared(false),

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

@ -7,16 +7,17 @@
#ifndef mozilla_dom_timeout_h
#define mozilla_dom_timeout_h
#include "mozilla/dom/PopupBlocker.h"
#include "mozilla/LinkedList.h"
#include "mozilla/TimeStamp.h"
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsGlobalWindow.h"
#include "nsITimeoutHandler.h"
class nsIEventTarget;
class nsIPrincipal;
class nsIEventTarget;
class nsGlobalWindowInner;
namespace mozilla {
namespace dom {
@ -83,7 +84,7 @@ class Timeout final : public LinkedListElement<RefPtr<Timeout>> {
// The popup state at timeout creation time if not created from
// another timeout
PopupControlState mPopupState;
PopupBlocker::PopupControlState mPopupState;
// Used to allow several reasons for setting a timeout, where each
// 'Reason' value is using a possibly overlapping set of id:s.

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

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "TimeoutManager.h"
#include "nsContentUtils.h"
#include "nsGlobalWindow.h"
#include "mozilla/Logging.h"
#include "mozilla/PerformanceCounter.h"
@ -17,6 +16,7 @@
#include "nsINamed.h"
#include "nsITimeoutHandler.h"
#include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/PopupBlocker.h"
#include "mozilla/dom/TabGroup.h"
#include "TimeoutExecutor.h"
#include "TimeoutBudgetManager.h"
@ -496,7 +496,7 @@ nsresult TimeoutManager::SetTimeout(nsITimeoutHandler* aHandler,
timeout->mReason = aReason;
// No popups from timeouts by default
timeout->mPopupState = openAbused;
timeout->mPopupState = PopupBlocker::openAbused;
timeout->mNestingLevel = sNestingLevel < DOM_CLAMP_TIMEOUT_NESTING_LEVEL
? sNestingLevel + 1
@ -516,7 +516,7 @@ nsresult TimeoutManager::SetTimeout(nsITimeoutHandler* aHandler,
}
if (gRunningTimeoutDepth == 0 &&
nsContentUtils::GetPopupControlState() < openBlocked) {
PopupBlocker::GetPopupControlState() < PopupBlocker::openBlocked) {
// This timeout is *not* set from another timeout and it's set
// while popups are enabled. Propagate the state to the timeout if
// its delay (interval) is equal to or less than what
@ -526,7 +526,7 @@ nsresult TimeoutManager::SetTimeout(nsITimeoutHandler* aHandler,
// because our lower bound for |realInterval| could be pretty high
// in some cases.
if (interval <= gDisableOpenClickDelay) {
timeout->mPopupState = nsContentUtils::GetPopupControlState();
timeout->mPopupState = PopupBlocker::GetPopupControlState();
}
}

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

@ -209,6 +209,7 @@ EXPORTS.mozilla.dom += [
'PlacesObservers.h',
'PlacesVisit.h',
'PlacesWeakCallbackWrapper.h',
'PopupBlocker.h',
'Pose.h',
'ProcessMessageManager.h',
'ResponsiveImageSelector.h',
@ -363,6 +364,7 @@ UNIFIED_SOURCES += [
'nsXHTMLContentSerializer.cpp',
'nsXMLContentSerializer.cpp',
'ParentProcessMessageManager.cpp',
'PopupBlocker.cpp',
'Pose.cpp',
'PostMessageEvent.cpp',
'ProcessMessageManager.cpp',

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

@ -290,7 +290,6 @@ nsIInterfaceRequestor* nsContentUtils::sSameOriginChecker = nullptr;
bool nsContentUtils::sIsHandlingKeyBoardEvent = false;
bool nsContentUtils::sAllowXULXBL_for_file = false;
bool nsContentUtils::sDisablePopups = false;
nsString* nsContentUtils::sShiftText = nullptr;
nsString* nsContentUtils::sControlText = nullptr;
@ -350,10 +349,6 @@ bool nsContentUtils::sAntiTrackingControlCenterUIEnabled = false;
mozilla::LazyLogModule nsContentUtils::sDOMDumpLog("Dump");
PopupControlState nsContentUtils::sPopupControlState = openAbused;
uint32_t nsContentUtils::sPopupStatePusherCount = 0;
bool nsContentUtils::sUnusedPopupToken = false;
int32_t nsContentUtils::sInnerOrOuterWindowCount = 0;
uint32_t nsContentUtils::sInnerOrOuterWindowSerialCounter = 0;
@ -703,9 +698,6 @@ nsresult nsContentUtils::Init() {
"dom.script_loader.bytecode_cache.enabled",
false);
Preferences::AddBoolVarCache(&sDisablePopups, "dom.disable_open_during_load",
false);
Preferences::AddBoolVarCache(
&sAntiTrackingControlCenterUIEnabled,
"browser.contentblocking.rejecttrackers.control-center.ui.enabled",
@ -10412,38 +10404,6 @@ nsContentUtils::TryGetTabChildGlobal(nsISupports* aFrom) {
--sInnerOrOuterWindowCount;
}
/* static */ bool nsContentUtils::CanShowPopupByPermission(
nsIPrincipal* aPrincipal) {
MOZ_ASSERT(aPrincipal);
uint32_t permit;
nsCOMPtr<nsIPermissionManager> permissionManager =
services::GetPermissionManager();
if (permissionManager &&
NS_SUCCEEDED(permissionManager->TestPermissionFromPrincipal(
aPrincipal, "popup", &permit))) {
if (permit == nsIPermissionManager::ALLOW_ACTION) {
return true;
}
if (permit == nsIPermissionManager::DENY_ACTION) {
return false;
}
}
return !sDisablePopups;
}
/* static */ bool nsContentUtils::TryUsePopupOpeningToken() {
MOZ_ASSERT(sPopupStatePusherCount);
if (!sUnusedPopupToken) {
sUnusedPopupToken = true;
return true;
}
return false;
}
static bool JSONCreator(const char16_t* aBuf, uint32_t aLen, void* aData) {
nsAString* result = static_cast<nsAString*>(aData);
result->Append(static_cast<const char16_t*>(aBuf),
@ -10546,15 +10506,3 @@ static bool JSONCreator(const char16_t* aBuf, uint32_t aLen, void* aData) {
nsDependentCSubstring(host, startIndexOfNextLevel);
}
}
/* static */ void nsContentUtils::PopupStatePusherCreated() {
++sPopupStatePusherCount;
}
/* static */ void nsContentUtils::PopupStatePusherDestroyed() {
MOZ_ASSERT(sPopupStatePusherCount);
if (!--sPopupStatePusherCount) {
sUnusedPopupToken = false;
}
}

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

@ -3280,26 +3280,6 @@ class nsContentUtils {
static already_AddRefed<mozilla::dom::ContentFrameMessageManager>
TryGetTabChildGlobal(nsISupports* aFrom);
static PopupControlState PushPopupControlState(PopupControlState aState,
bool aForce) {
MOZ_ASSERT(NS_IsMainThread());
PopupControlState old = sPopupControlState;
if (aState < old || aForce) {
sPopupControlState = aState;
}
return old;
}
static void PopPopupControlState(PopupControlState aState) {
MOZ_ASSERT(NS_IsMainThread());
sPopupControlState = aState;
}
static PopupControlState GetPopupControlState() { return sPopupControlState; }
static void PopupStatePusherCreated();
static void PopupStatePusherDestroyed();
// Get a serial number for a newly created inner or outer window.
static uint32_t InnerOrOuterWindowCreated();
// Record that an inner or outer window has been destroyed.
@ -3309,15 +3289,6 @@ class nsContentUtils {
return sInnerOrOuterWindowCount;
}
// This method checks if the principal is allowed by open popups by user
// permissions. In this case, the caller should not block popups.
static bool CanShowPopupByPermission(nsIPrincipal* aPrincipal);
// This method returns true if the caller is allowed to show a popup, and it
// consumes the popup token for the current event. There is just 1 popup
// allowed per event.
static bool TryUsePopupOpeningToken();
/**
* Serializes a JSON-like JS::Value into a string.
*
@ -3448,7 +3419,6 @@ class nsContentUtils {
static bool sIsHandlingKeyBoardEvent;
static bool sAllowXULXBL_for_file;
static bool sDisablePopups;
static bool sIsFullscreenApiEnabled;
static bool sIsUnprefixedFullscreenApiEnabled;
static bool sTrustedFullscreenOnly;
@ -3508,13 +3478,6 @@ class nsContentUtils {
static bool sDoNotTrackEnabled;
static mozilla::LazyLogModule sDOMDumpLog;
static PopupControlState sPopupControlState;
static uint32_t sPopupStatePusherCount;
// This token is by default set to false. When a popup/filePicker is shown, it
// is set to true.
static bool sUnusedPopupToken;
static int32_t sInnerOrOuterWindowCount;
static uint32_t sInnerOrOuterWindowSerialCounter;
};

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

@ -229,6 +229,7 @@
#include "mozilla/dom/HashChangeEvent.h"
#include "mozilla/dom/IntlUtils.h"
#include "mozilla/dom/PopStateEvent.h"
#include "mozilla/dom/PopupBlocker.h"
#include "mozilla/dom/PopupBlockedEvent.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/WindowBinding.h"
@ -1594,10 +1595,6 @@ void nsGlobalWindowInner::TraceGlobalJSObject(JSTracer* aTrc) {
TraceWrapper(aTrc, "active window global");
}
PopupControlState nsGlobalWindowInner::GetPopupControlState() const {
return nsContentUtils::GetPopupControlState();
}
nsresult nsGlobalWindowInner::SetNewDocument(nsIDocument* aDocument,
nsISupports* aState,
bool aForceReuseInnerWindow) {
@ -1937,7 +1934,7 @@ bool nsGlobalWindowInner::DialogsAreBeingAbused() {
DEFAULT_SUCCESSIVE_DIALOG_TIME_LIMIT)) {
mDialogAbuseCount++;
return GetPopupControlState() > openAllowed ||
return PopupBlocker::GetPopupControlState() > PopupBlocker::openAllowed ||
mDialogAbuseCount > MAX_SUCCESSIVE_DIALOG_COUNT;
}
@ -5953,7 +5950,7 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout,
// Clear the timeout's popup state, if any, to prevent interval
// timeouts from repeatedly opening poups.
timeout->mPopupState = openAbused;
timeout->mPopupState = PopupBlocker::openAbused;
bool trackNestingLevel = !timeout->mIsInterval;
uint32_t nestingLevel;

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

@ -321,8 +321,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
nsresult PostHandleEvent(mozilla::EventChainPostVisitor& aVisitor) override;
virtual PopupControlState GetPopupControlState() const override;
void Suspend();
void Resume();
virtual bool IsSuspended() const override;

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

@ -1356,19 +1356,6 @@ void nsGlobalWindowOuter::SetInitialPrincipalToSubject() {
}
}
PopupControlState nsGlobalWindowOuter::PushPopupControlState(
PopupControlState aState, bool aForce) const {
return nsContentUtils::PushPopupControlState(aState, aForce);
}
void nsGlobalWindowOuter::PopPopupControlState(PopupControlState aState) const {
nsContentUtils::PopPopupControlState(aState);
}
PopupControlState nsGlobalWindowOuter::GetPopupControlState() const {
return nsContentUtils::GetPopupControlState();
}
#define WINDOWSTATEHOLDER_IID \
{ \
0x0b917c3e, 0xbd50, 0x4683, { \
@ -2374,7 +2361,7 @@ bool nsGlobalWindowOuter::ConfirmDialogIfNeeded() {
// Reset popup state while opening a modal dialog, and firing events
// about the dialog, to prevent the current state from being active
// the whole time a modal dialog is open.
nsAutoPopupStatePusher popupStatePusher(openAbused, true);
nsAutoPopupStatePusher popupStatePusher(PopupBlocker::openAbused, true);
bool disableDialog = false;
nsAutoString label, title;
@ -4316,7 +4303,7 @@ bool nsGlobalWindowOuter::AlertOrConfirm(bool aAlert, const nsAString& aMessage,
// Reset popup state while opening a modal dialog, and firing events
// about the dialog, to prevent the current state from being active
// the whole time a modal dialog is open.
nsAutoPopupStatePusher popupStatePusher(openAbused, true);
nsAutoPopupStatePusher popupStatePusher(PopupBlocker::openAbused, true);
// Before bringing up the window, unsuppress painting and flush
// pending reflows.
@ -4404,7 +4391,7 @@ void nsGlobalWindowOuter::PromptOuter(const nsAString& aMessage,
// Reset popup state while opening a modal dialog, and firing events
// about the dialog, to prevent the current state from being active
// the whole time a modal dialog is open.
nsAutoPopupStatePusher popupStatePusher(openAbused, true);
nsAutoPopupStatePusher popupStatePusher(PopupBlocker::openAbused, true);
// Before bringing up the window, unsuppress painting and flush
// pending reflows.
@ -4500,7 +4487,8 @@ void nsGlobalWindowOuter::FocusOuter(ErrorResult& aError) {
// (bugs 355482 and 369306).
bool canFocus = CanSetProperty("dom.disable_window_flip") ||
(opener == callerOuter &&
RevisePopupAbuseLevel(GetPopupControlState()) < openBlocked);
RevisePopupAbuseLevel(PopupBlocker::GetPopupControlState()) <
PopupBlocker::openBlocked);
nsCOMPtr<mozIDOMWindowProxy> activeDOMWindow;
fm->GetActiveWindow(getter_AddRefs(activeDOMWindow));
@ -5129,7 +5117,7 @@ bool nsGlobalWindowOuter::CanSetProperty(const char* aPrefName) {
}
bool nsGlobalWindowOuter::PopupWhitelisted() {
if (mDoc && nsContentUtils::CanShowPopupByPermission(mDoc->NodePrincipal())) {
if (mDoc && PopupBlocker::CanShowPopupByPermission(mDoc->NodePrincipal())) {
return true;
}
@ -5147,45 +5135,48 @@ bool nsGlobalWindowOuter::PopupWhitelisted() {
* routine to determine whether to allow the new window.
* Returns a value from the PopupControlState enum.
*/
PopupControlState nsGlobalWindowOuter::RevisePopupAbuseLevel(
PopupControlState aControl) {
PopupBlocker::PopupControlState nsGlobalWindowOuter::RevisePopupAbuseLevel(
PopupBlocker::PopupControlState aControl) {
NS_ASSERTION(mDocShell, "Must have docshell");
if (mDocShell->ItemType() != nsIDocShellTreeItem::typeContent) {
return openAllowed;
return PopupBlocker::openAllowed;
}
PopupControlState abuse = aControl;
PopupBlocker::PopupControlState abuse = aControl;
switch (abuse) {
case openControlled:
case openBlocked:
case openOverridden:
if (PopupWhitelisted()) abuse = PopupControlState(abuse - 1);
break;
case openAbused:
case PopupBlocker::openControlled:
case PopupBlocker::openBlocked:
case PopupBlocker::openOverridden:
if (PopupWhitelisted())
// Skip openBlocked
abuse = openControlled;
abuse = PopupBlocker::PopupControlState(abuse - 1);
break;
case openAllowed:
case PopupBlocker::openAbused:
if (PopupWhitelisted())
// Skip PopupBlocker::openBlocked
abuse = PopupBlocker::openControlled;
break;
case PopupBlocker::openAllowed:
break;
default:
NS_WARNING("Strange PopupControlState!");
}
// limit the number of simultaneously open popups
if (abuse == openAbused || abuse == openBlocked || abuse == openControlled) {
if (abuse == PopupBlocker::openAbused || abuse == PopupBlocker::openBlocked ||
abuse == PopupBlocker::openControlled) {
int32_t popupMax = Preferences::GetInt("dom.popup_maximum", -1);
if (popupMax >= 0 && gOpenPopupSpamCount >= popupMax)
abuse = openOverridden;
abuse = PopupBlocker::openOverridden;
}
// If this popup is allowed, let's block any other for this event, forcing
// openBlocked state.
if ((abuse == openAllowed || abuse == openControlled) &&
// PopupBlocker::openBlocked state.
if ((abuse == PopupBlocker::openAllowed ||
abuse == PopupBlocker::openControlled) &&
StaticPrefs::dom_block_multiple_popups() && !PopupWhitelisted() &&
!nsContentUtils::TryUsePopupOpeningToken()) {
abuse = openBlocked;
!PopupBlocker::TryUsePopupOpeningToken()) {
abuse = PopupBlocker::openBlocked;
}
return abuse;
@ -6624,10 +6615,11 @@ nsresult nsGlobalWindowOuter::OpenInternal(
if (NS_FAILED(rv)) return rv;
PopupControlState abuseLevel = GetPopupControlState();
PopupBlocker::PopupControlState abuseLevel =
PopupBlocker::GetPopupControlState();
if (checkForPopup) {
abuseLevel = RevisePopupAbuseLevel(abuseLevel);
if (abuseLevel >= openBlocked) {
if (abuseLevel >= PopupBlocker::openBlocked) {
if (!aCalledNoScript) {
// If script in some other window is doing a window.open on us and
// it's being blocked, then it's OK to close us afterwards, probably.
@ -6663,18 +6655,20 @@ nsresult nsGlobalWindowOuter::OpenInternal(
nsCOMPtr<nsPIWindowWatcher> pwwatch(do_QueryInterface(wwatch));
NS_ENSURE_STATE(pwwatch);
MOZ_ASSERT_IF(checkForPopup, abuseLevel < openBlocked);
MOZ_ASSERT_IF(checkForPopup, abuseLevel < PopupBlocker::openBlocked);
// At this point we should know for a fact that if checkForPopup then
// abuseLevel < openBlocked, so we could just check for abuseLevel ==
// openControlled. But let's be defensive just in case and treat anything
// that fails the above assert as a spam popup too, if it ever happens.
bool isPopupSpamWindow = checkForPopup && (abuseLevel >= openControlled);
// abuseLevel < PopupBlocker::openBlocked, so we could just check for
// abuseLevel == PopupBlocker::openControlled. But let's be defensive just in
// case and treat anything that fails the above assert as a spam popup too, if
// it ever happens.
bool isPopupSpamWindow =
checkForPopup && (abuseLevel >= PopupBlocker::openControlled);
{
// Reset popup state while opening a window to prevent the
// current state from being active the whole time a modal
// dialog is open.
nsAutoPopupStatePusher popupStatePusher(openAbused, true);
nsAutoPopupStatePusher popupStatePusher(PopupBlocker::openAbused, true);
if (!aCalledNoScript) {
// We asserted at the top of this function that aNavigate is true for
@ -7389,17 +7383,6 @@ nsPIDOMWindowOuter::nsPIDOMWindowOuter(uint64_t aWindowID)
nsPIDOMWindowOuter::~nsPIDOMWindowOuter() {}
nsAutoPopupStatePusherInternal::nsAutoPopupStatePusherInternal(
PopupControlState aState, bool aForce)
: mOldState(nsContentUtils::PushPopupControlState(aState, aForce)) {
nsContentUtils::PopupStatePusherCreated();
}
nsAutoPopupStatePusherInternal::~nsAutoPopupStatePusherInternal() {
nsContentUtils::PopPopupControlState(mOldState);
nsContentUtils::PopupStatePusherDestroyed();
}
mozilla::dom::BrowsingContext* nsPIDOMWindowOuter::GetBrowsingContext() const {
return mDocShell ? nsDocShell::Cast(mDocShell)->GetBrowsingContext()
: nullptr;

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

@ -38,6 +38,7 @@
#include "prclist.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/ChromeMessageBroadcaster.h"
#include "mozilla/dom/PopupBlocker.h"
#include "mozilla/dom/StorageEvent.h"
#include "mozilla/dom/StorageEventBinding.h"
#include "mozilla/dom/UnionTypes.h"
@ -299,11 +300,6 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
// Outer windows only.
virtual void SetInitialPrincipalToSubject() override;
virtual PopupControlState PushPopupControlState(PopupControlState state,
bool aForce) const override;
virtual void PopPopupControlState(PopupControlState state) const override;
virtual PopupControlState GetPopupControlState() const override;
virtual already_AddRefed<nsISupports> SaveWindowState() override;
virtual nsresult RestoreWindowState(nsISupports* aState) override;
@ -850,7 +846,8 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
nsresult SecurityCheckURL(const char* aURL, nsIURI** aURI);
bool PopupWhitelisted();
PopupControlState RevisePopupAbuseLevel(PopupControlState);
mozilla::dom::PopupBlocker::PopupControlState RevisePopupAbuseLevel(
mozilla::dom::PopupBlocker::PopupControlState aState);
void FireAbuseEvents(const nsAString& aPopupURL,
const nsAString& aPopupWindowName,
const nsAString& aPopupWindowFeatures);

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

@ -74,19 +74,6 @@ enum class CallerType : uint32_t;
} // namespace dom
} // namespace mozilla
// Popup control state enum. The values in this enum must go from most
// permissive to least permissive so that it's safe to push state in
// all situations. Pushing popup state onto the stack never makes the
// current popup state less permissive (see
// nsGlobalWindow::PushPopupControlState()).
enum PopupControlState {
openAllowed = 0, // open that window without worries
openControlled, // it's a popup, but allow it
openBlocked, // it's a popup, but not from an allowed event
openAbused, // it's a popup. disallow it, but allow domain override.
openOverridden // disallow window open
};
enum UIStateChangeType {
UIStateChangeType_NoChange,
UIStateChangeType_Set,
@ -383,8 +370,6 @@ class nsPIDOMWindowInner : public mozIDOMWindow {
return mWindowGlobalChild;
}
virtual PopupControlState GetPopupControlState() const = 0;
// Determine if the window is suspended or frozen. Outer windows
// will forward this call to the inner window for convenience. If
// there is no inner window then the outer window is considered
@ -875,11 +860,6 @@ class nsPIDOMWindowOuter : public mozIDOMWindowProxy {
// principal.
virtual void SetInitialPrincipalToSubject() = 0;
virtual PopupControlState PushPopupControlState(PopupControlState aState,
bool aForce) const = 0;
virtual void PopPopupControlState(PopupControlState state) const = 0;
virtual PopupControlState GetPopupControlState() const = 0;
// Returns an object containing the window's state. This also suspends
// all running timeouts in the window.
virtual already_AddRefed<nsISupports> SaveWindowState() = 0;
@ -1210,52 +1190,4 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindowOuter, NS_PIDOMWINDOWOUTER_IID)
#include "nsPIDOMWindowInlines.h"
#ifdef MOZILLA_INTERNAL_API
#define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherInternal
#else
#define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherExternal
#endif
// Helper class that helps with pushing and popping popup control
// state. Note that this class looks different from within code that's
// part of the layout library than it does in code outside the layout
// library. We give the two object layouts different names so the symbols
// don't conflict, but code should always use the name
// |nsAutoPopupStatePusher|.
class NS_AUTO_POPUP_STATE_PUSHER {
public:
#ifdef MOZILLA_INTERNAL_API
explicit NS_AUTO_POPUP_STATE_PUSHER(PopupControlState aState,
bool aForce = false);
~NS_AUTO_POPUP_STATE_PUSHER();
#else
NS_AUTO_POPUP_STATE_PUSHER(nsPIDOMWindowOuter* aWindow,
PopupControlState aState)
: mWindow(aWindow), mOldState(openAbused) {
if (aWindow) {
mOldState = aWindow->PushPopupControlState(aState, false);
}
}
~NS_AUTO_POPUP_STATE_PUSHER() {
if (mWindow) {
mWindow->PopPopupControlState(mOldState);
}
}
#endif
protected:
#ifndef MOZILLA_INTERNAL_API
nsCOMPtr<nsPIDOMWindowOuter> mWindow;
#endif
PopupControlState mOldState;
private:
// Hide so that this class can only be stack-allocated
static void* operator new(size_t /*size*/) CPP_THROW_NEW { return nullptr; }
static void operator delete(void* /*memory*/) {}
};
#define nsAutoPopupStatePusher NS_AUTO_POPUP_STATE_PUSHER
#endif // nsPIDOMWindow_h__

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

@ -40,8 +40,6 @@
namespace mozilla {
namespace dom {
static char* sPopupAllowedEvents;
static bool sReturnHighResTimeStamp = false;
static bool sReturnHighResTimeStampIsSet = false;
@ -508,272 +506,6 @@ bool Event::IsDispatchStopped() { return mEvent->PropagationStopped(); }
WidgetEvent* Event::WidgetEventPtr() { return mEvent; }
// return true if eventName is contained within events, delimited by
// spaces
static bool PopupAllowedForEvent(const char* eventName) {
if (!sPopupAllowedEvents) {
Event::PopupAllowedEventsChanged();
if (!sPopupAllowedEvents) {
return false;
}
}
nsDependentCString events(sPopupAllowedEvents);
nsCString::const_iterator start, end;
nsCString::const_iterator startiter(events.BeginReading(start));
events.EndReading(end);
while (startiter != end) {
nsCString::const_iterator enditer(end);
if (!FindInReadable(nsDependentCString(eventName), startiter, enditer))
return false;
// the match is surrounded by spaces, or at a string boundary
if ((startiter == start || *--startiter == ' ') &&
(enditer == end || *enditer == ' ')) {
return true;
}
// Move on and see if there are other matches. (The delimitation
// requirement makes it pointless to begin the next search before
// the end of the invalid match just found.)
startiter = enditer;
}
return false;
}
// static
PopupControlState Event::GetEventPopupControlState(WidgetEvent* aEvent,
Event* aDOMEvent) {
// generally if an event handler is running, new windows are disallowed.
// check for exceptions:
PopupControlState abuse = openAbused;
if (aDOMEvent && aDOMEvent->GetWantsPopupControlCheck()) {
nsAutoString type;
aDOMEvent->GetType(type);
if (PopupAllowedForEvent(NS_ConvertUTF16toUTF8(type).get())) {
return openAllowed;
}
}
switch (aEvent->mClass) {
case eBasicEventClass:
// For these following events only allow popups if they're
// triggered while handling user input. See
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
abuse = openBlocked;
switch (aEvent->mMessage) {
case eFormSelect:
if (PopupAllowedForEvent("select")) {
abuse = openControlled;
}
break;
case eFormChange:
if (PopupAllowedForEvent("change")) {
abuse = openControlled;
}
break;
default:
break;
}
}
break;
case eEditorInputEventClass:
// For this following event only allow popups if it's triggered
// while handling user input. See
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
abuse = openBlocked;
switch (aEvent->mMessage) {
case eEditorInput:
if (PopupAllowedForEvent("input")) {
abuse = openControlled;
}
break;
default:
break;
}
}
break;
case eInputEventClass:
// For this following event only allow popups if it's triggered
// while handling user input. See
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
abuse = openBlocked;
switch (aEvent->mMessage) {
case eFormChange:
if (PopupAllowedForEvent("change")) {
abuse = openControlled;
}
break;
case eXULCommand:
abuse = openControlled;
break;
default:
break;
}
}
break;
case eKeyboardEventClass:
if (aEvent->IsTrusted()) {
abuse = openBlocked;
uint32_t key = aEvent->AsKeyboardEvent()->mKeyCode;
switch (aEvent->mMessage) {
case eKeyPress:
// return key on focused button. see note at eMouseClick.
if (key == NS_VK_RETURN) {
abuse = openAllowed;
} else if (PopupAllowedForEvent("keypress")) {
abuse = openControlled;
}
break;
case eKeyUp:
// space key on focused button. see note at eMouseClick.
if (key == NS_VK_SPACE) {
abuse = openAllowed;
} else if (PopupAllowedForEvent("keyup")) {
abuse = openControlled;
}
break;
case eKeyDown:
if (PopupAllowedForEvent("keydown")) {
abuse = openControlled;
}
break;
default:
break;
}
}
break;
case eTouchEventClass:
if (aEvent->IsTrusted()) {
abuse = openBlocked;
switch (aEvent->mMessage) {
case eTouchStart:
if (PopupAllowedForEvent("touchstart")) {
abuse = openControlled;
}
break;
case eTouchEnd:
if (PopupAllowedForEvent("touchend")) {
abuse = openControlled;
}
break;
default:
break;
}
}
break;
case eMouseEventClass:
if (aEvent->IsTrusted() &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
abuse = openBlocked;
switch (aEvent->mMessage) {
case eMouseUp:
if (PopupAllowedForEvent("mouseup")) {
abuse = openControlled;
}
break;
case eMouseDown:
if (PopupAllowedForEvent("mousedown")) {
abuse = openControlled;
}
break;
case eMouseClick:
/* Click events get special treatment because of their
historical status as a more legitimate event handler. If
click popups are enabled in the prefs, clear the popup
status completely. */
if (PopupAllowedForEvent("click")) {
abuse = openAllowed;
}
break;
case eMouseDoubleClick:
if (PopupAllowedForEvent("dblclick")) {
abuse = openControlled;
}
break;
default:
break;
}
}
break;
case ePointerEventClass:
if (aEvent->IsTrusted() &&
aEvent->AsPointerEvent()->button == WidgetMouseEvent::eLeftButton) {
switch (aEvent->mMessage) {
case ePointerUp:
if (PopupAllowedForEvent("pointerup")) {
abuse = openControlled;
}
break;
case ePointerDown:
if (PopupAllowedForEvent("pointerdown")) {
abuse = openControlled;
}
break;
default:
break;
}
}
break;
case eFormEventClass:
// For these following events only allow popups if they're
// triggered while handling user input. See
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
abuse = openBlocked;
switch (aEvent->mMessage) {
case eFormSubmit:
if (PopupAllowedForEvent("submit")) {
abuse = openControlled;
}
break;
case eFormReset:
if (PopupAllowedForEvent("reset")) {
abuse = openControlled;
}
break;
default:
break;
}
}
break;
default:
break;
}
return abuse;
}
// static
void Event::PopupAllowedEventsChanged() {
if (sPopupAllowedEvents) {
free(sPopupAllowedEvents);
}
nsAutoCString str;
Preferences::GetCString("dom.popup_allowed_events", str);
// We'll want to do this even if str is empty to avoid looking up
// this pref all the time if it's not set.
sPopupAllowedEvents = ToNewCString(str);
}
// static
void Event::Shutdown() {
if (sPopupAllowedEvents) {
free(sPopupAllowedEvents);
}
}
// static
CSSIntPoint Event::GetScreenCoords(nsPresContext* aPresContext,
WidgetEvent* aEvent,

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

@ -16,6 +16,7 @@
#include "nsCycleCollectionParticipant.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/EventBinding.h"
#include "mozilla/dom/PopupBlocker.h"
#include "nsIScriptGlobalObject.h"
#include "Units.h"
#include "js/TypeDecls.h"
@ -141,13 +142,6 @@ class Event : public nsISupports, public nsWrapperCache {
// Returns true if the event should be trusted.
bool Init(EventTarget* aGlobal);
static PopupControlState GetEventPopupControlState(
WidgetEvent* aEvent, Event* aDOMEvent = nullptr);
static void PopupAllowedEventsChanged();
static void Shutdown();
static const char* GetEventName(EventMessage aEventType);
static CSSIntPoint GetClientCoords(nsPresContext* aPresContext,
WidgetEvent* aEvent,
@ -284,6 +278,7 @@ class Event : public nsISupports, public nsWrapperCache {
already_AddRefed<nsIContent> GetTargetFromFrame();
friend class EventMessageAutoOverride;
friend class PopupBlocker;
friend class WantsPopupControlCheck;
void SetWantsPopupControlCheck(bool aCheck) {
mWantsPopupControlCheck = aCheck;

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

@ -22,6 +22,7 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/EventTargetBinding.h"
#include "mozilla/dom/PopupBlocker.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/TimelineConsumers.h"
@ -156,8 +157,6 @@ void EventListenerManager::RemoveAllListeners() {
mClearingListeners = false;
}
void EventListenerManager::Shutdown() { Event::Shutdown(); }
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(EventListenerManager, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(EventListenerManager, Release)
@ -1147,7 +1146,7 @@ void EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
Maybe<nsAutoPopupStatePusher> popupStatePusher;
if (mIsMainThreadELM) {
popupStatePusher.emplace(
Event::GetEventPopupControlState(aEvent, *aDOMEvent));
PopupBlocker::GetEventPopupControlState(aEvent, *aDOMEvent));
}
bool hasListener = false;

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

@ -401,8 +401,6 @@ class EventListenerManager final : public EventListenerManagerBase {
uint32_t GetIdentifierForEvent(nsAtom* aEvent);
static void Shutdown();
/**
* Returns true if there may be a paint event listener registered,
* false if there definitely isn't.

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

@ -296,7 +296,6 @@ EventStateManager::~EventStateManager() {
gUserInteractionTimer->Cancel();
NS_RELEASE(gUserInteractionTimer);
}
Prefs::Shutdown();
WheelPrefs::Shutdown();
DeltaAccumulator::Shutdown();
}
@ -6073,19 +6072,14 @@ bool EventStateManager::Prefs::sClickHoldContextMenu = false;
// static
void EventStateManager::Prefs::Init() {
DebugOnly<nsresult> rv =
Preferences::RegisterCallback(OnChange, "dom.popup_allowed_events");
MOZ_ASSERT(NS_SUCCEEDED(rv),
"Failed to observe \"dom.popup_allowed_events\"");
static bool sPrefsAlreadyCached = false;
if (sPrefsAlreadyCached) {
return;
}
rv = Preferences::AddBoolVarCache(&sKeyCausesActivation,
"accessibility.accesskeycausesactivation",
sKeyCausesActivation);
DebugOnly<nsresult> rv = Preferences::AddBoolVarCache(
&sKeyCausesActivation, "accessibility.accesskeycausesactivation",
sKeyCausesActivation);
MOZ_ASSERT(NS_SUCCEEDED(rv),
"Failed to observe \"accessibility.accesskeycausesactivation\"");
rv = Preferences::AddBoolVarCache(&sClickHoldContextMenu,
@ -6096,19 +6090,6 @@ void EventStateManager::Prefs::Init() {
sPrefsAlreadyCached = true;
}
// static
void EventStateManager::Prefs::OnChange(const char* aPrefName, void*) {
nsDependentCString prefName(aPrefName);
if (prefName.EqualsLiteral("dom.popup_allowed_events")) {
Event::PopupAllowedEventsChanged();
}
}
// static
void EventStateManager::Prefs::Shutdown() {
Preferences::UnregisterCallback(OnChange, "dom.popup_allowed_events");
}
/******************************************************************/
/* mozilla::AutoHandlingUserInputStatePusher */
/******************************************************************/

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

@ -377,8 +377,6 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
static bool ClickHoldContextMenu() { return sClickHoldContextMenu; }
static void Init();
static void OnChange(const char* aPrefName, void*);
static void Shutdown();
private:
static bool sKeyCausesActivation;

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

@ -109,7 +109,7 @@ HTMLFormElement::HTMLFormElement(
mFirstSubmitNotInElements(nullptr),
mImageNameLookupTable(FORM_CONTROL_LIST_HASHTABLE_LENGTH),
mPastNameLookupTable(FORM_CONTROL_LIST_HASHTABLE_LENGTH),
mSubmitPopupState(openAbused),
mSubmitPopupState(PopupBlocker::openAbused),
mInvalidElementsCount(0),
mGeneratingSubmit(false),
mGeneratingReset(false),
@ -568,11 +568,10 @@ nsresult HTMLFormElement::DoSubmit(WidgetEvent* aEvent) {
// XXXbz if the script global is that for an sXBL/XBL2 doc, it won't
// be a window...
nsPIDOMWindowOuter* window = OwnerDoc()->GetWindow();
if (window) {
mSubmitPopupState = window->GetPopupControlState();
mSubmitPopupState = PopupBlocker::GetPopupControlState();
} else {
mSubmitPopupState = openAbused;
mSubmitPopupState = PopupBlocker::openAbused;
}
mSubmitInitiatedFromUserInput = EventStateManager::IsHandlingUserInput();

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

@ -573,7 +573,7 @@ class HTMLFormElement final : public nsGenericHTMLElement,
nsInterfaceHashtable<nsStringHashKey, nsISupports> mPastNameLookupTable;
/** Keep track of what the popup state was when the submit was initiated */
PopupControlState mSubmitPopupState;
PopupBlocker::PopupControlState mSubmitPopupState;
/**
* Number of invalid and candidate for constraint validation elements in the

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

@ -654,12 +654,11 @@ bool HTMLInputElement::IsPopupBlocked() const {
}
// Check if page can open a popup without abuse regardless of allowed events
if (win->GetPopupControlState() <= openBlocked) {
return !nsContentUtils::TryUsePopupOpeningToken();
if (PopupBlocker::GetPopupControlState() <= PopupBlocker::openBlocked) {
return !PopupBlocker::TryUsePopupOpeningToken();
}
return !nsContentUtils::CanShowPopupByPermission(
OwnerDoc()->NodePrincipal());
return !PopupBlocker::CanShowPopupByPermission(OwnerDoc()->NodePrincipal());
}
nsresult HTMLInputElement::InitColorPicker() {

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

@ -201,8 +201,8 @@ bool HTMLLabelElement::PerformAccesskey(bool aKeyCausesActivation,
WidgetMouseEvent::eReal);
event.inputSource = MouseEvent_Binding::MOZ_SOURCE_KEYBOARD;
nsAutoPopupStatePusher popupStatePusher(aIsTrustedEvent ? openAllowed
: openAbused);
nsAutoPopupStatePusher popupStatePusher(
aIsTrustedEvent ? PopupBlocker::openAllowed : PopupBlocker::openAbused);
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext,
&event);

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

@ -2289,8 +2289,8 @@ bool nsGenericHTMLElement::PerformAccesskey(bool aKeyCausesActivation,
if (aKeyCausesActivation) {
// Click on it if the users prefs indicate to do so.
nsAutoPopupStatePusher popupStatePusher(aIsTrustedEvent ? openAllowed
: openAbused);
nsAutoPopupStatePusher popupStatePusher(
aIsTrustedEvent ? PopupBlocker::openAllowed : PopupBlocker::openAbused);
DispatchSimulatedClick(this, aIsTrustedEvent, presContext);
}

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

@ -47,6 +47,7 @@
#include "nsSandboxFlags.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/PopupBlocker.h"
#include "nsILoadInfo.h"
#include "nsContentSecurityManager.h"
@ -64,9 +65,10 @@ class nsJSThunk : public nsIInputStream {
NS_FORWARD_SAFE_NSIINPUTSTREAM(mInnerStream)
nsresult Init(nsIURI* uri);
nsresult EvaluateScript(nsIChannel* aChannel, PopupControlState aPopupState,
uint32_t aExecutionPolicy,
nsPIDOMWindowInner* aOriginalInnerWindow);
nsresult EvaluateScript(
nsIChannel* aChannel,
mozilla::dom::PopupBlocker::PopupControlState aPopupState,
uint32_t aExecutionPolicy, nsPIDOMWindowInner* aOriginalInnerWindow);
protected:
virtual ~nsJSThunk();
@ -126,10 +128,10 @@ static nsIScriptGlobalObject* GetGlobalObject(nsIChannel* aChannel) {
return global;
}
nsresult nsJSThunk::EvaluateScript(nsIChannel* aChannel,
PopupControlState aPopupState,
uint32_t aExecutionPolicy,
nsPIDOMWindowInner* aOriginalInnerWindow) {
nsresult nsJSThunk::EvaluateScript(
nsIChannel* aChannel,
mozilla::dom::PopupBlocker::PopupControlState aPopupState,
uint32_t aExecutionPolicy, nsPIDOMWindowInner* aOriginalInnerWindow) {
if (aExecutionPolicy == nsIScriptChannel::NO_EXECUTION) {
// Nothing to do here.
return NS_ERROR_DOM_RETVAL_UNDEFINED;
@ -345,7 +347,7 @@ class nsJSChannel : public nsIChannel,
nsLoadFlags mActualLoadFlags; // See AsyncOpen2
RefPtr<nsJSThunk> mIOThunk;
PopupControlState mPopupState;
mozilla::dom::PopupBlocker::PopupControlState mPopupState;
uint32_t mExecutionPolicy;
bool mIsAsync;
bool mIsActive;
@ -356,7 +358,7 @@ nsJSChannel::nsJSChannel()
: mStatus(NS_OK),
mLoadFlags(LOAD_NORMAL),
mActualLoadFlags(LOAD_NORMAL),
mPopupState(openOverridden),
mPopupState(mozilla::dom::PopupBlocker::openOverridden),
mExecutionPolicy(NO_EXECUTION),
mIsAsync(true),
mIsActive(false),
@ -573,7 +575,7 @@ nsJSChannel::AsyncOpen(nsIStreamListener* aListener, nsISupports* aContext) {
mDocumentOnloadBlockedOn->BlockOnload();
}
mPopupState = win->GetPopupControlState();
mPopupState = mozilla::dom::PopupBlocker::GetPopupControlState();
void (nsJSChannel::*method)();
const char* name;

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

@ -139,11 +139,7 @@ nsresult nsNPAPIPluginInstance::Stop() {
// Make sure the plugin didn't leave popups enabled.
if (mPopupStates.Length() > 0) {
nsCOMPtr<nsPIDOMWindowOuter> window = GetDOMWindow();
if (window) {
window->PopPopupControlState(openAbused);
}
PopupBlocker::PopPopupControlState(PopupBlocker::openAbused);
}
if (RUNNING != mRunning) {
@ -774,12 +770,14 @@ nsresult nsNPAPIPluginInstance::PushPopupsEnabledState(bool aEnabled) {
nsCOMPtr<nsPIDOMWindowOuter> window = GetDOMWindow();
if (!window) return NS_ERROR_FAILURE;
PopupControlState oldState =
window->PushPopupControlState(aEnabled ? openAllowed : openAbused, true);
PopupBlocker::PopupControlState oldState =
PopupBlocker::PushPopupControlState(
aEnabled ? PopupBlocker::openAllowed : PopupBlocker::openAbused,
true);
if (!mPopupStates.AppendElement(oldState)) {
// Appending to our state stack failed, pop what we just pushed.
window->PopPopupControlState(oldState);
PopupBlocker::PopPopupControlState(oldState);
return NS_ERROR_FAILURE;
}
@ -797,9 +795,9 @@ nsresult nsNPAPIPluginInstance::PopPopupsEnabledState() {
nsCOMPtr<nsPIDOMWindowOuter> window = GetDOMWindow();
if (!window) return NS_ERROR_FAILURE;
PopupControlState& oldState = mPopupStates[last];
PopupBlocker::PopupControlState& oldState = mPopupStates[last];
window->PopPopupControlState(oldState);
PopupBlocker::PopPopupControlState(oldState);
mPopupStates.RemoveElementAt(last);

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

@ -24,6 +24,7 @@
#include "mozilla/PluginLibrary.h"
#include "mozilla/RefPtr.h"
#include "mozilla/WeakPtr.h"
#include "mozilla/dom/PopupBlocker.h"
class nsPluginStreamListenerPeer; // browser-initiated stream class
class nsNPAPIPluginStreamListener; // plugin-initiated stream class
@ -269,7 +270,7 @@ class nsNPAPIPluginInstance final
nsTArray<nsPluginStreamListenerPeer*> mFileCachedStreamListeners;
nsTArray<PopupControlState> mPopupStates;
nsTArray<mozilla::dom::PopupBlocker::PopupControlState> mPopupStates;
char* mMIMEType;

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

@ -425,7 +425,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(
int32_t blockPopups =
Preferences::GetInt("privacy.popups.disable_from_plugins");
nsAutoPopupStatePusher popupStatePusher((PopupControlState)blockPopups);
nsAutoPopupStatePusher popupStatePusher(
(PopupBlocker::PopupControlState)blockPopups);
// if security checks (in particular CheckLoadURIWithPrincipal) needs
// to be skipped we are creating a codebasePrincipal to make sure

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

@ -43,8 +43,8 @@
#include "nsIContentIterator.h"
#include "nsIPresShellInlines.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h" // for Event::GetEventPopupControlState()
#include "mozilla/dom/PointerEventHandler.h"
#include "mozilla/dom/PopupBlocker.h"
#include "nsIDocument.h"
#include "nsAnimationManager.h"
#include "nsNameSpaceManager.h" // for Pref-related rule management (bugs 22963,20760,31816)
@ -7265,7 +7265,7 @@ nsresult PresShell::HandleEventInternal(WidgetEvent* aEvent,
}
nsAutoPopupStatePusher popupStatePusher(
Event::GetEventPopupControlState(aEvent));
PopupBlocker::GetEventPopupControlState(aEvent));
// FIXME. If the event was reused, we need to clear the old target,
// bug 329430

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

@ -18,6 +18,7 @@
#include "nsIContentViewer.h"
#include "nsIDocumentViewerPrint.h"
#include "mozilla/dom/BeforeUnloadEvent.h"
#include "mozilla/dom/PopupBlocker.h"
#include "nsIDocument.h"
#include "nsPresContext.h"
#include "nsIPresShell.h"
@ -1241,7 +1242,7 @@ nsresult nsDocumentViewer::PermitUnloadInternal(uint32_t* aPermitUnloadFlags,
{
// Never permit popups from the beforeunload handler, no matter
// how we get here.
nsAutoPopupStatePusher popupStatePusher(openAbused, true);
nsAutoPopupStatePusher popupStatePusher(PopupBlocker::openAbused, true);
// Never permit dialogs from the beforeunload handler
nsGlobalWindowOuter* globalWindow = nsGlobalWindowOuter::Cast(window);
@ -1449,7 +1450,7 @@ nsDocumentViewer::PageHide(bool aIsUnload) {
// Never permit popups from the unload handler, no matter how we get
// here.
nsAutoPopupStatePusher popupStatePusher(openAbused, true);
nsAutoPopupStatePusher popupStatePusher(PopupBlocker::openAbused, true);
nsIDocument::PageUnloadingEventTimeStamp timestamp(mDocument);

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

@ -25,7 +25,7 @@
#include "nsCSSRendering.h"
#include "nsGenericHTMLFrameElement.h"
#include "mozilla/dom/Attr.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/dom/PopupBlocker.h"
#include "nsFrame.h"
#include "nsFrameState.h"
#include "nsGlobalWindow.h"
@ -193,6 +193,8 @@ nsresult nsLayoutStatics::Initialize() {
#endif
Attr::Initialize();
PopupBlocker::Initialize();
rv = txMozillaXSLTProcessor::Startup();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize txMozillaXSLTProcessor");
@ -315,7 +317,7 @@ void nsLayoutStatics::Shutdown() {
StorageObserver::Shutdown();
txMozillaXSLTProcessor::Shutdown();
Attr::Shutdown();
EventListenerManager::Shutdown();
PopupBlocker::Shutdown();
IMEStateManager::Shutdown();
nsMediaFeatures::Shutdown();
nsHTMLDNSPrefetch::Shutdown();

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

@ -468,6 +468,12 @@ VARCACHE_PREF(
)
#undef PREF_VALUE
VARCACHE_PREF(
"dom.disable_open_during_load",
dom_disable_open_during_load,
bool, false
)
//---------------------------------------------------------------------------
// Clear-Site-Data prefs
//---------------------------------------------------------------------------

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

@ -1276,7 +1276,6 @@ pref("dom.allow_scripts_to_close_windows", false);
pref("dom.require_user_interaction_for_beforeunload", true);
pref("dom.disable_open_during_load", false);
pref("dom.popup_maximum", 20);
pref("dom.popup_allowed_events", "change click dblclick mouseup pointerup notificationclick reset submit touchend");

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

@ -133,11 +133,11 @@ class WhitelistClassifierCallback final
WhitelistClassifierCallback(
nsIChannel* aChannel, nsIURI* aURI,
const nsTArray<RefPtr<nsIUrlClassifierFeatureResult>>& aBlacklistResults,
std::function<void()>&& aCallback)
std::function<void()>& aCallback)
: mChannel(aChannel),
mURI(aURI),
mBlacklistResults(aBlacklistResults),
mChannelCallback(std::move(aCallback)) {
mChannelCallback(aCallback) {
MOZ_ASSERT(mChannel);
MOZ_ASSERT(mURI);
MOZ_ASSERT(!mBlacklistResults.IsEmpty());
@ -311,7 +311,7 @@ BlacklistClassifierCallback::OnClassifyComplete(
nsCOMPtr<nsIUrlClassifierFeatureCallback> callback =
new WhitelistClassifierCallback(mChannel, mURI, aResults,
std::move(mChannelCallback));
mChannelCallback);
// xpcom parser creates array of interfaces using RefPtr<>.
nsTArray<RefPtr<nsIUrlClassifierFeature>> refPtrFeatures;

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

@ -963,6 +963,10 @@ linux64-ccov/debug:
run-on-projects: ['mozilla-central', 'try']
worker-type: aws-provisioner-v1/gecko-{level}-b-linux
worker:
artifacts:
- name: public/code-coverage-grcov.zip
path: /builds/worker/workspace/build/src/obj-firefox/code-coverage-grcov.zip
type: file
max-run-time: 7200
env:
FORCE_GCC: '1'

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

@ -645,6 +645,10 @@ win64-ccov/debug:
tier: 2
worker-type: aws-provisioner-v1/gecko-{level}-b-win2012
worker:
artifacts:
- name: public/code-coverage-grcov.zip
path: build\src\obj-firefox\code-coverage-grcov.zip
type: file
max-run-time: 7200
env:
TOOLTOOL_MANIFEST: "browser/config/tooltool-manifests/win64/releng.manifest"

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

@ -1730,3 +1730,27 @@ or run without that action (ie: --no-{action})"
if return_code == self.return_code:
self.record_status(status, TBPL_STATUS_DICT[status])
self.summary()
@PostScriptRun
def _parse_build_tests_ccov(self):
if 'MOZ_FETCHES_DIR' not in os.environ:
return
dirs = self.query_abs_dirs()
topsrcdir = dirs['abs_src_dir']
base_work_dir = dirs['base_work_dir']
env = self.query_build_env()
grcov_path = os.path.join(os.environ['MOZ_FETCHES_DIR'], 'grcov')
if not os.path.isabs(grcov_path):
grcov_path = os.path.join(base_work_dir, grcov_path)
if self._is_windows():
grcov_path += '.exe'
env['GRCOV_PATH'] = grcov_path
cmd = self._query_mach() + [
'python',
os.path.join('testing', 'parse_build_tests_ccov.py'),
]
self.run_command(command=cmd, cwd=topsrcdir, env=env, halt_on_failure=True)

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

@ -0,0 +1,74 @@
#!/usr/bin/env python
#
# 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/.
from __future__ import absolute_import
import sys
import os
import shutil
import subprocess
import tempfile
import zipfile
import buildconfig
def main():
if not buildconfig.substs.get('MOZ_CODE_COVERAGE') or not buildconfig.substs.get('MOZ_RUST_TESTS'):
return
assert 'GRCOV_PATH' in os.environ, 'The environment variable GRCOV_PATH should contain a path to grcov'
grcov_path = os.environ['GRCOV_PATH']
assert os.path.exists(grcov_path), 'grcov should exist'
grcov_command = [
grcov_path,
'-t', 'lcov',
'-p', buildconfig.topsrcdir,
buildconfig.topobjdir
]
# We want to ignore system headers in our reports.
if buildconfig.substs['OS_TARGET'] == 'WINNT':
# We use WINDOWSSDKDIR to find the directory holding the system headers on Windows.
windows_sdk_dir = None
config_opts = buildconfig.substs['MOZ_CONFIGURE_OPTIONS'].split(' ')
for opt in config_opts:
if opt.startswith('WINDOWSSDKDIR='):
windows_sdk_dir = opt[len('WINDOWSSDKDIR='):]
break
assert windows_sdk_dir is not None, 'WINDOWSSDKDIR should be in MOZ_CONFIGURE_OPTIONS'
ignore_dir_abs = os.path.dirname(windows_sdk_dir)
else:
gcc_dir = os.path.join(buildconfig.topsrcdir, 'gcc')
ignore_dir_abs = gcc_dir
# globs passed to grcov must exist and must be relative to the source directory.
# If it doesn't exist, maybe it has moved and we need to update the paths above.
# If it is no longer relative to the source directory, we no longer need to ignore it and
# this code can be removed.
assert os.path.isdir(ignore_dir_abs), '{} is not a directory'.format(ignore_dir_abs)
assert ignore_dir_abs.startswith(buildconfig.topsrcdir), '{} should start with {}'.format(ignore_dir_abs, buildconfig.topsrcdir)
grcov_command += ['--ignore-dir', os.path.relpath(ignore_dir_abs, buildconfig.topsrcdir) + '*']
if buildconfig.substs['OS_TARGET'] == 'Linux':
if 'LD_LIBRARY_PATH' in os.environ:
os.environ['LD_LIBRARY_PATH'] = '{}/lib64/:{}'.format(gcc_dir, os.environ['LD_LIBRARY_PATH'])
else:
os.environ['LD_LIBRARY_PATH'] = '{}/lib64/'.format(gcc_dir)
os.environ['PATH'] = '{}/bin/:{}'.format(gcc_dir, os.environ['PATH'])
grcov_output = subprocess.check_output(grcov_command)
grcov_zip_path = os.path.join(buildconfig.topobjdir, 'code-coverage-grcov.zip')
with zipfile.ZipFile(grcov_zip_path, 'a', zipfile.ZIP_DEFLATED) as z:
z.writestr('grcov_lcov_output.info', grcov_output)
if __name__ == '__main__':
main()

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

@ -1202,7 +1202,7 @@ nsresult nsWindowWatcher::OpenWindowInternal(
// Reset popup state while opening a modal dialog, and firing
// events about the dialog, to prevent the current state from
// being active the whole time a modal dialog is open.
nsAutoPopupStatePusher popupStatePusher(openAbused);
nsAutoPopupStatePusher popupStatePusher(PopupBlocker::openAbused);
newChrome->ShowAsModal();
}